Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 574253002: Enhance WebMediaPlayer::buffered() to account for evicted ranges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 0fd74e8390402a15d3cc42dd6a12370e7555c171..091df700029f2c24c55aa01af6ba64572a25e780 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -478,9 +478,25 @@ blink::WebTimeRanges WebMediaPlayerImpl::buffered() const {
const base::TimeDelta duration = pipeline_.GetMediaDuration();
if (duration != kInfiniteDuration()) {
- buffered_data_source_host_.AddBufferedTimeRanges(
- &buffered_time_ranges, duration);
+ // Demuxed ranges are not useful for a streaming resource, since we can't
+ // actually seek to those points unless they're cached. Instead report
+ // buffered() based on the lowest cached byte range.
+ //
+ // Technically we could do this for non-streaming resources too since we're
+ // caching the same amount for them, but the returned range will be shown on
+ // the controls and historically there's been outcry when gaps are shown.
+ if (data_source_ && data_source_->IsStreaming()) {
+ Ranges<base::TimeDelta> cached_ranges;
+ buffered_data_source_host_.AddBufferedTimeRanges(&cached_ranges,
+ duration);
+ buffered_time_ranges =
+ buffered_time_ranges.IntersectionWith(cached_ranges);
+ } else {
+ buffered_data_source_host_.AddBufferedTimeRanges(&buffered_time_ranges,
+ duration);
+ }
}
+
return ConvertToWebTimeRanges(buffered_time_ranges);
}
« media/blink/buffered_data_source.h ('K') | « media/blink/buffered_resource_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698