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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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) | |
acolwell GONE FROM CHROMIUM
2014/09/10 17:16:26
nit: Add {} since this is a multiline statement.
wolenetz
2014/09/10 21:18:22
Done.
| |
503 ++insertPosition; | |
504 | |
505 m_activeSourceBuffers->insert(insertPosition, sourceBuffer); | |
506 } | |
507 | |
484 bool MediaSource::isClosed() const | 508 bool MediaSource::isClosed() const |
485 { | 509 { |
486 return readyState() == closedKeyword(); | 510 return readyState() == closedKeyword(); |
487 } | 511 } |
488 | 512 |
489 void MediaSource::close() | 513 void MediaSource::close() |
490 { | 514 { |
491 setReadyState(closedKeyword()); | 515 setReadyState(closedKeyword()); |
492 } | 516 } |
493 | 517 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 | 588 |
565 m_asyncEventQueue->enqueueEvent(event.release()); | 589 m_asyncEventQueue->enqueueEvent(event.release()); |
566 } | 590 } |
567 | 591 |
568 URLRegistry& MediaSource::registry() const | 592 URLRegistry& MediaSource::registry() const |
569 { | 593 { |
570 return MediaSourceRegistry::registry(); | 594 return MediaSourceRegistry::registry(); |
571 } | 595 } |
572 | 596 |
573 } // namespace blink | 597 } // namespace blink |
OLD | NEW |