blob: 08e29cfa6a1f324747069d374dfc26bef38a5ddd [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
Anders Carlssondd8c1652018-01-30 10:32:13 +010013#include "api/video_codecs/sdp_video_format.h"
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010014#include "media/base/mediaconstants.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssonb3306882018-05-14 10:11:42 +020016#include "modules/video_coding/codecs/vp8/include/vp8.h"
17#include "modules/video_coding/codecs/vp9/include/vp9.h"
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010018#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/logging.h"
magjeddd407022016-12-01 00:27:27 -080020
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010021namespace webrtc {
magjeddd407022016-12-01 00:27:27 -080022
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010023std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats()
24 const {
25 std::vector<SdpVideoFormat> formats;
26 formats.push_back(SdpVideoFormat(cricket::kVp8CodecName));
Emircan Uysaler98badbc2018-06-28 10:59:02 -070027 for (const SdpVideoFormat& format : SupportedVP9Codecs())
28 formats.push_back(format);
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010029 for (const SdpVideoFormat& h264_format : SupportedH264Codecs())
30 formats.push_back(h264_format);
31 return formats;
magjeddd407022016-12-01 00:27:27 -080032}
33
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010034std::unique_ptr<VideoDecoder> InternalDecoderFactory::CreateVideoDecoder(
35 const SdpVideoFormat& format) {
36 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010037 return VP8Decoder::Create();
Emircan Uysaler98badbc2018-06-28 10:59:02 -070038 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010039 return VP9Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010040 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010041 return H264Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010042 RTC_LOG(LS_ERROR) << "Trying to create decoder for unsupported format";
43 return nullptr;
Christian Fremerey267d84b2017-11-08 23:26:44 +000044}
45
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010046} // namespace webrtc