blob: d093b25915955b03c0b3376621b867d767ab83aa [file] [log] [blame]
magjed509e4fe2016-11-18 01:34:11 -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/internalencoderfactory.h"
magjed509e4fe2016-11-18 01:34:11 -080012
13#include <utility>
14
Anders Carlssondd8c1652018-01-30 10:32:13 +010015#include "api/video_codecs/sdp_video_format.h"
16#if defined(USE_BUILTIN_SW_CODECS)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssondd8c1652018-01-30 10:32:13 +010018#include "modules/video_coding/codecs/vp8/include/vp8.h" // nogncheck
19#include "modules/video_coding/codecs/vp9/include/vp9.h" // nogncheck
20#endif
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010021#include "rtc_base/logging.h"
magjed509e4fe2016-11-18 01:34:11 -080022
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010023namespace webrtc {
magjed509e4fe2016-11-18 01:34:11 -080024
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010025std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
26 const {
27 std::vector<SdpVideoFormat> supported_codecs;
Anders Carlssondd8c1652018-01-30 10:32:13 +010028#if defined(USE_BUILTIN_SW_CODECS)
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010029 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
magjed509e4fe2016-11-18 01:34:11 -080030 if (webrtc::VP9Encoder::IsSupported())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010031 supported_codecs.push_back(SdpVideoFormat(cricket::kVp9CodecName));
magjed509e4fe2016-11-18 01:34:11 -080032
Magnus Jedvert849b3ae2017-09-29 17:54:09 +020033 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010034 supported_codecs.push_back(format);
Anders Carlssondd8c1652018-01-30 10:32:13 +010035#endif
Oleh Prypinda850ef2017-11-16 11:59:29 +000036
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010037 return supported_codecs;
magjed509e4fe2016-11-18 01:34:11 -080038}
39
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010040VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
41 const SdpVideoFormat& format) const {
42 CodecInfo info;
43 info.is_hardware_accelerated = false;
44 info.has_internal_source = false;
45 return info;
magjed509e4fe2016-11-18 01:34:11 -080046}
47
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010048std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
49 const SdpVideoFormat& format) {
Anders Carlssondd8c1652018-01-30 10:32:13 +010050#if defined(USE_BUILTIN_SW_CODECS)
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010051 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
52 return VP8Encoder::Create();
53
54 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName))
55 return VP9Encoder::Create();
56
57 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
58 return H264Encoder::Create(cricket::VideoCodec(format));
Anders Carlssondd8c1652018-01-30 10:32:13 +010059#endif
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010060
61 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
62 << format.name;
63 return nullptr;
magjed509e4fe2016-11-18 01:34:11 -080064}
65
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010066} // namespace webrtc