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

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 2146203002: Add an option to make blink media logging verbose (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring back separate macros for MediaElement/MediaSource/SourceBuffer Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/modules/mediasource/MediaSource.cpp ('k') | 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "modules/mediasource/SourceBufferTrackBaseSupplement.h" 53 #include "modules/mediasource/SourceBufferTrackBaseSupplement.h"
54 #include "platform/Logging.h" 54 #include "platform/Logging.h"
55 #include "platform/RuntimeEnabledFeatures.h" 55 #include "platform/RuntimeEnabledFeatures.h"
56 #include "platform/TraceEvent.h" 56 #include "platform/TraceEvent.h"
57 #include "public/platform/WebSourceBuffer.h" 57 #include "public/platform/WebSourceBuffer.h"
58 #include "wtf/MathExtras.h" 58 #include "wtf/MathExtras.h"
59 #include <limits> 59 #include <limits>
60 #include <memory> 60 #include <memory>
61 #include <sstream> 61 #include <sstream>
62 62
63 #ifndef BLINK_SBLOG
64 #define BLINK_SBLOG DVLOG(3)
65 #endif
66
63 using blink::WebSourceBuffer; 67 using blink::WebSourceBuffer;
64 68
65 #define SBLOG DVLOG(3)
66
67 namespace blink { 69 namespace blink {
68 70
69 namespace { 71 namespace {
70 72
71 static bool throwExceptionIfRemovedOrUpdating(bool isRemoved, bool isUpdating, E xceptionState& exceptionState) 73 static bool throwExceptionIfRemovedOrUpdating(bool isRemoved, bool isUpdating, E xceptionState& exceptionState)
72 { 74 {
73 if (isRemoved) { 75 if (isRemoved) {
74 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "This SourceBuffer has been removed from the parent media source."); 76 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "This SourceBuffer has been removed from the parent media source.");
75 return true; 77 return true;
76 } 78 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 , m_firstInitializationSegmentReceived(false) 123 , m_firstInitializationSegmentReceived(false)
122 , m_pendingAppendDataOffset(0) 124 , m_pendingAppendDataOffset(0)
123 , m_appendBufferAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendBufferAsyncPart)) 125 , m_appendBufferAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendBufferAsyncPart))
124 , m_pendingRemoveStart(-1) 126 , m_pendingRemoveStart(-1)
125 , m_pendingRemoveEnd(-1) 127 , m_pendingRemoveEnd(-1)
126 , m_removeAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this, &Sou rceBuffer::removeAsyncPart)) 128 , m_removeAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this, &Sou rceBuffer::removeAsyncPart))
127 , m_streamMaxSizeValid(false) 129 , m_streamMaxSizeValid(false)
128 , m_streamMaxSize(0) 130 , m_streamMaxSize(0)
129 , m_appendStreamAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendStreamAsyncPart)) 131 , m_appendStreamAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendStreamAsyncPart))
130 { 132 {
131 SBLOG << __FUNCTION__ << " this=" << this; 133 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
132 134
133 DCHECK(m_webSourceBuffer); 135 DCHECK(m_webSourceBuffer);
134 DCHECK(m_source); 136 DCHECK(m_source);
135 DCHECK(m_source->mediaElement()); 137 DCHECK(m_source->mediaElement());
136 ThreadState::current()->registerPreFinalizer(this); 138 ThreadState::current()->registerPreFinalizer(this);
137 m_audioTracks = AudioTrackList::create(*m_source->mediaElement()); 139 m_audioTracks = AudioTrackList::create(*m_source->mediaElement());
138 m_videoTracks = VideoTrackList::create(*m_source->mediaElement()); 140 m_videoTracks = VideoTrackList::create(*m_source->mediaElement());
139 m_webSourceBuffer->setClient(this); 141 m_webSourceBuffer->setClient(this);
140 } 142 }
141 143
142 SourceBuffer::~SourceBuffer() 144 SourceBuffer::~SourceBuffer()
143 { 145 {
144 SBLOG << __FUNCTION__ << " this=" << this; 146 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
145 } 147 }
146 148
147 void SourceBuffer::dispose() 149 void SourceBuffer::dispose()
148 { 150 {
149 // Promptly clears a raw reference from content/ to an on-heap object 151 // Promptly clears a raw reference from content/ to an on-heap object
150 // so that content/ doesn't access it in a lazy sweeping phase. 152 // so that content/ doesn't access it in a lazy sweeping phase.
151 m_webSourceBuffer.reset(); 153 m_webSourceBuffer.reset();
152 } 154 }
153 155
154 const AtomicString& SourceBuffer::segmentsKeyword() 156 const AtomicString& SourceBuffer::segmentsKeyword()
155 { 157 {
156 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments")); 158 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments"));
157 return segments; 159 return segments;
158 } 160 }
159 161
160 const AtomicString& SourceBuffer::sequenceKeyword() 162 const AtomicString& SourceBuffer::sequenceKeyword()
161 { 163 {
162 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence")); 164 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence"));
163 return sequence; 165 return sequence;
164 } 166 }
165 167
166 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState) 168 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState)
167 { 169 {
168 SBLOG << __FUNCTION__ << " this=" << this << " newMode=" << newMode; 170 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " newMode=" << newMode;
169 // Section 3.1 On setting mode attribute steps. 171 // Section 3.1 On setting mode attribute steps.
170 // 1. Let new mode equal the new value being assigned to this attribute. 172 // 1. Let new mode equal the new value being assigned to this attribute.
171 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw 173 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw
172 // an INVALID_STATE_ERR exception and abort these steps. 174 // an INVALID_STATE_ERR exception and abort these steps.
173 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. 175 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
174 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 176 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
175 return; 177 return;
176 178
177 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 179 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
178 // 4.1 Set the readyState attribute of the parent media source to "open" 180 // 4.1 Set the readyState attribute of the parent media source to "open"
(...skipping 28 matching lines...) Expand all
207 return TimeRanges::create(m_webSourceBuffer->buffered()); 209 return TimeRanges::create(m_webSourceBuffer->buffered());
208 } 210 }
209 211
210 double SourceBuffer::timestampOffset() const 212 double SourceBuffer::timestampOffset() const
211 { 213 {
212 return m_timestampOffset; 214 return m_timestampOffset;
213 } 215 }
214 216
215 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt ate) 217 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt ate)
216 { 218 {
217 SBLOG << __FUNCTION__ << " this=" << this << " offset=" << offset; 219 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " offset=" << offset;
218 // Section 3.1 timestampOffset attribute setter steps. 220 // Section 3.1 timestampOffset attribute setter steps.
219 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-timestampOffset 221 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-timestampOffset
220 // 1. Let new timestamp offset equal the new value being assigned to this at tribute. 222 // 1. Let new timestamp offset equal the new value being assigned to this at tribute.
221 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw an 223 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw an
222 // InvalidStateError exception and abort these steps. 224 // InvalidStateError exception and abort these steps.
223 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 225 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
224 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 226 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
225 return; 227 return;
226 228
227 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 229 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
(...skipping 24 matching lines...) Expand all
252 return *m_videoTracks; 254 return *m_videoTracks;
253 } 255 }
254 256
255 double SourceBuffer::appendWindowStart() const 257 double SourceBuffer::appendWindowStart() const
256 { 258 {
257 return m_appendWindowStart; 259 return m_appendWindowStart;
258 } 260 }
259 261
260 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate) 262 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS tate)
261 { 263 {
262 SBLOG << __FUNCTION__ << " this=" << this << " start=" << start; 264 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " start=" << start;
263 // Section 3.1 appendWindowStart attribute setter steps. 265 // Section 3.1 appendWindowStart attribute setter steps.
264 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowStart 266 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowStart
265 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 267 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
266 // InvalidStateError exception and abort these steps. 268 // InvalidStateError exception and abort these steps.
267 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 269 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
268 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 270 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
269 return; 271 return;
270 272
271 // 3. If the new value is less than 0 or greater than or equal to appendWind owEnd then throw an InvalidAccessError 273 // 3. If the new value is less than 0 or greater than or equal to appendWind owEnd then throw an InvalidAccessError
272 // exception and abort these steps. 274 // exception and abort these steps.
273 if (start < 0 || start >= m_appendWindowEnd) { 275 if (start < 0 || start >= m_appendWindowEnd) {
274 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("value", start, 0.0, ExceptionMessages::Ex clusiveBound, m_appendWindowEnd, ExceptionMessages::InclusiveBound)); 276 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("value", start, 0.0, ExceptionMessages::Ex clusiveBound, m_appendWindowEnd, ExceptionMessages::InclusiveBound));
275 return; 277 return;
276 } 278 }
277 279
278 m_webSourceBuffer->setAppendWindowStart(start); 280 m_webSourceBuffer->setAppendWindowStart(start);
279 281
280 // 4. Update the attribute to the new value. 282 // 4. Update the attribute to the new value.
281 m_appendWindowStart = start; 283 m_appendWindowStart = start;
282 } 284 }
283 285
284 double SourceBuffer::appendWindowEnd() const 286 double SourceBuffer::appendWindowEnd() const
285 { 287 {
286 return m_appendWindowEnd; 288 return m_appendWindowEnd;
287 } 289 }
288 290
289 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState ) 291 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState )
290 { 292 {
291 SBLOG << __FUNCTION__ << " this=" << this << " end=" << end; 293 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " end=" << end;
292 // Section 3.1 appendWindowEnd attribute setter steps. 294 // Section 3.1 appendWindowEnd attribute setter steps.
293 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowEnd 295 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-SourceBuffer-appendWindowEnd
294 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 296 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
295 // InvalidStateError exception and abort these steps. 297 // InvalidStateError exception and abort these steps.
296 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. 298 // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
297 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) 299 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e))
298 return; 300 return;
299 301
300 // 3. If the new value equals NaN, then throw an InvalidAccessError and abor t these steps. 302 // 3. If the new value equals NaN, then throw an InvalidAccessError and abor t these steps.
301 if (std::isnan(end)) { 303 if (std::isnan(end)) {
302 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::notAFiniteNumber(end)); 304 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::notAFiniteNumber(end));
303 return; 305 return;
304 } 306 }
305 // 4. If the new value is less than or equal to appendWindowStart then throw an InvalidAccessError 307 // 4. If the new value is less than or equal to appendWindowStart then throw an InvalidAccessError
306 // exception and abort these steps. 308 // exception and abort these steps.
307 if (end <= m_appendWindowStart) { 309 if (end <= m_appendWindowStart) {
308 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound("value", end, m_appendWindowStart)) ; 310 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound("value", end, m_appendWindowStart)) ;
309 return; 311 return;
310 } 312 }
311 313
312 m_webSourceBuffer->setAppendWindowEnd(end); 314 m_webSourceBuffer->setAppendWindowEnd(end);
313 315
314 // 5. Update the attribute to the new value. 316 // 5. Update the attribute to the new value.
315 m_appendWindowEnd = end; 317 m_appendWindowEnd = end;
316 } 318 }
317 319
318 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS tate) 320 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS tate)
319 { 321 {
320 SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLength(); 322 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLen gth();
321 // Section 3.2 appendBuffer() 323 // Section 3.2 appendBuffer()
322 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 324 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
323 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data-> byteLength(), exceptionState); 325 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data-> byteLength(), exceptionState);
324 } 326 }
325 327
326 void SourceBuffer::appendBuffer(DOMArrayBufferView* data, ExceptionState& except ionState) 328 void SourceBuffer::appendBuffer(DOMArrayBufferView* data, ExceptionState& except ionState)
327 { 329 {
328 SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLength(); 330 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLen gth();
329 // Section 3.2 appendBuffer() 331 // Section 3.2 appendBuffer()
330 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 332 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
331 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()), data->byteLength(), exceptionState); 333 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()), data->byteLength(), exceptionState);
332 } 334 }
333 335
334 void SourceBuffer::appendStream(Stream* stream, ExceptionState& exceptionState) 336 void SourceBuffer::appendStream(Stream* stream, ExceptionState& exceptionState)
335 { 337 {
336 m_streamMaxSizeValid = false; 338 m_streamMaxSizeValid = false;
337 appendStreamInternal(stream, exceptionState); 339 appendStreamInternal(stream, exceptionState);
338 } 340 }
339 341
340 void SourceBuffer::appendStream(Stream* stream, unsigned long long maxSize, Exce ptionState& exceptionState) 342 void SourceBuffer::appendStream(Stream* stream, unsigned long long maxSize, Exce ptionState& exceptionState)
341 { 343 {
342 SBLOG << __FUNCTION__ << " this=" << this << " maxSize=" << maxSize; 344 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " maxSize=" << maxSize;
343 m_streamMaxSizeValid = maxSize > 0; 345 m_streamMaxSizeValid = maxSize > 0;
344 if (m_streamMaxSizeValid) 346 if (m_streamMaxSizeValid)
345 m_streamMaxSize = maxSize; 347 m_streamMaxSize = maxSize;
346 appendStreamInternal(stream, exceptionState); 348 appendStreamInternal(stream, exceptionState);
347 } 349 }
348 350
349 void SourceBuffer::abort(ExceptionState& exceptionState) 351 void SourceBuffer::abort(ExceptionState& exceptionState)
350 { 352 {
351 SBLOG << __FUNCTION__ << " this=" << this; 353 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
352 // http://w3c.github.io/media-source/#widl-SourceBuffer-abort-void 354 // http://w3c.github.io/media-source/#widl-SourceBuffer-abort-void
353 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source 355 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source
354 // then throw an InvalidStateError exception and abort these steps. 356 // then throw an InvalidStateError exception and abort these steps.
355 // 2. If the readyState attribute of the parent media source is not in the " open" state 357 // 2. If the readyState attribute of the parent media source is not in the " open" state
356 // then throw an InvalidStateError exception and abort these steps. 358 // then throw an InvalidStateError exception and abort these steps.
357 if (isRemoved()) { 359 if (isRemoved()) {
358 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "This SourceBuffer has been removed from the parent media source."); 360 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "This SourceBuffer has been removed from the parent media source.");
359 return; 361 return;
360 } 362 }
361 if (!m_source->isOpen()) { 363 if (!m_source->isOpen()) {
(...skipping 25 matching lines...) Expand all
387 389
388 // 6. Set appendWindowStart to 0. 390 // 6. Set appendWindowStart to 0.
389 setAppendWindowStart(0, exceptionState); 391 setAppendWindowStart(0, exceptionState);
390 392
391 // 7. Set appendWindowEnd to positive Infinity. 393 // 7. Set appendWindowEnd to positive Infinity.
392 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState); 394 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState);
393 } 395 }
394 396
395 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta te) 397 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta te)
396 { 398 {
397 SBLOG << __FUNCTION__ << " this=" << this << " start=" << start << " end=" < < end; 399 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " start=" << start << " e nd=" << end;
398 400
399 // Section 3.2 remove() method steps. 401 // Section 3.2 remove() method steps.
400 // 1. If duration equals NaN, then throw an InvalidAccessError exception and abort these steps. 402 // 1. If duration equals NaN, then throw an InvalidAccessError exception and abort these steps.
401 // 2. If start is negative or greater than duration, then throw an InvalidAc cessError exception and abort these steps. 403 // 2. If start is negative or greater than duration, then throw an InvalidAc cessError exception and abort these steps.
402 404
403 if (start < 0 || (m_source && (std::isnan(m_source->duration()) || start > m _source->duration()))) { 405 if (start < 0 || (m_source && (std::isnan(m_source->duration()) || start > m _source->duration()))) {
404 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("start", start, 0.0, ExceptionMessages::Ex clusiveBound, !m_source || std::isnan(m_source->duration()) ? 0 : m_source->dura tion(), ExceptionMessages::ExclusiveBound)); 406 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMessages::indexOutsideRange("start", start, 0.0, ExceptionMessages::Ex clusiveBound, !m_source || std::isnan(m_source->duration()) ? 0 : m_source->dura tion(), ExceptionMessages::ExclusiveBound));
405 return; 407 return;
406 } 408 }
407 409
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 scheduleEvent(EventTypeNames::updateend); 509 scheduleEvent(EventTypeNames::updateend);
508 510
509 TRACE_EVENT_ASYNC_END0("media", traceEventName, this); 511 TRACE_EVENT_ASYNC_END0("media", traceEventName, this);
510 } 512 }
511 513
512 void SourceBuffer::removedFromMediaSource() 514 void SourceBuffer::removedFromMediaSource()
513 { 515 {
514 if (isRemoved()) 516 if (isRemoved())
515 return; 517 return;
516 518
517 SBLOG << __FUNCTION__ << " this=" << this; 519 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
518 if (m_pendingRemoveStart != -1) { 520 if (m_pendingRemoveStart != -1) {
519 cancelRemove(); 521 cancelRemove();
520 } else { 522 } else {
521 abortIfUpdating(); 523 abortIfUpdating();
522 } 524 }
523 525
524 if (RuntimeEnabledFeatures::audioVideoTracksEnabled()) { 526 if (RuntimeEnabledFeatures::audioVideoTracksEnabled()) {
525 DCHECK(m_source); 527 DCHECK(m_source);
526 if (m_source->mediaElement()->audioTracks().length() > 0 528 if (m_source->mediaElement()->audioTracks().length() > 0
527 || m_source->mediaElement()->videoTracks().length() > 0) { 529 || m_source->mediaElement()->videoTracks().length() > 0) {
528 removeMediaTracks(); 530 removeMediaTracks();
529 } 531 }
530 } 532 }
531 533
532 m_webSourceBuffer->removedFromMediaSource(); 534 m_webSourceBuffer->removedFromMediaSource();
533 m_webSourceBuffer.reset(); 535 m_webSourceBuffer.reset();
534 m_source = nullptr; 536 m_source = nullptr;
535 m_asyncEventQueue = nullptr; 537 m_asyncEventQueue = nullptr;
536 } 538 }
537 539
538 double SourceBuffer::highestPresentationTimestamp() 540 double SourceBuffer::highestPresentationTimestamp()
539 { 541 {
540 DCHECK(!isRemoved()); 542 DCHECK(!isRemoved());
541 543
542 double pts = m_webSourceBuffer->highestPresentationTimestamp(); 544 double pts = m_webSourceBuffer->highestPresentationTimestamp();
543 SBLOG << __FUNCTION__ << " this=" << this << ", pts=" << pts; 545 BLINK_SBLOG << __FUNCTION__ << " this=" << this << ", pts=" << pts;
544 return pts; 546 return pts;
545 } 547 }
546 548
547 void SourceBuffer::removeMediaTracks() 549 void SourceBuffer::removeMediaTracks()
548 { 550 {
549 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 551 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
550 // Spec: http://w3c.github.io/media-source/#widl-MediaSource-removeSourceBuf fer-void-SourceBuffer-sourceBuffer 552 // Spec: http://w3c.github.io/media-source/#widl-MediaSource-removeSourceBuf fer-void-SourceBuffer-sourceBuffer
551 DCHECK(m_source); 553 DCHECK(m_source);
552 554
553 HTMLMediaElement* mediaElement = m_source->mediaElement(); 555 HTMLMediaElement* mediaElement = m_source->mediaElement();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 656
655 AtomicString SourceBuffer::defaultTrackLanguage(const AtomicString& trackType, c onst AtomicString& byteStreamTrackID) const 657 AtomicString SourceBuffer::defaultTrackLanguage(const AtomicString& trackType, c onst AtomicString& byteStreamTrackID) const
656 { 658 {
657 // Spec: https://w3c.github.io/media-source/#sourcebuffer-default-track-lang uage 659 // Spec: https://w3c.github.io/media-source/#sourcebuffer-default-track-lang uage
658 const TrackDefault* trackDefault = getTrackDefault(trackType, byteStreamTrac kID); 660 const TrackDefault* trackDefault = getTrackDefault(trackType, byteStreamTrac kID);
659 return trackDefault ? AtomicString(trackDefault->language()) : ""; 661 return trackDefault ? AtomicString(trackDefault->language()) : "";
660 } 662 }
661 663
662 bool SourceBuffer::initializationSegmentReceived(const WebVector<MediaTrackInfo> & newTracks) 664 bool SourceBuffer::initializationSegmentReceived(const WebVector<MediaTrackInfo> & newTracks)
663 { 665 {
664 SBLOG << __FUNCTION__ << " this=" << this << " tracks=" << newTracks.size(); 666 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " tracks=" << newTracks.s ize();
665 DCHECK(m_source); 667 DCHECK(m_source);
666 DCHECK(m_source->mediaElement()); 668 DCHECK(m_source->mediaElement());
667 DCHECK(m_updating); 669 DCHECK(m_updating);
668 670
669 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { 671 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) {
670 if (!m_firstInitializationSegmentReceived) { 672 if (!m_firstInitializationSegmentReceived) {
671 m_source->setSourceBufferActive(this); 673 m_source->setSourceBufferActive(this);
672 m_firstInitializationSegmentReceived = true; 674 m_firstInitializationSegmentReceived = true;
673 } 675 }
674 return true; 676 return true;
(...skipping 10 matching lines...) Expand all
685 const TrackBase* track = nullptr; 687 const TrackBase* track = nullptr;
686 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { 688 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) {
687 newAudioTracks.append(trackInfo); 689 newAudioTracks.append(trackInfo);
688 if (m_firstInitializationSegmentReceived) 690 if (m_firstInitializationSegmentReceived)
689 track = findExistingTrackById(audioTracks(), trackInfo.id); 691 track = findExistingTrackById(audioTracks(), trackInfo.id);
690 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { 692 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) {
691 newVideoTracks.append(trackInfo); 693 newVideoTracks.append(trackInfo);
692 if (m_firstInitializationSegmentReceived) 694 if (m_firstInitializationSegmentReceived)
693 track = findExistingTrackById(videoTracks(), trackInfo.id); 695 track = findExistingTrackById(videoTracks(), trackInfo.id);
694 } else { 696 } else {
695 SBLOG << __FUNCTION__ << " this=" << this << " failed: unsupported t rack type " << trackInfo.trackType; 697 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: unsuppo rted track type " << trackInfo.trackType;
696 // TODO(servolk): Add handling of text tracks. 698 // TODO(servolk): Add handling of text tracks.
697 NOTREACHED(); 699 NOTREACHED();
698 } 700 }
699 if (m_firstInitializationSegmentReceived && !track) { 701 if (m_firstInitializationSegmentReceived && !track) {
700 SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks mismat ch the first init segment."; 702 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks mismatch the first init segment.";
701 return false; 703 return false;
702 } 704 }
703 #if !LOG_DISABLED 705 #if !LOG_DISABLED
704 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au dioTrack) ? "audio" : "video"; 706 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au dioTrack) ? "audio" : "video";
705 SBLOG << __FUNCTION__ << " this=" << this << " : " << logTrackTypeStr << " track " 707 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " : " << logTrackType Str << " track "
706 << " id=" << String(trackInfo.id) << " byteStreamTrackID=" << String (trackInfo.byteStreamTrackID) 708 << " id=" << String(trackInfo.id) << " byteStreamTrackID=" << String (trackInfo.byteStreamTrackID)
707 << " kind=" << String(trackInfo.kind) << " label=" << String(trackIn fo.label) << " language=" << String(trackInfo.language); 709 << " kind=" << String(trackInfo.kind) << " label=" << String(trackIn fo.label) << " language=" << String(trackInfo.language);
708 #endif 710 #endif
709 } 711 }
710 712
711 // 1. Update the duration attribute if it currently equals NaN: 713 // 1. Update the duration attribute if it currently equals NaN:
712 // TODO(servolk): Pass also stream duration into initSegmentReceived. 714 // TODO(servolk): Pass also stream duration into initSegmentReceived.
713 715
714 // 2. If the initialization segment has no audio, video, or text tracks, the n run the append error algorithm with the decode error parameter set to true and abort these steps. 716 // 2. If the initialization segment has no audio, video, or text tracks, the n run the append error algorithm with the decode error parameter set to true and abort these steps.
715 if (newTracks.size() == 0) { 717 if (newTracks.size() == 0) {
716 SBLOG << __FUNCTION__ << " this=" << this << " failed: no tracks found i n the init segment."; 718 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: no tracks f ound in the init segment.";
717 // The append error algorithm will be called at the top level after we r eturn false here to indicate failure. 719 // The append error algorithm will be called at the top level after we r eturn false here to indicate failure.
718 return false; 720 return false;
719 } 721 }
720 722
721 // 3. If the first initialization segment received flag is true, then run th e following steps: 723 // 3. If the first initialization segment received flag is true, then run th e following steps:
722 if (m_firstInitializationSegmentReceived) { 724 if (m_firstInitializationSegmentReceived) {
723 // 3.1 Verify the following properties. If any of the checks fail then r un the append error algorithm with the decode error parameter set to true and ab ort these steps. 725 // 3.1 Verify the following properties. If any of the checks fail then r un the append error algorithm with the decode error parameter set to true and ab ort these steps.
724 bool tracksMatchFirstInitSegment = true; 726 bool tracksMatchFirstInitSegment = true;
725 // - The number of audio, video, and text tracks match what was in the f irst initialization segment. 727 // - The number of audio, video, and text tracks match what was in the f irst initialization segment.
726 if (newAudioTracks.size() != audioTracks().length() || newVideoTracks.si ze() != videoTracks().length()) { 728 if (newAudioTracks.size() != audioTracks().length() || newVideoTracks.si ze() != videoTracks().length()) {
(...skipping 16 matching lines...) Expand all
743 for (size_t i = 0; i < newVideoTracks.size(); ++i) { 745 for (size_t i = 0; i < newVideoTracks.size(); ++i) {
744 const String& newTrackId = newVideoTracks[i].id; 746 const String& newTrackId = newVideoTracks[i].id;
745 if (newTrackId != String(videoTracks().anonymousIndexedGetter(i) ->id())) { 747 if (newTrackId != String(videoTracks().anonymousIndexedGetter(i) ->id())) {
746 tracksMatchFirstInitSegment = false; 748 tracksMatchFirstInitSegment = false;
747 break; 749 break;
748 } 750 }
749 } 751 }
750 } 752 }
751 753
752 if (!tracksMatchFirstInitSegment) { 754 if (!tracksMatchFirstInitSegment) {
753 SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks mismat ch the first init segment."; 755 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks mismatch the first init segment.";
754 // The append error algorithm will be called at the top level after we return false here to indicate failure. 756 // The append error algorithm will be called at the top level after we return false here to indicate failure.
755 return false; 757 return false;
756 } 758 }
757 759
758 // 3.2 Add the appropriate track descriptions from this initialization s egment to each of the track buffers. 760 // 3.2 Add the appropriate track descriptions from this initialization s egment to each of the track buffers.
759 // This is done in Chromium code in stream parsers and demuxer implement ations. 761 // This is done in Chromium code in stream parsers and demuxer implement ations.
760 762
761 // 3.3 Set the need random access point flag on all track buffers to tru e. 763 // 3.3 Set the need random access point flag on all track buffers to tru e.
762 // This is done in Chromium code, see MediaSourceState::OnNewConfigs. 764 // This is done in Chromium code, see MediaSourceState::OnNewConfigs.
763 } 765 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 936 }
935 937
936 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 938 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
937 // 1. Set the readyState attribute of the parent media source to "open" 939 // 1. Set the readyState attribute of the parent media source to "open"
938 // 2. Queue a task to fire a simple event named sourceopen at the parent media source. 940 // 2. Queue a task to fire a simple event named sourceopen at the parent media source.
939 m_source->openIfInEndedState(); 941 m_source->openIfInEndedState();
940 942
941 // 5. Run the coded frame eviction algorithm. 943 // 5. Run the coded frame eviction algorithm.
942 if (!evictCodedFrames(newDataSize)) { 944 if (!evictCodedFrames(newDataSize)) {
943 // 6. If the buffer full flag equals true, then throw a QUOTA_EXCEEDED_E RR exception and abort these steps. 945 // 6. If the buffer full flag equals true, then throw a QUOTA_EXCEEDED_E RR exception and abort these steps.
944 SBLOG << __FUNCTION__ << " this=" << this << " -> throw QuotaExceededErr or"; 946 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " -> throw QuotaExcee dedError";
945 MediaSource::logAndThrowDOMException(exceptionState, QuotaExceededError, "The SourceBuffer is full, and cannot free space to append additional buffers." ); 947 MediaSource::logAndThrowDOMException(exceptionState, QuotaExceededError, "The SourceBuffer is full, and cannot free space to append additional buffers." );
946 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); 948 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this);
947 return false; 949 return false;
948 } 950 }
949 951
950 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); 952 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this);
951 return true; 953 return true;
952 } 954 }
953 955
954 bool SourceBuffer::evictCodedFrames(size_t newDataSize) 956 bool SourceBuffer::evictCodedFrames(size_t newDataSize)
955 { 957 {
956 DCHECK(m_source); 958 DCHECK(m_source);
957 DCHECK(m_source->mediaElement()); 959 DCHECK(m_source->mediaElement());
958 double currentTime = m_source->mediaElement()->currentTime(); 960 double currentTime = m_source->mediaElement()->currentTime();
959 bool result = m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize); 961 bool result = m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize);
960 if (!result) { 962 if (!result) {
961 SBLOG << __FUNCTION__ << " this=" << this << " failed. newDataSize=" << newDataSize 963 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed. newDataSize =" << newDataSize
962 << " currentTime=" << currentTime << " buffered=" << webTimeRangesTo String(m_webSourceBuffer->buffered()); 964 << " currentTime=" << currentTime << " buffered=" << webTimeRangesTo String(m_webSourceBuffer->buffered());
963 } 965 }
964 return result; 966 return result;
965 } 967 }
966 968
967 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState) 969 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState)
968 { 970 {
969 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size" , size); 971 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size" , size);
970 // Section 3.2 appendBuffer() 972 // Section 3.2 appendBuffer()
971 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 973 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 m_pendingAppendDataOffset = 0; 1049 m_pendingAppendDataOffset = 0;
1048 1050
1049 // 4. Queue a task to fire a simple event named update at this SourceBuf fer object. 1051 // 4. Queue a task to fire a simple event named update at this SourceBuf fer object.
1050 scheduleEvent(EventTypeNames::update); 1052 scheduleEvent(EventTypeNames::update);
1051 1053
1052 // 5. Queue a task to fire a simple event named updateend at this Source Buffer object. 1054 // 5. Queue a task to fire a simple event named updateend at this Source Buffer object.
1053 scheduleEvent(EventTypeNames::updateend); 1055 scheduleEvent(EventTypeNames::updateend);
1054 } 1056 }
1055 1057
1056 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); 1058 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this);
1057 SBLOG << __FUNCTION__ << " done. this=" << this << " buffered=" << webTimeRa ngesToString(m_webSourceBuffer->buffered()); 1059 BLINK_SBLOG << __FUNCTION__ << " done. this=" << this << " buffered=" << web TimeRangesToString(m_webSourceBuffer->buffered());
1058 } 1060 }
1059 1061
1060 void SourceBuffer::removeAsyncPart() 1062 void SourceBuffer::removeAsyncPart()
1061 { 1063 {
1062 DCHECK(m_updating); 1064 DCHECK(m_updating);
1063 DCHECK_GE(m_pendingRemoveStart, 0); 1065 DCHECK_GE(m_pendingRemoveStart, 0);
1064 DCHECK_LT(m_pendingRemoveStart, m_pendingRemoveEnd); 1066 DCHECK_LT(m_pendingRemoveStart, m_pendingRemoveEnd);
1065 1067
1066 // Section 3.2 remove() method steps 1068 // Section 3.2 remove() method steps
1067 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-remove-void-double-start-double-end 1069 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-remove-void-double-start-double-end
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1163
1162 // 12. Loop Done: Set the updating attribute to false. 1164 // 12. Loop Done: Set the updating attribute to false.
1163 m_updating = false; 1165 m_updating = false;
1164 1166
1165 // 13. Queue a task to fire a simple event named update at this SourceBuffer object. 1167 // 13. Queue a task to fire a simple event named update at this SourceBuffer object.
1166 scheduleEvent(EventTypeNames::update); 1168 scheduleEvent(EventTypeNames::update);
1167 1169
1168 // 14. Queue a task to fire a simple event named updateend at this SourceBuf fer object. 1170 // 14. Queue a task to fire a simple event named updateend at this SourceBuf fer object.
1169 scheduleEvent(EventTypeNames::updateend); 1171 scheduleEvent(EventTypeNames::updateend);
1170 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); 1172 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this);
1171 SBLOG << __FUNCTION__ << " ended. this=" << this << " buffered=" << webTimeR angesToString(m_webSourceBuffer->buffered()); 1173 BLINK_SBLOG << __FUNCTION__ << " ended. this=" << this << " buffered=" << we bTimeRangesToString(m_webSourceBuffer->buffered());
1172 } 1174 }
1173 1175
1174 void SourceBuffer::clearAppendStreamState() 1176 void SourceBuffer::clearAppendStreamState()
1175 { 1177 {
1176 m_streamMaxSizeValid = false; 1178 m_streamMaxSizeValid = false;
1177 m_streamMaxSize = 0; 1179 m_streamMaxSize = 0;
1178 m_loader.reset(); 1180 m_loader.reset();
1179 m_stream = nullptr; 1181 m_stream = nullptr;
1180 } 1182 }
1181 1183
1182 void SourceBuffer::appendError(AppendError err) 1184 void SourceBuffer::appendError(AppendError err)
1183 { 1185 {
1184 SBLOG << __FUNCTION__ << " this=" << this << " AppendError=" << err; 1186 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " AppendError=" << err;
1185 // Section 3.5.3 Append Error Algorithm 1187 // Section 3.5.3 Append Error Algorithm
1186 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#sourcebuffer-append-error 1188 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#sourcebuffer-append-error
1187 1189
1188 // 1. Run the reset parser state algorithm. 1190 // 1. Run the reset parser state algorithm.
1189 m_webSourceBuffer->resetParserState(); 1191 m_webSourceBuffer->resetParserState();
1190 1192
1191 // 2. Set the updating attribute to false. 1193 // 2. Set the updating attribute to false.
1192 m_updating = false; 1194 m_updating = false;
1193 1195
1194 // 3. Queue a task to fire a simple event named error at this SourceBuffer o bject. 1196 // 3. Queue a task to fire a simple event named error at this SourceBuffer o bject.
1195 scheduleEvent(EventTypeNames::error); 1197 scheduleEvent(EventTypeNames::error);
1196 1198
1197 // 4. Queue a task to fire a simple event named updateend at this SourceBuff er object. 1199 // 4. Queue a task to fire a simple event named updateend at this SourceBuff er object.
1198 scheduleEvent(EventTypeNames::updateend); 1200 scheduleEvent(EventTypeNames::updateend);
1199 1201
1200 // 5. If decode error is true, then run the end of stream algorithm with the 1202 // 5. If decode error is true, then run the end of stream algorithm with the
1201 // error parameter set to "decode". 1203 // error parameter set to "decode".
1202 if (err == DecodeError) { 1204 if (err == DecodeError) {
1203 m_source->endOfStream("decode", ASSERT_NO_EXCEPTION); 1205 m_source->endOfStream("decode", ASSERT_NO_EXCEPTION);
1204 } else { 1206 } else {
1205 DCHECK_EQ(err, NoDecodeError); 1207 DCHECK_EQ(err, NoDecodeError);
1206 // Nothing else to do in this case. 1208 // Nothing else to do in this case.
1207 } 1209 }
1208 } 1210 }
1209 1211
1210 void SourceBuffer::didStartLoading() 1212 void SourceBuffer::didStartLoading()
1211 { 1213 {
1212 SBLOG << __FUNCTION__ << " this=" << this; 1214 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
1213 } 1215 }
1214 1216
1215 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength ) 1217 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength )
1216 { 1218 {
1217 SBLOG << __FUNCTION__ << " this=" << this << " dataLength=" << dataLength; 1219 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " dataLength=" << dataLen gth;
1218 DCHECK(m_updating); 1220 DCHECK(m_updating);
1219 DCHECK(m_loader); 1221 DCHECK(m_loader);
1220 1222
1221 // Section 3.5.6 Stream Append Loop 1223 // Section 3.5.6 Stream Append Loop
1222 // http://w3c.github.io/media-source/#sourcebuffer-stream-append-loop 1224 // http://w3c.github.io/media-source/#sourcebuffer-stream-append-loop
1223 1225
1224 // 10. Run the coded frame eviction algorithm. 1226 // 10. Run the coded frame eviction algorithm.
1225 if (!evictCodedFrames(dataLength)) { 1227 if (!evictCodedFrames(dataLength)) {
1226 // 11. (in appendStreamDone) If the buffer full flag equals true, then r un the append error algorithm with the decode error parameter set to false and a bort this algorithm. 1228 // 11. (in appendStreamDone) If the buffer full flag equals true, then r un the append error algorithm with the decode error parameter set to false and a bort this algorithm.
1227 appendStreamDone(RunAppendErrorWithNoDecodeError); 1229 appendStreamDone(RunAppendErrorWithNoDecodeError);
1228 return; 1230 return;
1229 } 1231 }
1230 1232
1231 if (!m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), dataLength, &m_timestampOffset)) 1233 if (!m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), dataLength, &m_timestampOffset))
1232 appendStreamDone(RunAppendErrorWithDecodeError); 1234 appendStreamDone(RunAppendErrorWithDecodeError);
1233 } 1235 }
1234 1236
1235 void SourceBuffer::didFinishLoading() 1237 void SourceBuffer::didFinishLoading()
1236 { 1238 {
1237 SBLOG << __FUNCTION__ << " this=" << this; 1239 BLINK_SBLOG << __FUNCTION__ << " this=" << this;
1238 DCHECK(m_loader); 1240 DCHECK(m_loader);
1239 appendStreamDone(NoError); 1241 appendStreamDone(NoError);
1240 } 1242 }
1241 1243
1242 void SourceBuffer::didFail(FileError::ErrorCode errorCode) 1244 void SourceBuffer::didFail(FileError::ErrorCode errorCode)
1243 { 1245 {
1244 SBLOG << __FUNCTION__ << " this=" << this << " errorCode=" << errorCode; 1246 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " errorCode=" << errorCod e;
1245 // m_loader might be already released, in case appendStream has failed due 1247 // m_loader might be already released, in case appendStream has failed due
1246 // to evictCodedFrames or WebSourceBuffer append failing in 1248 // to evictCodedFrames or WebSourceBuffer append failing in
1247 // didReceiveDataForClient. In that case appendStreamDone will be invoked 1249 // didReceiveDataForClient. In that case appendStreamDone will be invoked
1248 // from there, no need to repeat it here. 1250 // from there, no need to repeat it here.
1249 if (m_loader) 1251 if (m_loader)
1250 appendStreamDone(RunAppendErrorWithNoDecodeError); 1252 appendStreamDone(RunAppendErrorWithNoDecodeError);
1251 } 1253 }
1252 1254
1253 DEFINE_TRACE(SourceBuffer) 1255 DEFINE_TRACE(SourceBuffer)
1254 { 1256 {
1255 visitor->trace(m_source); 1257 visitor->trace(m_source);
1256 visitor->trace(m_trackDefaults); 1258 visitor->trace(m_trackDefaults);
1257 visitor->trace(m_asyncEventQueue); 1259 visitor->trace(m_asyncEventQueue);
1258 visitor->trace(m_appendBufferAsyncPartRunner); 1260 visitor->trace(m_appendBufferAsyncPartRunner);
1259 visitor->trace(m_removeAsyncPartRunner); 1261 visitor->trace(m_removeAsyncPartRunner);
1260 visitor->trace(m_appendStreamAsyncPartRunner); 1262 visitor->trace(m_appendStreamAsyncPartRunner);
1261 visitor->trace(m_stream); 1263 visitor->trace(m_stream);
1262 visitor->trace(m_audioTracks); 1264 visitor->trace(m_audioTracks);
1263 visitor->trace(m_videoTracks); 1265 visitor->trace(m_videoTracks);
1264 EventTargetWithInlineData::trace(visitor); 1266 EventTargetWithInlineData::trace(visitor);
1265 ActiveDOMObject::trace(visitor); 1267 ActiveDOMObject::trace(visitor);
1266 } 1268 }
1267 1269
1268 } // namespace blink 1270 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediasource/MediaSource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698