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