From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/media/webcodecs/DecoderTypes.h | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'dom/media/webcodecs/DecoderTypes.h') diff --git a/dom/media/webcodecs/DecoderTypes.h b/dom/media/webcodecs/DecoderTypes.h index 339a164f70..4817a66f17 100644 --- a/dom/media/webcodecs/DecoderTypes.h +++ b/dom/media/webcodecs/DecoderTypes.h @@ -50,22 +50,22 @@ class VideoDecoderConfigInternal { Maybe&& aCodedHeight, Maybe&& aCodedWidth, Maybe&& aColorSpace, - Maybe>&& aDescription, + already_AddRefed aDescription, Maybe&& aDisplayAspectHeight, Maybe&& aDisplayAspectWidth, const HardwareAcceleration& aHardwareAcceleration, Maybe&& aOptimizeForLatency); ~VideoDecoderConfigInternal() = default; - nsString ToString() const; + nsCString ToString() const; bool Equals(const VideoDecoderConfigInternal& aOther) const { - if (mDescription.isSome() != aOther.mDescription.isSome()) { + if (mDescription != aOther.mDescription) { return false; } - if (mDescription.isSome() && aOther.mDescription.isSome()) { - auto lhs = mDescription.value(); - auto rhs = aOther.mDescription.value(); + if (mDescription && aOther.mDescription) { + auto lhs = mDescription; + auto rhs = aOther.mDescription; if (lhs->Length() != rhs->Length()) { return false; } @@ -86,7 +86,7 @@ class VideoDecoderConfigInternal { Maybe mCodedHeight; Maybe mCodedWidth; Maybe mColorSpace; - Maybe> mDescription; + RefPtr mDescription; Maybe mDisplayAspectHeight; Maybe mDisplayAspectWidth; HardwareAcceleration mHardwareAcceleration; @@ -116,24 +116,42 @@ class VideoDecoderTraits { class AudioDecoderConfigInternal { public: + AudioDecoderConfigInternal(const nsAString& aCodec, uint32_t aSampleRate, + uint32_t aNumberOfChannels, + already_AddRefed aDescription); static UniquePtr Create( const AudioDecoderConfig& aConfig); ~AudioDecoderConfigInternal() = default; + bool Equals(const AudioDecoderConfigInternal& aOther) const { + if (mDescription != aOther.mDescription) { + return false; + } + if (mDescription && aOther.mDescription) { + auto lhs = mDescription; + auto rhs = aOther.mDescription; + if (lhs->Length() != rhs->Length()) { + return false; + } + if (!ArrayEqual(lhs->Elements(), rhs->Elements(), lhs->Length())) { + return false; + } + } + return mCodec.Equals(aOther.mCodec) && mSampleRate == aOther.mSampleRate && + mNumberOfChannels == aOther.mNumberOfChannels && + mOptimizeForLatency == aOther.mOptimizeForLatency; + } + nsCString ToString() const; + nsString mCodec; uint32_t mSampleRate; uint32_t mNumberOfChannels; - Maybe> mDescription; + RefPtr mDescription; // Compilation fix, should be abstracted by DecoderAgent since those are not // supported HardwareAcceleration mHardwareAcceleration = HardwareAcceleration::No_preference; Maybe mOptimizeForLatency; - - private: - AudioDecoderConfigInternal(const nsAString& aCodec, uint32_t aSampleRate, - uint32_t aNumberOfChannels, - Maybe>&& aDescription); }; class AudioDecoderTraits { -- cgit v1.2.3