| Index: Source/modules/mediasource/SourceBuffer.cpp
|
| diff --git a/Source/modules/mediasource/SourceBuffer.cpp b/Source/modules/mediasource/SourceBuffer.cpp
|
| index e44acdd05d626cece4f1c5cec1854f1354e93d36..cbfbb8ced08c4d3cd299b58d94d2c878c4f76293 100644
|
| --- a/Source/modules/mediasource/SourceBuffer.cpp
|
| +++ b/Source/modules/mediasource/SourceBuffer.cpp
|
| @@ -513,7 +513,12 @@ void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size
|
| // 3. If the readyState attribute of the parent media source is in the "ended" state then run the following steps: ...
|
| m_source->openIfInEndedState();
|
|
|
| - // Steps 4-5 - end "prepare append" algorithm.
|
| + // 4. Run the coded frame eviction algorithm.
|
| + if (!evictCodedFrames()) {
|
| + // 5. If the buffer full flag equals true, then throw a QUOTA_EXCEEDED_ERR exception and abort these steps.
|
| + exceptionState.throwDOMException(QuotaExceededError, "The SourceBuffer is full, and cannot free space to append additional buffers.");
|
| + return;
|
| + }
|
|
|
| // 2. Add data to the end of the input buffer.
|
| ASSERT(data || size == 0);
|
| @@ -611,6 +616,11 @@ void SourceBuffer::removeAsyncPart()
|
| scheduleEvent(EventTypeNames::updateend);
|
| }
|
|
|
| +bool SourceBuffer::evictCodedFrames()
|
| +{
|
| + return m_webSourceBuffer->evictCodedFrames();
|
| +}
|
| +
|
| void SourceBuffer::appendStreamInternal(PassRefPtrWillBeRawPtr<Stream> stream, ExceptionState& exceptionState)
|
| {
|
| // Section 3.2 appendStream()
|
| @@ -634,7 +644,12 @@ void SourceBuffer::appendStreamInternal(PassRefPtrWillBeRawPtr<Stream> stream, E
|
| // 3. If the readyState attribute of the parent media source is in the "ended" state then run the following steps: ...
|
| m_source->openIfInEndedState();
|
|
|
| - // Steps 4-5 of the prepare append algorithm are handled by m_webSourceBuffer.
|
| + // 4. Run the coded frame eviction algorithm.
|
| + if (!evictCodedFrames()) {
|
| + // 5. If the buffer full flag equals true, then throw a QUOTA_EXCEEDED_ERR exception and abort these steps.
|
| + exceptionState.throwDOMException(QuotaExceededError, "The SourceBuffer is full, and cannot free space to append stream.");
|
| + return;
|
| + }
|
|
|
| // 2. Set the updating attribute to true.
|
| m_updating = true;
|
| @@ -666,7 +681,7 @@ void SourceBuffer::appendStreamAsyncPart()
|
| return;
|
| }
|
|
|
| - // Steps 3-11 are handled by m_loader.
|
| + // Steps 3-9 are handled by m_loader.
|
| // Note: Passing 0 here signals that maxSize was not set. (i.e. Read all the data in the stream).
|
| m_loader->start(executionContext(), *m_stream, m_streamMaxSizeValid ? m_streamMaxSize : 0);
|
| }
|
| @@ -680,24 +695,22 @@ void SourceBuffer::appendStreamDone(bool success)
|
| clearAppendStreamState();
|
|
|
| if (!success) {
|
| - // Section 3.5.3 Append Error Algorithm
|
| - // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#sourcebuffer-append-error
|
| - //
|
| - // 1. Run the reset parser state algorithm. (Handled by caller)
|
| - // 2. Set the updating attribute to false.
|
| - m_updating = false;
|
| -
|
| - // 3. Queue a task to fire a simple event named error at this SourceBuffer object.
|
| - scheduleEvent(EventTypeNames::error);
|
| -
|
| - // 4. Queue a task to fire a simple event named updateend at this SourceBuffer object.
|
| - scheduleEvent(EventTypeNames::updateend);
|
| + appendError();
|
| TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this);
|
| return;
|
| }
|
|
|
| // Section 3.5.6 Stream Append Loop
|
| - // Steps 1-11 are handled by appendStreamAsyncPart(), |m_loader|, and |m_webSourceBuffer|.
|
| + // Steps 1-9 are handled by appendStreamAsyncPart(), |m_loader|, and |m_webSourceBuffer|.
|
| +
|
| + // 10. Run the coded frame eviction algorithm.
|
| + if (!evictCodedFrames()) {
|
| + // 11. If the buffer full flag equals true, then run the append error algorithm with the decode error parameter set to false and abort this algorithm.
|
| + appendError();
|
| + TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this);
|
| + return;
|
| + }
|
| +
|
| // 12. Loop Done: Set the updating attribute to false.
|
| m_updating = false;
|
|
|
| @@ -717,6 +730,22 @@ void SourceBuffer::clearAppendStreamState()
|
| m_stream = nullptr;
|
| }
|
|
|
| +void SourceBuffer::appendError()
|
| +{
|
| + // Section 3.5.3 Append Error Algorithm
|
| + // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#sourcebuffer-append-error
|
| + //
|
| + // 1. Run the reset parser state algorithm. (Handled by caller)
|
| + // 2. Set the updating attribute to false.
|
| + m_updating = false;
|
| +
|
| + // 3. Queue a task to fire a simple event named error at this SourceBuffer object.
|
| + scheduleEvent(EventTypeNames::error);
|
| +
|
| + // 4. Queue a task to fire a simple event named updateend at this SourceBuffer object.
|
| + scheduleEvent(EventTypeNames::updateend);
|
| +}
|
| +
|
| void SourceBuffer::didStartLoading()
|
| {
|
| WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this);
|
|
|