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

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

Issue 1013923002: Fix MSE GC, make it less aggressive, more spec-compliant (Blink CL) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added decodeError parameter for appendError function Created 5 years, 7 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: Source/modules/mediasource/SourceBuffer.cpp
diff --git a/Source/modules/mediasource/SourceBuffer.cpp b/Source/modules/mediasource/SourceBuffer.cpp
index ceea5a8db2bc65ba31173ef4588b53b514fd3e84..0d1e128f4597b969abee68eeedfaa91384169476 100644
--- a/Source/modules/mediasource/SourceBuffer.cpp
+++ b/Source/modules/mediasource/SourceBuffer.cpp
@@ -530,7 +530,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);
@@ -628,6 +633,11 @@ void SourceBuffer::removeAsyncPart()
scheduleEvent(EventTypeNames::updateend);
}
+bool SourceBuffer::evictCodedFrames()
+{
+ return m_webSourceBuffer->evictCodedFrames();
+}
+
void SourceBuffer::appendStreamInternal(Stream* stream, ExceptionState& exceptionState)
{
// Section 3.2 appendStream()
@@ -651,7 +661,12 @@ void SourceBuffer::appendStreamInternal(Stream* stream, ExceptionState& exceptio
// 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;
@@ -683,7 +698,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);
}
@@ -697,24 +712,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(false);
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(false);
+ TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendStream", this);
+ return;
+ }
+
// 12. Loop Done: Set the updating attribute to false.
m_updating = false;
@@ -734,6 +747,29 @@ void SourceBuffer::clearAppendStreamState()
m_stream = nullptr;
}
+void SourceBuffer::appendError(bool decodeError)
+{
+ // 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);
+
+ // 5. If decode error is true, then run the end of stream algorithm with the
+ // error parameter set to "decode".
+ // TODO(servolk): endOfStream expects ExceptionState parameter, but it is
philipj_slow 2015/06/03 12:43:32 The exception to worry about is the throwException
servolk 2015/06/18 23:23:28 Done.
+ // unavailable here. Do we need to implement passing ExceptionState from
+ // somewhere or just instantiate it here?
+ // m_source->endOfStream("decode", ExceptionState?);
+}
+
void SourceBuffer::didStartLoading()
{
WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this);

Powered by Google App Engine
This is Rietveld 408576698