1 /* 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 11 #include "media/engine/internal_encoder_factory.h" 12 13 #include <string> 14 15 #include "absl/strings/match.h" 16 #include "api/video_codecs/sdp_video_format.h" 17 #include "media/base/codec.h" 18 #include "media/base/media_constants.h" 19 #include "modules/video_coding/codecs/av1/libaom_av1_encoder.h" 20 #include "modules/video_coding/codecs/h264/include/h264.h" 21 #include "modules/video_coding/codecs/vp8/include/vp8.h" 22 #include "modules/video_coding/codecs/vp9/include/vp9.h" 23 #include "rtc_base/logging.h" 24 25 namespace webrtc { 26 SupportedFormats()27std::vector<SdpVideoFormat> InternalEncoderFactory::SupportedFormats() { 28 std::vector<SdpVideoFormat> supported_codecs; 29 supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName)); 30 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs()) 31 supported_codecs.push_back(format); 32 for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs()) 33 supported_codecs.push_back(format); 34 if (kIsLibaomAv1EncoderSupported) 35 supported_codecs.push_back(SdpVideoFormat(cricket::kAv1CodecName)); 36 return supported_codecs; 37 } 38 GetSupportedFormats() const39std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats() 40 const { 41 return SupportedFormats(); 42 } 43 QueryVideoEncoder(const SdpVideoFormat & format) const44VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder( 45 const SdpVideoFormat& format) const { 46 CodecInfo info; 47 info.is_hardware_accelerated = false; 48 info.has_internal_source = false; 49 return info; 50 } 51 CreateVideoEncoder(const SdpVideoFormat & format)52std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder( 53 const SdpVideoFormat& format) { 54 if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName)) 55 return VP8Encoder::Create(); 56 if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName)) 57 return VP9Encoder::Create(cricket::VideoCodec(format)); 58 if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) 59 return H264Encoder::Create(cricket::VideoCodec(format)); 60 if (kIsLibaomAv1EncoderSupported && 61 absl::EqualsIgnoreCase(format.name, cricket::kAv1CodecName)) 62 return CreateLibaomAv1Encoder(); 63 RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " 64 << format.name; 65 return nullptr; 66 } 67 68 } // namespace webrtc 69