blob: e8cecb79a43e52b3612c6b6e852590289ab3d087 [file] [log] [blame]
magjeddd407022016-12-01 00:27:27 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "media/engine/internaldecoderfactory.h"
magjeddd407022016-12-01 00:27:27 -080012
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010013#include "media/base/mediaconstants.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#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 Jedvert7501b1c2017-11-09 13:43:42 +010017#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "rtc_base/logging.h"
magjeddd407022016-12-01 00:27:27 -080019
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010020namespace webrtc {
magjeddd407022016-12-01 00:27:27 -080021
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010022std::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;
magjeddd407022016-12-01 00:27:27 -080031}
32
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010033std::unique_ptr<VideoDecoder> InternalDecoderFactory::CreateVideoDecoder(
34 const SdpVideoFormat& format) {
35 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010036 return VP8Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010037
38 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName)) {
39 RTC_DCHECK(VP9Decoder::IsSupported());
Magnus Jedvert46a27652017-11-13 14:10:02 +010040 return VP9Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010041 }
42
43 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010044 return H264Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010045
46 RTC_LOG(LS_ERROR) << "Trying to create decoder for unsupported format";
47 return nullptr;
Christian Fremerey267d84b2017-11-08 23:26:44 +000048}
49
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010050} // namespace webrtc