OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 , m_firstInitializationSegmentReceived(false) | 123 , m_firstInitializationSegmentReceived(false) |
124 , m_pendingAppendDataOffset(0) | 124 , m_pendingAppendDataOffset(0) |
125 , m_appendBufferAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this
, &SourceBuffer::appendBufferAsyncPart)) | 125 , m_appendBufferAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this
, &SourceBuffer::appendBufferAsyncPart)) |
126 , m_pendingRemoveStart(-1) | 126 , m_pendingRemoveStart(-1) |
127 , m_pendingRemoveEnd(-1) | 127 , m_pendingRemoveEnd(-1) |
128 , m_removeAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this, &Sou
rceBuffer::removeAsyncPart)) | 128 , m_removeAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this, &Sou
rceBuffer::removeAsyncPart)) |
129 , m_streamMaxSizeValid(false) | 129 , m_streamMaxSizeValid(false) |
130 , m_streamMaxSize(0) | 130 , m_streamMaxSize(0) |
131 , m_appendStreamAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this
, &SourceBuffer::appendStreamAsyncPart)) | 131 , m_appendStreamAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this
, &SourceBuffer::appendStreamAsyncPart)) |
132 { | 132 { |
133 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 133 BLINK_SBLOG << __func__ << " this=" << this; |
134 | 134 |
135 DCHECK(m_webSourceBuffer); | 135 DCHECK(m_webSourceBuffer); |
136 DCHECK(m_source); | 136 DCHECK(m_source); |
137 DCHECK(m_source->mediaElement()); | 137 DCHECK(m_source->mediaElement()); |
138 ThreadState::current()->registerPreFinalizer(this); | 138 ThreadState::current()->registerPreFinalizer(this); |
139 m_audioTracks = AudioTrackList::create(*m_source->mediaElement()); | 139 m_audioTracks = AudioTrackList::create(*m_source->mediaElement()); |
140 m_videoTracks = VideoTrackList::create(*m_source->mediaElement()); | 140 m_videoTracks = VideoTrackList::create(*m_source->mediaElement()); |
141 m_webSourceBuffer->setClient(this); | 141 m_webSourceBuffer->setClient(this); |
142 } | 142 } |
143 | 143 |
144 SourceBuffer::~SourceBuffer() | 144 SourceBuffer::~SourceBuffer() |
145 { | 145 { |
146 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 146 BLINK_SBLOG << __func__ << " this=" << this; |
147 } | 147 } |
148 | 148 |
149 void SourceBuffer::dispose() | 149 void SourceBuffer::dispose() |
150 { | 150 { |
151 // 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 |
152 // 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. |
153 m_webSourceBuffer.reset(); | 153 m_webSourceBuffer.reset(); |
154 } | 154 } |
155 | 155 |
156 const AtomicString& SourceBuffer::segmentsKeyword() | 156 const AtomicString& SourceBuffer::segmentsKeyword() |
157 { | 157 { |
158 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments")); | 158 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments")); |
159 return segments; | 159 return segments; |
160 } | 160 } |
161 | 161 |
162 const AtomicString& SourceBuffer::sequenceKeyword() | 162 const AtomicString& SourceBuffer::sequenceKeyword() |
163 { | 163 { |
164 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence")); | 164 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence")); |
165 return sequence; | 165 return sequence; |
166 } | 166 } |
167 | 167 |
168 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio
nState) | 168 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio
nState) |
169 { | 169 { |
170 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " newMode=" << newMode; | 170 BLINK_SBLOG << __func__ << " this=" << this << " newMode=" << newMode; |
171 // Section 3.1 On setting mode attribute steps. | 171 // Section 3.1 On setting mode attribute steps. |
172 // 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. |
173 // 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 |
174 // an INVALID_STATE_ERR exception and abort these steps. | 174 // 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. | 175 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR
exception and abort these steps. |
176 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 176 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
177 return; | 177 return; |
178 | 178 |
179 // 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: |
180 // 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 Loading... |
209 return TimeRanges::create(m_webSourceBuffer->buffered()); | 209 return TimeRanges::create(m_webSourceBuffer->buffered()); |
210 } | 210 } |
211 | 211 |
212 double SourceBuffer::timestampOffset() const | 212 double SourceBuffer::timestampOffset() const |
213 { | 213 { |
214 return m_timestampOffset; | 214 return m_timestampOffset; |
215 } | 215 } |
216 | 216 |
217 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt
ate) | 217 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt
ate) |
218 { | 218 { |
219 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " offset=" << offset; | 219 BLINK_SBLOG << __func__ << " this=" << this << " offset=" << offset; |
220 // Section 3.1 timestampOffset attribute setter steps. | 220 // Section 3.1 timestampOffset attribute setter steps. |
221 // 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 |
222 // 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. |
223 // 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 |
224 // InvalidStateError exception and abort these steps. | 224 // InvalidStateError exception and abort these steps. |
225 // 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. |
226 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 226 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
227 return; | 227 return; |
228 | 228 |
229 // 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 Loading... |
254 return *m_videoTracks; | 254 return *m_videoTracks; |
255 } | 255 } |
256 | 256 |
257 double SourceBuffer::appendWindowStart() const | 257 double SourceBuffer::appendWindowStart() const |
258 { | 258 { |
259 return m_appendWindowStart; | 259 return m_appendWindowStart; |
260 } | 260 } |
261 | 261 |
262 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS
tate) | 262 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& exceptionS
tate) |
263 { | 263 { |
264 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " start=" << start; | 264 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start; |
265 // Section 3.1 appendWindowStart attribute setter steps. | 265 // Section 3.1 appendWindowStart attribute setter steps. |
266 // 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 |
267 // 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 |
268 // InvalidStateError exception and abort these steps. | 268 // InvalidStateError exception and abort these steps. |
269 // 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. |
270 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 270 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
271 return; | 271 return; |
272 | 272 |
273 // 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 |
274 // exception and abort these steps. | 274 // exception and abort these steps. |
275 if (start < 0 || start >= m_appendWindowEnd) { | 275 if (start < 0 || start >= m_appendWindowEnd) { |
276 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)); |
277 return; | 277 return; |
278 } | 278 } |
279 | 279 |
280 m_webSourceBuffer->setAppendWindowStart(start); | 280 m_webSourceBuffer->setAppendWindowStart(start); |
281 | 281 |
282 // 4. Update the attribute to the new value. | 282 // 4. Update the attribute to the new value. |
283 m_appendWindowStart = start; | 283 m_appendWindowStart = start; |
284 } | 284 } |
285 | 285 |
286 double SourceBuffer::appendWindowEnd() const | 286 double SourceBuffer::appendWindowEnd() const |
287 { | 287 { |
288 return m_appendWindowEnd; | 288 return m_appendWindowEnd; |
289 } | 289 } |
290 | 290 |
291 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState
) | 291 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& exceptionState
) |
292 { | 292 { |
293 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " end=" << end; | 293 BLINK_SBLOG << __func__ << " this=" << this << " end=" << end; |
294 // Section 3.1 appendWindowEnd attribute setter steps. | 294 // Section 3.1 appendWindowEnd attribute setter steps. |
295 // 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 |
296 // 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 |
297 // InvalidStateError exception and abort these steps. | 297 // InvalidStateError exception and abort these steps. |
298 // 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. |
299 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 299 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
300 return; | 300 return; |
301 | 301 |
302 // 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. |
303 if (std::isnan(end)) { | 303 if (std::isnan(end)) { |
304 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError,
ExceptionMessages::notAFiniteNumber(end)); | 304 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError,
ExceptionMessages::notAFiniteNumber(end)); |
305 return; | 305 return; |
306 } | 306 } |
307 // 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 |
308 // exception and abort these steps. | 308 // exception and abort these steps. |
309 if (end <= m_appendWindowStart) { | 309 if (end <= m_appendWindowStart) { |
310 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError,
ExceptionMessages::indexExceedsMinimumBound("value", end, m_appendWindowStart))
; | 310 MediaSource::logAndThrowDOMException(exceptionState, InvalidAccessError,
ExceptionMessages::indexExceedsMinimumBound("value", end, m_appendWindowStart))
; |
311 return; | 311 return; |
312 } | 312 } |
313 | 313 |
314 m_webSourceBuffer->setAppendWindowEnd(end); | 314 m_webSourceBuffer->setAppendWindowEnd(end); |
315 | 315 |
316 // 5. Update the attribute to the new value. | 316 // 5. Update the attribute to the new value. |
317 m_appendWindowEnd = end; | 317 m_appendWindowEnd = end; |
318 } | 318 } |
319 | 319 |
320 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS
tate) | 320 void SourceBuffer::appendBuffer(DOMArrayBuffer* data, ExceptionState& exceptionS
tate) |
321 { | 321 { |
322 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLen
gth(); | 322 BLINK_SBLOG << __func__ << " this=" << this << " size=" << data->byteLength(
); |
323 // Section 3.2 appendBuffer() | 323 // Section 3.2 appendBuffer() |
324 // 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 |
325 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data->
byteLength(), exceptionState); | 325 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data->
byteLength(), exceptionState); |
326 } | 326 } |
327 | 327 |
328 void SourceBuffer::appendBuffer(DOMArrayBufferView* data, ExceptionState& except
ionState) | 328 void SourceBuffer::appendBuffer(DOMArrayBufferView* data, ExceptionState& except
ionState) |
329 { | 329 { |
330 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " size=" << data->byteLen
gth(); | 330 BLINK_SBLOG << __func__ << " this=" << this << " size=" << data->byteLength(
); |
331 // Section 3.2 appendBuffer() | 331 // Section 3.2 appendBuffer() |
332 // 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 |
333 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()),
data->byteLength(), exceptionState); | 333 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()),
data->byteLength(), exceptionState); |
334 } | 334 } |
335 | 335 |
336 void SourceBuffer::appendStream(Stream* stream, ExceptionState& exceptionState) | 336 void SourceBuffer::appendStream(Stream* stream, ExceptionState& exceptionState) |
337 { | 337 { |
338 m_streamMaxSizeValid = false; | 338 m_streamMaxSizeValid = false; |
339 appendStreamInternal(stream, exceptionState); | 339 appendStreamInternal(stream, exceptionState); |
340 } | 340 } |
341 | 341 |
342 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) |
343 { | 343 { |
344 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " maxSize=" << maxSize; | 344 BLINK_SBLOG << __func__ << " this=" << this << " maxSize=" << maxSize; |
345 m_streamMaxSizeValid = maxSize > 0; | 345 m_streamMaxSizeValid = maxSize > 0; |
346 if (m_streamMaxSizeValid) | 346 if (m_streamMaxSizeValid) |
347 m_streamMaxSize = maxSize; | 347 m_streamMaxSize = maxSize; |
348 appendStreamInternal(stream, exceptionState); | 348 appendStreamInternal(stream, exceptionState); |
349 } | 349 } |
350 | 350 |
351 void SourceBuffer::abort(ExceptionState& exceptionState) | 351 void SourceBuffer::abort(ExceptionState& exceptionState) |
352 { | 352 { |
353 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 353 BLINK_SBLOG << __func__ << " this=" << this; |
354 // http://w3c.github.io/media-source/#widl-SourceBuffer-abort-void | 354 // http://w3c.github.io/media-source/#widl-SourceBuffer-abort-void |
355 // 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 |
356 // then throw an InvalidStateError exception and abort these steps. | 356 // then throw an InvalidStateError exception and abort these steps. |
357 // 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 |
358 // then throw an InvalidStateError exception and abort these steps. | 358 // then throw an InvalidStateError exception and abort these steps. |
359 if (isRemoved()) { | 359 if (isRemoved()) { |
360 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."); |
361 return; | 361 return; |
362 } | 362 } |
363 if (!m_source->isOpen()) { | 363 if (!m_source->isOpen()) { |
(...skipping 25 matching lines...) Expand all Loading... |
389 | 389 |
390 // 6. Set appendWindowStart to 0. | 390 // 6. Set appendWindowStart to 0. |
391 setAppendWindowStart(0, exceptionState); | 391 setAppendWindowStart(0, exceptionState); |
392 | 392 |
393 // 7. Set appendWindowEnd to positive Infinity. | 393 // 7. Set appendWindowEnd to positive Infinity. |
394 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState); | 394 setAppendWindowEnd(std::numeric_limits<double>::infinity(), exceptionState); |
395 } | 395 } |
396 | 396 |
397 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta
te) | 397 void SourceBuffer::remove(double start, double end, ExceptionState& exceptionSta
te) |
398 { | 398 { |
399 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " start=" << start << " e
nd=" << end; | 399 BLINK_SBLOG << __func__ << " this=" << this << " start=" << start << " end="
<< end; |
400 | 400 |
401 // Section 3.2 remove() method steps. | 401 // Section 3.2 remove() method steps. |
402 // 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. |
403 // 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. |
404 | 404 |
405 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()))) { |
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)); | 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)); |
407 return; | 407 return; |
408 } | 408 } |
409 | 409 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 scheduleEvent(EventTypeNames::updateend); | 509 scheduleEvent(EventTypeNames::updateend); |
510 | 510 |
511 TRACE_EVENT_ASYNC_END0("media", traceEventName, this); | 511 TRACE_EVENT_ASYNC_END0("media", traceEventName, this); |
512 } | 512 } |
513 | 513 |
514 void SourceBuffer::removedFromMediaSource() | 514 void SourceBuffer::removedFromMediaSource() |
515 { | 515 { |
516 if (isRemoved()) | 516 if (isRemoved()) |
517 return; | 517 return; |
518 | 518 |
519 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 519 BLINK_SBLOG << __func__ << " this=" << this; |
520 if (m_pendingRemoveStart != -1) { | 520 if (m_pendingRemoveStart != -1) { |
521 cancelRemove(); | 521 cancelRemove(); |
522 } else { | 522 } else { |
523 abortIfUpdating(); | 523 abortIfUpdating(); |
524 } | 524 } |
525 | 525 |
526 if (RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 526 if (RuntimeEnabledFeatures::audioVideoTracksEnabled()) { |
527 DCHECK(m_source); | 527 DCHECK(m_source); |
528 if (m_source->mediaElement()->audioTracks().length() > 0 | 528 if (m_source->mediaElement()->audioTracks().length() > 0 |
529 || m_source->mediaElement()->videoTracks().length() > 0) { | 529 || m_source->mediaElement()->videoTracks().length() > 0) { |
530 removeMediaTracks(); | 530 removeMediaTracks(); |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 m_webSourceBuffer->removedFromMediaSource(); | 534 m_webSourceBuffer->removedFromMediaSource(); |
535 m_webSourceBuffer.reset(); | 535 m_webSourceBuffer.reset(); |
536 m_source = nullptr; | 536 m_source = nullptr; |
537 m_asyncEventQueue = nullptr; | 537 m_asyncEventQueue = nullptr; |
538 } | 538 } |
539 | 539 |
540 double SourceBuffer::highestPresentationTimestamp() | 540 double SourceBuffer::highestPresentationTimestamp() |
541 { | 541 { |
542 DCHECK(!isRemoved()); | 542 DCHECK(!isRemoved()); |
543 | 543 |
544 double pts = m_webSourceBuffer->highestPresentationTimestamp(); | 544 double pts = m_webSourceBuffer->highestPresentationTimestamp(); |
545 BLINK_SBLOG << __FUNCTION__ << " this=" << this << ", pts=" << pts; | 545 BLINK_SBLOG << __func__ << " this=" << this << ", pts=" << pts; |
546 return pts; | 546 return pts; |
547 } | 547 } |
548 | 548 |
549 void SourceBuffer::removeMediaTracks() | 549 void SourceBuffer::removeMediaTracks() |
550 { | 550 { |
551 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 551 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
552 // 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 |
553 DCHECK(m_source); | 553 DCHECK(m_source); |
554 | 554 |
555 HTMLMediaElement* mediaElement = m_source->mediaElement(); | 555 HTMLMediaElement* mediaElement = m_source->mediaElement(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 656 |
657 AtomicString SourceBuffer::defaultTrackLanguage(const AtomicString& trackType, c
onst AtomicString& byteStreamTrackID) const | 657 AtomicString SourceBuffer::defaultTrackLanguage(const AtomicString& trackType, c
onst AtomicString& byteStreamTrackID) const |
658 { | 658 { |
659 // 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 |
660 const TrackDefault* trackDefault = getTrackDefault(trackType, byteStreamTrac
kID); | 660 const TrackDefault* trackDefault = getTrackDefault(trackType, byteStreamTrac
kID); |
661 return trackDefault ? AtomicString(trackDefault->language()) : ""; | 661 return trackDefault ? AtomicString(trackDefault->language()) : ""; |
662 } | 662 } |
663 | 663 |
664 bool SourceBuffer::initializationSegmentReceived(const WebVector<MediaTrackInfo>
& newTracks) | 664 bool SourceBuffer::initializationSegmentReceived(const WebVector<MediaTrackInfo>
& newTracks) |
665 { | 665 { |
666 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " tracks=" << newTracks.s
ize(); | 666 BLINK_SBLOG << __func__ << " this=" << this << " tracks=" << newTracks.size(
); |
667 DCHECK(m_source); | 667 DCHECK(m_source); |
668 DCHECK(m_source->mediaElement()); | 668 DCHECK(m_source->mediaElement()); |
669 DCHECK(m_updating); | 669 DCHECK(m_updating); |
670 | 670 |
671 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { | 671 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) { |
672 if (!m_firstInitializationSegmentReceived) { | 672 if (!m_firstInitializationSegmentReceived) { |
673 m_source->setSourceBufferActive(this); | 673 m_source->setSourceBufferActive(this); |
674 m_firstInitializationSegmentReceived = true; | 674 m_firstInitializationSegmentReceived = true; |
675 } | 675 } |
676 return true; | 676 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
687 const TrackBase* track = nullptr; | 687 const TrackBase* track = nullptr; |
688 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { | 688 if (trackInfo.trackType == WebMediaPlayer::AudioTrack) { |
689 newAudioTracks.append(trackInfo); | 689 newAudioTracks.append(trackInfo); |
690 if (m_firstInitializationSegmentReceived) | 690 if (m_firstInitializationSegmentReceived) |
691 track = findExistingTrackById(audioTracks(), trackInfo.id); | 691 track = findExistingTrackById(audioTracks(), trackInfo.id); |
692 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { | 692 } else if (trackInfo.trackType == WebMediaPlayer::VideoTrack) { |
693 newVideoTracks.append(trackInfo); | 693 newVideoTracks.append(trackInfo); |
694 if (m_firstInitializationSegmentReceived) | 694 if (m_firstInitializationSegmentReceived) |
695 track = findExistingTrackById(videoTracks(), trackInfo.id); | 695 track = findExistingTrackById(videoTracks(), trackInfo.id); |
696 } else { | 696 } else { |
697 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: unsuppo
rted track type " << trackInfo.trackType; | 697 BLINK_SBLOG << __func__ << " this=" << this << " failed: unsupported
track type " << trackInfo.trackType; |
698 // TODO(servolk): Add handling of text tracks. | 698 // TODO(servolk): Add handling of text tracks. |
699 NOTREACHED(); | 699 NOTREACHED(); |
700 } | 700 } |
701 if (m_firstInitializationSegmentReceived && !track) { | 701 if (m_firstInitializationSegmentReceived && !track) { |
702 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks
mismatch the first init segment."; | 702 BLINK_SBLOG << __func__ << " this=" << this << " failed: tracks mism
atch the first init segment."; |
703 return false; | 703 return false; |
704 } | 704 } |
705 #if !LOG_DISABLED | 705 #if !LOG_DISABLED |
706 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au
dioTrack) ? "audio" : "video"; | 706 const char* logTrackTypeStr = (trackInfo.trackType == WebMediaPlayer::Au
dioTrack) ? "audio" : "video"; |
707 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " : " << logTrackType
Str << " track " | 707 BLINK_SBLOG << __func__ << " this=" << this << " : " << logTrackTypeStr
<< " track " |
708 << " id=" << String(trackInfo.id) << " byteStreamTrackID=" << String
(trackInfo.byteStreamTrackID) | 708 << " id=" << String(trackInfo.id) << " byteStreamTrackID=" << String
(trackInfo.byteStreamTrackID) |
709 << " 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); |
710 #endif | 710 #endif |
711 } | 711 } |
712 | 712 |
713 // 1. Update the duration attribute if it currently equals NaN: | 713 // 1. Update the duration attribute if it currently equals NaN: |
714 // TODO(servolk): Pass also stream duration into initSegmentReceived. | 714 // TODO(servolk): Pass also stream duration into initSegmentReceived. |
715 | 715 |
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. | 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. |
717 if (newTracks.size() == 0) { | 717 if (newTracks.size() == 0) { |
718 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: no tracks f
ound in the init segment."; | 718 BLINK_SBLOG << __func__ << " this=" << this << " failed: no tracks found
in the init segment."; |
719 // 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. |
720 return false; | 720 return false; |
721 } | 721 } |
722 | 722 |
723 // 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: |
724 if (m_firstInitializationSegmentReceived) { | 724 if (m_firstInitializationSegmentReceived) { |
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. | 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. |
726 bool tracksMatchFirstInitSegment = true; | 726 bool tracksMatchFirstInitSegment = true; |
727 // - 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. |
728 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 Loading... |
745 for (size_t i = 0; i < newVideoTracks.size(); ++i) { | 745 for (size_t i = 0; i < newVideoTracks.size(); ++i) { |
746 const String& newTrackId = newVideoTracks[i].id; | 746 const String& newTrackId = newVideoTracks[i].id; |
747 if (newTrackId != String(videoTracks().anonymousIndexedGetter(i)
->id())) { | 747 if (newTrackId != String(videoTracks().anonymousIndexedGetter(i)
->id())) { |
748 tracksMatchFirstInitSegment = false; | 748 tracksMatchFirstInitSegment = false; |
749 break; | 749 break; |
750 } | 750 } |
751 } | 751 } |
752 } | 752 } |
753 | 753 |
754 if (!tracksMatchFirstInitSegment) { | 754 if (!tracksMatchFirstInitSegment) { |
755 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed: tracks
mismatch the first init segment."; | 755 BLINK_SBLOG << __func__ << " this=" << this << " failed: tracks mism
atch the first init segment."; |
756 // 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. |
757 return false; | 757 return false; |
758 } | 758 } |
759 | 759 |
760 // 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. |
761 // 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. |
762 | 762 |
763 // 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. |
764 // This is done in Chromium code, see MediaSourceState::OnNewConfigs. | 764 // This is done in Chromium code, see MediaSourceState::OnNewConfigs. |
765 } | 765 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 } | 936 } |
937 | 937 |
938 // 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: |
939 // 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" |
940 // 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. |
941 m_source->openIfInEndedState(); | 941 m_source->openIfInEndedState(); |
942 | 942 |
943 // 5. Run the coded frame eviction algorithm. | 943 // 5. Run the coded frame eviction algorithm. |
944 if (!evictCodedFrames(newDataSize)) { | 944 if (!evictCodedFrames(newDataSize)) { |
945 // 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. |
946 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " -> throw QuotaExcee
dedError"; | 946 BLINK_SBLOG << __func__ << " this=" << this << " -> throw QuotaExceededE
rror"; |
947 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."
); |
948 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); | 948 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); |
949 return false; | 949 return false; |
950 } | 950 } |
951 | 951 |
952 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); | 952 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); |
953 return true; | 953 return true; |
954 } | 954 } |
955 | 955 |
956 bool SourceBuffer::evictCodedFrames(size_t newDataSize) | 956 bool SourceBuffer::evictCodedFrames(size_t newDataSize) |
957 { | 957 { |
958 DCHECK(m_source); | 958 DCHECK(m_source); |
959 DCHECK(m_source->mediaElement()); | 959 DCHECK(m_source->mediaElement()); |
960 double currentTime = m_source->mediaElement()->currentTime(); | 960 double currentTime = m_source->mediaElement()->currentTime(); |
961 bool result = m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize); | 961 bool result = m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize); |
962 if (!result) { | 962 if (!result) { |
963 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " failed. newDataSize
=" << newDataSize | 963 BLINK_SBLOG << __func__ << " this=" << this << " failed. newDataSize=" <
< newDataSize |
964 << " currentTime=" << currentTime << " buffered=" << webTimeRangesTo
String(m_webSourceBuffer->buffered()); | 964 << " currentTime=" << currentTime << " buffered=" << webTimeRangesTo
String(m_webSourceBuffer->buffered()); |
965 } | 965 } |
966 return result; | 966 return result; |
967 } | 967 } |
968 | 968 |
969 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size
, ExceptionState& exceptionState) | 969 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size
, ExceptionState& exceptionState) |
970 { | 970 { |
971 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size"
, size); | 971 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size"
, size); |
972 // Section 3.2 appendBuffer() | 972 // Section 3.2 appendBuffer() |
973 // 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 Loading... |
1049 m_pendingAppendDataOffset = 0; | 1049 m_pendingAppendDataOffset = 0; |
1050 | 1050 |
1051 // 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. |
1052 scheduleEvent(EventTypeNames::update); | 1052 scheduleEvent(EventTypeNames::update); |
1053 | 1053 |
1054 // 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. |
1055 scheduleEvent(EventTypeNames::updateend); | 1055 scheduleEvent(EventTypeNames::updateend); |
1056 } | 1056 } |
1057 | 1057 |
1058 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); | 1058 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); |
1059 BLINK_SBLOG << __FUNCTION__ << " done. this=" << this << " buffered=" << web
TimeRangesToString(m_webSourceBuffer->buffered()); | 1059 BLINK_SBLOG << __func__ << " done. this=" << this << " buffered=" << webTime
RangesToString(m_webSourceBuffer->buffered()); |
1060 } | 1060 } |
1061 | 1061 |
1062 void SourceBuffer::removeAsyncPart() | 1062 void SourceBuffer::removeAsyncPart() |
1063 { | 1063 { |
1064 DCHECK(m_updating); | 1064 DCHECK(m_updating); |
1065 DCHECK_GE(m_pendingRemoveStart, 0); | 1065 DCHECK_GE(m_pendingRemoveStart, 0); |
1066 DCHECK_LT(m_pendingRemoveStart, m_pendingRemoveEnd); | 1066 DCHECK_LT(m_pendingRemoveStart, m_pendingRemoveEnd); |
1067 | 1067 |
1068 // Section 3.2 remove() method steps | 1068 // Section 3.2 remove() method steps |
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 | 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 Loading... |
1163 | 1163 |
1164 // 12. Loop Done: Set the updating attribute to false. | 1164 // 12. Loop Done: Set the updating attribute to false. |
1165 m_updating = false; | 1165 m_updating = false; |
1166 | 1166 |
1167 // 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. |
1168 scheduleEvent(EventTypeNames::update); | 1168 scheduleEvent(EventTypeNames::update); |
1169 | 1169 |
1170 // 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. |
1171 scheduleEvent(EventTypeNames::updateend); | 1171 scheduleEvent(EventTypeNames::updateend); |
1172 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); | 1172 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); |
1173 BLINK_SBLOG << __FUNCTION__ << " ended. this=" << this << " buffered=" << we
bTimeRangesToString(m_webSourceBuffer->buffered()); | 1173 BLINK_SBLOG << __func__ << " ended. this=" << this << " buffered=" << webTim
eRangesToString(m_webSourceBuffer->buffered()); |
1174 } | 1174 } |
1175 | 1175 |
1176 void SourceBuffer::clearAppendStreamState() | 1176 void SourceBuffer::clearAppendStreamState() |
1177 { | 1177 { |
1178 m_streamMaxSizeValid = false; | 1178 m_streamMaxSizeValid = false; |
1179 m_streamMaxSize = 0; | 1179 m_streamMaxSize = 0; |
1180 m_loader.reset(); | 1180 m_loader.reset(); |
1181 m_stream = nullptr; | 1181 m_stream = nullptr; |
1182 } | 1182 } |
1183 | 1183 |
1184 void SourceBuffer::appendError(AppendError err) | 1184 void SourceBuffer::appendError(AppendError err) |
1185 { | 1185 { |
1186 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " AppendError=" << err; | 1186 BLINK_SBLOG << __func__ << " this=" << this << " AppendError=" << err; |
1187 // Section 3.5.3 Append Error Algorithm | 1187 // Section 3.5.3 Append Error Algorithm |
1188 // 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 |
1189 | 1189 |
1190 // 1. Run the reset parser state algorithm. | 1190 // 1. Run the reset parser state algorithm. |
1191 m_webSourceBuffer->resetParserState(); | 1191 m_webSourceBuffer->resetParserState(); |
1192 | 1192 |
1193 // 2. Set the updating attribute to false. | 1193 // 2. Set the updating attribute to false. |
1194 m_updating = false; | 1194 m_updating = false; |
1195 | 1195 |
1196 // 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. |
1197 scheduleEvent(EventTypeNames::error); | 1197 scheduleEvent(EventTypeNames::error); |
1198 | 1198 |
1199 // 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. |
1200 scheduleEvent(EventTypeNames::updateend); | 1200 scheduleEvent(EventTypeNames::updateend); |
1201 | 1201 |
1202 // 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 |
1203 // error parameter set to "decode". | 1203 // error parameter set to "decode". |
1204 if (err == DecodeError) { | 1204 if (err == DecodeError) { |
1205 m_source->endOfStream("decode", ASSERT_NO_EXCEPTION); | 1205 m_source->endOfStream("decode", ASSERT_NO_EXCEPTION); |
1206 } else { | 1206 } else { |
1207 DCHECK_EQ(err, NoDecodeError); | 1207 DCHECK_EQ(err, NoDecodeError); |
1208 // Nothing else to do in this case. | 1208 // Nothing else to do in this case. |
1209 } | 1209 } |
1210 } | 1210 } |
1211 | 1211 |
1212 void SourceBuffer::didStartLoading() | 1212 void SourceBuffer::didStartLoading() |
1213 { | 1213 { |
1214 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 1214 BLINK_SBLOG << __func__ << " this=" << this; |
1215 } | 1215 } |
1216 | 1216 |
1217 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) | 1217 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) |
1218 { | 1218 { |
1219 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " dataLength=" << dataLen
gth; | 1219 BLINK_SBLOG << __func__ << " this=" << this << " dataLength=" << dataLength; |
1220 DCHECK(m_updating); | 1220 DCHECK(m_updating); |
1221 DCHECK(m_loader); | 1221 DCHECK(m_loader); |
1222 | 1222 |
1223 // Section 3.5.6 Stream Append Loop | 1223 // Section 3.5.6 Stream Append Loop |
1224 // http://w3c.github.io/media-source/#sourcebuffer-stream-append-loop | 1224 // http://w3c.github.io/media-source/#sourcebuffer-stream-append-loop |
1225 | 1225 |
1226 // 10. Run the coded frame eviction algorithm. | 1226 // 10. Run the coded frame eviction algorithm. |
1227 if (!evictCodedFrames(dataLength)) { | 1227 if (!evictCodedFrames(dataLength)) { |
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. | 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. |
1229 appendStreamDone(RunAppendErrorWithNoDecodeError); | 1229 appendStreamDone(RunAppendErrorWithNoDecodeError); |
1230 return; | 1230 return; |
1231 } | 1231 } |
1232 | 1232 |
1233 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)) |
1234 appendStreamDone(RunAppendErrorWithDecodeError); | 1234 appendStreamDone(RunAppendErrorWithDecodeError); |
1235 } | 1235 } |
1236 | 1236 |
1237 void SourceBuffer::didFinishLoading() | 1237 void SourceBuffer::didFinishLoading() |
1238 { | 1238 { |
1239 BLINK_SBLOG << __FUNCTION__ << " this=" << this; | 1239 BLINK_SBLOG << __func__ << " this=" << this; |
1240 DCHECK(m_loader); | 1240 DCHECK(m_loader); |
1241 appendStreamDone(NoError); | 1241 appendStreamDone(NoError); |
1242 } | 1242 } |
1243 | 1243 |
1244 void SourceBuffer::didFail(FileError::ErrorCode errorCode) | 1244 void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
1245 { | 1245 { |
1246 BLINK_SBLOG << __FUNCTION__ << " this=" << this << " errorCode=" << errorCod
e; | 1246 BLINK_SBLOG << __func__ << " this=" << this << " errorCode=" << errorCode; |
1247 // 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 |
1248 // to evictCodedFrames or WebSourceBuffer append failing in | 1248 // to evictCodedFrames or WebSourceBuffer append failing in |
1249 // didReceiveDataForClient. In that case appendStreamDone will be invoked | 1249 // didReceiveDataForClient. In that case appendStreamDone will be invoked |
1250 // from there, no need to repeat it here. | 1250 // from there, no need to repeat it here. |
1251 if (m_loader) | 1251 if (m_loader) |
1252 appendStreamDone(RunAppendErrorWithNoDecodeError); | 1252 appendStreamDone(RunAppendErrorWithNoDecodeError); |
1253 } | 1253 } |
1254 | 1254 |
1255 DEFINE_TRACE(SourceBuffer) | 1255 DEFINE_TRACE(SourceBuffer) |
1256 { | 1256 { |
1257 visitor->trace(m_source); | 1257 visitor->trace(m_source); |
1258 visitor->trace(m_trackDefaults); | 1258 visitor->trace(m_trackDefaults); |
1259 visitor->trace(m_asyncEventQueue); | 1259 visitor->trace(m_asyncEventQueue); |
1260 visitor->trace(m_appendBufferAsyncPartRunner); | 1260 visitor->trace(m_appendBufferAsyncPartRunner); |
1261 visitor->trace(m_removeAsyncPartRunner); | 1261 visitor->trace(m_removeAsyncPartRunner); |
1262 visitor->trace(m_appendStreamAsyncPartRunner); | 1262 visitor->trace(m_appendStreamAsyncPartRunner); |
1263 visitor->trace(m_stream); | 1263 visitor->trace(m_stream); |
1264 visitor->trace(m_audioTracks); | 1264 visitor->trace(m_audioTracks); |
1265 visitor->trace(m_videoTracks); | 1265 visitor->trace(m_videoTracks); |
1266 EventTargetWithInlineData::trace(visitor); | 1266 EventTargetWithInlineData::trace(visitor); |
1267 ActiveDOMObject::trace(visitor); | 1267 ActiveDOMObject::trace(visitor); |
1268 } | 1268 } |
1269 | 1269 |
1270 } // namespace blink | 1270 } // namespace blink |
OLD | NEW |