Bug 1312958: P1. Do not modify original Audio/Video info. r=gerald

The issue is particularly problematic with the Apple audio decoder. The Apple decoder relies on the sampling rate to configure the CoreAudio transform.
The actual output rate may be different (such as with HE-AAC). Should the decoder ever need to be reset again, future initialization would have failed as the initial rate was now incorrect.

MozReview-Commit-ID: 7kTiaUYuOgf

--HG--
extra : rebase_source : 00119a13205c610542a2f690ce6c3b9caeb1b69c
This commit is contained in:
Jean-Yves Avenard 2016-10-26 20:09:41 +11:00
parent 84abd2cc9a
commit f1049dae10
2 changed files with 10 additions and 2 deletions

View File

@ -288,6 +288,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
for (const MetadataTag& tag : videoInfo->mTags) {
tags->Put(tag.mKey, tag.mValue);
}
mVideo.mOriginalInfo = Move(videoInfo);
mVideo.mCallback = new DecoderCallback(this, TrackInfo::kVideoTrack);
mVideo.mTimeRanges = mVideo.mTrackDemuxer->GetBuffered();
mTrackDemuxersMayBlock |= mVideo.mTrackDemuxer->GetSamplesMayBlock();
@ -316,6 +317,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
for (const MetadataTag& tag : audioInfo->mTags) {
tags->Put(tag.mKey, tag.mValue);
}
mAudio.mOriginalInfo = Move(audioInfo);
mAudio.mCallback = new DecoderCallback(this, TrackInfo::kAudioTrack);
mAudio.mTimeRanges = mAudio.mTrackDemuxer->GetBuffered();
mTrackDemuxersMayBlock |= mAudio.mTrackDemuxer->GetSamplesMayBlock();
@ -403,7 +405,9 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
switch (aTrack) {
case TrackType::kAudioTrack: {
decoder.mDecoder = mPlatform->CreateDecoder({
decoder.mInfo ? *decoder.mInfo->GetAsAudioInfo() : mInfo.mAudio,
decoder.mInfo
? *decoder.mInfo->GetAsAudioInfo()
: *decoder.mOriginalInfo->GetAsAudioInfo(),
decoder.mTaskQueue,
decoder.mCallback.get(),
mCrashHelper,
@ -417,7 +421,9 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
// Decoders use the layers backend to decide if they can use hardware decoding,
// so specify LAYERS_NONE if we want to forcibly disable it.
decoder.mDecoder = mPlatform->CreateDecoder({
mVideo.mInfo ? *mVideo.mInfo->GetAsVideoInfo() : mInfo.mVideo,
decoder.mInfo
? *decoder.mInfo->GetAsVideoInfo()
: *decoder.mOriginalInfo->GetAsVideoInfo(),
decoder.mTaskQueue,
decoder.mCallback.get(),
mKnowsCompositor,

View File

@ -425,6 +425,8 @@ private:
Maybe<uint32_t> mNextStreamSourceID;
media::TimeIntervals mTimeRanges;
Maybe<media::TimeUnit> mLastTimeRangesEnd;
// TrackInfo as first discovered during ReadMetadata.
UniquePtr<TrackInfo> mOriginalInfo;
RefPtr<SharedTrackInfo> mInfo;
Maybe<media::TimeUnit> mFirstDemuxedSampleTime;
// Use BlankDecoderModule or not.