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

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

Issue 198213008: Fix DCHECK caused by specifying a negative timestamp offset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | no next file » | 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 <limits>
8
7 #include "base/float_util.h" 9 #include "base/float_util.h"
8 #include "media/filters/chunk_demuxer.h" 10 #include "media/filters/chunk_demuxer.h"
9 11
10 namespace content { 12 namespace content {
11 13
12 static base::TimeDelta DoubleToTimeDelta(double time) { 14 static base::TimeDelta DoubleToTimeDelta(double time) {
13 DCHECK(!base::IsNaN(time)); 15 DCHECK(!base::IsNaN(time));
14 DCHECK_GE(time, 0); 16 DCHECK_NE(time, -std::numeric_limits<double>::infinity());
17
15 if (time == std::numeric_limits<double>::infinity()) 18 if (time == std::numeric_limits<double>::infinity())
16 return media::kInfiniteDuration(); 19 return media::kInfiniteDuration();
17 20
18 // Don't use base::TimeDelta::Max() here, as we want the largest finite time 21 // Don't use base::TimeDelta::Max() here, as we want the largest finite time
19 // delta. 22 // delta.
20 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); 23 base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1);
21 double max_time_in_seconds = max_time.InSecondsF(); 24 double max_time_in_seconds = max_time.InSecondsF();
22 25
23 if (time >= max_time_in_seconds) 26 if (time >= max_time_in_seconds)
24 return max_time; 27 return max_time;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // more than microsecond precision. 85 // more than microsecond precision.
83 if (timestamp_offset && old_offset != timestamp_offset_) 86 if (timestamp_offset && old_offset != timestamp_offset_)
84 *timestamp_offset = timestamp_offset_.InSecondsF(); 87 *timestamp_offset = timestamp_offset_.InSecondsF();
85 } 88 }
86 89
87 void WebSourceBufferImpl::abort() { 90 void WebSourceBufferImpl::abort() {
88 demuxer_->Abort(id_); 91 demuxer_->Abort(id_);
89 } 92 }
90 93
91 void WebSourceBufferImpl::remove(double start, double end) { 94 void WebSourceBufferImpl::remove(double start, double end) {
95 DCHECK_GE(start, 0);
96 DCHECK_GE(end, 0);
92 demuxer_->Remove(id_, DoubleToTimeDelta(start), DoubleToTimeDelta(end)); 97 demuxer_->Remove(id_, DoubleToTimeDelta(start), DoubleToTimeDelta(end));
93 } 98 }
94 99
95 bool WebSourceBufferImpl::setTimestampOffset(double offset) { 100 bool WebSourceBufferImpl::setTimestampOffset(double offset) {
96 if (demuxer_->IsParsingMediaSegment(id_)) 101 if (demuxer_->IsParsingMediaSegment(id_))
97 return false; 102 return false;
98 103
99 timestamp_offset_ = DoubleToTimeDelta(offset); 104 timestamp_offset_ = DoubleToTimeDelta(offset);
100 return true; 105 return true;
101 } 106 }
102 107
103 void WebSourceBufferImpl::setAppendWindowStart(double start) { 108 void WebSourceBufferImpl::setAppendWindowStart(double start) {
109 DCHECK_GE(start, 0);
104 append_window_start_ = DoubleToTimeDelta(start); 110 append_window_start_ = DoubleToTimeDelta(start);
105 } 111 }
106 112
107 void WebSourceBufferImpl::setAppendWindowEnd(double end) { 113 void WebSourceBufferImpl::setAppendWindowEnd(double end) {
114 DCHECK_GE(end, 0);
108 append_window_end_ = DoubleToTimeDelta(end); 115 append_window_end_ = DoubleToTimeDelta(end);
109 } 116 }
110 117
111 void WebSourceBufferImpl::removedFromMediaSource() { 118 void WebSourceBufferImpl::removedFromMediaSource() {
112 demuxer_->RemoveId(id_); 119 demuxer_->RemoveId(id_);
113 demuxer_ = NULL; 120 demuxer_ = NULL;
114 } 121 }
115 122
116 } // namespace content 123 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698