blob: 5f8479cfb82bfa55dc34e9e8c2e42854fd047895 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "modules/video_coding/codecs/h264/include/h264.h"
16#include "modules/video_coding/codecs/vp8/include/vp8.h"
17#include "modules/video_coding/codecs/vp9/include/vp9.h"
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010018#include "rtc_base/logging.h"
magjed509e4fe2016-11-18 01:34:11 -080019
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010020namespace webrtc {
magjed509e4fe2016-11-18 01:34:11 -080021
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010022std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
23 const {
24 std::vector<SdpVideoFormat> supported_codecs;
25 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
magjed509e4fe2016-11-18 01:34:11 -080026 if (webrtc::VP9Encoder::IsSupported())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010027 supported_codecs.push_back(SdpVideoFormat(cricket::kVp9CodecName));
magjed509e4fe2016-11-18 01:34:11 -080028
Magnus Jedvert849b3ae2017-09-29 17:54:09 +020029 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010030 supported_codecs.push_back(format);
Oleh Prypinda850ef2017-11-16 11:59:29 +000031
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010032 return supported_codecs;
magjed509e4fe2016-11-18 01:34:11 -080033}
34
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010035VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
36 const SdpVideoFormat& format) const {
37 CodecInfo info;
38 info.is_hardware_accelerated = false;
39 info.has_internal_source = false;
40 return info;
magjed509e4fe2016-11-18 01:34:11 -080041}
42
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010043std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
44 const SdpVideoFormat& format) {
45 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
46 return VP8Encoder::Create();
47
48 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName))
49 return VP9Encoder::Create();
50
51 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
52 return H264Encoder::Create(cricket::VideoCodec(format));
53
54 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
55 << format.name;
56 return nullptr;
magjed509e4fe2016-11-18 01:34:11 -080057}
58
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010059} // namespace webrtc