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 21 matching lines...) Expand all Loading... |
32 #include "modules/mediasource/SourceBuffer.h" | 32 #include "modules/mediasource/SourceBuffer.h" |
33 | 33 |
34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/events/GenericEventQueue.h" | 38 #include "core/events/GenericEventQueue.h" |
39 #include "core/fileapi/FileReaderLoader.h" | 39 #include "core/fileapi/FileReaderLoader.h" |
40 #include "core/fileapi/Stream.h" | 40 #include "core/fileapi/Stream.h" |
41 #include "core/html/TimeRanges.h" | 41 #include "core/html/TimeRanges.h" |
42 #include "core/platform/graphics/SourceBufferPrivate.h" | |
43 #include "modules/mediasource/MediaSource.h" | 42 #include "modules/mediasource/MediaSource.h" |
44 #include "platform/Logging.h" | 43 #include "platform/Logging.h" |
45 #include "platform/TraceEvent.h" | 44 #include "platform/TraceEvent.h" |
| 45 #include "public/platform/WebSourceBuffer.h" |
46 #include "wtf/ArrayBuffer.h" | 46 #include "wtf/ArrayBuffer.h" |
47 #include "wtf/ArrayBufferView.h" | 47 #include "wtf/ArrayBufferView.h" |
48 #include "wtf/MathExtras.h" | 48 #include "wtf/MathExtras.h" |
49 | 49 |
50 #include <limits> | 50 #include <limits> |
51 | 51 |
| 52 using blink::WebSourceBuffer; |
| 53 |
52 namespace WebCore { | 54 namespace WebCore { |
53 | 55 |
54 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> so
urceBufferPrivate, MediaSource* source, GenericEventQueue* asyncEventQueue) | 56 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<WebSourceBuffer> webSou
rceBuffer, MediaSource* source, GenericEventQueue* asyncEventQueue) |
55 { | 57 { |
56 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(sourceBufferPriv
ate, source, asyncEventQueue))); | 58 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(webSourceBuffer,
source, asyncEventQueue))); |
57 sourceBuffer->suspendIfNeeded(); | 59 sourceBuffer->suspendIfNeeded(); |
58 return sourceBuffer.release(); | 60 return sourceBuffer.release(); |
59 } | 61 } |
60 | 62 |
61 SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate,
MediaSource* source, GenericEventQueue* asyncEventQueue) | 63 SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou
rce* source, GenericEventQueue* asyncEventQueue) |
62 : ActiveDOMObject(source->executionContext()) | 64 : ActiveDOMObject(source->executionContext()) |
63 , m_private(sourceBufferPrivate) | 65 , m_webSourceBuffer(webSourceBuffer) |
64 , m_source(source) | 66 , m_source(source) |
65 , m_asyncEventQueue(asyncEventQueue) | 67 , m_asyncEventQueue(asyncEventQueue) |
66 , m_updating(false) | 68 , m_updating(false) |
67 , m_timestampOffset(0) | 69 , m_timestampOffset(0) |
68 , m_appendWindowStart(0) | 70 , m_appendWindowStart(0) |
69 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) | 71 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) |
70 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) | 72 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) |
71 , m_pendingRemoveStart(-1) | 73 , m_pendingRemoveStart(-1) |
72 , m_pendingRemoveEnd(-1) | 74 , m_pendingRemoveEnd(-1) |
73 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) | 75 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) |
74 , m_streamMaxSizeValid(false) | 76 , m_streamMaxSizeValid(false) |
75 , m_streamMaxSize(0) | 77 , m_streamMaxSize(0) |
76 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) | 78 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) |
77 { | 79 { |
78 ASSERT(m_private); | 80 ASSERT(m_webSourceBuffer); |
79 ASSERT(m_source); | 81 ASSERT(m_source); |
80 ScriptWrappable::init(this); | 82 ScriptWrappable::init(this); |
81 } | 83 } |
82 | 84 |
83 SourceBuffer::~SourceBuffer() | 85 SourceBuffer::~SourceBuffer() |
84 { | 86 { |
85 ASSERT(isRemoved()); | 87 ASSERT(isRemoved()); |
86 ASSERT(!m_loader); | 88 ASSERT(!m_loader); |
87 ASSERT(!m_stream); | 89 ASSERT(!m_stream); |
88 } | 90 } |
89 | 91 |
90 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& es) const | 92 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& es) const |
91 { | 93 { |
92 // Section 3.1 buffered attribute steps. | 94 // Section 3.1 buffered attribute steps. |
93 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an | 95 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an |
94 // InvalidStateError exception and abort these steps. | 96 // InvalidStateError exception and abort these steps. |
95 if (isRemoved()) { | 97 if (isRemoved()) { |
96 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 98 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
97 return 0; | 99 return 0; |
98 } | 100 } |
99 | 101 |
100 // 2. Return a new static normalized TimeRanges object for the media segment
s buffered. | 102 // 2. Return a new static normalized TimeRanges object for the media segment
s buffered. |
101 return m_private->buffered(); | 103 return TimeRanges::create(m_webSourceBuffer->buffered()); |
102 } | 104 } |
103 | 105 |
104 double SourceBuffer::timestampOffset() const | 106 double SourceBuffer::timestampOffset() const |
105 { | 107 { |
106 return m_timestampOffset; | 108 return m_timestampOffset; |
107 } | 109 } |
108 | 110 |
109 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& es) | 111 void SourceBuffer::setTimestampOffset(double offset, ExceptionState& es) |
110 { | 112 { |
111 // Section 3.1 timestampOffset attribute setter steps. | 113 // Section 3.1 timestampOffset attribute setter steps. |
112 // 1. Let new timestamp offset equal the new value being assigned to this at
tribute. | 114 // 1. Let new timestamp offset equal the new value being assigned to this at
tribute. |
113 // 2. If this object has been removed from the sourceBuffers attribute of th
e parent media source, then throw an | 115 // 2. If this object has been removed from the sourceBuffers attribute of th
e parent media source, then throw an |
114 // InvalidStateError exception and abort these steps. | 116 // InvalidStateError exception and abort these steps. |
115 // 3. If the updating attribute equals true, then throw an InvalidStateError
exception and abort these steps. | 117 // 3. If the updating attribute equals true, then throw an InvalidStateError
exception and abort these steps. |
116 if (isRemoved() || m_updating) { | 118 if (isRemoved() || m_updating) { |
117 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 119 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
118 return; | 120 return; |
119 } | 121 } |
120 | 122 |
121 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: | 123 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: |
122 // 4.1 Set the readyState attribute of the parent media source to "open" | 124 // 4.1 Set the readyState attribute of the parent media source to "open" |
123 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. | 125 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. |
124 m_source->openIfInEndedState(); | 126 m_source->openIfInEndedState(); |
125 | 127 |
126 // 5. If this object is waiting for the end of a media segment to be appende
d, then throw an InvalidStateError | 128 // 5. If this object is waiting for the end of a media segment to be appende
d, then throw an InvalidStateError |
127 // and abort these steps. | 129 // and abort these steps. |
128 // | 130 // |
129 // FIXME: Add step 6 text when mode attribute is implemented. | 131 // FIXME: Add step 6 text when mode attribute is implemented. |
130 if (!m_private->setTimestampOffset(offset)) { | 132 if (!m_webSourceBuffer->setTimestampOffset(offset)) { |
131 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 133 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
132 return; | 134 return; |
133 } | 135 } |
134 | 136 |
135 // 7. Update the attribute to new timestamp offset. | 137 // 7. Update the attribute to new timestamp offset. |
136 m_timestampOffset = offset; | 138 m_timestampOffset = offset; |
137 } | 139 } |
138 | 140 |
139 double SourceBuffer::appendWindowStart() const | 141 double SourceBuffer::appendWindowStart() const |
140 { | 142 { |
(...skipping 19 matching lines...) Expand all Loading... |
160 return; | 162 return; |
161 } | 163 } |
162 | 164 |
163 // 3. If the new value is less than 0 or greater than or equal to appendWind
owEnd then throw an InvalidAccessError | 165 // 3. If the new value is less than 0 or greater than or equal to appendWind
owEnd then throw an InvalidAccessError |
164 // exception and abort these steps. | 166 // exception and abort these steps. |
165 if (start < 0 || start >= m_appendWindowEnd) { | 167 if (start < 0 || start >= m_appendWindowEnd) { |
166 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 168 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
167 return; | 169 return; |
168 } | 170 } |
169 | 171 |
170 m_private->setAppendWindowStart(start); | 172 m_webSourceBuffer->setAppendWindowStart(start); |
171 | 173 |
172 // 4. Update the attribute to the new value. | 174 // 4. Update the attribute to the new value. |
173 m_appendWindowStart = start; | 175 m_appendWindowStart = start; |
174 } | 176 } |
175 | 177 |
176 double SourceBuffer::appendWindowEnd() const | 178 double SourceBuffer::appendWindowEnd() const |
177 { | 179 { |
178 return m_appendWindowEnd; | 180 return m_appendWindowEnd; |
179 } | 181 } |
180 | 182 |
181 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& es) | 183 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& es) |
182 { | 184 { |
183 // Section 3.1 appendWindowEnd attribute setter steps. | 185 // Section 3.1 appendWindowEnd attribute setter steps. |
184 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an | 186 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an |
185 // InvalidStateError exception and abort these steps. | 187 // InvalidStateError exception and abort these steps. |
186 // 2. If the updating attribute equals true, then throw an InvalidStateError
exception and abort these steps. | 188 // 2. If the updating attribute equals true, then throw an InvalidStateError
exception and abort these steps. |
187 if (isRemoved() || m_updating) { | 189 if (isRemoved() || m_updating) { |
188 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 190 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
189 return; | 191 return; |
190 } | 192 } |
191 | 193 |
192 // 3. If the new value equals NaN, then throw an InvalidAccessError and abor
t these steps. | 194 // 3. If the new value equals NaN, then throw an InvalidAccessError and abor
t these steps. |
193 // 4. If the new value is less than or equal to appendWindowStart then throw
an InvalidAccessError | 195 // 4. If the new value is less than or equal to appendWindowStart then throw
an InvalidAccessError |
194 // exception and abort these steps. | 196 // exception and abort these steps. |
195 if (std::isnan(end) || end <= m_appendWindowStart) { | 197 if (std::isnan(end) || end <= m_appendWindowStart) { |
196 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 198 es.throwUninformativeAndGenericDOMException(InvalidAccessError); |
197 return; | 199 return; |
198 } | 200 } |
199 | 201 |
200 m_private->setAppendWindowEnd(end); | 202 m_webSourceBuffer->setAppendWindowEnd(end); |
201 | 203 |
202 // 5. Update the attribute to the new value. | 204 // 5. Update the attribute to the new value. |
203 m_appendWindowEnd = end; | 205 m_appendWindowEnd = end; |
204 } | 206 } |
205 | 207 |
206 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es
) | 208 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es
) |
207 { | 209 { |
208 // Section 3.2 appendBuffer() | 210 // Section 3.2 appendBuffer() |
209 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 211 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
210 // 1. If data is null then throw an InvalidAccessError exception and abort t
hese steps. | 212 // 1. If data is null then throw an InvalidAccessError exception and abort t
hese steps. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // then throw an InvalidStateError exception and abort these steps. | 255 // then throw an InvalidStateError exception and abort these steps. |
254 if (isRemoved() || !m_source->isOpen()) { | 256 if (isRemoved() || !m_source->isOpen()) { |
255 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 257 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
256 return; | 258 return; |
257 } | 259 } |
258 | 260 |
259 // 3. If the sourceBuffer.updating attribute equals true, then run the follo
wing steps: ... | 261 // 3. If the sourceBuffer.updating attribute equals true, then run the follo
wing steps: ... |
260 abortIfUpdating(); | 262 abortIfUpdating(); |
261 | 263 |
262 // 4. Run the reset parser state algorithm. | 264 // 4. Run the reset parser state algorithm. |
263 m_private->abort(); | 265 m_webSourceBuffer->abort(); |
264 | 266 |
265 // 5. Set appendWindowStart to 0. | 267 // 5. Set appendWindowStart to 0. |
266 setAppendWindowStart(0, es); | 268 setAppendWindowStart(0, es); |
267 | 269 |
268 // 6. Set appendWindowEnd to positive Infinity. | 270 // 6. Set appendWindowEnd to positive Infinity. |
269 setAppendWindowEnd(std::numeric_limits<double>::infinity(), es); | 271 setAppendWindowEnd(std::numeric_limits<double>::infinity(), es); |
270 } | 272 } |
271 | 273 |
272 void SourceBuffer::remove(double start, double end, ExceptionState& es) | 274 void SourceBuffer::remove(double start, double end, ExceptionState& es) |
273 { | 275 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 TRACE_EVENT_ASYNC_END0("media", traceEventName, this); | 350 TRACE_EVENT_ASYNC_END0("media", traceEventName, this); |
349 } | 351 } |
350 | 352 |
351 void SourceBuffer::removedFromMediaSource() | 353 void SourceBuffer::removedFromMediaSource() |
352 { | 354 { |
353 if (isRemoved()) | 355 if (isRemoved()) |
354 return; | 356 return; |
355 | 357 |
356 abortIfUpdating(); | 358 abortIfUpdating(); |
357 | 359 |
358 m_private->removedFromMediaSource(); | 360 m_webSourceBuffer->removedFromMediaSource(); |
| 361 m_webSourceBuffer.clear(); |
359 m_source = 0; | 362 m_source = 0; |
360 m_asyncEventQueue = 0; | 363 m_asyncEventQueue = 0; |
361 } | 364 } |
362 | 365 |
363 bool SourceBuffer::hasPendingActivity() const | 366 bool SourceBuffer::hasPendingActivity() const |
364 { | 367 { |
365 return m_source; | 368 return m_source; |
366 } | 369 } |
367 | 370 |
368 void SourceBuffer::suspend() | 371 void SourceBuffer::suspend() |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 TRACE_EVENT_ASYNC_STEP0("media", "SourceBuffer::appendBuffer", this, "append
ing"); | 456 TRACE_EVENT_ASYNC_STEP0("media", "SourceBuffer::appendBuffer", this, "append
ing"); |
454 | 457 |
455 // Section 3.5.4 Buffer Append Algorithm | 458 // Section 3.5.4 Buffer Append Algorithm |
456 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#sourcebuffer-buffer-append | 459 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#sourcebuffer-buffer-append |
457 | 460 |
458 // 1. Run the segment parser loop algorithm. | 461 // 1. Run the segment parser loop algorithm. |
459 // Step 2 doesn't apply since we run Step 1 synchronously here. | 462 // Step 2 doesn't apply since we run Step 1 synchronously here. |
460 size_t appendSize = m_pendingAppendData.size(); | 463 size_t appendSize = m_pendingAppendData.size(); |
461 if (!appendSize) { | 464 if (!appendSize) { |
462 // Resize buffer for 0 byte appends so we always have a valid pointer. | 465 // Resize buffer for 0 byte appends so we always have a valid pointer. |
463 // We need to convey all appends, even 0 byte ones to |m_private| so | 466 // We need to convey all appends, even 0 byte ones to |m_webSourceBuffer
| |
464 // that it can clear its end of stream state if necessary. | 467 // so that it can clear its end of stream state if necessary. |
465 m_pendingAppendData.resize(1); | 468 m_pendingAppendData.resize(1); |
466 } | 469 } |
467 m_private->append(m_pendingAppendData.data(), appendSize); | 470 m_webSourceBuffer->append(m_pendingAppendData.data(), appendSize); |
468 | 471 |
469 // 3. Set the updating attribute to false. | 472 // 3. Set the updating attribute to false. |
470 m_updating = false; | 473 m_updating = false; |
471 m_pendingAppendData.clear(); | 474 m_pendingAppendData.clear(); |
472 | 475 |
473 // 4. Queue a task to fire a simple event named update at this SourceBuffer
object. | 476 // 4. Queue a task to fire a simple event named update at this SourceBuffer
object. |
474 scheduleEvent(EventTypeNames::update); | 477 scheduleEvent(EventTypeNames::update); |
475 | 478 |
476 // 5. Queue a task to fire a simple event named updateend at this SourceBuff
er object. | 479 // 5. Queue a task to fire a simple event named updateend at this SourceBuff
er object. |
477 scheduleEvent(EventTypeNames::updateend); | 480 scheduleEvent(EventTypeNames::updateend); |
478 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); | 481 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); |
479 } | 482 } |
480 | 483 |
481 void SourceBuffer::removeAsyncPart() | 484 void SourceBuffer::removeAsyncPart() |
482 { | 485 { |
483 ASSERT(m_updating); | 486 ASSERT(m_updating); |
484 ASSERT(m_pendingRemoveStart >= 0); | 487 ASSERT(m_pendingRemoveStart >= 0); |
485 ASSERT(m_pendingRemoveStart < m_pendingRemoveEnd); | 488 ASSERT(m_pendingRemoveStart < m_pendingRemoveEnd); |
486 | 489 |
487 // Section 3.2 remove() method steps | 490 // Section 3.2 remove() method steps |
488 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-remove-void-double-start-double-end | 491 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-remove-void-double-start-double-end |
489 | 492 |
490 // 9. Run the coded frame removal algorithm with start and end as the start
and end of the removal range. | 493 // 9. Run the coded frame removal algorithm with start and end as the start
and end of the removal range. |
491 m_private->remove(m_pendingRemoveStart, m_pendingRemoveEnd); | 494 m_webSourceBuffer->remove(m_pendingRemoveStart, m_pendingRemoveEnd); |
492 | 495 |
493 // 10. Set the updating attribute to false. | 496 // 10. Set the updating attribute to false. |
494 m_updating = false; | 497 m_updating = false; |
495 m_pendingRemoveStart = -1; | 498 m_pendingRemoveStart = -1; |
496 m_pendingRemoveEnd = -1; | 499 m_pendingRemoveEnd = -1; |
497 | 500 |
498 // 11. Queue a task to fire a simple event named update at this SourceBuffer
object. | 501 // 11. Queue a task to fire a simple event named update at this SourceBuffer
object. |
499 scheduleEvent(EventTypeNames::update); | 502 scheduleEvent(EventTypeNames::update); |
500 | 503 |
501 // 12. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. | 504 // 12. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. |
(...skipping 18 matching lines...) Expand all Loading... |
520 if (isRemoved() || m_updating) { | 523 if (isRemoved() || m_updating) { |
521 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 524 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
522 return; | 525 return; |
523 } | 526 } |
524 | 527 |
525 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendStream", this); | 528 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendStream", this); |
526 | 529 |
527 // 3. If the readyState attribute of the parent media source is in the "end
ed" state then run the following steps: ... | 530 // 3. If the readyState attribute of the parent media source is in the "end
ed" state then run the following steps: ... |
528 m_source->openIfInEndedState(); | 531 m_source->openIfInEndedState(); |
529 | 532 |
530 // Steps 4-5 of the prepare append algorithm are handled by m_private. | 533 // Steps 4-5 of the prepare append algorithm are handled by m_webSourceBuffe
r. |
531 | 534 |
532 // 3. Set the updating attribute to true. | 535 // 3. Set the updating attribute to true. |
533 m_updating = true; | 536 m_updating = true; |
534 | 537 |
535 // 4. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. | 538 // 4. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. |
536 scheduleEvent(EventTypeNames::updatestart); | 539 scheduleEvent(EventTypeNames::updatestart); |
537 | 540 |
538 // 5. Asynchronously run the stream append loop algorithm with stream and ma
xSize. | 541 // 5. Asynchronously run the stream append loop algorithm with stream and ma
xSize. |
539 | 542 |
540 stream->neuter(); | 543 stream->neuter(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // 3. Queue a task to fire a simple event named error at this SourceBuff
er object. | 586 // 3. Queue a task to fire a simple event named error at this SourceBuff
er object. |
584 scheduleEvent(EventTypeNames::error); | 587 scheduleEvent(EventTypeNames::error); |
585 | 588 |
586 // 4. Queue a task to fire a simple event named updateend at this Source
Buffer object. | 589 // 4. Queue a task to fire a simple event named updateend at this Source
Buffer object. |
587 scheduleEvent(EventTypeNames::updateend); | 590 scheduleEvent(EventTypeNames::updateend); |
588 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); | 591 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); |
589 return; | 592 return; |
590 } | 593 } |
591 | 594 |
592 // Section 3.5.6 Stream Append Loop | 595 // Section 3.5.6 Stream Append Loop |
593 // Steps 1-11 are handled by appendStreamAsyncPart(), |m_loader|, and |m_pri
vate|. | 596 // Steps 1-11 are handled by appendStreamAsyncPart(), |m_loader|, and |m_web
SourceBuffer|. |
594 // 12. Loop Done: Set the updating attribute to false. | 597 // 12. Loop Done: Set the updating attribute to false. |
595 m_updating = false; | 598 m_updating = false; |
596 | 599 |
597 // 13. Queue a task to fire a simple event named update at this SourceBuffer
object. | 600 // 13. Queue a task to fire a simple event named update at this SourceBuffer
object. |
598 scheduleEvent(EventTypeNames::update); | 601 scheduleEvent(EventTypeNames::update); |
599 | 602 |
600 // 14. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. | 603 // 14. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. |
601 scheduleEvent(EventTypeNames::updateend); | 604 scheduleEvent(EventTypeNames::updateend); |
602 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); | 605 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); |
603 } | 606 } |
(...skipping 10 matching lines...) Expand all Loading... |
614 { | 617 { |
615 LOG(Media, "SourceBuffer::didStartLoading() %p", this); | 618 LOG(Media, "SourceBuffer::didStartLoading() %p", this); |
616 } | 619 } |
617 | 620 |
618 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) | 621 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) |
619 { | 622 { |
620 LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, this)
; | 623 LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, this)
; |
621 ASSERT(m_updating); | 624 ASSERT(m_updating); |
622 ASSERT(m_loader); | 625 ASSERT(m_loader); |
623 | 626 |
624 m_private->append(reinterpret_cast<const unsigned char*>(data), dataLength); | 627 m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), data
Length); |
625 } | 628 } |
626 | 629 |
627 void SourceBuffer::didFinishLoading() | 630 void SourceBuffer::didFinishLoading() |
628 { | 631 { |
629 LOG(Media, "SourceBuffer::didFinishLoading() %p", this); | 632 LOG(Media, "SourceBuffer::didFinishLoading() %p", this); |
630 appendStreamDone(true); | 633 appendStreamDone(true); |
631 } | 634 } |
632 | 635 |
633 void SourceBuffer::didFail(FileError::ErrorCode errorCode) | 636 void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
634 { | 637 { |
635 LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); | 638 LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); |
636 appendStreamDone(false); | 639 appendStreamDone(false); |
637 } | 640 } |
638 | 641 |
639 } // namespace WebCore | 642 } // namespace WebCore |
OLD | NEW |