blob: 331f22b794007036dd34ce0cdce058c2cdd7f5fe [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
Steve Anton10542f22019-01-11 09:11:00 -080011#include "media/engine/internal_encoder_factory.h"
magjed509e4fe2016-11-18 01:34:11 -080012
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <string>
magjed509e4fe2016-11-18 01:34:11 -080014
Niels Möller039743e2018-10-23 10:07:25 +020015#include "absl/strings/match.h"
Anders Carlssondd8c1652018-01-30 10:32:13 +010016#include "api/video_codecs/sdp_video_format.h"
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "media/base/codec.h"
Steve Anton10542f22019-01-11 09:11:00 -080018#include "media/base/media_constants.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/video_coding/codecs/h264/include/h264.h"
Anders Carlssonb3306882018-05-14 10:11:42 +020020#include "modules/video_coding/codecs/vp8/include/vp8.h"
21#include "modules/video_coding/codecs/vp9/include/vp9.h"
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010022#include "rtc_base/logging.h"
magjed509e4fe2016-11-18 01:34:11 -080023
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010024namespace webrtc {
magjed509e4fe2016-11-18 01:34:11 -080025
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010026std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
27 const {
28 std::vector<SdpVideoFormat> supported_codecs;
29 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
Emircan Uysaler98badbc2018-06-28 10:59:02 -070030 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs())
31 supported_codecs.push_back(format);
Magnus Jedvert849b3ae2017-09-29 17:54:09 +020032 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010033 supported_codecs.push_back(format);
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010034 return supported_codecs;
magjed509e4fe2016-11-18 01:34:11 -080035}
36
Mirta Dvornicic1ec2a162018-12-10 09:47:34 +000037VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
38 const SdpVideoFormat& format) const {
39 CodecInfo info;
40 info.is_hardware_accelerated = false;
41 info.has_internal_source = false;
42 return info;
43}
44
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010045std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
46 const SdpVideoFormat& format) {
Niels Möller039743e2018-10-23 10:07:25 +020047 if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010048 return VP8Encoder::Create();
Niels Möller039743e2018-10-23 10:07:25 +020049 if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName))
Emircan Uysaler0823eec2018-07-13 17:10:00 -070050 return VP9Encoder::Create(cricket::VideoCodec(format));
Niels Möller039743e2018-10-23 10:07:25 +020051 if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName))
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010052 return H264Encoder::Create(cricket::VideoCodec(format));
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010053 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
54 << format.name;
55 return nullptr;
magjed509e4fe2016-11-18 01:34:11 -080056}
57
Magnus Jedvertdf4883d2017-11-17 14:44:55 +010058} // namespace webrtc