| 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. |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void WebSourceBufferImpl::setAppendWindowEnd(double end) { | 93 void WebSourceBufferImpl::setAppendWindowEnd(double end) { |
| 92 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); | 94 demuxer_->SetAppendWindowEnd(id_, DoubleToTimeDelta(end)); |
| 93 } | 95 } |
| 94 | 96 |
| 95 void WebSourceBufferImpl::removedFromMediaSource() { | 97 void WebSourceBufferImpl::removedFromMediaSource() { |
| 96 demuxer_->RemoveId(id_); | 98 demuxer_->RemoveId(id_); |
| 97 demuxer_ = NULL; | 99 demuxer_ = NULL; |
| 98 } | 100 } |
| 99 | 101 |
| 100 } // namespace content | 102 } // namespace content |
| OLD | NEW |