From bf28a582ea5e7ad3a9aa12abe68f25ee6e80e0c8 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 29 Oct 2015 00:46:31 +1100 Subject: [PATCH] Bug 1195094: P2. Ensure TrackInfo object passed to constructor is never modified. r=cpearce The PDM documentation states that it is safe to keep a reference to the TrackInfo object provided to the constructor. However, this wasn't enforced by the H264Converter which would modify the object and worse, did in a non thread-safe fashion --- dom/media/platforms/PlatformDecoderModule.h | 2 ++ dom/media/platforms/wrappers/H264Converter.cpp | 3 ++- dom/media/platforms/wrappers/H264Converter.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h index 46d3ecde8ed..9ce212a4f4a 100644 --- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -214,6 +214,8 @@ public: // that the format of the next input sample is about to change. // If video decoder, aConfig will be a VideoInfo object. // If audio decoder, aConfig will be a AudioInfo object. + // It is not safe to store a reference to this object and the decoder must + // make a copy. virtual nsresult ConfigurationChanged(const TrackInfo& aConfig) { return NS_OK; diff --git a/dom/media/platforms/wrappers/H264Converter.cpp b/dom/media/platforms/wrappers/H264Converter.cpp index 4afdd44f851..104c3c92fc8 100644 --- a/dom/media/platforms/wrappers/H264Converter.cpp +++ b/dom/media/platforms/wrappers/H264Converter.cpp @@ -22,6 +22,7 @@ H264Converter::H264Converter(PlatformDecoderModule* aPDM, FlushableTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback) : mPDM(aPDM) + , mOriginalConfig(aConfig) , mCurrentConfig(aConfig) , mLayersBackend(aLayersBackend) , mImageContainer(aImageContainer) @@ -139,7 +140,7 @@ H264Converter::CreateDecoder() } UpdateConfigFromExtraData(mCurrentConfig.mExtraData); - mDecoder = mPDM->CreateVideoDecoder(mCurrentConfig, + mDecoder = mPDM->CreateVideoDecoder(mNeedAVCC ? mCurrentConfig : mOriginalConfig, mLayersBackend, mImageContainer, mVideoTaskQueue, diff --git a/dom/media/platforms/wrappers/H264Converter.h b/dom/media/platforms/wrappers/H264Converter.h index 132a3f8e9dc..bba2ac6349f 100644 --- a/dom/media/platforms/wrappers/H264Converter.h +++ b/dom/media/platforms/wrappers/H264Converter.h @@ -53,6 +53,7 @@ private: void OnDecoderInitFailed(MediaDataDecoder::DecoderFailureReason aReason); RefPtr mPDM; + const VideoInfo& mOriginalConfig; VideoInfo mCurrentConfig; layers::LayersBackend mLayersBackend; RefPtr mImageContainer;