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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2581533002: MSE: Fix logic bugs with high precision duration (Closed)
Patch Set: Feedback Created 3 years, 11 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
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index ce7dfcb76a427d06c6245fb2eee528e60bae89bf..a1b6a14982cc0f8eb12590f9fdad87c4a8370ee2 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -714,7 +714,18 @@ double WebMediaPlayerImpl::duration() const {
if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
return std::numeric_limits<double>::quiet_NaN();
- return GetPipelineDuration();
+ // Use duration from ChunkDemuxer when present. MSE allows users to specify
+ // duration as a double. This propagates to the rest of the pipeline as a
+ // TimeDelta with potentially reduced precision (limited to Microseconds).
+ // ChunkDemuxer returns the full-precision user-specified double. This ensures
+ // users can "get" the exact duration they "set".
+ if (chunk_demuxer_)
+ return chunk_demuxer_->GetDuration();
+
+ base::TimeDelta pipeline_duration = pipeline_.GetMediaDuration();
+ return pipeline_duration == kInfiniteDuration
+ ? std::numeric_limits<double>::infinity()
+ : pipeline_duration.InSecondsF();
}
double WebMediaPlayerImpl::timelineOffset() const {
@@ -1723,17 +1734,6 @@ blink::WebAudioSourceProvider* WebMediaPlayerImpl::getAudioSourceProvider() {
return audio_source_provider_.get();
}
-double WebMediaPlayerImpl::GetPipelineDuration() const {
- base::TimeDelta duration = pipeline_.GetMediaDuration();
-
- // Return positive infinity if the resource is unbounded.
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-duration
- if (duration == kInfiniteDuration)
- return std::numeric_limits<double>::infinity();
-
- return duration.InSecondsF();
-}
-
static void GetCurrentFrameAndSignal(
VideoFrameCompositor* compositor,
scoped_refptr<VideoFrame>* video_frame_out,
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698