magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "media/engine/internalencoderfactory.h" |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 12 | |
| 13 | #include <utility> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "modules/video_coding/codecs/h264/include/h264.h" |
| 16 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
| 17 | #include "modules/video_coding/codecs/vp9/include/vp9.h" |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 18 | #include "rtc_base/logging.h" |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 19 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 20 | namespace webrtc { |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 21 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 22 | std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats() |
| 23 | const { |
| 24 | std::vector<SdpVideoFormat> supported_codecs; |
| 25 | supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName)); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 26 | if (webrtc::VP9Encoder::IsSupported()) |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 27 | supported_codecs.push_back(SdpVideoFormat(cricket::kVp9CodecName)); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 28 | |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 29 | for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs()) |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 30 | supported_codecs.push_back(format); |
Oleh Prypin | da850ef | 2017-11-16 11:59:29 +0000 | [diff] [blame] | 31 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 32 | return supported_codecs; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 33 | } |
| 34 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 35 | VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder( |
| 36 | const SdpVideoFormat& format) const { |
| 37 | CodecInfo info; |
| 38 | info.is_hardware_accelerated = false; |
| 39 | info.has_internal_source = false; |
| 40 | return info; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 43 | std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder( |
| 44 | const SdpVideoFormat& format) { |
| 45 | if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName)) |
| 46 | return VP8Encoder::Create(); |
| 47 | |
| 48 | if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName)) |
| 49 | return VP9Encoder::Create(); |
| 50 | |
| 51 | if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) |
| 52 | return H264Encoder::Create(cricket::VideoCodec(format)); |
| 53 | |
| 54 | RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " |
| 55 | << format.name; |
| 56 | return nullptr; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 59 | } // namespace webrtc |