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