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
This commit is contained in:
Jean-Yves Avenard 2015-10-29 00:46:31 +11:00
parent 1906624f4a
commit 3a242f3099
3 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -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,

View File

@ -53,6 +53,7 @@ private:
void OnDecoderInitFailed(MediaDataDecoder::DecoderFailureReason aReason);
RefPtr<PlatformDecoderModule> mPDM;
const VideoInfo& mOriginalConfig;
VideoInfo mCurrentConfig;
layers::LayersBackend mLayersBackend;
RefPtr<layers::ImageContainer> mImageContainer;