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

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

Issue 552943002: MSE: Start letting SourceBuffer begin to do initialization segment received algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. Addressed philipj@'s PS5 comments. Created 6 years, 3 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
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediasource/MediaSource.cpp
diff --git a/Source/modules/mediasource/MediaSource.cpp b/Source/modules/mediasource/MediaSource.cpp
index 5b695d2b600a577c3af37b093b8ad84834d53959..b532e860cf45ae39e372b654f46d766fcec58c42 100644
--- a/Source/modules/mediasource/MediaSource.cpp
+++ b/Source/modules/mediasource/MediaSource.cpp
@@ -155,7 +155,9 @@ SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e
SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, m_asyncEventQueue.get());
// 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
m_sourceBuffers->add(buffer);
- m_activeSourceBuffers->add(buffer);
+ // FIXME: Remove the following once Chromium calls WebSourceBufferClient::InitSegmentReceived()
+ setSourceBufferActive(buffer);
+
// 7. Return the new object to the caller.
return buffer;
}
@@ -480,6 +482,29 @@ bool MediaSource::isOpen() const
return readyState() == openKeyword();
}
+void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer)
+{
+ if (m_activeSourceBuffers->contains(sourceBuffer))
+ return;
+
+ // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-activeSourceBuffers
+ // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in
+ // the same order as they appear in SourceBuffer.sourceBuffers.
+ // SourceBuffer transitions to active are not guaranteed to occur in the
+ // same order as buffers in |m_sourceBuffers|, so this method needs to
+ // insert |sourceBuffer| into |m_activeSourceBuffers|.
+ size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer);
+ ASSERT(indexInSourceBuffers != kNotFound);
+
+ size_t insertPosition = 0;
+ while (insertPosition < m_activeSourceBuffers->length()
+ && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) {
+ ++insertPosition;
+ }
+
+ m_activeSourceBuffers->insert(insertPosition, sourceBuffer);
+}
+
bool MediaSource::isClosed() const
{
return readyState() == closedKeyword();
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698