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

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

Issue 163413004: Add base::TimeDelta::Max(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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
« no previous file with comments | « cc/resources/picture_pile_impl.cc ('k') | media/base/buffers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/filters/chunk_demuxer.h" 8 #include "media/filters/chunk_demuxer.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 static base::TimeDelta DoubleToTimeDelta(double time) { 12 static base::TimeDelta DoubleToTimeDelta(double time) {
13 DCHECK(!base::IsNaN(time)); 13 DCHECK(!base::IsNaN(time));
14 DCHECK_GE(time, 0); 14 DCHECK_GE(time, 0);
15 if (time == std::numeric_limits<double>::infinity()) 15 if (time == std::numeric_limits<double>::infinity())
16 return media::kInfiniteDuration(); 16 return media::kInfiniteDuration();
17 17
18 // Don't use base::TimeDelta::Max() here, as we want the largest finite time
19 // delta.
18 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); 20 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1);
19 double max_time_in_seconds = max_time.InSecondsF(); 21 double max_time_in_seconds = max_time.InSecondsF();
20 22
21 if (time >= max_time_in_seconds) 23 if (time >= max_time_in_seconds)
22 return max_time; 24 return max_time;
23 25
24 return base::TimeDelta::FromMicroseconds( 26 return base::TimeDelta::FromMicroseconds(
25 time * base::Time::kMicrosecondsPerSecond); 27 time * base::Time::kMicrosecondsPerSecond);
26 } 28 }
27 29
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void WebSourceBufferImpl::setAppendWindowEnd(double end) { 86 void WebSourceBufferImpl::setAppendWindowEnd(double end) {
85 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); 87 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end));
86 } 88 }
87 89
88 void WebSourceBufferImpl::removedFromMediaSource() { 90 void WebSourceBufferImpl::removedFromMediaSource() {
89 demuxer_->RemoveId(id_); 91 demuxer_->RemoveId(id_);
90 demuxer_ = NULL; 92 demuxer_ = NULL;
91 } 93 }
92 94
93 } // namespace content 95 } // namespace content
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_impl.cc ('k') | media/base/buffers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698