зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500713: P3 - Prevent duration in GetBuffered from being overestimated. r=kinetik,jya
Depends on D19097 Differential Revision: https://phabricator.services.mozilla.com/D22048 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
97d1b59173
Коммит
9a23c18c8f
|
@ -322,6 +322,13 @@ TimeIntervals MP3TrackDemuxer::GetBuffered() {
|
||||||
buffered += TimeInterval(start, end);
|
buffered += TimeInterval(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the number of frames reported by the header is valid,
|
||||||
|
// the duration calculated from it is the maximal duration.
|
||||||
|
if (ValidNumAudioFrames() && Duration() > TimeUnit()) {
|
||||||
|
TimeInterval duration = TimeInterval(TimeUnit(), Duration());
|
||||||
|
return buffered.Intersection(duration);
|
||||||
|
}
|
||||||
|
|
||||||
return buffered;
|
return buffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,8 +340,8 @@ TimeUnit MP3TrackDemuxer::Duration() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t numFrames = 0;
|
int64_t numFrames = 0;
|
||||||
const auto numAudioFrames = mParser.VBRInfo().NumAudioFrames();
|
const auto numAudioFrames = ValidNumAudioFrames();
|
||||||
if (mParser.VBRInfo().IsValid() && numAudioFrames.valueOr(0) + 1 > 1) {
|
if (numAudioFrames) {
|
||||||
// VBR headers don't include the VBR header frame.
|
// VBR headers don't include the VBR header frame.
|
||||||
numFrames = numAudioFrames.value() + 1;
|
numFrames = numAudioFrames.value() + 1;
|
||||||
return Duration(numFrames);
|
return Duration(numFrames);
|
||||||
|
@ -728,6 +735,13 @@ double MP3TrackDemuxer::AverageFrameLength() const {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Maybe<uint32_t> MP3TrackDemuxer::ValidNumAudioFrames() const {
|
||||||
|
return mParser.VBRInfo().IsValid() &&
|
||||||
|
mParser.VBRInfo().NumAudioFrames().valueOr(0) + 1 > 1
|
||||||
|
? mParser.VBRInfo().NumAudioFrames()
|
||||||
|
: Nothing();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#undef MP3LOG
|
#undef MP3LOG
|
||||||
|
|
|
@ -122,6 +122,10 @@ class MP3TrackDemuxer : public MediaTrackDemuxer,
|
||||||
// Returns the average frame length derived from the previously parsed frames.
|
// Returns the average frame length derived from the previously parsed frames.
|
||||||
double AverageFrameLength() const;
|
double AverageFrameLength() const;
|
||||||
|
|
||||||
|
// Returns the number of frames reported by the header if it's valid. Nothing
|
||||||
|
// otherwise.
|
||||||
|
Maybe<uint32_t> ValidNumAudioFrames() const;
|
||||||
|
|
||||||
// The (hopefully) MPEG resource.
|
// The (hopefully) MPEG resource.
|
||||||
MediaResourceIndex mSource;
|
MediaResourceIndex mSource;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче