OLD | NEW |
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. | |
20 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); | 18 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); |
21 double max_time_in_seconds = max_time.InSecondsF(); | 19 double max_time_in_seconds = max_time.InSecondsF(); |
22 | 20 |
23 if (time >= max_time_in_seconds) | 21 if (time >= max_time_in_seconds) |
24 return max_time; | 22 return max_time; |
25 | 23 |
26 return base::TimeDelta::FromMicroseconds( | 24 return base::TimeDelta::FromMicroseconds( |
27 time * base::Time::kMicrosecondsPerSecond); | 25 time * base::Time::kMicrosecondsPerSecond); |
28 } | 26 } |
29 | 27 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void WebSourceBufferImpl::setAppendWindowEnd(double end) { | 91 void WebSourceBufferImpl::setAppendWindowEnd(double end) { |
94 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); | 92 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); |
95 } | 93 } |
96 | 94 |
97 void WebSourceBufferImpl::removedFromMediaSource() { | 95 void WebSourceBufferImpl::removedFromMediaSource() { |
98 demuxer_->RemoveId(id_); | 96 demuxer_->RemoveId(id_); |
99 demuxer_ = NULL; | 97 demuxer_ = NULL; |
100 } | 98 } |
101 | 99 |
102 } // namespace content | 100 } // namespace content |
OLD | NEW |