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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2581533002: MSE: Fix logic bugs with high precision duration (Closed)
Patch Set: Fix failing test Created 3 years, 12 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 654ba89050299e2a31ec49243c759482815edc6c..a6b4cfa4488eafe15fc83d52b9e405e6f076ab80 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -703,7 +703,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 {
@@ -1666,17 +1677,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') | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698