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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 : ActiveScriptWrappable(this) | 112 : ActiveScriptWrappable(this) |
113 , ActiveDOMObject(context) | 113 , ActiveDOMObject(context) |
114 , m_readyState(closedKeyword()) | 114 , m_readyState(closedKeyword()) |
115 , m_asyncEventQueue(GenericEventQueue::create(this)) | 115 , m_asyncEventQueue(GenericEventQueue::create(this)) |
116 , m_attachedElement(nullptr) | 116 , m_attachedElement(nullptr) |
117 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve
ntQueue.get())) | 117 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve
ntQueue.get())) |
118 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as
yncEventQueue.get())) | 118 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as
yncEventQueue.get())) |
119 , m_liveSeekableRange(TimeRanges::create()) | 119 , m_liveSeekableRange(TimeRanges::create()) |
120 , m_addedToRegistryCounter(0) | 120 , m_addedToRegistryCounter(0) |
121 { | 121 { |
122 BLINK_MSLOG << __FUNCTION__ << " this=" << this; | 122 BLINK_MSLOG << __func__ << " this=" << this; |
123 } | 123 } |
124 | 124 |
125 MediaSource::~MediaSource() | 125 MediaSource::~MediaSource() |
126 { | 126 { |
127 BLINK_MSLOG << __FUNCTION__ << " this=" << this; | 127 BLINK_MSLOG << __func__ << " this=" << this; |
128 DCHECK(isClosed()); | 128 DCHECK(isClosed()); |
129 } | 129 } |
130 | 130 |
131 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const
ExceptionCode& error, const String& message) | 131 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const
ExceptionCode& error, const String& message) |
132 { | 132 { |
133 BLINK_MSLOG << __FUNCTION__ << " (error=" << error << ", message=" << messag
e << ")"; | 133 BLINK_MSLOG << __func__ << " (error=" << error << ", message=" << message <<
")"; |
134 exceptionState.throwDOMException(error, message); | 134 exceptionState.throwDOMException(error, message); |
135 } | 135 } |
136 | 136 |
137 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e
xceptionState) | 137 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e
xceptionState) |
138 { | 138 { |
139 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " type=" << type; | 139 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type; |
140 | 140 |
141 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 141 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type |
142 // 1. If type is an empty string then throw an InvalidAccessError exception | 142 // 1. If type is an empty string then throw an InvalidAccessError exception |
143 // and abort these steps. | 143 // and abort these steps. |
144 if (type.isEmpty()) { | 144 if (type.isEmpty()) { |
145 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr
ovided is empty."); | 145 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr
ovided is empty."); |
146 return 0; | 146 return 0; |
147 } | 147 } |
148 | 148 |
149 // 2. If type contains a MIME type that is not supported ..., then throw a | 149 // 2. If type contains a MIME type that is not supported ..., then throw a |
(...skipping 20 matching lines...) Expand all Loading... |
170 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. | 170 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. |
171 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps | 171 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps |
172 return 0; | 172 return 0; |
173 } | 173 } |
174 | 174 |
175 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this
, m_asyncEventQueue.get()); | 175 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this
, m_asyncEventQueue.get()); |
176 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. | 176 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. |
177 m_sourceBuffers->add(buffer); | 177 m_sourceBuffers->add(buffer); |
178 | 178 |
179 // 7. Return the new object to the caller. | 179 // 7. Return the new object to the caller. |
180 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " type=" << type << " ->
" << buffer; | 180 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type << " -> " <<
buffer; |
181 return buffer; | 181 return buffer; |
182 } | 182 } |
183 | 183 |
184 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep
tionState) | 184 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep
tionState) |
185 { | 185 { |
186 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " buffer=" << buffer; | 186 BLINK_MSLOG << __func__ << " this=" << this << " buffer=" << buffer; |
187 | 187 |
188 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer | 188 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer |
189 | 189 |
190 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then | 190 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then |
191 // throw a NotFoundError exception and abort these steps. | 191 // throw a NotFoundError exception and abort these steps. |
192 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { | 192 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { |
193 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer
provided is not contained in this MediaSource."); | 193 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer
provided is not contained in this MediaSource."); |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 return false; | 245 return false; |
246 } | 246 } |
247 | 247 |
248 bool MediaSource::isTypeSupported(const String& type) | 248 bool MediaSource::isTypeSupported(const String& type) |
249 { | 249 { |
250 // Section 2.2 isTypeSupported() method steps. | 250 // Section 2.2 isTypeSupported() method steps. |
251 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.
html#widl-MediaSource-isTypeSupported-boolean-DOMString-type | 251 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.
html#widl-MediaSource-isTypeSupported-boolean-DOMString-type |
252 // 1. If type is an empty string, then return false. | 252 // 1. If type is an empty string, then return false. |
253 if (type.isEmpty()) { | 253 if (type.isEmpty()) { |
254 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (empty input)"
; | 254 BLINK_MSLOG << __func__ << "(" << type << ") -> false (empty input)"; |
255 return false; | 255 return false; |
256 } | 256 } |
257 | 257 |
258 ContentType contentType(type); | 258 ContentType contentType(type); |
259 String codecs = contentType.parameter("codecs"); | 259 String codecs = contentType.parameter("codecs"); |
260 | 260 |
261 // 2. If type does not contain a valid MIME type string, then return false. | 261 // 2. If type does not contain a valid MIME type string, then return false. |
262 if (contentType.type().isEmpty()) { | 262 if (contentType.type().isEmpty()) { |
263 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (invalid mime
type)"; | 263 BLINK_MSLOG << __func__ << "(" << type << ") -> false (invalid mime type
)"; |
264 return false; | 264 return false; |
265 } | 265 } |
266 | 266 |
267 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia
Element.canPlayType() will return "maybe" or "probably" | 267 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia
Element.canPlayType() will return "maybe" or "probably" |
268 // since it does not make sense for a MediaSource to support a type the HTML
MediaElement knows it cannot play. | 268 // since it does not make sense for a MediaSource to support a type the HTML
MediaElement knows it cannot play. |
269 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup
ported) { | 269 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup
ported) { |
270 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (not supported
by HTMLMediaElement)"; | 270 BLINK_MSLOG << __func__ << "(" << type << ") -> false (not supported by
HTMLMediaElement)"; |
271 return false; | 271 return false; |
272 } | 272 } |
273 | 273 |
274 // 3. If type contains a media type or media subtype that the MediaSource do
es not support, then return false. | 274 // 3. If type contains a media type or media subtype that the MediaSource do
es not support, then return false. |
275 // 4. If type contains at a codec that the MediaSource does not support, the
n return false. | 275 // 4. If type contains at a codec that the MediaSource does not support, the
n return false. |
276 // 5. If the MediaSource does not support the specified combination of media
type, media subtype, and codecs then return false. | 276 // 5. If the MediaSource does not support the specified combination of media
type, media subtype, and codecs then return false. |
277 // 6. Return true. | 277 // 6. Return true. |
278 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t
ype(), codecs); | 278 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t
ype(), codecs); |
279 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> " << (result ? "true" :
"false"); | 279 BLINK_MSLOG << __func__ << "(" << type << ") -> " << (result ? "true" : "fal
se"); |
280 return result; | 280 return result; |
281 } | 281 } |
282 | 282 |
283 const AtomicString& MediaSource::interfaceName() const | 283 const AtomicString& MediaSource::interfaceName() const |
284 { | 284 { |
285 return EventTargetNames::MediaSource; | 285 return EventTargetNames::MediaSource; |
286 } | 286 } |
287 | 287 |
288 ExecutionContext* MediaSource::getExecutionContext() const | 288 ExecutionContext* MediaSource::getExecutionContext() const |
289 { | 289 { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 493 |
494 // 6. Update the media controller duration to new duration and run the HTMLM
ediaElement duration change algorithm. | 494 // 6. Update the media controller duration to new duration and run the HTMLM
ediaElement duration change algorithm. |
495 m_attachedElement->durationChanged(newDuration, requestSeek); | 495 m_attachedElement->durationChanged(newDuration, requestSeek); |
496 } | 496 } |
497 | 497 |
498 void MediaSource::setReadyState(const AtomicString& state) | 498 void MediaSource::setReadyState(const AtomicString& state) |
499 { | 499 { |
500 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK
eyword()); | 500 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK
eyword()); |
501 | 501 |
502 AtomicString oldState = readyState(); | 502 AtomicString oldState = readyState(); |
503 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " : " << oldState << " ->
" << state; | 503 BLINK_MSLOG << __func__ << " this=" << this << " : " << oldState << " -> " <
< state; |
504 | 504 |
505 if (state == closedKeyword()) { | 505 if (state == closedKeyword()) { |
506 m_webMediaSource.reset(); | 506 m_webMediaSource.reset(); |
507 } | 507 } |
508 | 508 |
509 if (oldState == state) | 509 if (oldState == state) |
510 return; | 510 return; |
511 | 511 |
512 m_readyState = state; | 512 m_readyState = state; |
513 | 513 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 712 |
713 m_asyncEventQueue->enqueueEvent(event); | 713 m_asyncEventQueue->enqueueEvent(event); |
714 } | 714 } |
715 | 715 |
716 URLRegistry& MediaSource::registry() const | 716 URLRegistry& MediaSource::registry() const |
717 { | 717 { |
718 return MediaSourceRegistry::registry(); | 718 return MediaSourceRegistry::registry(); |
719 } | 719 } |
720 | 720 |
721 } // namespace blink | 721 } // namespace blink |
OLD | NEW |