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