blob: 2f7df9f58fd2728d330503abd240a0fe634aca9f [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"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssonb3306882018-05-14 10:11:42 +020017#include "modules/video_coding/codecs/vp8/include/vp8.h"
18#include "modules/video_coding/codecs/vp9/include/vp9.h"
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010019#include "rtc_base/logging.h"
magjed509e4fe2016-11-18 01:34:11 -080020
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010021namespace webrtc {
magjed509e4fe2016-11-18 01:34:11 -080022
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010023std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
24 const {
25 std::vector<SdpVideoFormat> supported_codecs;
26 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
magjed509e4fe2016-11-18 01:34:11 -080027 if (webrtc::VP9Encoder::IsSupported())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010028 supported_codecs.push_back(SdpVideoFormat(cricket::kVp9CodecName));
magjed509e4fe2016-11-18 01:34:11 -080029
Magnus Jedvert849b3ae2017-09-29 17:54:09 +020030 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010031 supported_codecs.push_back(format);
Oleh Prypinda850ef2017-11-16 11:59:29 +000032
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010033 return supported_codecs;
magjed509e4fe2016-11-18 01:34:11 -080034}
35
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010036VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
37 const SdpVideoFormat& format) const {
38 CodecInfo info;
39 info.is_hardware_accelerated = false;
40 info.has_internal_source = false;
41 return info;
magjed509e4fe2016-11-18 01:34:11 -080042}
43
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010044std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
45 const SdpVideoFormat& format) {
46 if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName))
47 return VP8Encoder::Create();
48
49 if (cricket::CodecNamesEq(format.name, cricket::kVp9CodecName))
50 return VP9Encoder::Create();
51
52 if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName))
53 return H264Encoder::Create(cricket::VideoCodec(format));
54
55 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
56 << format.name;
57 return nullptr;
magjed509e4fe2016-11-18 01:34:11 -080058}
59
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010060} // namespace webrtc