зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1141333: Mark reader has ended when EndOfStream explicit. r=mattwoodrow
This commit is contained in:
Родитель
66af51d5a7
Коммит
ece3ad624d
|
@ -297,15 +297,14 @@ MediaSource::EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, Er
|
|||
|
||||
SetReadyState(MediaSourceReadyState::Ended);
|
||||
mSourceBuffers->Ended();
|
||||
mDecoder->Ended();
|
||||
if (!aError.WasPassed()) {
|
||||
mDecoder->SetMediaSourceDuration(mSourceBuffers->GetHighestBufferedEndTime(),
|
||||
MSRangeRemovalAction::SKIP);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
// TODO:
|
||||
// Notify media element that all data is now available.
|
||||
// Notify reader that all data is now available.
|
||||
mDecoder->Ended(true);
|
||||
return;
|
||||
}
|
||||
switch (aError.Value()) {
|
||||
|
@ -456,6 +455,10 @@ MediaSource::SetReadyState(MediaSourceReadyState aState)
|
|||
(oldState == MediaSourceReadyState::Closed ||
|
||||
oldState == MediaSourceReadyState::Ended)) {
|
||||
QueueAsyncSimpleEvent("sourceopen");
|
||||
if (oldState == MediaSourceReadyState::Ended) {
|
||||
// Notify reader that more data may come.
|
||||
mDecoder->Ended(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,10 +156,10 @@ MediaSourceDecoder::OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const Med
|
|||
}
|
||||
|
||||
void
|
||||
MediaSourceDecoder::Ended()
|
||||
MediaSourceDecoder::Ended(bool aEnded)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
mReader->Ended();
|
||||
mReader->Ended(aEnded);
|
||||
mon.NotifyAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void RemoveTrackBuffer(TrackBuffer* aTrackBuffer);
|
||||
void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
|
||||
|
||||
void Ended();
|
||||
void Ended(bool aEnded);
|
||||
bool IsExpectingMoreData() override;
|
||||
|
||||
// Return the duration of the video in seconds.
|
||||
|
|
|
@ -39,12 +39,6 @@ extern PRLogModuleInfo* GetMediaSourceLog();
|
|||
// default value used in Blink, kDefaultBufferDurationInMs.
|
||||
#define EOS_FUZZ_US 125000
|
||||
|
||||
// Audio and video source buffers often have a slight duration
|
||||
// discrepency. We want to handle the case where a source buffer is smaller than
|
||||
// another by more than EOS_FUZZ_US so we can properly detect EOS in IsNearEnd().
|
||||
// This value was chosen at random, to cater for most streams seen in the wild.
|
||||
#define DURATION_DIFFERENCE_FUZZ 300000
|
||||
|
||||
using mozilla::dom::TimeRanges;
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -1127,10 +1121,10 @@ MediaSourceReader::ReadUpdatedMetadata(MediaInfo* aInfo)
|
|||
}
|
||||
|
||||
void
|
||||
MediaSourceReader::Ended()
|
||||
MediaSourceReader::Ended(bool aEnded)
|
||||
{
|
||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
mEnded = true;
|
||||
mEnded = aEnded;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1147,21 +1141,11 @@ MediaSourceReader::IsNearEnd(MediaData::Type aType, int64_t aTime)
|
|||
if (!mEnded) {
|
||||
return false;
|
||||
}
|
||||
if (aTime >= (mMediaSourceDuration * USECS_PER_S - EOS_FUZZ_US)) {
|
||||
return true;
|
||||
}
|
||||
// We may have discrepencies between the mediasource duration and the
|
||||
// sourcebuffer end time (mMediaSourceDuration == max(audio.EndTime, video.EndTime)
|
||||
// If the sourcebuffer duration is close enough to the mediasource duration,
|
||||
// then use it instead to determine if we're near the end.
|
||||
TrackBuffer* trackBuffer =
|
||||
aType == MediaData::AUDIO_DATA ? mAudioTrack : mVideoTrack;
|
||||
nsRefPtr<dom::TimeRanges> buffered = new dom::TimeRanges();
|
||||
trackBuffer->Buffered(buffered);
|
||||
if ((mMediaSourceDuration - buffered->GetEndTime()) * USECS_PER_S <= DURATION_DIFFERENCE_FUZZ) {
|
||||
return aTime >= std::floor(buffered->GetEndTime() * USECS_PER_S);
|
||||
}
|
||||
return false;
|
||||
return aTime >= (buffered->GetEndTime() * USECS_PER_S - EOS_FUZZ_US);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -135,11 +135,11 @@ public:
|
|||
bool TrackBuffersContainTime(int64_t aTime);
|
||||
|
||||
// Mark the reader to indicate that EndOfStream has been called on our MediaSource
|
||||
void Ended();
|
||||
|
||||
// Return true if the Ended method has been called
|
||||
// and that the media element has all the media data.
|
||||
// If called with true, the reader will come out of ended mode.
|
||||
void Ended(bool aEnded);
|
||||
// Return true if reader has all of the media data.
|
||||
bool IsEnded();
|
||||
bool IsNearEnd(MediaData::Type aType, int64_t aTime /* microseconds */);
|
||||
|
||||
// Set the duration of the attached mediasource element.
|
||||
void SetMediaSourceDuration(double aDuration /* seconds */);
|
||||
|
@ -227,6 +227,8 @@ private:
|
|||
void AttemptSeek();
|
||||
bool IsSeeking() { return mPendingSeekTime != -1; }
|
||||
|
||||
bool IsNearEnd(MediaData::Type aType, int64_t aTime /* microseconds */);
|
||||
|
||||
nsRefPtr<SourceBufferDecoder> mAudioSourceDecoder;
|
||||
nsRefPtr<SourceBufferDecoder> mVideoSourceDecoder;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче