From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../platforms/android/AndroidEncoderModule.cpp | 47 ++++++++++++++++++++++ 1 file changed, 47 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..15b23330e2 --- /dev/null +++ b/dom/media/platforms/android/AndroidEncoderModule.cpp @@ -0,0 +1,47 @@ +/* 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 "mozilla/Logging.h" +#include "mozilla/java/HardwareCodecCapabilityUtilsWrappers.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::SupportsCodec(CodecType aCodec) const { + return (aCodec == CodecType::H264 && + java::HardwareCodecCapabilityUtils::HasHWH264(true /* encoder */)) || + (aCodec == CodecType::VP8 && + java::HardwareCodecCapabilityUtils::HasHWVP8(true /* encoder */)) || + (aCodec == CodecType::VP9 && + java::HardwareCodecCapabilityUtils::HasHWVP9(true /* encoder */)); +} + +bool AndroidEncoderModule::Supports(const EncoderConfig& aConfig) const { + if (!CanLikelyEncode(aConfig)) { + return false; + } + return SupportsCodec(aConfig.mCodec); +} + +already_AddRefed AndroidEncoderModule::CreateVideoEncoder( + const EncoderConfig& aConfig, const RefPtr& aTaskQueue) const { + if (!Supports(aConfig)) { + AND_PEM_LOG("Unsupported codec type: %s", + GetCodecTypeString(aConfig.mCodec)); + return nullptr; + } + return MakeRefPtr(aConfig, aTaskQueue).forget(); +} + +} // namespace mozilla + +#undef AND_PEM_LOG -- cgit v1.2.3