diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/media/platforms/android/AndroidEncoderModule.cpp | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/platforms/android/AndroidEncoderModule.cpp')
-rw-r--r-- | dom/media/platforms/android/AndroidEncoderModule.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/dom/media/platforms/android/AndroidEncoderModule.cpp b/dom/media/platforms/android/AndroidEncoderModule.cpp new file mode 100644 index 0000000000..6c0cbd2c62 --- /dev/null +++ b/dom/media/platforms/android/AndroidEncoderModule.cpp @@ -0,0 +1,53 @@ +/* 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<MediaDataEncoder> AndroidEncoderModule::CreateVideoEncoder( + const CreateEncoderParams& aParams) const { + RefPtr<MediaDataEncoder> encoder; + switch (CreateEncoderParams::CodecTypeForMime(aParams.mConfig.mMimeType)) { + case MediaDataEncoder::CodecType::H264: + return MakeRefPtr<AndroidDataEncoder<MediaDataEncoder::H264Config>>( + aParams.ToH264Config(), aParams.mTaskQueue) + .forget(); + case MediaDataEncoder::CodecType::VP8: + return MakeRefPtr<AndroidDataEncoder<MediaDataEncoder::VP8Config>>( + aParams.ToVP8Config(), aParams.mTaskQueue) + .forget(); + case MediaDataEncoder::CodecType::VP9: + return MakeRefPtr<AndroidDataEncoder<MediaDataEncoder::VP9Config>>( + 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 |