magjed | dd40702 | 2016-12-01 00:27:27 -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/internaldecoderfactory.h" |
magjed | dd40702 | 2016-12-01 00:27:27 -0800 | [diff] [blame] | 12 | |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 13 | #include "api/video_codecs/sdp_video_format.h" |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 14 | #include "media/base/mediaconstants.h" |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 15 | #if defined(USE_BUILTIN_SW_CODECS) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/video_coding/codecs/h264/include/h264.h" |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 17 | #include "modules/video_coding/codecs/vp8/include/vp8.h" // nogncheck |
| 18 | #include "modules/video_coding/codecs/vp9/include/vp9.h" // nogncheck |
| 19 | #endif |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 20 | #include "rtc_base/checks.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "rtc_base/logging.h" |
magjed | dd40702 | 2016-12-01 00:27:27 -0800 | [diff] [blame] | 22 | |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 23 | namespace webrtc { |
magjed | dd40702 | 2016-12-01 00:27:27 -0800 | [diff] [blame] | 24 | |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 25 | std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats() |
| 26 | const { |
| 27 | std::vector<SdpVideoFormat> formats; |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 28 | #if defined(USE_BUILTIN_SW_CODECS) |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 29 | formats.push_back(SdpVideoFormat(cricket::kVp8CodecName)); |
| 30 | if (VP9Decoder::IsSupported()) |
| 31 | formats.push_back(SdpVideoFormat(cricket::kVp9CodecName)); |
| 32 | for (const SdpVideoFormat& h264_format : SupportedH264Codecs()) |
| 33 | formats.push_back(h264_format); |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 34 | #endif |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 35 | return formats; |
magjed | dd40702 | 2016-12-01 00:27:27 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 38 | std::unique_ptr<VideoDecoder> InternalDecoderFactory::CreateVideoDecoder( |
| 39 | const SdpVideoFormat& format) { |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 40 | #if defined(USE_BUILTIN_SW_CODECS) |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 41 | if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName)) |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 42 | return VP8Decoder::Create(); |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 43 | |
| 44 | if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName)) { |
| 45 | RTC_DCHECK(VP9Decoder::IsSupported()); |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 46 | return VP9Decoder::Create(); |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 50 | return H264Decoder::Create(); |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame^] | 51 | #endif |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 52 | |
| 53 | RTC_LOG(LS_ERROR) << "Trying to create decoder for unsupported format"; |
| 54 | return nullptr; |
Christian Fremerey | 267d84b | 2017-11-08 23:26:44 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Magnus Jedvert | 7501b1c | 2017-11-09 13:43:42 +0100 | [diff] [blame] | 57 | } // namespace webrtc |