Index: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp |
diff --git a/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp b/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp |
index dded7a29c82428154f54db1c675262f8f314347c..2d08473ff1f179e7e31bfa37863b6c3d40f2eb35 100644 |
--- a/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp |
+++ b/third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp |
@@ -814,26 +814,33 @@ void SourceBuffer::appendBufferAsyncPart() |
if (appendSize) |
appendData = m_pendingAppendData.data() + m_pendingAppendDataOffset; |
- m_webSourceBuffer->append(appendData, appendSize, &m_timestampOffset); |
+ bool appendSuccess = m_webSourceBuffer->append(appendData, appendSize, &m_timestampOffset); |
- m_pendingAppendDataOffset += appendSize; |
+ if (!appendSuccess) { |
+ m_pendingAppendData.clear(); |
+ m_pendingAppendDataOffset = 0; |
+ appendError(true); |
+ } else { |
+ m_pendingAppendDataOffset += appendSize; |
- if (m_pendingAppendDataOffset < m_pendingAppendData.size()) { |
- m_appendBufferAsyncPartRunner->runAsync(); |
- TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "nextPieceDelay"); |
- return; |
- } |
+ if (m_pendingAppendDataOffset < m_pendingAppendData.size()) { |
+ m_appendBufferAsyncPartRunner->runAsync(); |
+ TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "nextPieceDelay"); |
+ return; |
+ } |
- // 3. Set the updating attribute to false. |
- m_updating = false; |
- m_pendingAppendData.clear(); |
- m_pendingAppendDataOffset = 0; |
+ // 3. Set the updating attribute to false. |
+ m_updating = false; |
+ m_pendingAppendData.clear(); |
+ m_pendingAppendDataOffset = 0; |
- // 4. Queue a task to fire a simple event named update at this SourceBuffer object. |
- scheduleEvent(EventTypeNames::update); |
+ // 4. Queue a task to fire a simple event named update at this SourceBuffer object. |
+ scheduleEvent(EventTypeNames::update); |
+ |
+ // 5. Queue a task to fire a simple event named updateend at this SourceBuffer object. |
+ scheduleEvent(EventTypeNames::updateend); |
+ } |
- // 5. Queue a task to fire a simple event named updateend at this SourceBuffer object. |
- scheduleEvent(EventTypeNames::updateend); |
TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); |
SBLOG << __FUNCTION__ << " done. this=" << this << " buffered=" << webTimeRangesToString(m_webSourceBuffer->buffered()); |
} |
@@ -908,7 +915,7 @@ void SourceBuffer::appendStreamAsyncPart() |
// 1. If maxSize is set, then let bytesLeft equal maxSize. |
// 2. Loop Top: If maxSize is set and bytesLeft equals 0, then jump to the loop done step below. |
if (m_streamMaxSizeValid && !m_streamMaxSize) { |
- appendStreamDone(true); |
+ appendStreamDone(false, false); |
return; |
} |
@@ -917,7 +924,7 @@ void SourceBuffer::appendStreamAsyncPart() |
m_loader->start(getExecutionContext(), *m_stream, m_streamMaxSizeValid ? m_streamMaxSize : 0); |
} |
-void SourceBuffer::appendStreamDone(bool success) |
+void SourceBuffer::appendStreamDone(bool runAppendError, bool decodeError) |
{ |
DCHECK(m_updating); |
DCHECK(m_loader); |
@@ -925,8 +932,8 @@ void SourceBuffer::appendStreamDone(bool success) |
clearAppendStreamState(); |
- if (!success) { |
- appendError(false); |
+ if (runAppendError) { |
+ appendError(decodeError); |
TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this); |
return; |
} |
@@ -995,28 +1002,30 @@ void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength |
// 10. Run the coded frame eviction algorithm. |
if (!evictCodedFrames(dataLength)) { |
// 11. (in appendStreamDone) 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. |
- appendStreamDone(false); |
+ appendStreamDone(true, false); |
return; |
} |
- m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), dataLength, &m_timestampOffset); |
+ if (!m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), dataLength, &m_timestampOffset)) |
+ appendStreamDone(true, true); |
} |
void SourceBuffer::didFinishLoading() |
{ |
SBLOG << __FUNCTION__ << " this=" << this; |
DCHECK(m_loader); |
- appendStreamDone(true); |
+ appendStreamDone(false, false); |
} |
void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
{ |
SBLOG << __FUNCTION__ << " this=" << this << " errorCode=" << errorCode; |
// m_loader might be already released, in case appendStream has failed due |
- // to evictCodedFrames failing in didReceiveDataForClient. In that case |
- // appendStreamDone will be invoked from there, no need to repeat it here. |
+ // to evictCodedFrames or WebSourceBuffer append failing in |
+ // didReceiveDataForClient. In that case appendStreamDone will be invoked |
+ // from there, no need to repeat it here. |
if (m_loader) |
- appendStreamDone(false); |
+ appendStreamDone(true, false); |
} |
DEFINE_TRACE(SourceBuffer) |