Commit cc67f9bf authored by servolk@chromium.org's avatar servolk@chromium.org

Fix MSE GC, make it less aggressive, more spec-compliant (Blink CL)

Provided interface in ChunkDemuxer/WebSourceBuffer to allow blink to
invoke "3.5.12 Coded Frame Eviction Algorithm"
https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction

This allows us to detect when buffer is full, even after GC
and throw QuotaExceededErr exception as MSE spec prescribes.
See step #6 in section 3.5.4 at
https://w3c.github.io/media-source/#sourcebuffer-prepare-append
Related Chromium CL: https://codereview.chromium.org/1008463002/

BUG=421694

Review URL: https://codereview.chromium.org/1013923002

git-svn-id: svn://svn.chromium.org/blink/trunk@200989 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 73d45a8b
...@@ -156,6 +156,7 @@ SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e ...@@ -156,6 +156,7 @@ SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e
m_sourceBuffers->add(buffer); m_sourceBuffers->add(buffer);
// 7. Return the new object to the caller. // 7. Return the new object to the caller.
WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p -> %p", type.ascii().data(), this, buffer);
return buffer; return buffer;
} }
...@@ -515,6 +516,11 @@ void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer) ...@@ -515,6 +516,11 @@ void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer)
m_activeSourceBuffers->insert(insertPosition, sourceBuffer); m_activeSourceBuffers->insert(insertPosition, sourceBuffer);
} }
HTMLMediaElement* MediaSource::mediaElement() const
{
return m_attachedElement.get();
}
bool MediaSource::isClosed() const bool MediaSource::isClosed() const
{ {
return readyState() == closedKeyword(); return readyState() == closedKeyword();
......
...@@ -101,6 +101,7 @@ public: ...@@ -101,6 +101,7 @@ public:
void openIfInEndedState(); void openIfInEndedState();
bool isOpen() const; bool isOpen() const;
void setSourceBufferActive(SourceBuffer*); void setSourceBufferActive(SourceBuffer*);
HTMLMediaElement* mediaElement() const;
// Used by MediaSourceRegistry. // Used by MediaSourceRegistry.
void addedToRegistry(); void addedToRegistry();
......
...@@ -114,8 +114,11 @@ private: ...@@ -114,8 +114,11 @@ private:
bool isRemoved() const; bool isRemoved() const;
void scheduleEvent(const AtomicString& eventName); void scheduleEvent(const AtomicString& eventName);
bool prepareAppend(size_t newDataSize, ExceptionState&);
bool evictCodedFrames(size_t newDataSize);
void appendBufferInternal(const unsigned char*, unsigned, ExceptionState&); void appendBufferInternal(const unsigned char*, unsigned, ExceptionState&);
void appendBufferAsyncPart(); void appendBufferAsyncPart();
void appendError(bool decodeError);
void removeAsyncPart(); void removeAsyncPart();
......
...@@ -53,6 +53,14 @@ public: ...@@ -53,6 +53,14 @@ public:
virtual bool setMode(AppendMode) = 0; virtual bool setMode(AppendMode) = 0;
virtual WebTimeRanges buffered() = 0; virtual WebTimeRanges buffered() = 0;
// Run coded frame eviction/garbage collection algorithm.
// |currentPlaybackTime| is HTMLMediaElement::currentTime. The algorithm
// will try to preserve data around current playback position.
// |newDataSize| is size of new data about to be appended to SourceBuffer.
// Could be zero for appendStream if stream size is unknown in advance.
// Returns false if buffer is still full after eviction.
virtual bool evictCodedFrames(double currentPlaybackTime, size_t newDataSize) = 0;
// Appends data and runs the segment parser loop algorithm. // Appends data and runs the segment parser loop algorithm.
// The algorithm may update |*timestampOffset| if |timestampOffset| is not null. // The algorithm may update |*timestampOffset| if |timestampOffset| is not null.
virtual void append(const unsigned char* data, unsigned length, double* timestampOffset) = 0; virtual void append(const unsigned char* data, unsigned length, double* timestampOffset) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment