Chromium Code Reviews| 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); | |
| 160 // 7. Return the new object to the caller. | 159 // 7. Return the new object to the caller. |
| 161 return buffer; | 160 return buffer; |
| 162 } | 161 } |
| 163 | 162 |
| 164 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) | 163 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) |
| 165 { | 164 { |
| 166 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); | 165 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); |
| 167 | 166 |
| 168 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer | 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 | 168 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 | 473 |
| 475 // 3. Do various steps based on |eosStatus|. | 474 // 3. Do various steps based on |eosStatus|. |
| 476 m_webMediaSource->markEndOfStream(eosStatus); | 475 m_webMediaSource->markEndOfStream(eosStatus); |
| 477 } | 476 } |
| 478 | 477 |
| 479 bool MediaSource::isOpen() const | 478 bool MediaSource::isOpen() const |
| 480 { | 479 { |
| 481 return readyState() == openKeyword(); | 480 return readyState() == openKeyword(); |
| 482 } | 481 } |
| 483 | 482 |
| 483 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer) | |
| 484 { | |
| 485 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers | |
| 486 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in | |
| 487 // the same order as they appear in SourceBuffer.sourceBuffers. | |
| 488 // SourceBuffer transitions to active are not guaranteed to occur in the | |
| 489 // same order as buffers in |m_sourceBuffers|, so this method needs to | |
| 490 // insert |sourceBuffer| into |m_activeSourceBuffers|. | |
| 491 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer); | |
| 492 ASSERT(indexInSourceBuffers != kNotFound); | |
| 493 | |
| 494 size_t insertPosition = 0; | |
| 495 while (insertPosition < m_activeSourceBuffers->length()) { | |
| 496 if (m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) > = indexInSourceBuffers) | |
|
acolwell GONE FROM CHROMIUM
2014/09/09 22:23:21
nit: Reverse and merge into while condition?
wolenetz
2014/09/10 00:42:29
Done.
| |
| 497 break; | |
| 498 | |
| 499 ++insertPosition; | |
| 500 } | |
| 501 | |
| 502 m_activeSourceBuffers->insert(insertPosition, sourceBuffer); | |
| 503 } | |
| 504 | |
| 484 bool MediaSource::isClosed() const | 505 bool MediaSource::isClosed() const |
| 485 { | 506 { |
| 486 return readyState() == closedKeyword(); | 507 return readyState() == closedKeyword(); |
| 487 } | 508 } |
| 488 | 509 |
| 489 void MediaSource::close() | 510 void MediaSource::close() |
| 490 { | 511 { |
| 491 setReadyState(closedKeyword()); | 512 setReadyState(closedKeyword()); |
| 492 } | 513 } |
| 493 | 514 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 | 585 |
| 565 m_asyncEventQueue->enqueueEvent(event.release()); | 586 m_asyncEventQueue->enqueueEvent(event.release()); |
| 566 } | 587 } |
| 567 | 588 |
| 568 URLRegistry& MediaSource::registry() const | 589 URLRegistry& MediaSource::registry() const |
| 569 { | 590 { |
| 570 return MediaSourceRegistry::registry(); | 591 return MediaSourceRegistry::registry(); |
| 571 } | 592 } |
| 572 | 593 |
| 573 } // namespace blink | 594 } // namespace blink |
| OLD | NEW |