blob: 04baffd9d5fa24ca12a01247866dd4ef8e8a4dd3 [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"
Anders Carlssondd8c1652018-01-30 10:32:13 +010015#if defined(USE_BUILTIN_SW_CODECS)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssondd8c1652018-01-30 10:32:13 +010017#include "modules/video_coding/codecs/vp8/include/vp8.h" // nogncheck
18#include "modules/video_coding/codecs/vp9/include/vp9.h" // nogncheck
19#endif
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010020#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/logging.h"
magjeddd407022016-12-01 00:27:27 -080022
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010023namespace webrtc {
magjeddd407022016-12-01 00:27:27 -080024
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010025std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats()
26 const {
27 std::vector<SdpVideoFormat> formats;
Anders Carlssondd8c1652018-01-30 10:32:13 +010028#if defined(USE_BUILTIN_SW_CODECS)
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010029 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 Carlssondd8c1652018-01-30 10:32:13 +010034#endif
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010035 return formats;
magjeddd407022016-12-01 00:27:27 -080036}
37
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010038std::unique_ptr<VideoDecoder> InternalDecoderFactory::CreateVideoDecoder(
39 const SdpVideoFormat& format) {
Anders Carlssondd8c1652018-01-30 10:32:13 +010040#if defined(USE_BUILTIN_SW_CODECS)
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010041 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010042 return VP8Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010043
44 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName)) {
45 RTC_DCHECK(VP9Decoder::IsSupported());
Magnus Jedvert46a27652017-11-13 14:10:02 +010046 return VP9Decoder::Create();
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010047 }
48
49 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
Magnus Jedvert46a27652017-11-13 14:10:02 +010050 return H264Decoder::Create();
Anders Carlssondd8c1652018-01-30 10:32:13 +010051#endif
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010052
53 RTC_LOG(LS_ERROR) << "Trying to create decoder for unsupported format";
54 return nullptr;
Christian Fremerey267d84b2017-11-08 23:26:44 +000055}
56
Magnus Jedvert7501b1c2017-11-09 13:43:42 +010057} // namespace webrtc