Bug 1309516 part 3 - make MediaDecoderReaderWrapper keeps the start time returned from reader;r=jwwang

MozReview-Commit-ID: F57avqCENTj

--HG--
extra : rebase_source : 4e61cb46687539f5b5b2a775b46ad5347ccc6e2a
extra : intermediate-source : 50c6ae37fa51c52d533bb5cdcd1267a869d49410
extra : source : cb9924bcc2c1d2a820b7b942c89feb861be85569
This commit is contained in:
Kaku Kuo 2016-10-14 19:10:24 +08:00
Родитель cbdf4764bf
Коммит e9f26909ec
2 изменённых файлов: 9 добавлений и 33 удалений

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

@ -153,7 +153,7 @@ MediaDecoderReaderWrapper::StartTime() const
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
return media::TimeUnit::FromMicroseconds(mStartTimeRendezvous->StartTime());
return mStartTime.ref();
}
RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
@ -186,13 +186,6 @@ MediaDecoderReaderWrapper::RequestAudioData()
auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
&MediaDecoderReader::RequestAudioData);
if (!mStartTimeRendezvous->HaveStartTime()) {
p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
&StartTimeRendezvous::ProcessFirstSample<MediaData::AUDIO_DATA>,
&StartTimeRendezvous::FirstSampleRejected<MediaData::AUDIO_DATA>)
->CompletionPromise();
}
RefPtr<MediaDecoderReaderWrapper> self = this;
mAudioDataRequest.Begin(p->Then(mOwnerThread, __func__,
[self] (MediaData* aAudioSample) {
@ -217,8 +210,7 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
// a TimeStamp as its second parameter.
TimeStamp videoDecodeStartTime = TimeStamp::Now();
if (aTimeThreshold.ToMicroseconds() > 0 &&
mStartTimeRendezvous->HaveStartTime()) {
if (aTimeThreshold.ToMicroseconds() > 0) {
aTimeThreshold += StartTime();
}
@ -226,13 +218,6 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
&MediaDecoderReader::RequestVideoData,
aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());
if (!mStartTimeRendezvous->HaveStartTime()) {
p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
&StartTimeRendezvous::ProcessFirstSample<MediaData::VIDEO_DATA>,
&StartTimeRendezvous::FirstSampleRejected<MediaData::VIDEO_DATA>)
->CompletionPromise();
}
RefPtr<MediaDecoderReaderWrapper> self = this;
mVideoDataRequest.Begin(p->Then(mOwnerThread, __func__,
[self, videoDecodeStartTime] (MediaData* aVideoSample) {
@ -389,23 +374,13 @@ MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder* aMetadata)
if (mShutdown) {
return;
}
// Set up the start time rendezvous if it doesn't already exist (which is
// generally the case, unless we're coming out of dormant mode).
if (!mStartTimeRendezvous) {
mStartTimeRendezvous = new StartTimeRendezvous(
mOwnerThread, aMetadata->mInfo.HasAudio(),
aMetadata->mInfo.HasVideo(), mForceZeroStartTime);
RefPtr<MediaDecoderReaderWrapper> self = this;
mStartTimeRendezvous->AwaitStartTime()->Then(
mOwnerThread, __func__,
[self] () {
NS_ENSURE_TRUE_VOID(!self->mShutdown);
self->mReader->DispatchSetStartTime(self->StartTime().ToMicroseconds());
},
[] () {
NS_WARNING("Setting start time on reader failed");
});
if (mStartTime.isNothing()) {
mStartTime.emplace(aMetadata->mInfo.mStartTime);
// Note: MFR should be able to setup its start time by itself without going
// through here. MediaDecoderReader::DispatchSetStartTime() will be removed
// once we remove all the legacy readers' code in the following bugs.
mReader->DispatchSetStartTime(StartTime().ToMicroseconds());
}
}

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

@ -131,6 +131,7 @@ private:
bool mShutdown = false;
RefPtr<StartTimeRendezvous> mStartTimeRendezvous;
Maybe<media::TimeUnit> mStartTime;
MozPromiseRequestHolder<MediaDataPromise> mAudioDataRequest;
MozPromiseRequestHolder<MediaDataPromise> mVideoDataRequest;