Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 2076673005: MSE: Plumb ChunkDemuxer appendData failures into append Error algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the layout test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698