Bug 1293646: [MSE] P2. Only reject a seek request with EOS if it's passed the explicit duration. r=gerald

With MSE, the actual duration is always exact as it is amended when data is added. We do not want to fire ended when we attempt to seek to unbuffered data once endOfStream has been called. Instead we will fire the waiting event.

MozReview-Commit-ID: Cl2uBLk2qRQ

--HG--
extra : rebase_source : 6763c6f5a6e15264e276e486fab4d39491ea7f1b
This commit is contained in:
Jean-Yves Avenard 2016-08-10 15:30:12 +10:00
Родитель aecc883033
Коммит 58cb3ab298
4 изменённых файлов: 38 добавлений и 4 удалений

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

@ -61,6 +61,7 @@ public:
virtual void NotifyDecodedFrames(const FrameStatisticsData& aStats) = 0;
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
virtual AbstractCanonical<Maybe<double>>* CanonicalExplicitDuration() { return nullptr; }
// Return an event that will be notified when data arrives in MediaResource.
// MediaDecoderReader will register with this event to receive notifications

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

@ -822,6 +822,9 @@ protected:
public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() override;
AbstractCanonical<Maybe<double>>* CanonicalExplicitDuration() override {
return &mExplicitDuration;
}
AbstractCanonical<double>* CanonicalVolume() {
return &mVolume;
}
@ -834,9 +837,6 @@ public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalEstimatedDuration() {
return &mEstimatedDuration;
}
AbstractCanonical<Maybe<double>>* CanonicalExplicitDuration() {
return &mExplicitDuration;
}
AbstractCanonical<PlayState>* CanonicalPlayState() {
return &mPlayState;
}

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

@ -77,6 +77,7 @@ MediaFormatReader::MediaFormatReader(AbstractMediaDecoder* aDecoder,
, mDemuxOnly(false)
, mSeekScheduled(false)
, mVideoFrameContainer(aVideoFrameContainer)
, mExplicitDuration(mTaskQueue, Maybe<double>(), "MediaFormatReader::mExplicitDuration(Mirror)")
{
MOZ_ASSERT(aDemuxer);
MOZ_COUNT_CTOR(MediaFormatReader);
@ -141,6 +142,8 @@ MediaFormatReader::Shutdown()
mPlatform = nullptr;
mVideoFrameContainer = nullptr;
mExplicitDuration.DisconnectIfConnected();
return MediaDecoderReader::Shutdown();
}
@ -253,6 +256,10 @@ MediaFormatReader::AsyncReadMetadata()
return MetadataPromise::CreateAndResolve(metadata, __func__);
}
if (mDecoder->CanonicalExplicitDuration()) {
mExplicitDuration.Connect(mDecoder->CanonicalExplicitDuration());
}
RefPtr<MetadataPromise> p = mMetadataPromise.Ensure(__func__);
mDemuxerInitRequest.Begin(mDemuxer->Init()
@ -1077,6 +1084,20 @@ MediaFormatReader::InternalSeek(TrackType aTrack, const InternalSeekTarget& aTar
[self, aTrack] (DemuxerFailureReason aResult) {
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
if (aResult == DemuxerFailureReason::END_OF_STREAM) {
// We want to enter EOS when performing an
// internal seek only if we're attempting to seek past
// the explicit duration to avoid unwanted ended
// event to be fired.
if (self->mExplicitDuration.Ref().isSome() &&
decoder.mTimeThreshold.ref().Time() <
TimeUnit::FromSeconds(
self->mExplicitDuration.Ref().ref())) {
aResult = DemuxerFailureReason::WAITING_FOR_DATA;
}
}
switch (aResult) {
case DemuxerFailureReason::WAITING_FOR_DATA:
self->NotifyWaitingForData(aTrack);
@ -1726,6 +1747,14 @@ MediaFormatReader::OnSeekFailed(TrackType aTrack, DemuxerFailureReason aResult)
mAudio.mSeekRequest.Complete();
}
// We want to enter EOS when performing a seek only if we're attempting to
// seek past the explicit duration to avoid unwanted ended
// event to be fired.
if (mExplicitDuration.Ref().isSome() &&
mPendingSeekTime.ref() < TimeUnit::FromSeconds(mExplicitDuration.Ref().ref())) {
aResult = DemuxerFailureReason::WAITING_FOR_DATA;
}
if (aResult == DemuxerFailureReason::WAITING_FOR_DATA) {
if (HasVideo() && aTrack == TrackType::kAudioTrack &&
mFallbackSeekTime.isSome() &&

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

@ -9,8 +9,9 @@
#include "mozilla/Atomics.h"
#include "mozilla/Maybe.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/Monitor.h"
#include "mozilla/StateMirroring.h"
#include "mozilla/TaskQueue.h"
#include "MediaDataDemuxer.h"
#include "MediaDecoderReader.h"
@ -579,6 +580,9 @@ private:
RefPtr<GMPCrashHelper> mCrashHelper;
void SetBlankDecode(TrackType aTrack, bool aIsBlankDecode);
// The duration explicitly set by JS, mirrored from the main thread.
Mirror<Maybe<double>> mExplicitDuration;
};
} // namespace mozilla