| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/html/HTMLMediaElement.h" | 39 #include "core/html/HTMLMediaElement.h" |
| 40 #include "core/html/TimeRanges.h" | 40 #include "core/html/TimeRanges.h" |
| 41 #include "modules/mediasource/MediaSourceRegistry.h" | 41 #include "modules/mediasource/MediaSourceRegistry.h" |
| 42 #include "platform/ContentType.h" | 42 #include "platform/ContentType.h" |
| 43 #include "platform/Logging.h" | 43 #include "platform/Logging.h" |
| 44 #include "platform/MIMETypeRegistry.h" | 44 #include "platform/MIMETypeRegistry.h" |
| 45 #include "platform/RuntimeEnabledFeatures.h" | 45 #include "platform/RuntimeEnabledFeatures.h" |
| 46 #include "platform/TraceEvent.h" | 46 #include "platform/TraceEvent.h" |
| 47 #include "public/platform/WebMediaSource.h" | 47 #include "public/platform/WebMediaSource.h" |
| 48 #include "public/platform/WebSourceBuffer.h" | 48 #include "public/platform/WebSourceBuffer.h" |
| 49 #include "wtf/PtrUtil.h" |
| 49 #include "wtf/text/CString.h" | 50 #include "wtf/text/CString.h" |
| 51 #include <memory> |
| 50 | 52 |
| 51 using blink::WebMediaSource; | 53 using blink::WebMediaSource; |
| 52 using blink::WebSourceBuffer; | 54 using blink::WebSourceBuffer; |
| 53 | 55 |
| 54 #define MEDIA_SOURCE_LOG_LEVEL 3 | 56 #define MEDIA_SOURCE_LOG_LEVEL 3 |
| 55 | 57 |
| 56 namespace blink { | 58 namespace blink { |
| 57 | 59 |
| 58 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep
tionState& exceptionState) | 60 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep
tionState& exceptionState) |
| 59 { | 61 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // 4. If the readyState attribute is not in the "open" state then throw an | 143 // 4. If the readyState attribute is not in the "open" state then throw an |
| 142 // InvalidStateError exception and abort these steps. | 144 // InvalidStateError exception and abort these steps. |
| 143 if (!isOpen()) { | 145 if (!isOpen()) { |
| 144 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou
rce's readyState is not 'open'."); | 146 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou
rce's readyState is not 'open'."); |
| 145 return 0; | 147 return 0; |
| 146 } | 148 } |
| 147 | 149 |
| 148 // 5. Create a new SourceBuffer object and associated resources. | 150 // 5. Create a new SourceBuffer object and associated resources. |
| 149 ContentType contentType(type); | 151 ContentType contentType(type); |
| 150 String codecs = contentType.parameter("codecs"); | 152 String codecs = contentType.parameter("codecs"); |
| 151 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, exceptionState); | 153 std::unique_ptr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(con
tentType.type(), codecs, exceptionState); |
| 152 | 154 |
| 153 if (!webSourceBuffer) { | 155 if (!webSourceBuffer) { |
| 154 DCHECK(exceptionState.code() == NotSupportedError || exceptionState.code
() == QuotaExceededError); | 156 DCHECK(exceptionState.code() == NotSupportedError || exceptionState.code
() == QuotaExceededError); |
| 155 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. | 157 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. |
| 156 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps | 158 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps |
| 157 return 0; | 159 return 0; |
| 158 } | 160 } |
| 159 | 161 |
| 160 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this
, m_asyncEventQueue.get()); | 162 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this
, m_asyncEventQueue.get()); |
| 161 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. | 163 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 DEFINE_TRACE(MediaSource) | 280 DEFINE_TRACE(MediaSource) |
| 279 { | 281 { |
| 280 visitor->trace(m_asyncEventQueue); | 282 visitor->trace(m_asyncEventQueue); |
| 281 visitor->trace(m_attachedElement); | 283 visitor->trace(m_attachedElement); |
| 282 visitor->trace(m_sourceBuffers); | 284 visitor->trace(m_sourceBuffers); |
| 283 visitor->trace(m_activeSourceBuffers); | 285 visitor->trace(m_activeSourceBuffers); |
| 284 EventTargetWithInlineData::trace(visitor); | 286 EventTargetWithInlineData::trace(visitor); |
| 285 ActiveDOMObject::trace(visitor); | 287 ActiveDOMObject::trace(visitor); |
| 286 } | 288 } |
| 287 | 289 |
| 288 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo
urce) | 290 void MediaSource::setWebMediaSourceAndOpen(std::unique_ptr<WebMediaSource> webMe
diaSource) |
| 289 { | 291 { |
| 290 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); | 292 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); |
| 291 DCHECK(webMediaSource); | 293 DCHECK(webMediaSource); |
| 292 DCHECK(!m_webMediaSource); | 294 DCHECK(!m_webMediaSource); |
| 293 DCHECK(m_attachedElement); | 295 DCHECK(m_attachedElement); |
| 294 m_webMediaSource = std::move(webMediaSource); | 296 m_webMediaSource = std::move(webMediaSource); |
| 295 setReadyState(openKeyword()); | 297 setReadyState(openKeyword()); |
| 296 } | 298 } |
| 297 | 299 |
| 298 void MediaSource::addedToRegistry() | 300 void MediaSource::addedToRegistry() |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 572 } |
| 571 | 573 |
| 572 void MediaSource::stop() | 574 void MediaSource::stop() |
| 573 { | 575 { |
| 574 m_asyncEventQueue->close(); | 576 m_asyncEventQueue->close(); |
| 575 if (!isClosed()) | 577 if (!isClosed()) |
| 576 setReadyState(closedKeyword()); | 578 setReadyState(closedKeyword()); |
| 577 m_webMediaSource.reset(); | 579 m_webMediaSource.reset(); |
| 578 } | 580 } |
| 579 | 581 |
| 580 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ
e, const String& codecs, ExceptionState& exceptionState) | 582 std::unique_ptr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String
& type, const String& codecs, ExceptionState& exceptionState) |
| 581 { | 583 { |
| 582 WebSourceBuffer* webSourceBuffer = 0; | 584 WebSourceBuffer* webSourceBuffer = 0; |
| 583 | 585 |
| 584 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { | 586 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { |
| 585 case WebMediaSource::AddStatusOk: | 587 case WebMediaSource::AddStatusOk: |
| 586 return adoptPtr(webSourceBuffer); | 588 return wrapUnique(webSourceBuffer); |
| 587 case WebMediaSource::AddStatusNotSupported: | 589 case WebMediaSource::AddStatusNotSupported: |
| 588 DCHECK(!webSourceBuffer); | 590 DCHECK(!webSourceBuffer); |
| 589 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 591 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type |
| 590 // Step 2: If type contains a MIME type ... that is not supported with t
he types | 592 // Step 2: If type contains a MIME type ... that is not supported with t
he types |
| 591 // specified for the other SourceBuffer objects in sourceBuffers, then t
hrow | 593 // specified for the other SourceBuffer objects in sourceBuffers, then t
hrow |
| 592 // a NotSupportedError exception and abort these steps. | 594 // a NotSupportedError exception and abort these steps. |
| 593 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro
vided ('" + type + "') is not supported."); | 595 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro
vided ('" + type + "') is not supported."); |
| 594 return nullptr; | 596 return nullptr; |
| 595 case WebMediaSource::AddStatusReachedIdLimit: | 597 case WebMediaSource::AddStatusReachedIdLimit: |
| 596 DCHECK(!webSourceBuffer); | 598 DCHECK(!webSourceBuffer); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 614 | 616 |
| 615 m_asyncEventQueue->enqueueEvent(event); | 617 m_asyncEventQueue->enqueueEvent(event); |
| 616 } | 618 } |
| 617 | 619 |
| 618 URLRegistry& MediaSource::registry() const | 620 URLRegistry& MediaSource::registry() const |
| 619 { | 621 { |
| 620 return MediaSourceRegistry::registry(); | 622 return MediaSourceRegistry::registry(); |
| 621 } | 623 } |
| 622 | 624 |
| 623 } // namespace blink | 625 } // namespace blink |
| OLD | NEW |