Bug 1297036: [MSE] P5. Make fuzz research consistent. r?gerald
The aim is to only allow skipping gaps of fuzz=500ms.
MozReview-Commit-ID: 8uHxni2nPHI
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -389,32 +389,32 @@ MediaSourceTrackDemuxer::DoSeek(media::T
if (mManager->IsEnded() && seekTime >= buffered.GetEnd()) {
// We're attempting to seek past the end time. Cap seekTime so that we seek
// to the last sample instead.
seekTime =
std::max(mManager->HighestStartTime(mType) - mPreRoll,
TimeUnit::FromMicroseconds(0));
}
- if (!buffered.Contains(seekTime)) {
- if (!buffered.Contains(aTime)) {
+ if (!buffered.ContainsWithStrictEnd(seekTime)) {
+ if (!buffered.ContainsWithStrictEnd(aTime)) {
// We don't have the data to seek to.
return SeekPromise::CreateAndReject(DemuxerFailureReason::WAITING_FOR_DATA,
__func__);
}
// Theoretically we should reject the promise with WAITING_FOR_DATA,
// however, to avoid unwanted regressions we assume that if at this time
// we don't have the wanted data it won't come later.
// Instead of using the pre-rolled time, use the earliest time available in
// the interval.
TimeIntervals::IndexType index = buffered.Find(aTime);
MOZ_ASSERT(index != TimeIntervals::NoIndex);
seekTime = buffered[index].mStart;
}
- seekTime = mManager->Seek(mType, seekTime, MediaSourceDemuxer::EOS_FUZZ / 2);
+ seekTime = mManager->Seek(mType, seekTime, MediaSourceDemuxer::EOS_FUZZ);
Result result;
RefPtr<MediaRawData> sample =
mManager->GetSample(mType,
media::TimeUnit(),
result);
MOZ_ASSERT(result != Result::ERROR && sample);
mNextSample = Some(sample);
mReset = false;
@@ -430,23 +430,23 @@ RefPtr<MediaSourceTrackDemuxer::SamplesP
MediaSourceTrackDemuxer::DoGetSamples(int32_t aNumSamples)
{
typedef TrackBuffersManager::GetSampleResult Result;
if (mReset) {
// If a seek (or reset) was recently performed, we ensure that the data
// we are about to retrieve is still available.
TimeIntervals buffered = mManager->Buffered(mType);
- buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ);
+ buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
if (!buffered.Length() && mManager->IsEnded()) {
return SamplesPromise::CreateAndReject(DemuxerFailureReason::END_OF_STREAM,
__func__);
}
- if (!buffered.Contains(TimeUnit::FromMicroseconds(0))) {
+ if (!buffered.ContainsWithStrictEnd(TimeUnit::FromMicroseconds(0))) {
return SamplesPromise::CreateAndReject(DemuxerFailureReason::WAITING_FOR_DATA,
__func__);
}
mReset = false;
}
RefPtr<MediaRawData> sample;
if (mNextSample) {
sample = mNextSample.ref();
@@ -475,18 +475,18 @@ MediaSourceTrackDemuxer::DoGetSamples(in
}
RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(media::TimeUnit aTimeThreadshold)
{
uint32_t parsed = 0;
// Ensure that the data we are about to skip to is still available.
TimeIntervals buffered = mManager->Buffered(mType);
- buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ);
- if (buffered.Contains(aTimeThreadshold)) {
+ buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
+ if (buffered.ContainsWithStrictEnd(aTimeThreadshold)) {
bool found;
parsed = mManager->SkipToNextRandomAccessPoint(mType,
aTimeThreadshold,
MediaSourceDemuxer::EOS_FUZZ,
found);
if (found) {
return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
}
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1981,21 +1981,24 @@ TrackBuffersManager::Seek(TrackInfo::Tra
return TimeUnit();
}
uint32_t i = 0;
if (aTime != TimeUnit()) {
// Determine the interval of samples we're attempting to seek to.
TimeIntervals buffered = trackBuffer.mBufferedRanges;
- buffered.SetFuzz(aFuzz);
+ // Fuzz factor is +/- aFuzz; as we want to only eliminate gaps
+ // that are less than aFuzz wide, we set a fuzz factor aFuzz/2.
+ buffered.SetFuzz(aFuzz / 2);
TimeIntervals::IndexType index = buffered.Find(aTime);
MOZ_ASSERT(index != TimeIntervals::NoIndex,
"We shouldn't be called if aTime isn't buffered");
TimeInterval target = buffered[index];
+ target.mFuzz = aFuzz;
i = FindSampleIndex(track, target);
}
Maybe<TimeUnit> lastKeyFrameTime;
TimeUnit lastKeyFrameTimecode;
uint32_t lastKeyFrameIndex = 0;
for (; i < track.Length(); i++) {
const RefPtr<MediaRawData>& sample = track[i];