Bug 1274626 part 5 - provide APIs to switch to blank decoders dynamically; r=jya

MozReview-Commit-ID: PyoIsrEf1r

--HG--
extra : transplant_source : C%D6%9E%89%E2O%DB%DFb%A8%9Az%1FE%11%06oo%EE%3C
This commit is contained in:
Kaku Kuo 2016-07-29 14:51:18 +08:00
Родитель 849fdb252e
Коммит c058f404b8
5 изменённых файлов: 57 добавлений и 2 удалений

Просмотреть файл

@ -317,6 +317,11 @@ public:
return &mIsSuspended;
}
// Switch the video decoder to BlankDecoderModule. It might takes effective
// since a few samples later depends on how much demuxed samples are already
// queued in the original video decoder.
virtual void SetVideoBlankDecode(bool aIsBlankDecode) {}
protected:
virtual ~MediaDecoderReader();

Просмотреть файл

@ -410,4 +410,14 @@ MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder* aMetadata)
}
}
void
MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
NewRunnableMethod<bool>(mReader, &MediaDecoderReader::SetVideoBlankDecode,
aIsBlankDecode);
mReader->OwnerThread()->Dispatch(r.forget());
}
} // namespace mozilla

Просмотреть файл

@ -121,6 +121,8 @@ public:
void SetCDMProxy(CDMProxy* aProxy) { mReader->SetCDMProxy(aProxy); }
#endif
void SetVideoBlankDecode(bool aIsBlankDecode);
private:
~MediaDecoderReaderWrapper();

Просмотреть файл

@ -418,7 +418,8 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
decoder.mInfo ? *decoder.mInfo->GetAsAudioInfo() : mInfo.mAudio,
decoder.mTaskQueue,
decoder.mCallback.get(),
mCrashHelper
mCrashHelper,
decoder.mIsBlankDecode
});
break;
}
@ -432,7 +433,8 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
decoder.mCallback.get(),
mLayersBackendType,
GetImageContainer(),
mCrashHelper
mCrashHelper,
decoder.mIsBlankDecode
});
break;
}
@ -2060,4 +2062,32 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
aString += NS_ConvertUTF8toUTF16(result);
}
void
MediaFormatReader::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(OnTaskQueue());
return SetBlankDecode(TrackType::kVideoTrack, aIsBlankDecode);
}
void
MediaFormatReader::SetBlankDecode(TrackType aTrack, bool aIsBlankDecode)
{
MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack);
LOG("%s, decoder.mIsBlankDecode = %d => aIsBlankDecode = %d",
TrackTypeToStr(aTrack), decoder.mIsBlankDecode, aIsBlankDecode);
if (decoder.mIsBlankDecode == aIsBlankDecode) {
return;
}
decoder.mIsBlankDecode = aIsBlankDecode;
decoder.Flush();
decoder.ShutdownDecoder();
NotifyDecodingRequested(TrackInfo::kVideoTrack); // Calls ScheduleUpdate().
return;
}
} // namespace mozilla

Просмотреть файл

@ -101,6 +101,8 @@ public:
// Used for debugging purposes.
void GetMozDebugReaderData(nsAString& aString);
void SetVideoBlankDecode(bool aIsBlankDecode) override;
private:
bool HasVideo() { return mVideo.mTrackDemuxer; }
@ -253,6 +255,7 @@ private:
, mSizeOfQueue(0)
, mIsHardwareAccelerated(false)
, mLastStreamSourceID(UINT32_MAX)
, mIsBlankDecode(false)
{}
MediaFormatReader* mOwner;
@ -427,6 +430,9 @@ private:
Maybe<media::TimeUnit> mLastTimeRangesEnd;
RefPtr<SharedTrackInfo> mInfo;
Maybe<media::TimeUnit> mFirstDemuxedSampleTime;
// Use BlankDecoderModule or not.
bool mIsBlankDecode;
};
class DecoderDataWithPromise : public DecoderData {
@ -571,6 +577,8 @@ private:
RefPtr<CDMProxy> mCDMProxy;
#endif
RefPtr<GMPCrashHelper> mCrashHelper;
void SetBlankDecode(TrackType aTrack, bool aIsBlankDecode);
};
} // namespace mozilla