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

Side by Side Diff: content/renderer/media/websourcebuffer_impl.cc

Issue 178153004: Enable round-tripping and updating of WebSourceBufferImpl timestamp offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address PS3 comments Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/websourcebuffer_impl.h" 5 #include "content/renderer/media/websourcebuffer_impl.h"
6 6
7 #include "base/float_util.h" 7 #include "base/float_util.h"
8 #include "media/base/buffers.h"
8 #include "media/filters/chunk_demuxer.h" 9 #include "media/filters/chunk_demuxer.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 static base::TimeDelta DoubleToTimeDelta(double time) { 13 static base::TimeDelta DoubleToTimeDelta(double time) {
13 DCHECK(!base::IsNaN(time)); 14 DCHECK(!base::IsNaN(time));
14 DCHECK_GE(time, 0); 15 DCHECK_GE(time, 0);
15 if (time == std::numeric_limits<double>::infinity()) 16 if (time == std::numeric_limits<double>::infinity())
16 return media::kInfiniteDuration(); 17 return media::kInfiniteDuration();
17 18
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void WebSourceBufferImpl::remove(double start, double end) { 71 void WebSourceBufferImpl::remove(double start, double end) {
71 demuxer_->Remove(id_, DoubleToTimeDelta(start), DoubleToTimeDelta(end)); 72 demuxer_->Remove(id_, DoubleToTimeDelta(start), DoubleToTimeDelta(end));
72 } 73 }
73 74
74 bool WebSourceBufferImpl::setTimestampOffset(double offset) { 75 bool WebSourceBufferImpl::setTimestampOffset(double offset) {
75 base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds( 76 base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds(
76 offset * base::Time::kMicrosecondsPerSecond); 77 offset * base::Time::kMicrosecondsPerSecond);
77 return demuxer_->SetTimestampOffset(id_, time_offset); 78 return demuxer_->SetTimestampOffset(id_, time_offset);
78 } 79 }
79 80
81 double WebSourceBufferImpl::updatedTimestampOffset() {
82 base::TimeDelta updated_offset = demuxer_->GetUpdatedTimestampOffset(id_);
83
84 if (updated_offset == media::kNoTimestamp())
85 return std::numeric_limits<double>::quiet_NaN();
86
87 return updated_offset.InSecondsF();
88 }
89
80 void WebSourceBufferImpl::setAppendWindowStart(double start) { 90 void WebSourceBufferImpl::setAppendWindowStart(double start) {
81 demuxer_->SetAppendWindowStart(id_, DoubleToTimeDelta(start)); 91 demuxer_->SetAppendWindowStart(id_, DoubleToTimeDelta(start));
82 } 92 }
83 93
84 void WebSourceBufferImpl::setAppendWindowEnd(double end) { 94 void WebSourceBufferImpl::setAppendWindowEnd(double end) {
85 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); 95 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end));
86 } 96 }
87 97
88 void WebSourceBufferImpl::removedFromMediaSource() { 98 void WebSourceBufferImpl::removedFromMediaSource() {
89 demuxer_->RemoveId(id_); 99 demuxer_->RemoveId(id_);
90 demuxer_ = NULL; 100 demuxer_ = NULL;
91 } 101 }
92 102
93 } // namespace content 103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698