Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/MediaSource.cpp

Issue 1996603002: media: Replace wtf/Assertions.h macros in favor of base/logging.h macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/text/CString.h" 49 #include "wtf/text/CString.h"
50 50
51 using blink::WebMediaSource; 51 using blink::WebMediaSource;
52 using blink::WebSourceBuffer; 52 using blink::WebSourceBuffer;
53 53
54 #define MEDIA_SOURCE_LOG_LEVEL 3
55
54 namespace blink { 56 namespace blink {
55 57
56 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState) 58 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState)
57 { 59 {
58 if (!isOpen) { 60 if (!isOpen) {
59 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSource's readyState is not 'open'."); 61 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSource's readyState is not 'open'.");
60 return true; 62 return true;
61 } 63 }
62 if (isUpdating) { 64 if (isUpdating) {
63 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The 'updating' attribute is true on one or more of this MediaSource's SourceBuf fers."); 65 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The 'updating' attribute is true on one or more of this MediaSource's SourceBuf fers.");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 MediaSource::MediaSource(ExecutionContext* context) 97 MediaSource::MediaSource(ExecutionContext* context)
96 : ActiveScriptWrappable(this) 98 : ActiveScriptWrappable(this)
97 , ActiveDOMObject(context) 99 , ActiveDOMObject(context)
98 , m_readyState(closedKeyword()) 100 , m_readyState(closedKeyword())
99 , m_asyncEventQueue(GenericEventQueue::create(this)) 101 , m_asyncEventQueue(GenericEventQueue::create(this))
100 , m_attachedElement(nullptr) 102 , m_attachedElement(nullptr)
101 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get())) 103 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get()))
102 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get())) 104 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get()))
103 , m_isAddedToRegistry(false) 105 , m_isAddedToRegistry(false)
104 { 106 {
105 WTF_LOG(Media, "MediaSource::MediaSource %p", this); 107 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")";
106 } 108 }
107 109
108 MediaSource::~MediaSource() 110 MediaSource::~MediaSource()
109 { 111 {
110 WTF_LOG(Media, "MediaSource::~MediaSource %p", this); 112 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")";
111 ASSERT(isClosed()); 113 DCHECK(isClosed());
112 } 114 }
113 115
114 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message) 116 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message)
115 { 117 {
116 WTF_LOG(Media, "throwDOMException: error=%d msg=%s", error, message.utf8().d ata()); 118 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(error=" << error << ", me ssage=" << message << ")";
117 exceptionState.throwDOMException(error, message); 119 exceptionState.throwDOMException(error, message);
118 } 120 }
119 121
120 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) 122 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState)
121 { 123 {
122 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), t his); 124 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") " << this ;
123 125
124 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 126 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
125 // 1. If type is an empty string then throw an InvalidAccessError exception 127 // 1. If type is an empty string then throw an InvalidAccessError exception
126 // and abort these steps. 128 // and abort these steps.
127 if (type.isEmpty()) { 129 if (type.isEmpty()) {
128 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr ovided is empty."); 130 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr ovided is empty.");
129 return 0; 131 return 0;
130 } 132 }
131 133
132 // 2. If type contains a MIME type that is not supported ..., then throw a 134 // 2. If type contains a MIME type that is not supported ..., then throw a
133 // NotSupportedError exception and abort these steps. 135 // NotSupportedError exception and abort these steps.
134 if (!isTypeSupported(type)) { 136 if (!isTypeSupported(type)) {
135 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is unsupported."); 137 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is unsupported.");
136 return 0; 138 return 0;
137 } 139 }
138 140
139 // 4. If the readyState attribute is not in the "open" state then throw an 141 // 4. If the readyState attribute is not in the "open" state then throw an
140 // InvalidStateError exception and abort these steps. 142 // InvalidStateError exception and abort these steps.
141 if (!isOpen()) { 143 if (!isOpen()) {
142 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou rce's readyState is not 'open'."); 144 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou rce's readyState is not 'open'.");
143 return 0; 145 return 0;
144 } 146 }
145 147
146 // 5. Create a new SourceBuffer object and associated resources. 148 // 5. Create a new SourceBuffer object and associated resources.
147 ContentType contentType(type); 149 ContentType contentType(type);
148 String codecs = contentType.parameter("codecs"); 150 String codecs = contentType.parameter("codecs");
149 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType. type(), codecs, exceptionState); 151 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType. type(), codecs, exceptionState);
150 152
151 if (!webSourceBuffer) { 153 if (!webSourceBuffer) {
152 ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError); 154 DCHECK(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError);
153 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. 155 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps.
154 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError 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
155 return 0; 157 return 0;
156 } 158 }
157 159
158 SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, m_asyncEventQueue.get()); 160 SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this, m_asyncEventQueue.get());
159 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 161 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
160 m_sourceBuffers->add(buffer); 162 m_sourceBuffers->add(buffer);
161 163
162 // 7. Return the new object to the caller. 164 // 7. Return the new object to the caller.
163 WTF_LOG(Media, "MediaSource::addSourceBuffer(%s) %p -> %p", type.ascii().dat a(), this, buffer); 165 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") " << this << " -> " << buffer;
164 return buffer; 166 return buffer;
165 } 167 }
166 168
167 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) 169 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState)
168 { 170 {
169 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); 171 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") -> " << b uffer;
wolenetz 2016/05/20 19:58:15 nit: swap |this| and |buffer| placement in the log
Srirama 2016/05/21 08:28:28 Done.
170 172
171 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 173 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
172 174
173 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then 175 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then
174 // throw a NotFoundError exception and abort these steps. 176 // throw a NotFoundError exception and abort these steps.
175 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 177 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
176 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource."); 178 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource.");
177 return; 179 return;
178 } 180 }
179 181
(...skipping 19 matching lines...) Expand all
199 if (isOpen()) { 201 if (isOpen()) {
200 scheduleEvent(EventTypeNames::sourceopen); 202 scheduleEvent(EventTypeNames::sourceopen);
201 return; 203 return;
202 } 204 }
203 205
204 if (oldState == openKeyword() && newState == endedKeyword()) { 206 if (oldState == openKeyword() && newState == endedKeyword()) {
205 scheduleEvent(EventTypeNames::sourceended); 207 scheduleEvent(EventTypeNames::sourceended);
206 return; 208 return;
207 } 209 }
208 210
209 ASSERT(isClosed()); 211 DCHECK(isClosed());
210 212
211 m_activeSourceBuffers->clear(); 213 m_activeSourceBuffers->clear();
212 214
213 // Clear SourceBuffer references to this object. 215 // Clear SourceBuffer references to this object.
214 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) 216 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i)
215 m_sourceBuffers->item(i)->removedFromMediaSource(); 217 m_sourceBuffers->item(i)->removedFromMediaSource();
216 m_sourceBuffers->clear(); 218 m_sourceBuffers->clear();
217 219
218 scheduleEvent(EventTypeNames::sourceclose); 220 scheduleEvent(EventTypeNames::sourceclose);
219 } 221 }
220 222
221 bool MediaSource::isUpdating() const 223 bool MediaSource::isUpdating() const
222 { 224 {
223 // Return true if any member of |m_sourceBuffers| is updating. 225 // Return true if any member of |m_sourceBuffers| is updating.
224 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) { 226 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) {
225 if (m_sourceBuffers->item(i)->updating()) 227 if (m_sourceBuffers->item(i)->updating())
226 return true; 228 return true;
227 } 229 }
228 230
229 return false; 231 return false;
230 } 232 }
231 233
232 bool MediaSource::isTypeSupported(const String& type) 234 bool MediaSource::isTypeSupported(const String& type)
233 { 235 {
234 // Section 2.2 isTypeSupported() method steps. 236 // Section 2.2 isTypeSupported() method steps.
235 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type 237 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
236 // 1. If type is an empty string, then return false. 238 // 1. If type is an empty string, then return false.
237 if (type.isEmpty()) { 239 if (type.isEmpty()) {
238 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (empty input)" , type.ascii().data()); 240 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (empty input)";
wolenetz 2016/05/20 19:58:15 nit: In Chromium, |this| shouldn't make a differen
Srirama 2016/05/21 08:28:27 Same static function issue here.
239 return false; 241 return false;
240 } 242 }
241 243
242 ContentType contentType(type); 244 ContentType contentType(type);
243 String codecs = contentType.parameter("codecs"); 245 String codecs = contentType.parameter("codecs");
244 246
245 // 2. If type does not contain a valid MIME type string, then return false. 247 // 2. If type does not contain a valid MIME type string, then return false.
246 if (contentType.type().isEmpty()) { 248 if (contentType.type().isEmpty()) {
247 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (invalid mime type)", type.ascii().data()); 249 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (invalid mime type)";
248 return false; 250 return false;
249 } 251 }
250 252
251 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably" 253 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably"
252 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play. 254 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play.
253 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) { 255 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) {
254 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (not supported by HTMLMediaElement)", type.ascii().data()); 256 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (not supported by HTMLMediaElement)";
255 return false; 257 return false;
256 } 258 }
257 259
258 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false. 260 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false.
259 // 4. If type contains at a codec that the MediaSource does not support, the n return false. 261 // 4. If type contains at a codec that the MediaSource does not support, the n return false.
260 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false. 262 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
261 // 6. Return true. 263 // 6. Return true.
262 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs); 264 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs);
263 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> %s", type.ascii().data() , result ? "true" : "false"); 265 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> " << ( result ? "true" : "false");
264 return result; 266 return result;
265 } 267 }
266 268
267 const AtomicString& MediaSource::interfaceName() const 269 const AtomicString& MediaSource::interfaceName() const
268 { 270 {
269 return EventTargetNames::MediaSource; 271 return EventTargetNames::MediaSource;
270 } 272 }
271 273
272 ExecutionContext* MediaSource::getExecutionContext() const 274 ExecutionContext* MediaSource::getExecutionContext() const
273 { 275 {
274 return ActiveDOMObject::getExecutionContext(); 276 return ActiveDOMObject::getExecutionContext();
275 } 277 }
276 278
277 DEFINE_TRACE(MediaSource) 279 DEFINE_TRACE(MediaSource)
278 { 280 {
279 visitor->trace(m_asyncEventQueue); 281 visitor->trace(m_asyncEventQueue);
280 visitor->trace(m_attachedElement); 282 visitor->trace(m_attachedElement);
281 visitor->trace(m_sourceBuffers); 283 visitor->trace(m_sourceBuffers);
282 visitor->trace(m_activeSourceBuffers); 284 visitor->trace(m_activeSourceBuffers);
283 EventTargetWithInlineData::trace(visitor); 285 EventTargetWithInlineData::trace(visitor);
284 ActiveDOMObject::trace(visitor); 286 ActiveDOMObject::trace(visitor);
285 } 287 }
286 288
287 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce) 289 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce)
288 { 290 {
289 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); 291 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this);
290 ASSERT(webMediaSource); 292 DCHECK(webMediaSource);
291 ASSERT(!m_webMediaSource); 293 DCHECK(!m_webMediaSource);
292 ASSERT(m_attachedElement); 294 DCHECK(m_attachedElement);
293 m_webMediaSource = std::move(webMediaSource); 295 m_webMediaSource = std::move(webMediaSource);
294 setReadyState(openKeyword()); 296 setReadyState(openKeyword());
295 } 297 }
296 298
297 void MediaSource::addedToRegistry() 299 void MediaSource::addedToRegistry()
298 { 300 {
299 ASSERT(!m_isAddedToRegistry); 301 DCHECK(!m_isAddedToRegistry);
300 m_isAddedToRegistry = true; 302 m_isAddedToRegistry = true;
301 } 303 }
302 304
303 void MediaSource::removedFromRegistry() 305 void MediaSource::removedFromRegistry()
304 { 306 {
305 ASSERT(m_isAddedToRegistry); 307 DCHECK(m_isAddedToRegistry);
306 m_isAddedToRegistry = false; 308 m_isAddedToRegistry = false;
307 } 309 }
308 310
309 double MediaSource::duration() const 311 double MediaSource::duration() const
310 { 312 {
311 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration(); 313 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration();
312 } 314 }
313 315
314 TimeRanges* MediaSource::buffered() const 316 TimeRanges* MediaSource::buffered() const
315 { 317 {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // 5. If a user agent is unable to partially render audio frames or text cue s that start before and end after the duration, then run the following steps: 438 // 5. If a user agent is unable to partially render audio frames or text cue s that start before and end after the duration, then run the following steps:
437 // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media 439 // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media
438 // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps. 440 // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps.
439 441
440 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm. 442 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm.
441 m_attachedElement->durationChanged(newDuration, requestSeek); 443 m_attachedElement->durationChanged(newDuration, requestSeek);
442 } 444 }
443 445
444 void MediaSource::setReadyState(const AtomicString& state) 446 void MediaSource::setReadyState(const AtomicString& state)
445 { 447 {
446 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 448 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
447 449
448 AtomicString oldState = readyState(); 450 AtomicString oldState = readyState();
449 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 451 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")" << " : " << oldState << " -> " << state;
450 452
451 if (state == closedKeyword()) { 453 if (state == closedKeyword()) {
452 m_webMediaSource.clear(); 454 m_webMediaSource.clear();
453 m_attachedElement.clear(); 455 m_attachedElement.clear();
454 } 456 }
455 457
456 if (oldState == state) 458 if (oldState == state)
457 return; 459 return;
458 460
459 m_readyState = state; 461 m_readyState = state;
460 462
461 onReadyStateChange(oldState, state); 463 onReadyStateChange(oldState, state);
462 } 464 }
463 465
464 void MediaSource::endOfStream(const AtomicString& error, ExceptionState& excepti onState) 466 void MediaSource::endOfStream(const AtomicString& error, ExceptionState& excepti onState)
465 { 467 {
466 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network")); 468 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network"));
467 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode")); 469 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode"));
468 470
469 if (error == network) { 471 if (error == network) {
470 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNetworkError, excep tionState); 472 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNetworkError, excep tionState);
471 } else if (error == decode) { 473 } else if (error == decode) {
472 endOfStreamInternal(WebMediaSource::EndOfStreamStatusDecodeError, except ionState); 474 endOfStreamInternal(WebMediaSource::EndOfStreamStatusDecodeError, except ionState);
473 } else { 475 } else {
474 ASSERT_NOT_REACHED(); // IDL enforcement should prevent this case. 476 NOTREACHED(); // IDL enforcement should prevent this case.
475 } 477 }
476 } 478 }
477 479
478 void MediaSource::endOfStream(ExceptionState& exceptionState) 480 void MediaSource::endOfStream(ExceptionState& exceptionState)
479 { 481 {
480 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNoError, exceptionState ); 482 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNoError, exceptionState );
481 } 483 }
482 484
483 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo sStatus, ExceptionState& exceptionState) 485 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo sStatus, ExceptionState& exceptionState)
484 { 486 {
(...skipping 14 matching lines...) Expand all
499 m_webMediaSource->markEndOfStream(eosStatus); 501 m_webMediaSource->markEndOfStream(eosStatus);
500 } 502 }
501 503
502 bool MediaSource::isOpen() const 504 bool MediaSource::isOpen() const
503 { 505 {
504 return readyState() == openKeyword(); 506 return readyState() == openKeyword();
505 } 507 }
506 508
507 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer) 509 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer)
508 { 510 {
509 ASSERT(!m_activeSourceBuffers->contains(sourceBuffer)); 511 DCHECK(!m_activeSourceBuffers->contains(sourceBuffer));
510 512
511 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers 513 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers
512 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in 514 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in
513 // the same order as they appear in SourceBuffer.sourceBuffers. 515 // the same order as they appear in SourceBuffer.sourceBuffers.
514 // SourceBuffer transitions to active are not guaranteed to occur in the 516 // SourceBuffer transitions to active are not guaranteed to occur in the
515 // same order as buffers in |m_sourceBuffers|, so this method needs to 517 // same order as buffers in |m_sourceBuffers|, so this method needs to
516 // insert |sourceBuffer| into |m_activeSourceBuffers|. 518 // insert |sourceBuffer| into |m_activeSourceBuffers|.
517 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer); 519 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer);
518 ASSERT(indexInSourceBuffers != kNotFound); 520 DCHECK(indexInSourceBuffers != kNotFound);
519 521
520 size_t insertPosition = 0; 522 size_t insertPosition = 0;
521 while (insertPosition < m_activeSourceBuffers->length() 523 while (insertPosition < m_activeSourceBuffers->length()
522 && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) { 524 && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) {
523 ++insertPosition; 525 ++insertPosition;
524 } 526 }
525 527
526 m_activeSourceBuffers->insert(insertPosition, sourceBuffer); 528 m_activeSourceBuffers->insert(insertPosition, sourceBuffer);
527 } 529 }
528 530
(...skipping 10 matching lines...) Expand all
539 void MediaSource::close() 541 void MediaSource::close()
540 { 542 {
541 setReadyState(closedKeyword()); 543 setReadyState(closedKeyword());
542 } 544 }
543 545
544 bool MediaSource::attachToElement(HTMLMediaElement* element) 546 bool MediaSource::attachToElement(HTMLMediaElement* element)
545 { 547 {
546 if (m_attachedElement) 548 if (m_attachedElement)
547 return false; 549 return false;
548 550
549 ASSERT(isClosed()); 551 DCHECK(isClosed());
550 552
551 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSource::attachToElement", this); 553 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSource::attachToElement", this);
552 m_attachedElement = element; 554 m_attachedElement = element;
553 return true; 555 return true;
554 } 556 }
555 557
556 void MediaSource::openIfInEndedState() 558 void MediaSource::openIfInEndedState()
557 { 559 {
558 if (m_readyState != endedKeyword()) 560 if (m_readyState != endedKeyword())
559 return; 561 return;
(...skipping 18 matching lines...) Expand all
578 } 580 }
579 581
580 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ e, const String& codecs, ExceptionState& exceptionState) 582 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ e, 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 adoptPtr(webSourceBuffer);
587 case WebMediaSource::AddStatusNotSupported: 589 case WebMediaSource::AddStatusNotSupported:
588 ASSERT(!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 ASSERT(!webSourceBuffer); 598 DCHECK(!webSourceBuffer);
597 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 599 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
598 // Step 3: If the user agent can't handle any more SourceBuffer objects then throw 600 // Step 3: If the user agent can't handle any more SourceBuffer objects then throw
599 // a QuotaExceededError exception and abort these steps. 601 // a QuotaExceededError exception and abort these steps.
600 logAndThrowDOMException(exceptionState, QuotaExceededError, "This MediaS ource has reached the limit of SourceBuffer objects it can handle. No additional SourceBuffer objects may be added."); 602 logAndThrowDOMException(exceptionState, QuotaExceededError, "This MediaS ource has reached the limit of SourceBuffer objects it can handle. No additional SourceBuffer objects may be added.");
601 return nullptr; 603 return nullptr;
602 } 604 }
603 605
604 ASSERT_NOT_REACHED(); 606 NOTREACHED();
605 return nullptr; 607 return nullptr;
606 } 608 }
607 609
608 void MediaSource::scheduleEvent(const AtomicString& eventName) 610 void MediaSource::scheduleEvent(const AtomicString& eventName)
609 { 611 {
610 ASSERT(m_asyncEventQueue); 612 DCHECK(m_asyncEventQueue);
611 613
612 Event* event = Event::create(eventName); 614 Event* event = Event::create(eventName);
613 event->setTarget(this); 615 event->setTarget(this);
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698