blob: e6c3c2e72fd632eac71eb38dfab61327a18b82df [file] [log] [blame]
magjed509e4fe2016-11-18 01:34:11 -08001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "media/engine/internalencoderfactory.h"
magjed509e4fe2016-11-18 01:34:11 -080012
13#include <utility>
14
Anders Carlssondd8c1652018-01-30 10:32:13 +010015#include "api/video_codecs/sdp_video_format.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssonb3306882018-05-14 10:11:42 +020017#include "modules/video_coding/codecs/vp8/include/vp8.h"
18#include "modules/video_coding/codecs/vp9/include/vp9.h"
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010019#include "rtc_base/logging.h"
magjed509e4fe2016-11-18 01:34:11 -080020
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010021namespace webrtc {
magjed509e4fe2016-11-18 01:34:11 -080022
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010023std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
24 const {
25 std::vector<SdpVideoFormat> supported_codecs;
26 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
Emircan Uysaler98badbc2018-06-28 10:59:02 -070027 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs())
28 supported_codecs.push_back(format);
Magnus Jedvert849b3ae2017-09-29 17:54:09 +020029 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010030 supported_codecs.push_back(format);
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010031 return supported_codecs;
magjed509e4fe2016-11-18 01:34:11 -080032}
33
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010034VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
35 const SdpVideoFormat& format) const {
36 CodecInfo info;
37 info.is_hardware_accelerated = false;
38 info.has_internal_source = false;
39 return info;
magjed509e4fe2016-11-18 01:34:11 -080040}
41
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010042std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
43 const SdpVideoFormat& format) {
Oleh Prypin6e8e2992018-10-23 15:18:23 +020044 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010045 return VP8Encoder::Create();
Oleh Prypin6e8e2992018-10-23 15:18:23 +020046 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName))
Emircan Uysaler0823eec2018-07-13 17:10:00 -070047 return VP9Encoder::Create(cricket::VideoCodec(format));
Oleh Prypin6e8e2992018-10-23 15:18:23 +020048 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010049 return H264Encoder::Create(cricket::VideoCodec(format));
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010050 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
51 << format.name;
52 return nullptr;
magjed509e4fe2016-11-18 01:34:11 -080053}
54
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010055} // namespace webrtc