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" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/video_coding/codecs/h264/include/h264.h" |
Anders Carlsson | b330688 | 2018-05-14 10:11:42 +0200 | [diff] [blame] | 17 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
| 18 | #include "modules/video_coding/codecs/vp9/include/vp9.h" |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 19 | #include "rtc_base/logging.h" |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 20 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 21 | namespace webrtc { |
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 | std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats() |
| 24 | const { |
| 25 | std::vector<SdpVideoFormat> supported_codecs; |
| 26 | supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName)); |
Emircan Uysaler | 98badbc | 2018-06-28 10:59:02 -0700 | [diff] [blame] | 27 | for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs()) |
| 28 | supported_codecs.push_back(format); |
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); |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 31 | return supported_codecs; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 32 | } |
| 33 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 34 | VideoEncoderFactory::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; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 40 | } |
| 41 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 42 | std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder( |
| 43 | const SdpVideoFormat& format) { |
Oleh Prypin | 6e8e299 | 2018-10-23 15:18:23 +0200 | [diff] [blame^] | 44 | if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName)) |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 45 | return VP8Encoder::Create(); |
Oleh Prypin | 6e8e299 | 2018-10-23 15:18:23 +0200 | [diff] [blame^] | 46 | if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName)) |
Emircan Uysaler | 0823eec | 2018-07-13 17:10:00 -0700 | [diff] [blame] | 47 | return VP9Encoder::Create(cricket::VideoCodec(format)); |
Oleh Prypin | 6e8e299 | 2018-10-23 15:18:23 +0200 | [diff] [blame^] | 48 | if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 49 | return H264Encoder::Create(cricket::VideoCodec(format)); |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 50 | RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " |
| 51 | << format.name; |
| 52 | return nullptr; |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Magnus Jedvert | df4883d | 2017-11-17 14:44:55 +0100 | [diff] [blame] | 55 | } // namespace webrtc |