diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/media/platforms/android | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/platforms/android')
4 files changed, 68 insertions, 22 deletions
diff --git a/dom/media/platforms/android/AndroidDecoderModule.cpp b/dom/media/platforms/android/AndroidDecoderModule.cpp index fff8669a74..21d0ede270 100644 --- a/dom/media/platforms/android/AndroidDecoderModule.cpp +++ b/dom/media/platforms/android/AndroidDecoderModule.cpp @@ -64,21 +64,28 @@ AndroidDecoderModule::AndroidDecoderModule(CDMProxy* aProxy) { mProxy = static_cast<MediaDrmCDMProxy*>(aProxy); } -StaticAutoPtr<nsTArray<nsCString>> AndroidDecoderModule::sSupportedSwMimeTypes; -StaticAutoPtr<nsTArray<nsCString>> AndroidDecoderModule::sSupportedHwMimeTypes; -StaticAutoPtr<MediaCodecsSupported> AndroidDecoderModule::sSupportedCodecs; +/* static */ bool AndroidDecoderModule::AreSupportedMimeTypesReady() { + StaticMutexAutoLock lock(sMutex); + return sSupportedSwMimeTypes && sSupportedHwMimeTypes; +} + +/* static */ bool AndroidDecoderModule::IsSupportedCodecsReady() { + StaticMutexAutoLock lock(sMutex); + return sSupportedCodecs; +} /* static */ media::MediaCodecsSupported AndroidDecoderModule::GetSupportedCodecs() { - if (!sSupportedSwMimeTypes || !sSupportedHwMimeTypes || !sSupportedCodecs) { + if (!AreSupportedMimeTypesReady() || !IsSupportedCodecsReady()) { SetSupportedMimeTypes(); } + StaticMutexAutoLock lock(sMutex); return *sSupportedCodecs; } DecodeSupportSet AndroidDecoderModule::SupportsMimeType( const nsACString& aMimeType) { - if (!sSupportedSwMimeTypes) { + if (!AreSupportedMimeTypesReady()) { SetSupportedMimeTypes(); } @@ -135,13 +142,16 @@ DecodeSupportSet AndroidDecoderModule::SupportsMimeType( // If a codec has no special handling or can't be determined from the // MIME type string, check if the MIME type string itself is supported. - if (sSupportedHwMimeTypes && - sSupportedHwMimeTypes->Contains(TranslateMimeType(aMimeType))) { - return DecodeSupport::HardwareDecode; - } - if (sSupportedSwMimeTypes && - sSupportedSwMimeTypes->Contains(TranslateMimeType(aMimeType))) { - return DecodeSupport::SoftwareDecode; + { + StaticMutexAutoLock lock(sMutex); + if (sSupportedHwMimeTypes && + sSupportedHwMimeTypes->Contains(TranslateMimeType(aMimeType))) { + return DecodeSupport::HardwareDecode; + } + if (sSupportedSwMimeTypes && + sSupportedSwMimeTypes->Contains(TranslateMimeType(aMimeType))) { + return DecodeSupport::SoftwareDecode; + } } return media::DecodeSupportSet{}; } @@ -179,24 +189,45 @@ void AndroidDecoderModule::SetSupportedMimeTypes() { // Inbound MIME types prefixed with SW/HW need to be processed void AndroidDecoderModule::SetSupportedMimeTypes( nsTArray<nsCString>&& aSupportedTypes) { + StaticMutexAutoLock lock(sMutex); // Return if support is already cached if (sSupportedSwMimeTypes && sSupportedHwMimeTypes && sSupportedCodecs) { return; } if (!sSupportedSwMimeTypes) { sSupportedSwMimeTypes = new nsTArray<nsCString>; - ClearOnShutdown(&sSupportedSwMimeTypes); + if (NS_IsMainThread()) { + ClearOnShutdown(&sSupportedSwMimeTypes); + } else { + Unused << NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, []() { + StaticMutexAutoLock lock(sMutex); + ClearOnShutdown(&sSupportedSwMimeTypes); + })); + } } if (!sSupportedHwMimeTypes) { sSupportedHwMimeTypes = new nsTArray<nsCString>; - ClearOnShutdown(&sSupportedHwMimeTypes); + if (NS_IsMainThread()) { + ClearOnShutdown(&sSupportedHwMimeTypes); + } else { + Unused << NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, []() { + StaticMutexAutoLock lock(sMutex); + ClearOnShutdown(&sSupportedHwMimeTypes); + })); + } } if (!sSupportedCodecs) { sSupportedCodecs = new MediaCodecsSupported(); - ClearOnShutdown(&sSupportedCodecs); + if (NS_IsMainThread()) { + ClearOnShutdown(&sSupportedCodecs); + } else { + Unused << NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, []() { + StaticMutexAutoLock lock(sMutex); + ClearOnShutdown(&sSupportedCodecs); + })); + } } - DecodeSupportSet support; // Process each MIME type string for (const auto& s : aSupportedTypes) { // Verify MIME type string present @@ -212,12 +243,13 @@ void AndroidDecoderModule::SetSupportedMimeTypes( // Extract SW/HW support prefix const auto caps = Substring(s, 0, 2); + DecodeSupport support{}; if (caps == "SW"_ns) { sSupportedSwMimeTypes->AppendElement(mimeType); - support += DecodeSupport::SoftwareDecode; + support = DecodeSupport::SoftwareDecode; } else if (caps == "HW"_ns) { sSupportedHwMimeTypes->AppendElement(mimeType); - support += DecodeSupport::HardwareDecode; + support = DecodeSupport::HardwareDecode; } else { SLOG("Error parsing acceleration info from JNI codec string %s", s.Data()); diff --git a/dom/media/platforms/android/AndroidDecoderModule.h b/dom/media/platforms/android/AndroidDecoderModule.h index 37a0f08588..5550e123f3 100644 --- a/dom/media/platforms/android/AndroidDecoderModule.h +++ b/dom/media/platforms/android/AndroidDecoderModule.h @@ -54,16 +54,25 @@ class AndroidDecoderModule : public PlatformDecoderModule { private: explicit AndroidDecoderModule(CDMProxy* aProxy = nullptr); virtual ~AndroidDecoderModule() = default; + + static bool AreSupportedMimeTypesReady(); + static bool IsSupportedCodecsReady(); + RefPtr<MediaDrmCDMProxy> mProxy; // SW compatible MIME type strings - static StaticAutoPtr<nsTArray<nsCString>> sSupportedSwMimeTypes; + static inline StaticAutoPtr<nsTArray<nsCString>> sSupportedSwMimeTypes + MOZ_GUARDED_BY(sMutex); // HW compatible MIME type strings - static StaticAutoPtr<nsTArray<nsCString>> sSupportedHwMimeTypes; + static inline StaticAutoPtr<nsTArray<nsCString>> sSupportedHwMimeTypes + MOZ_GUARDED_BY(sMutex); // EnumSet containing SW/HW codec support information parsed from // MIME type strings. If a specific codec could not be determined // it will not be included in this EnumSet. All supported MIME type strings // are still stored in sSupportedSwMimeTypes and sSupportedHwMimeTypes. - static StaticAutoPtr<media::MediaCodecsSupported> sSupportedCodecs; + static inline StaticAutoPtr<media::MediaCodecsSupported> sSupportedCodecs + MOZ_GUARDED_BY(sMutex); + + static inline StaticMutex sMutex; }; extern LazyLogModule sAndroidDecoderModuleLog; diff --git a/dom/media/platforms/android/AndroidEncoderModule.cpp b/dom/media/platforms/android/AndroidEncoderModule.cpp index 15b23330e2..23c76cba5f 100644 --- a/dom/media/platforms/android/AndroidEncoderModule.cpp +++ b/dom/media/platforms/android/AndroidEncoderModule.cpp @@ -29,6 +29,9 @@ bool AndroidEncoderModule::Supports(const EncoderConfig& aConfig) const { if (!CanLikelyEncode(aConfig)) { return false; } + if (aConfig.mScalabilityMode != ScalabilityMode::None) { + return false; + } return SupportsCodec(aConfig.mCodec); } diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index f0fbc7a77c..260b70abdb 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -527,6 +527,8 @@ class RemoteVideoDecoder final : public RemoteDataDecoder { }); aStage.SetResolution(v->mImage->GetSize().Width(), v->mImage->GetSize().Height()); + aStage.SetStartTimeAndEndTime(v->mTime.ToMicroseconds(), + v->GetEndTime().ToMicroseconds()); }); RemoteDataDecoder::UpdateOutputStatus(std::move(v)); @@ -574,7 +576,7 @@ class RemoteVideoDecoder final : public RemoteDataDecoder { bool mIsHardwareAccelerated = false; // Accessed on mThread and reader's thread. SimpleMap however is // thread-safe, so it's okay to do so. - SimpleMap<InputInfo> mInputInfos; + SimpleMap<int64_t, InputInfo, ThreadSafePolicy> mInputInfos; // Only accessed on mThread. Maybe<TimeUnit> mSeekTarget; Maybe<TimeUnit> mLatestOutputTime; |