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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2581533002: MSE: Fix logic bugs with high precision duration (Closed)
Patch Set: Created 4 years 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') | media/filters/chunk_demuxer.cc » ('J')
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 03b11fb029fee3a10beeb932a0c0a33fb3d41955..023cb9904d4cf73494a0dd05dc8ef85000c2b4b1 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -696,7 +696,19 @@ 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();
wolenetz 2016/12/16 00:56:51 Is WMPI::duration() ever queried in a code path wh
chcunningham 2017/01/03 17:48:05 Not that I'm aware of. I did some searching and co
+ }
mlamouri (slow - plz ping) 2016/12/15 10:20:51 style: no { }
chcunningham 2017/01/03 17:48:05 Done.
+
+ base::TimeDelta pipeline_duration = pipeline_.GetMediaDuration();
+ return (pipeline_duration == kInfiniteDuration)
mlamouri (slow - plz ping) 2016/12/15 10:20:51 nit: () are not needed
chcunningham 2017/01/03 17:48:05 Done.
+ ? std::numeric_limits<double>::infinity()
+ : pipeline_duration.InSecondsF();
}
double WebMediaPlayerImpl::timelineOffset() const {
@@ -1659,17 +1671,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') | media/filters/chunk_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698