зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1345599 - part 3: for recyclable decoder, don't drain/flush when stream ID/SPS change. r=jya
MozReview-Commit-ID: 4qtlbMWgfPo --HG-- extra : rebase_source : f5b71b6803e2f725639e675081bc30cd0b1bde2a
This commit is contained in:
Родитель
5a454c0c9d
Коммит
66e158e1c6
|
@ -1961,8 +1961,11 @@ MediaFormatReader::HandleDemuxedSamples(
|
|||
RefPtr<TrackInfoSharedPtr> info = sample->mTrackInfo;
|
||||
|
||||
if (info && decoder.mLastStreamSourceID != info->GetID()) {
|
||||
if (decoder.mNextStreamSourceID.isNothing()
|
||||
|| decoder.mNextStreamSourceID.ref() != info->GetID()) {
|
||||
bool recyclable = MediaPrefs::MediaDecoderCheckRecycling()
|
||||
&& decoder.mDecoder->SupportDecoderRecycling();
|
||||
if (!recyclable
|
||||
&& (decoder.mNextStreamSourceID.isNothing()
|
||||
|| decoder.mNextStreamSourceID.ref() != info->GetID())) {
|
||||
LOG("%s stream id has changed from:%d to:%d, draining decoder.",
|
||||
TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
|
||||
info->GetID());
|
||||
|
@ -1978,8 +1981,7 @@ MediaFormatReader::HandleDemuxedSamples(
|
|||
decoder.mLastStreamSourceID = info->GetID();
|
||||
decoder.mNextStreamSourceID.reset();
|
||||
|
||||
if (!MediaPrefs::MediaDecoderCheckRecycling()
|
||||
|| !decoder.mDecoder->SupportDecoderRecycling()) {
|
||||
if (!recyclable) {
|
||||
LOG("Decoder does not support recycling, recreate decoder.");
|
||||
// If flushing is required, it will clear our array of queued samples.
|
||||
// So make a copy now.
|
||||
|
|
|
@ -332,32 +332,11 @@ H264Converter::CheckForSPSChange(MediaRawData* aSample)
|
|||
if (CanRecycleDecoder()) {
|
||||
// Do not recreate the decoder, reuse it.
|
||||
UpdateConfigFromExtraData(extra_data);
|
||||
// Ideally we would want to drain the decoder instead of flushing it.
|
||||
// However the draining operation requires calling Drain and looping several
|
||||
// times which isn't possible from within the H264Converter. So instead we
|
||||
// flush the decoder. In practice, this is a no-op as SPS change will only
|
||||
// be used with MSE. And with MSE, the MediaFormatReader would have drained
|
||||
// the decoder already.
|
||||
RefPtr<H264Converter> self = this;
|
||||
if (!sample->mTrackInfo) {
|
||||
sample->mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, 0);
|
||||
}
|
||||
mDecoder->Flush()
|
||||
->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
|
||||
__func__,
|
||||
[self, sample, this]() {
|
||||
mFlushRequest.Complete();
|
||||
DecodeFirstSample(sample);
|
||||
},
|
||||
[self, this](const MediaResult& aError) {
|
||||
mFlushRequest.Complete();
|
||||
mDecodePromise.Reject(aError, __func__);
|
||||
})
|
||||
->Track(mFlushRequest);
|
||||
mNeedKeyframe = true;
|
||||
// This is not really initializing the decoder, but it will do as it
|
||||
// indicates an operation is pending.
|
||||
return NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The SPS has changed, signal to flush the current decoder and create a
|
||||
|
|
Загрузка…
Ссылка в новой задаче