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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const AtomicString& SourceBuffer::sequenceKeyword() | 118 const AtomicString& SourceBuffer::sequenceKeyword() |
119 { | 119 { |
120 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence", AtomicString:
:ConstructFromLiteral)); | 120 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence", AtomicString:
:ConstructFromLiteral)); |
121 return sequence; | 121 return sequence; |
122 } | 122 } |
123 | 123 |
124 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio
nState) | 124 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio
nState) |
125 { | 125 { |
126 // Section 3.1 On setting mode attribute steps. | 126 // Section 3.1 On setting mode attribute steps. |
127 // 1. Let new mode equal the new value being assigned to this attribute. | 127 // 1. Let new mode equal the new value being assigned to this attribute. |
128 // 2. If new mode does not equal "segments" or "sequence", then throw an INV
ALID_ACCESS_ERR exception and abort | 128 // 2. If this object has been removed from the sourceBuffers attribute of th
e parent media source, then throw |
129 // these steps. | |
130 // Step 2 is unnecessary: IDL enforcement prevents this case and should j
ust return immediately to script | |
131 // without calling this method in this case. | |
132 // 3. If this object has been removed from the sourceBuffers attribute of th
e parent media source, then throw | |
133 // an INVALID_STATE_ERR exception and abort these steps. | 129 // an INVALID_STATE_ERR exception and abort these steps. |
134 // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR
exception and abort these steps. | 130 // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR
exception and abort these steps. |
135 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 131 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
136 return; | 132 return; |
137 | 133 |
138 // 5. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: | 134 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: |
139 // 5.1 Set the readyState attribute of the parent media source to "open" | 135 // 4.1 Set the readyState attribute of the parent media source to "open" |
140 // 5.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. | 136 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. |
141 m_source->openIfInEndedState(); | 137 m_source->openIfInEndedState(); |
142 | 138 |
143 // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALI
D_STATE_ERR and abort these steps. | 139 // 5. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALI
D_STATE_ERR and abort these steps. |
144 // 7. If the new mode equals "sequence", then set the group start timestamp
to the highest presentation end timestamp. | 140 // 6. If the new mode equals "sequence", then set the group start timestamp
to the highest presentation end timestamp. |
145 WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::AppendModeSegments
; | 141 WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::AppendModeSegments
; |
146 if (newMode == sequenceKeyword()) | 142 if (newMode == sequenceKeyword()) |
147 appendMode = WebSourceBuffer::AppendModeSequence; | 143 appendMode = WebSourceBuffer::AppendModeSequence; |
148 if (!m_webSourceBuffer->setMode(appendMode)) { | 144 if (!m_webSourceBuffer->setMode(appendMode)) { |
149 exceptionState.throwDOMException(InvalidStateError, "The mode may not be
set while the SourceBuffer's append state is 'PARSING_MEDIA_SEGMENT'."); | 145 exceptionState.throwDOMException(InvalidStateError, "The mode may not be
set while the SourceBuffer's append state is 'PARSING_MEDIA_SEGMENT'."); |
150 return; | 146 return; |
151 } | 147 } |
152 | 148 |
153 // 8. Update the attribute to new mode. | 149 // 7. Update the attribute to new mode. |
154 m_mode = newMode; | 150 m_mode = newMode; |
155 } | 151 } |
156 | 152 |
157 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co
nst | 153 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co
nst |
158 { | 154 { |
159 // Section 3.1 buffered attribute steps. | 155 // Section 3.1 buffered attribute steps. |
160 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an | 156 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an |
161 // InvalidStateError exception and abort these steps. | 157 // InvalidStateError exception and abort these steps. |
162 if (isRemoved()) { | 158 if (isRemoved()) { |
163 exceptionState.throwDOMException(InvalidStateError, "This SourceBuffer h
as been removed from the parent media source."); | 159 exceptionState.throwDOMException(InvalidStateError, "This SourceBuffer h
as been removed from the parent media source."); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 m_webSourceBuffer->setAppendWindowEnd(end); | 255 m_webSourceBuffer->setAppendWindowEnd(end); |
260 | 256 |
261 // 5. Update the attribute to the new value. | 257 // 5. Update the attribute to the new value. |
262 m_appendWindowEnd = end; | 258 m_appendWindowEnd = end; |
263 } | 259 } |
264 | 260 |
265 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& ex
ceptionState) | 261 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& ex
ceptionState) |
266 { | 262 { |
267 // Section 3.2 appendBuffer() | 263 // Section 3.2 appendBuffer() |
268 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 264 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
269 // 1. If data is null then throw an InvalidAccessError exception and abort t
hese steps. | |
270 if (!data) { | |
271 exceptionState.throwDOMException(InvalidAccessError, "The ArrayBuffer pr
ovided is invalid."); | |
272 return; | |
273 } | |
274 | |
275 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data->
byteLength(), exceptionState); | 265 appendBufferInternal(static_cast<const unsigned char*>(data->data()), data->
byteLength(), exceptionState); |
276 } | 266 } |
277 | 267 |
278 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionState
& exceptionState) | 268 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionState
& exceptionState) |
279 { | 269 { |
280 // Section 3.2 appendBuffer() | 270 // Section 3.2 appendBuffer() |
281 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 271 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
282 // 1. If data is null then throw an InvalidAccessError exception and abort t
hese steps. | |
283 if (!data) { | |
284 exceptionState.throwDOMException(InvalidAccessError, "The ArrayBuffer pr
ovided is invalid."); | |
285 return; | |
286 } | |
287 | |
288 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()),
data->byteLength(), exceptionState); | 272 appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()),
data->byteLength(), exceptionState); |
289 } | 273 } |
290 | 274 |
291 void SourceBuffer::appendStream(PassRefPtrWillBeRawPtr<Stream> stream, Exception
State& exceptionState) | 275 void SourceBuffer::appendStream(PassRefPtrWillBeRawPtr<Stream> stream, Exception
State& exceptionState) |
292 { | 276 { |
293 m_streamMaxSizeValid = false; | 277 m_streamMaxSizeValid = false; |
294 appendStreamInternal(stream, exceptionState); | 278 appendStreamInternal(stream, exceptionState); |
295 } | 279 } |
296 | 280 |
297 void SourceBuffer::appendStream(PassRefPtrWillBeRawPtr<Stream> stream, unsigned
long long maxSize, ExceptionState& exceptionState) | 281 void SourceBuffer::appendStream(PassRefPtrWillBeRawPtr<Stream> stream, unsigned
long long maxSize, ExceptionState& exceptionState) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 event->setTarget(this); | 460 event->setTarget(this); |
477 | 461 |
478 m_asyncEventQueue->enqueueEvent(event.release()); | 462 m_asyncEventQueue->enqueueEvent(event.release()); |
479 } | 463 } |
480 | 464 |
481 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size
, ExceptionState& exceptionState) | 465 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size
, ExceptionState& exceptionState) |
482 { | 466 { |
483 // Section 3.2 appendBuffer() | 467 // Section 3.2 appendBuffer() |
484 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 468 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
485 | 469 |
486 // Step 1 is enforced by the caller. | 470 // 1. Run the prepare append algorithm. |
487 // 2. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an InvalidStateError exception and abort these
steps. | 471 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#sourcebuffer-prepare-append |
488 // 3. If the updating attribute equals true, then throw an InvalidStateError
exception and abort these steps. | 472 // 1. If this object has been removed from the sourceBuffers attribute of t
he parent media source then throw an InvalidStateError exception and abort these
steps. |
| 473 // 2. If the updating attribute equals true, then throw an InvalidStateErro
r exception and abort these steps. |
489 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 474 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
490 return; | 475 return; |
491 | 476 |
492 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendBuffer", this); | 477 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendBuffer", this); |
493 | 478 |
494 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: ... | 479 // 3. If the readyState attribute of the parent media source is in the "end
ed" state then run the following steps: ... |
495 m_source->openIfInEndedState(); | 480 m_source->openIfInEndedState(); |
496 | 481 |
497 // Steps 5-6 | 482 // Steps 4-5 - end "prepare append" algorithm. |
498 | 483 |
499 // 7. Add data to the end of the input buffer. | 484 // 2. Add data to the end of the input buffer. |
500 m_pendingAppendData.append(data, size); | 485 m_pendingAppendData.append(data, size); |
501 | 486 |
502 // 8. Set the updating attribute to true. | 487 // 3. Set the updating attribute to true. |
503 m_updating = true; | 488 m_updating = true; |
504 | 489 |
505 // 9. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. | 490 // 4. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. |
506 scheduleEvent(EventTypeNames::updatestart); | 491 scheduleEvent(EventTypeNames::updatestart); |
507 | 492 |
508 // 10. Asynchronously run the buffer append algorithm. | 493 // 5. Asynchronously run the buffer append algorithm. |
509 m_appendBufferAsyncPartRunner.runAsync(); | 494 m_appendBufferAsyncPartRunner.runAsync(); |
510 | 495 |
511 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "w
aiting"); | 496 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "w
aiting"); |
512 } | 497 } |
513 | 498 |
514 void SourceBuffer::appendBufferAsyncPart() | 499 void SourceBuffer::appendBufferAsyncPart() |
515 { | 500 { |
516 ASSERT(m_updating); | 501 ASSERT(m_updating); |
517 | 502 |
518 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "a
ppending"); | 503 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "a
ppending"); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 scheduleEvent(EventTypeNames::update); | 549 scheduleEvent(EventTypeNames::update); |
565 | 550 |
566 // 12. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. | 551 // 12. Queue a task to fire a simple event named updateend at this SourceBuf
fer object. |
567 scheduleEvent(EventTypeNames::updateend); | 552 scheduleEvent(EventTypeNames::updateend); |
568 } | 553 } |
569 | 554 |
570 void SourceBuffer::appendStreamInternal(PassRefPtrWillBeRawPtr<Stream> stream, E
xceptionState& exceptionState) | 555 void SourceBuffer::appendStreamInternal(PassRefPtrWillBeRawPtr<Stream> stream, E
xceptionState& exceptionState) |
571 { | 556 { |
572 // Section 3.2 appendStream() | 557 // Section 3.2 appendStream() |
573 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-ma
xSize | 558 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-ma
xSize |
574 // 1. If stream is null then throw an InvalidAccessError exception and abort
these steps. | 559 // (0. If the stream has been neutered, then throw an InvalidAccessError exc
eption and abort these steps.) |
575 if (!stream || stream->isNeutered()) { | 560 if (stream->isNeutered()) { |
576 exceptionState.throwDOMException(InvalidAccessError, stream ? "The strea
m provided has been neutered." : "The stream provided is invalid."); | 561 exceptionState.throwDOMException(InvalidAccessError, "The stream provide
d has been neutered."); |
577 return; | 562 return; |
578 } | 563 } |
579 | 564 |
580 // 2. Run the prepare append algorithm. | 565 // 1. Run the prepare append algorithm. |
581 // Section 3.5.4 Prepare Append Algorithm. | 566 // Section 3.5.4 Prepare Append Algorithm. |
582 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-so
urce.html#sourcebuffer-prepare-append | 567 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-so
urce.html#sourcebuffer-prepare-append |
583 // 1. If this object has been removed from the sourceBuffers attribute of t
he parent media source then throw an InvalidStateError exception and abort these
steps. | 568 // 1. If this object has been removed from the sourceBuffers attribute of t
he parent media source then throw an InvalidStateError exception and abort these
steps. |
584 // 2. If the updating attribute equals true, then throw an InvalidStateErro
r exception and abort these steps. | 569 // 2. If the updating attribute equals true, then throw an InvalidStateErro
r exception and abort these steps. |
585 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) | 570 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat
e)) |
586 return; | 571 return; |
587 | 572 |
588 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendStream", this); | 573 TRACE_EVENT_ASYNC_BEGIN0("media", "SourceBuffer::appendStream", this); |
589 | 574 |
590 // 3. If the readyState attribute of the parent media source is in the "end
ed" state then run the following steps: ... | 575 // 3. If the readyState attribute of the parent media source is in the "end
ed" state then run the following steps: ... |
591 m_source->openIfInEndedState(); | 576 m_source->openIfInEndedState(); |
592 | 577 |
593 // Steps 4-5 of the prepare append algorithm are handled by m_webSourceBuffe
r. | 578 // Steps 4-5 of the prepare append algorithm are handled by m_webSourceBuffe
r. |
594 | 579 |
595 // 3. Set the updating attribute to true. | 580 // 2. Set the updating attribute to true. |
596 m_updating = true; | 581 m_updating = true; |
597 | 582 |
598 // 4. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. | 583 // 3. Queue a task to fire a simple event named updatestart at this SourceBu
ffer object. |
599 scheduleEvent(EventTypeNames::updatestart); | 584 scheduleEvent(EventTypeNames::updatestart); |
600 | 585 |
601 // 5. Asynchronously run the stream append loop algorithm with stream and ma
xSize. | 586 // 4. Asynchronously run the stream append loop algorithm with stream and ma
xSize. |
602 | 587 |
603 stream->neuter(); | 588 stream->neuter(); |
604 m_loader = adoptPtr(new FileReaderLoader(FileReaderLoader::ReadByClient, thi
s)); | 589 m_loader = adoptPtr(new FileReaderLoader(FileReaderLoader::ReadByClient, thi
s)); |
605 m_stream = stream; | 590 m_stream = stream; |
606 m_appendStreamAsyncPartRunner.runAsync(); | 591 m_appendStreamAsyncPartRunner.runAsync(); |
607 } | 592 } |
608 | 593 |
609 void SourceBuffer::appendStreamAsyncPart() | 594 void SourceBuffer::appendStreamAsyncPart() |
610 { | 595 { |
611 ASSERT(m_updating); | 596 ASSERT(m_updating); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 appendStreamDone(false); | 683 appendStreamDone(false); |
699 } | 684 } |
700 | 685 |
701 void SourceBuffer::trace(Visitor* visitor) | 686 void SourceBuffer::trace(Visitor* visitor) |
702 { | 687 { |
703 visitor->trace(m_source); | 688 visitor->trace(m_source); |
704 visitor->trace(m_stream); | 689 visitor->trace(m_stream); |
705 } | 690 } |
706 | 691 |
707 } // namespace WebCore | 692 } // namespace WebCore |
OLD | NEW |