commit 6576267517eb37a756953394b12992fb6549d18e parent abcd5886a452776da17a80eb9023e735a3be6864 Author: Cosmin Sabou <csabou@mozilla.com> Date: Mon, 27 Oct 2025 21:41:06 +0200 Revert "Bug 1905878 - p3: Use decode property when available. r=media-playback-reviewers,alwu" for causing gtest failures on MFTDecoder This reverts commit f0c2b93a23455f346905af822d0131949e831a92. Revert "Bug 1905878 - p2: test decoding properties. r=media-playback-reviewers,chunmin" This reverts commit 7248bea6c4fc35ae1d847479ca5d8d3a1ee468e6. Revert "Bug 1905878 - p1: let MediaDataDecoder define video decoding related properties. r=media-playback-reviewers,chunmin" This reverts commit dbecb0c4758dd36fe8caffa0fee1a4e9ec5e1153. Revert "Bug 1905878 - don't use SW VPX MediaCodec decoders. r=media-playback-reviewers,alwu" This reverts commit 4ee3b55e4f10bd33589106d7d7eb014b203b2049. Diffstat:
24 files changed, 25 insertions(+), 379 deletions(-)
diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp @@ -137,7 +137,11 @@ static constexpr auto EXHAUSTED_DATA_MARGIN = static const uint32_t MIN_VIDEO_QUEUE_SIZE = 3; static const uint32_t MAX_VIDEO_QUEUE_SIZE = 10; +#ifdef MOZ_APPLEMEDIA +static const uint32_t HW_VIDEO_QUEUE_SIZE = 10; +#else static const uint32_t HW_VIDEO_QUEUE_SIZE = 3; +#endif static const uint32_t VIDEO_QUEUE_SEND_TO_COMPOSITOR_SIZE = 9999; static uint32_t sVideoQueueDefaultSize = MAX_VIDEO_QUEUE_SIZE; @@ -748,12 +752,10 @@ class MediaDecoderStateMachine::DecodingState } uint32_t VideoPrerollFrames() const { - uint32_t preroll = static_cast<uint32_t>( - mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1); - // Keep it under maximal queue size. - mMaster->mReader->GetMaxVideoQueueSize().apply( - [&preroll](const uint32_t& x) { preroll = std::min(preroll, x); }); - return preroll; + return std::min( + static_cast<uint32_t>( + mMaster->GetAmpleVideoFrames() / 2. * mMaster->mPlaybackRate + 1), + sVideoQueueDefaultSize); } bool DonePrerollingAudio() const { @@ -4239,9 +4241,6 @@ void MediaDecoderStateMachine::FinishDecodeFirstFrame() { LOG("FinishDecodeFirstFrame"); mMediaSink->Redraw(Info().mVideo); - mReader->GetSendToCompositorSize().apply([self = RefPtr{this}](uint32_t x) { - self->mMediaSink->SetVideoQueueSendToCompositorSize(x); - }); LOG("Media duration %" PRId64 ", mediaSeekable=%d", Duration().ToMicroseconds(), mMediaSeekable); @@ -4658,23 +4657,9 @@ void MediaDecoderStateMachine::OnMediaSinkAudioError(nsresult aResult) { uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const { MOZ_ASSERT(OnTaskQueue()); - if (mReader->VideoIsHardwareAccelerated()) { - // HW decoding should be fast so queue size can be as small as possible - // to lower frame latency. - uint32_t hw = - std::max<uint32_t>(sVideoQueueHWAccelSize, MIN_VIDEO_QUEUE_SIZE); - mReader->GetMinVideoQueueSize().apply( - [&hw](const uint32_t& x) { hw = std::max(hw, x); }); - return hw; - } else { - // SW decoding is slower and queuing more frames in advance reduces the - // chances of dropping late frames. - uint32_t sw = - std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE); - mReader->GetMaxVideoQueueSize().apply( - [&sw](const uint32_t& x) { sw = std::min(sw, x); }); - return sw; - } + return mReader->VideoIsHardwareAccelerated() + ? std::max<uint32_t>(sVideoQueueHWAccelSize, MIN_VIDEO_QUEUE_SIZE) + : std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE); } void MediaDecoderStateMachine::GetDebugInfo( diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp @@ -1834,7 +1834,6 @@ void MediaFormatReader::NotifyNewOutput( // update the decoder name again, instead of using the wrong name. if (decoder.mNumSamplesOutput == 1) { decoder.mDescription = mVideo.mDecoder->GetDescriptionName(); - decoder.LoadDecodeProperties(); } } decoder.mDecodePerfRecorder->Record( @@ -3536,22 +3535,6 @@ void MediaFormatReader::SetEncryptedCustomIdent() { mEncryptedCustomIdent = true; } -void MediaFormatReader::VideoDecodeProperties::Load( - RefPtr<MediaDataDecoder>& aDecoder) { - using V = MediaDataDecoder::PropertyValue; - aDecoder - ->GetDecodeProperty(MediaDataDecoder::PropertyName::MaxNumVideoBuffers) - .apply([this](const V& v) { mMaxQueueSize = Some(v.as<uint32_t>()); }); - aDecoder - ->GetDecodeProperty(MediaDataDecoder::PropertyName::MinNumVideoBuffers) - .apply([this](const V& v) { mMinQueueSize = Some(v.as<uint32_t>()); }); - aDecoder - ->GetDecodeProperty(MediaDataDecoder::PropertyName::MaxNumCurrentImages) - .apply([this](const V& v) { - mSendToCompositorSize = Some(v.as<uint32_t>()); - }); -} - } // namespace mozilla #undef NS_DispatchToMainThread diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h @@ -257,30 +257,6 @@ class MediaFormatReader final template <typename T> friend struct DDLoggedTypeTraits; // For DecoderData - class VideoDecodeProperties final { - public: - void Load(RefPtr<MediaDataDecoder>& aDecoder); - void Clear() { - mMaxQueueSize.reset(); - mMinQueueSize.reset(); - mSendToCompositorSize.reset(); - } - - Maybe<uint32_t> MaxQueueSize() { return mMaxQueueSize; } - Maybe<uint32_t> MinQueueSize() { return mMinQueueSize; } - Maybe<uint32_t> SendToCompositorSize() { return mSendToCompositorSize; } - - private: - Maybe<uint32_t> mMaxQueueSize; - Maybe<uint32_t> mMinQueueSize; - Maybe<uint32_t> mSendToCompositorSize; - }; - - VideoDecodeProperties& GetVideoDecodeProperties() { - MutexAutoLock lock(mVideo.mMutex); - return mVideo.mVideoDecodeProperties; - } - private: bool HasVideo() const { return mVideo.mTrackDemuxer; } bool HasAudio() const { return mAudio.mTrackDemuxer; } @@ -439,25 +415,15 @@ class MediaFormatReader final RefPtr<TaskQueue> mTaskQueue; // Mutex protecting mDescription, mDecoder, mTrackDemuxer, mWorkingInfo, - // mProcessName, mCodecName and mDecodeProperties as those can be read - // outside the TaskQueue. They are only written on the TaskQueue however, as - // such mMutex doesn't need to be held when those members are read on the - // TaskQueue. + // mProcessName and mCodecName as those can be read outside the TaskQueue. + // They are only written on the TaskQueue however, as such mMutex doesn't + // need to be held when those members are read on the TaskQueue. Mutex mMutex MOZ_UNANNOTATED; // The platform decoder. RefPtr<MediaDataDecoder> mDecoder; nsCString mDescription; nsCString mProcessName; nsCString mCodecName; - VideoDecodeProperties mVideoDecodeProperties; - - void LoadDecodeProperties() { - MOZ_ASSERT(mOwner->OnTaskQueue()); - if (mType == MediaData::Type::VIDEO_DATA) { - mVideoDecodeProperties.Load(mDecoder); - } - } - void ShutdownDecoder(); // Only accessed from reader's task queue. @@ -634,9 +600,6 @@ class MediaFormatReader final if (!HasFatalError()) { mError.reset(); } - if (mType == MediaData::Type::VIDEO_DATA) { - mVideoDecodeProperties.Clear(); - } } // Return whether an InternalSeek() has been requested but has not yet diff --git a/dom/media/ReaderProxy.h b/dom/media/ReaderProxy.h @@ -92,16 +92,6 @@ class ReaderProxy { bool IsEncryptedCustomIdent() const; - Maybe<uint32_t> GetMaxVideoQueueSize() { - return mReader->GetVideoDecodeProperties().MaxQueueSize(); - } - Maybe<uint32_t> GetMinVideoQueueSize() { - return mReader->GetVideoDecodeProperties().MinQueueSize(); - } - Maybe<uint32_t> GetSendToCompositorSize() { - return mReader->GetVideoDecodeProperties().SendToCompositorSize(); - } - private: ~ReaderProxy(); RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder&& aMetadata); diff --git a/dom/media/gtest/TestMediaDataDecoder.cpp b/dom/media/gtest/TestMediaDataDecoder.cpp @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 <type_traits> - -#include "H264.h" -#include "PDMFactory.h" -#include "gtest/gtest.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/gtest/WaitFor.h" - -using namespace mozilla; - -using MDD = MediaDataDecoder; -using ParamType = std::underlying_type<MDD::PropertyName>::type; - -class PropertyTest : public ::testing::TestWithParam<ParamType> { - public: - static void SetUpTestSuite() { - sFactory = MakeRefPtr<PDMFactory>(); - sAVCInfo = MakeUnique<VideoInfo>(sDummyVideoSize); - sAVCInfo->mMimeType = "video/avc"_ns; - sAVCInfo->mExtraData = H264::CreateExtraData( - H264_PROFILE::H264_PROFILE_BASE, 0 /* constraint */, - H264_LEVEL::H264_LEVEL_1, sDummyVideoSize); - sVP9Info = MakeUnique<VideoInfo>(sDummyVideoSize); - sVP9Info->mMimeType = "video/vp9"_ns; - sVP9Info->SetAlpha(true); - } - - static void TearDownTestSuite() { - sFactory = nullptr; - sTaskQueue = nullptr; - sAVCInfo.reset(); - sVP9Info.reset(); - } - - static constexpr gfx::IntSize sDummyVideoSize{640, 480}; - static RefPtr<PDMFactory> sFactory; - static RefPtr<TaskQueue> sTaskQueue; - static UniquePtr<VideoInfo> sAVCInfo; - static UniquePtr<VideoInfo> sVP9Info; -}; -MOZ_RUNINIT RefPtr<PDMFactory> PropertyTest::sFactory; -MOZ_RUNINIT RefPtr<TaskQueue> PropertyTest::sTaskQueue; -MOZ_RUNINIT UniquePtr<VideoInfo> PropertyTest::sAVCInfo; -MOZ_RUNINIT UniquePtr<VideoInfo> PropertyTest::sVP9Info; - -void CheckEquals(VideoInfo& aVideoInfo, MDD::PropertyName aPropertyName, - const Maybe<MDD::PropertyValue>&& aExpectedValue, - const char* aCallSite) { - using V = Maybe<MDD::PropertyValue>; - auto d = WaitFor( - PropertyTest::sFactory->CreateDecoder(CreateDecoderParams{aVideoInfo})); - EXPECT_TRUE(d.isOk()); - RefPtr<MDD> dec = d.unwrap(); - auto t = WaitFor(dec->Init()); - EXPECT_TRUE(t.isOk()); - EXPECT_EQ(t.unwrap(), TrackInfo::TrackType::kVideoTrack); - const V v = dec->GetDecodeProperty(aPropertyName); - // Although Maybe supports operator<<(), PropertyValue/Variant doesn't and - // needs special care. - auto maybeStr = [](const V& v) -> std::string { - if (v.isNothing()) { - return "undefined"; - } - // Only uint32_t for now. - return std::to_string(v.ref().match([](uint32_t x) { return x; })); - }; - - EXPECT_TRUE(v == aExpectedValue) - << "[" << aCallSite << "] " - << "Decode property: " << MDD::EnumValueToString(aPropertyName) - << std::endl - << " Actual: " << maybeStr(v) - << " Expected: " << maybeStr(aExpectedValue); -} - -#define CHECK_NOT_DEFINED(info, prop) \ - do { \ - CheckEquals(info, prop, Nothing(), __func__); \ - } while (0) - -#ifdef MOZ_WIDGET_ANDROID -void CheckAndroid(VideoInfo& aVideoInfo, MDD::PropertyName aProperty) { - switch (aProperty) { - case MDD::PropertyName::MaxNumVideoBuffers: - [[fallthrough]]; - case MDD::PropertyName::MinNumVideoBuffers: - CheckEquals(aVideoInfo, aProperty, Some(MDD::PropertyValue(3U)), - __func__); - break; - case MDD::PropertyName::MaxNumCurrentImages: - CheckEquals(aVideoInfo, aProperty, Some(MDD::PropertyValue(1U)), - __func__); - break; - default: - CHECK_NOT_DEFINED(aVideoInfo, aProperty); - } -} -#endif - -#ifdef MOZ_APPLEMEDIA -void CheckApple(VideoInfo& aVideoInfo, MDD::PropertyName aProperty) { - switch (aProperty) { - case MDD::PropertyName::MinNumVideoBuffers: - CheckEquals(aVideoInfo, aProperty, Some(MDD::PropertyValue(10U)), - __func__); - break; - default: - CHECK_NOT_DEFINED(aVideoInfo, aProperty); - } -} -#endif - -INSTANTIATE_TEST_SUITE_P(TestMediaDataDecoder, PropertyTest, - ::testing::Range<ParamType>(0, - MDD::sPropertyNameCount), - [](const ::testing::TestParamInfo<ParamType>& info) { - return std::string(MDD::EnumValueToString( - static_cast<MDD::PropertyName>(info.param))); - }); - -TEST_P(PropertyTest, DefaultValues) { - auto param = static_cast<MDD::PropertyName>(GetParam()); -#ifdef MOZ_WIDGET_ANDROID - CheckAndroid(*sAVCInfo, param); -#elif defined(MOZ_APPLEMEDIA) - CheckApple(*sAVCInfo, param); -#else - CHECK_NOT_DEFINED(*sAVCInfo, param); -#endif -} - -// On Android, VP9 video with alpha channel is decoded with libvpx. -#ifdef MOZ_WIDGET_ANDROID -TEST_P(PropertyTest, NotDefinedForVP9WithAlphaOnAndroid) { - CHECK_NOT_DEFINED(*sVP9Info, static_cast<MDD::PropertyName>(GetParam())); -} -#endif diff --git a/dom/media/gtest/moz.build b/dom/media/gtest/moz.build @@ -47,7 +47,6 @@ UNIFIED_SOURCES += [ "TestImageConversion.cpp", "TestIntervalSet.cpp", "TestMediaCodecsSupport.cpp", - "TestMediaDataDecoder.cpp", "TestMediaDataEncoder.cpp", "TestMediaEventSource.cpp", "TestMediaFormatReader.cpp", diff --git a/dom/media/ipc/MediaIPCUtils.h b/dom/media/ipc/MediaIPCUtils.h @@ -223,13 +223,6 @@ struct ParamTraits<mozilla::MediaDataDecoder::ConversionRequired> mozilla::MediaDataDecoder::ConversionRequired::kNeedHVCC)> {}; template <> -struct ParamTraits<mozilla::MediaDataDecoder::PropertyName> - : public ContiguousEnumSerializerInclusive< - mozilla::MediaDataDecoder::PropertyName, - mozilla::MediaDataDecoder::PropertyName(0), - mozilla::MediaDataDecoder::sHighestPropertyName> {}; - -template <> struct ParamTraits<mozilla::media::TimeUnit> { using paramType = mozilla::media::TimeUnit; diff --git a/dom/media/ipc/PRemoteDecoder.ipdl b/dom/media/ipc/PRemoteDecoder.ipdl @@ -8,8 +8,6 @@ include "mozilla/dom/MediaIPCUtils.h"; include protocol PRemoteMediaManager; using mozilla::MediaDataDecoder::ConversionRequired from "PlatformDecoderModule.h"; -using mozilla::MediaDataDecoder::PropertyName from "PlatformDecoderModule.h"; -using mozilla::MediaDataDecoder::PropertyValue from "PlatformDecoderModule.h"; using mozilla::TrackInfo::TrackType from "MediaInfo.h"; using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; using mozilla::MediaResult from "MediaResult.h"; @@ -27,11 +25,6 @@ union DecodedOutputIPDL nullable ArrayOfRemoteVideoData; }; -struct DecodePropertyIPDL { - PropertyName name; - PropertyValue value; -}; - struct InitCompletionIPDL { TrackType type; @@ -42,7 +35,6 @@ struct InitCompletionIPDL nsCString hardwareReason; ConversionRequired conversion; bool shouldDecoderAlwaysBeRecycled; - DecodePropertyIPDL[] decodeProperties; }; union InitResultIPDL diff --git a/dom/media/ipc/RemoteDecoderChild.cpp b/dom/media/ipc/RemoteDecoderChild.cpp @@ -75,9 +75,6 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteDecoderChild::Init() { mConversion = initResponse.conversion(); mShouldDecoderAlwaysBeRecycled = initResponse.shouldDecoderAlwaysBeRecycled(); - for (auto p : initResponse.decodeProperties()) { - mDecodeProperties[p.name()] = Some(p.value()); - } // Either the promise has not yet been resolved or the handler has // been disconnected and we can't get here. mInitPromise.Resolve(initResponse.type(), __func__); diff --git a/dom/media/ipc/RemoteDecoderChild.h b/dom/media/ipc/RemoteDecoderChild.h @@ -6,7 +6,6 @@ #ifndef include_dom_media_ipc_RemoteDecoderChild_h #define include_dom_media_ipc_RemoteDecoderChild_h -#include "mozilla/EnumeratedArray.h" #include "mozilla/PRemoteDecoderChild.h" #include "mozilla/RemoteMediaManagerChild.h" #include "mozilla/ShmemRecycleAllocator.h" @@ -43,14 +42,6 @@ class RemoteDecoderChild : public ShmemRecycleAllocator<RemoteDecoderChild>, void SetSeekThreshold(const media::TimeUnit& aTime); MediaDataDecoder::ConversionRequired NeedsConversion() const; bool ShouldDecoderAlwaysBeRecycled() const; - using DecodeProperties = - EnumeratedArray<MediaDataDecoder::PropertyName, - Maybe<MediaDataDecoder::PropertyValue>, - MediaDataDecoder::sPropertyNameCount>; - const DecodeProperties& GetDecodeProperties() const { - return mDecodeProperties; - } - void DestroyIPDL(); // Called from IPDL when our actor has been destroyed @@ -88,7 +79,6 @@ class RemoteDecoderChild : public ShmemRecycleAllocator<RemoteDecoderChild>, MediaDataDecoder::ConversionRequired mConversion = MediaDataDecoder::ConversionRequired::kNeedNone; bool mShouldDecoderAlwaysBeRecycled = false; - DecodeProperties mDecodeProperties; }; } // namespace mozilla diff --git a/dom/media/ipc/RemoteDecoderParent.cpp b/dom/media/ipc/RemoteDecoderParent.cpp @@ -65,21 +65,12 @@ mozilla::ipc::IPCResult RemoteDecoderParent::RecvInit( nsCString hardwareReason; bool hardwareAccelerated = self->mDecoder->IsHardwareAccelerated(hardwareReason); - nsTArray<DecodePropertyIPDL> properties; - for (size_t i = 0; i < MediaDataDecoder::sPropertyNameCount; i++) { - MediaDataDecoder::PropertyName name = - static_cast<MediaDataDecoder::PropertyName>(i); - if (auto v = self->mDecoder->GetDecodeProperty(name)) { - properties.AppendElement( - DecodePropertyIPDL(name, std::move(v.ref()))); - } - } resolver(InitCompletionIPDL{ track, self->mDecoder->GetDescriptionName(), self->mDecoder->GetProcessName(), self->mDecoder->GetCodecName(), hardwareAccelerated, hardwareReason, self->mDecoder->NeedsConversion(), - self->mDecoder->ShouldDecoderAlwaysBeRecycled(), properties}); + self->mDecoder->ShouldDecoderAlwaysBeRecycled()}); } }); return IPC_OK(); diff --git a/dom/media/ipc/RemoteMediaDataDecoder.cpp b/dom/media/ipc/RemoteMediaDataDecoder.cpp @@ -68,7 +68,6 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() { mIsHardwareAccelerated = mChild->IsHardwareAccelerated(mHardwareAcceleratedReason); mConversion = mChild->NeedsConversion(); - mDecodeProperties = mChild->GetDecodeProperties(); mShouldDecoderAlwaysBeRecycled = mChild->ShouldDecoderAlwaysBeRecycled(); LOG("%p RemoteDecoderChild has been initialized - description: %s, " @@ -159,13 +158,6 @@ MediaDataDecoder::ConversionRequired RemoteMediaDataDecoder::NeedsConversion() return mConversion; } -Maybe<MediaDataDecoder::PropertyValue> -RemoteMediaDataDecoder::GetDecodeProperty( - MediaDataDecoder::PropertyName aName) const { - MutexAutoLock lock(mMutex); - return mDecodeProperties[aName]; -} - nsCString RemoteMediaDataDecoder::GetDescriptionName() const { MutexAutoLock lock(mMutex); return mDescription; diff --git a/dom/media/ipc/RemoteMediaDataDecoder.h b/dom/media/ipc/RemoteMediaDataDecoder.h @@ -7,7 +7,6 @@ #define include_dom_media_ipc_RemoteMediaDataDecoder_h #include "MediaData.h" #include "PlatformDecoderModule.h" -#include "mozilla/EnumeratedArray.h" namespace mozilla { @@ -45,7 +44,6 @@ class RemoteMediaDataDecoder final nsCString GetProcessName() const override; nsCString GetCodecName() const override; ConversionRequired NeedsConversion() const override; - Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override; bool ShouldDecoderAlwaysBeRecycled() const override; private: @@ -66,8 +64,6 @@ class RemoteMediaDataDecoder final nsCString mHardwareAcceleratedReason MOZ_GUARDED_BY(mMutex); ConversionRequired mConversion MOZ_GUARDED_BY(mMutex); bool mShouldDecoderAlwaysBeRecycled MOZ_GUARDED_BY(mMutex); - EnumeratedArray<PropertyName, Maybe<PropertyValue>, sPropertyNameCount> - mDecodeProperties MOZ_GUARDED_BY(mMutex); }; } // namespace mozilla diff --git a/dom/media/mediasink/MediaSink.h b/dom/media/mediasink/MediaSink.h @@ -141,8 +141,6 @@ class MediaSink { virtual void GetDebugInfo(dom::MediaSinkDebugInfo& aInfo) {} - virtual void SetVideoQueueSendToCompositorSize(const uint32_t aSize) {} - protected: virtual ~MediaSink() = default; }; diff --git a/dom/media/mediasink/VideoSink.h b/dom/media/mediasink/VideoSink.h @@ -73,10 +73,6 @@ class VideoSink : public MediaSink { void GetDebugInfo(dom::MediaSinkDebugInfo& aInfo) override; - void SetVideoQueueSendToCompositorSize(const uint32_t aSize) override { - mVideoQueueSendToCompositorSize = aSize; - } - private: virtual ~VideoSink(); @@ -153,8 +149,8 @@ class VideoSink : public MediaSink { DelayedScheduler<TimeStamp> mUpdateScheduler; // Max frame number sent to compositor at a time. - // Based on the value obtained in MDSM. - uint32_t mVideoQueueSendToCompositorSize; + // Based on the pref value obtained in MDSM. + const uint32_t mVideoQueueSendToCompositorSize; #ifdef XP_WIN // Whether we've called timeBeginPeriod(1) to request high resolution diff --git a/dom/media/platforms/AllocationPolicy.h b/dom/media/platforms/AllocationPolicy.h @@ -164,10 +164,6 @@ class AllocationWrapper final : public MediaDataDecoder { return mDecoder->NeedsConversion(); } - Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override { - return mDecoder->GetDecodeProperty(aName); - } - typedef MozPromise<RefPtr<MediaDataDecoder>, MediaResult, /* IsExclusive = */ true> AllocateDecoderPromise; diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h @@ -645,31 +645,6 @@ class MediaDataDecoder : public DecoderDoctorLifeLogger<MediaDataDecoder> { virtual ConversionRequired NeedsConversion() const { return ConversionRequired::kNeedNone; } - - // Properties specific to platform decoders. They can be consulted by the - // client to improve playback smoothness. When not defined by the decoder, the - // client can choose its own. - // MaxNumVideoBuffers: some platform decoders have limited output buffers. - // This specifies how many (output) video buffers can be held at most by the - // client. Holding more will exhaust the deocder buffer pool and block further - // decoding. - // MinNumVideoBuffers: some platform decoders have decoding time longer than - // frame duration. To avoid frame dropping in this case, the client queues - // frames before starting to play. This value tells the client the least - // amount of frames it should queue. - // MaxNumCurrentImages: specifies how many (output) video buffers are current - // (renderable) at a time. - // The result is not accurated until Init() is resolved. - MOZ_DEFINE_ENUM_CLASS_WITH_TOSTRING_AT_CLASS_SCOPE(PropertyName, - (MaxNumVideoBuffers, - MinNumVideoBuffers, - MaxNumCurrentImages)); - // Generic type for property values to avoid breaking existing client code in - // the future. - using PropertyValue = Variant<uint32_t>; - virtual Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const { - return Nothing(); - } }; } // namespace mozilla diff --git a/dom/media/platforms/android/AndroidDecoderModule.cpp b/dom/media/platforms/android/AndroidDecoderModule.cpp @@ -341,16 +341,6 @@ already_AddRefed<MediaDataDecoder> AndroidDecoderModule::CreateVideoDecoder( return nullptr; } - // Don't use SW VPX MediaCodecs. Prefering VPXDecoder over MediaCodec SW - // decoder implementation allow us to have more consistent cross-platform VPX - // playback experience and be able to get upstream bug fixes/improvements more - // frequently. - if (VPXDecoder::IsVPX(aParams.VideoConfig().mMimeType) && - !SupportsMimeType(aParams.VideoConfig().mMimeType) - .contains(DecodeSupport::HardwareDecode)) { - return nullptr; - } - nsString drmStubId; if (mProxy) { drmStubId = mProxy->GetMediaDrmStubId(); diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -348,25 +348,6 @@ class RemoteVideoDecoder final : public RemoteDataDecoder { return ConversionRequired::kNeedAnnexB; } - Maybe<MediaDataDecoder::PropertyValue> GetDecodeProperty( - MediaDataDecoder::PropertyName aName) const override { - // Android has limited amount of output buffers. See Bug 794747. - static constexpr uint32_t kNumOutputBuffers = 3; - // SurfaceTexture can have only one current/renderable image at a time. - // See Bug 1299068 - static constexpr uint32_t kNumCurrentImages = 1; - switch (aName) { - case PropertyName::MaxNumVideoBuffers: - [[fallthrough]]; - case PropertyName::MinNumVideoBuffers: - return Some(PropertyValue(kNumOutputBuffers)); - case PropertyName::MaxNumCurrentImages: - return Some(PropertyValue(kNumCurrentImages)); - default: - return MediaDataDecoder::GetDecodeProperty(aName); - } - } - private: // Param and LocalRef are only valid for the duration of a JNI method call. // Use GlobalRef as the parameter type to keep the Java object referenced diff --git a/dom/media/platforms/apple/AppleVTDecoder.h b/dom/media/platforms/apple/AppleVTDecoder.h @@ -81,18 +81,6 @@ class AppleVTDecoder final : public MediaDataDecoder, return ConversionRequired::kNeedNone; } - Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override { - // Some Intel GPU has long decoding time and needs more frames queued to - // play smoothly. See bug 1230641. - static constexpr uint32_t kMinNumOutputBuffers = 10; - switch (aName) { - case PropertyName::MinNumVideoBuffers: - return Some(PropertyValue(kMinNumOutputBuffers)); - default: - return MediaDataDecoder::GetDecodeProperty(aName); - } - } - // Access from the taskqueue and the decoder's thread. // OutputFrame is thread-safe. void OutputFrame(CVPixelBufferRef aImage, AppleFrameRef aFrameRef); diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.h b/dom/media/platforms/wrappers/MediaChangeMonitor.h @@ -79,13 +79,6 @@ class MediaChangeMonitor final return ConversionRequired::kNeedNone; } - Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override { - if (RefPtr<MediaDataDecoder> decoder = GetDecoderOnNonOwnerThread()) { - return decoder->GetDecodeProperty(aName); - } - return MediaDataDecoder::GetDecodeProperty(aName); - } - class CodecChangeMonitor { public: virtual bool CanBeInstantiated() const = 0; diff --git a/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp b/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp @@ -152,11 +152,4 @@ MediaDataDecoder::ConversionRequired MediaDataDecoderProxy::NeedsConversion() return mProxyDecoder->NeedsConversion(); } -Maybe<MediaDataDecoder::PropertyValue> MediaDataDecoderProxy::GetDecodeProperty( - MediaDataDecoder::PropertyName aName) const { - MOZ_ASSERT(!mIsShutdown); - - return mProxyDecoder->GetDecodeProperty(aName); -} - } // namespace mozilla diff --git a/dom/media/platforms/wrappers/MediaDataDecoderProxy.h b/dom/media/platforms/wrappers/MediaDataDecoderProxy.h @@ -46,7 +46,6 @@ class MediaDataDecoderProxy bool SupportDecoderRecycling() const override; bool ShouldDecoderAlwaysBeRecycled() const override; ConversionRequired NeedsConversion() const override; - Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override; protected: ~MediaDataDecoderProxy() = default; diff --git a/mobile/android/app/geckoview-prefs.js b/mobile/android/app/geckoview-prefs.js @@ -323,6 +323,14 @@ pref("media.navigator.permission.device", true); // this is to preserve battery and data (bug 1540573) pref("media.throttle-cellular-regardless-of-download-rate", true); +// Number of video frames we buffer while decoding video. +// On Android this is decided by a similar value which varies for +// each OMX decoder |OMX_PARAM_PORTDEFINITIONTYPE::nBufferCountMin|. This +// number must be less than the OMX equivalent or gecko will think it is +// chronically starved of video frames. All decoders seen so far have a value +// of at least 4. (bug 973408) +pref("media.video-queue.default-size", 3); + // The maximum number of queued frames to send to the compositor. // On Android, it needs to be throttled because SurfaceTexture contains only one // (the most recent) image data. (bug 1299068)