AppleEncoderModule.cpp (1924B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "AppleEncoderModule.h" 8 9 #include "AppleUtils.h" 10 #include "AppleVTEncoder.h" 11 #include "VideoUtils.h" 12 13 using mozilla::media::EncodeSupport; 14 using mozilla::media::EncodeSupportSet; 15 16 namespace mozilla { 17 18 extern LazyLogModule sPEMLog; 19 #define LOGE(fmt, ...) \ 20 MOZ_LOG(sPEMLog, mozilla::LogLevel::Error, \ 21 ("[AppleEncoderModule] %s: " fmt, __func__, ##__VA_ARGS__)) 22 #define LOGD(fmt, ...) \ 23 MOZ_LOG(sPEMLog, mozilla::LogLevel::Debug, \ 24 ("[AppleEncoderModule] %s: " fmt, __func__, ##__VA_ARGS__)) 25 26 EncodeSupportSet AppleEncoderModule::SupportsCodec(CodecType aCodec) const { 27 if (aCodec != CodecType::H264) { 28 return EncodeSupportSet{}; 29 } 30 return EncodeSupportSet{EncodeSupport::HardwareEncode, 31 EncodeSupport::SoftwareEncode}; 32 } 33 34 EncodeSupportSet AppleEncoderModule::Supports( 35 const EncoderConfig& aConfig) const { 36 if (!CanLikelyEncode(aConfig)) { 37 return EncodeSupportSet{}; 38 } 39 // Only two temporal layers supported, and only from 11.3 and more recent 40 if (aConfig.mScalabilityMode == ScalabilityMode::L1T3 || 41 (aConfig.mScalabilityMode != ScalabilityMode::None && !OSSupportsSVC())) { 42 return EncodeSupportSet{}; 43 } 44 return SupportsCodec(aConfig.mCodec); 45 } 46 47 already_AddRefed<MediaDataEncoder> AppleEncoderModule::CreateVideoEncoder( 48 const EncoderConfig& aConfig, const RefPtr<TaskQueue>& aTaskQueue) const { 49 RefPtr<MediaDataEncoder> encoder(new AppleVTEncoder(aConfig, aTaskQueue)); 50 return encoder.forget(); 51 } 52 53 #undef LOGE 54 #undef LOGD 55 56 } // namespace mozilla