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

Side by Side 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: Addresses acolwell@'s PS4 nits 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (!webSourceBuffer) { 149 if (!webSourceBuffer) {
150 ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError); 150 ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError);
151 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. 151 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps.
152 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps 152 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps
153 return 0; 153 return 0;
154 } 154 }
155 155
156 SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, m_asyncEventQueue.get()); 156 SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, m_asyncEventQueue.get());
157 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 157 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
158 m_sourceBuffers->add(buffer); 158 m_sourceBuffers->add(buffer);
159 m_activeSourceBuffers->add(buffer); 159 // FIXME: Remove the following once Chromium calls WebSourceBufferClient::In itSegmentReceived()
160 setSourceBufferActive(buffer);
161
160 // 7. Return the new object to the caller. 162 // 7. Return the new object to the caller.
161 return buffer; 163 return buffer;
162 } 164 }
163 165
164 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) 166 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState)
165 { 167 {
166 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); 168 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this);
167 169
168 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 170 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
169 171
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 476
475 // 3. Do various steps based on |eosStatus|. 477 // 3. Do various steps based on |eosStatus|.
476 m_webMediaSource->markEndOfStream(eosStatus); 478 m_webMediaSource->markEndOfStream(eosStatus);
477 } 479 }
478 480
479 bool MediaSource::isOpen() const 481 bool MediaSource::isOpen() const
480 { 482 {
481 return readyState() == openKeyword(); 483 return readyState() == openKeyword();
482 } 484 }
483 485
486 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer)
487 {
488 if (m_activeSourceBuffers->contains(sourceBuffer))
489 return;
490
491 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers
492 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in
493 // the same order as they appear in SourceBuffer.sourceBuffers.
494 // SourceBuffer transitions to active are not guaranteed to occur in the
495 // same order as buffers in |m_sourceBuffers|, so this method needs to
496 // insert |sourceBuffer| into |m_activeSourceBuffers|.
497 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer);
498 ASSERT(indexInSourceBuffers != kNotFound);
499
500 size_t insertPosition = 0;
501 while (insertPosition < m_activeSourceBuffers->length()
502 && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) {
503 ++insertPosition;
504 }
505
506 m_activeSourceBuffers->insert(insertPosition, sourceBuffer);
507 }
508
484 bool MediaSource::isClosed() const 509 bool MediaSource::isClosed() const
485 { 510 {
486 return readyState() == closedKeyword(); 511 return readyState() == closedKeyword();
487 } 512 }
488 513
489 void MediaSource::close() 514 void MediaSource::close()
490 { 515 {
491 setReadyState(closedKeyword()); 516 setReadyState(closedKeyword());
492 } 517 }
493 518
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 589
565 m_asyncEventQueue->enqueueEvent(event.release()); 590 m_asyncEventQueue->enqueueEvent(event.release());
566 } 591 }
567 592
568 URLRegistry& MediaSource::registry() const 593 URLRegistry& MediaSource::registry() const
569 { 594 {
570 return MediaSourceRegistry::registry(); 595 return MediaSourceRegistry::registry();
571 } 596 }
572 597
573 } // namespace blink 598 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698