From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../platforms/android/AndroidEncoderModule.cpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 dom/media/platforms/android/AndroidEncoderModule.cpp (limited to 'dom/media/platforms/android/AndroidEncoderModule.cpp') diff --git a/dom/media/platforms/android/AndroidEncoderModule.cpp b/dom/media/platforms/android/AndroidEncoderModule.cpp new file mode 100644 index 0000000000..4fd85e3182 --- /dev/null +++ b/dom/media/platforms/android/AndroidEncoderModule.cpp @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "AndroidEncoderModule.h" + +#include "AndroidDataEncoder.h" +#include "MP4Decoder.h" +#include "VPXDecoder.h" + +#include "mozilla/Logging.h" + +namespace mozilla { +extern LazyLogModule sPEMLog; +#define AND_PEM_LOG(arg, ...) \ + MOZ_LOG( \ + sPEMLog, mozilla::LogLevel::Debug, \ + ("AndroidEncoderModule(%p)::%s: " arg, this, __func__, ##__VA_ARGS__)) + +bool AndroidEncoderModule::SupportsMimeType(const nsACString& aMimeType) const { + return (MP4Decoder::IsH264(aMimeType) && + java::HardwareCodecCapabilityUtils::HasHWH264(true /* encoder */)) || + (VPXDecoder::IsVP8(aMimeType) && + java::HardwareCodecCapabilityUtils::HasHWVP8(true /* encoder */)) || + (VPXDecoder::IsVP9(aMimeType) && + java::HardwareCodecCapabilityUtils::HasHWVP9(true /* encoder */)); +} + +already_AddRefed AndroidEncoderModule::CreateVideoEncoder( + const CreateEncoderParams& aParams, const bool aHardwareNotAllowed) const { + // TODO: extend AndroidDataEncoder and Java codec to accept this option. + MOZ_ASSERT(!aHardwareNotAllowed); + + RefPtr encoder; + switch (CreateEncoderParams::CodecTypeForMime(aParams.mConfig.mMimeType)) { + case MediaDataEncoder::CodecType::H264: + return MakeRefPtr>( + aParams.ToH264Config(), aParams.mTaskQueue) + .forget(); + case MediaDataEncoder::CodecType::VP8: + return MakeRefPtr>( + aParams.ToVP8Config(), aParams.mTaskQueue) + .forget(); + case MediaDataEncoder::CodecType::VP9: + return MakeRefPtr>( + aParams.ToVP9Config(), aParams.mTaskQueue) + .forget(); + default: + AND_PEM_LOG("Unsupported MIME type:%s", aParams.mConfig.mMimeType.get()); + return nullptr; + } +} + +} // namespace mozilla + +#undef AND_PEM_LOG -- cgit v1.2.3