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

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 nits 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(std::move(webSourceBuffer), this , m_asyncEventQueue.get()); 160 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), 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 << ") " << buff er << " -> " << this;
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__ << "(" << buffer << ") -> " << this;
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 16 matching lines...) Expand all
196 if (isOpen()) { 198 if (isOpen()) {
197 scheduleEvent(EventTypeNames::sourceopen); 199 scheduleEvent(EventTypeNames::sourceopen);
198 return; 200 return;
199 } 201 }
200 202
201 if (oldState == openKeyword() && newState == endedKeyword()) { 203 if (oldState == openKeyword() && newState == endedKeyword()) {
202 scheduleEvent(EventTypeNames::sourceended); 204 scheduleEvent(EventTypeNames::sourceended);
203 return; 205 return;
204 } 206 }
205 207
206 ASSERT(isClosed()); 208 DCHECK(isClosed());
207 209
208 m_activeSourceBuffers->clear(); 210 m_activeSourceBuffers->clear();
209 211
210 // Clear SourceBuffer references to this object. 212 // Clear SourceBuffer references to this object.
211 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) 213 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i)
212 m_sourceBuffers->item(i)->removedFromMediaSource(); 214 m_sourceBuffers->item(i)->removedFromMediaSource();
213 m_sourceBuffers->clear(); 215 m_sourceBuffers->clear();
214 216
215 m_attachedElement.clear(); 217 m_attachedElement.clear();
216 218
(...skipping 10 matching lines...) Expand all
227 229
228 return false; 230 return false;
229 } 231 }
230 232
231 bool MediaSource::isTypeSupported(const String& type) 233 bool MediaSource::isTypeSupported(const String& type)
232 { 234 {
233 // Section 2.2 isTypeSupported() method steps. 235 // Section 2.2 isTypeSupported() method steps.
234 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type 236 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
235 // 1. If type is an empty string, then return false. 237 // 1. If type is an empty string, then return false.
236 if (type.isEmpty()) { 238 if (type.isEmpty()) {
237 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (empty input)" , type.ascii().data()); 239 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (empty input)";
238 return false; 240 return false;
239 } 241 }
240 242
241 ContentType contentType(type); 243 ContentType contentType(type);
242 String codecs = contentType.parameter("codecs"); 244 String codecs = contentType.parameter("codecs");
243 245
244 // 2. If type does not contain a valid MIME type string, then return false. 246 // 2. If type does not contain a valid MIME type string, then return false.
245 if (contentType.type().isEmpty()) { 247 if (contentType.type().isEmpty()) {
246 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (invalid mime type)", type.ascii().data()); 248 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (invalid mime type)";
247 return false; 249 return false;
248 } 250 }
249 251
250 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably" 252 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably"
251 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play. 253 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play.
252 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) { 254 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) {
253 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> false (not supported by HTMLMediaElement)", type.ascii().data()); 255 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> fa lse (not supported by HTMLMediaElement)";
254 return false; 256 return false;
255 } 257 }
256 258
257 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false. 259 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false.
258 // 4. If type contains at a codec that the MediaSource does not support, the n return false. 260 // 4. If type contains at a codec that the MediaSource does not support, the n return false.
259 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false. 261 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
260 // 6. Return true. 262 // 6. Return true.
261 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs); 263 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs);
262 WTF_LOG(Media, "MediaSource::isTypeSupported(%s) -> %s", type.ascii().data() , result ? "true" : "false"); 264 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << "(" << type << ") -> " << ( result ? "true" : "false");
263 return result; 265 return result;
264 } 266 }
265 267
266 const AtomicString& MediaSource::interfaceName() const 268 const AtomicString& MediaSource::interfaceName() const
267 { 269 {
268 return EventTargetNames::MediaSource; 270 return EventTargetNames::MediaSource;
269 } 271 }
270 272
271 ExecutionContext* MediaSource::getExecutionContext() const 273 ExecutionContext* MediaSource::getExecutionContext() const
272 { 274 {
273 return ActiveDOMObject::getExecutionContext(); 275 return ActiveDOMObject::getExecutionContext();
274 } 276 }
275 277
276 DEFINE_TRACE(MediaSource) 278 DEFINE_TRACE(MediaSource)
277 { 279 {
278 visitor->trace(m_asyncEventQueue); 280 visitor->trace(m_asyncEventQueue);
279 visitor->trace(m_attachedElement); 281 visitor->trace(m_attachedElement);
280 visitor->trace(m_sourceBuffers); 282 visitor->trace(m_sourceBuffers);
281 visitor->trace(m_activeSourceBuffers); 283 visitor->trace(m_activeSourceBuffers);
282 EventTargetWithInlineData::trace(visitor); 284 EventTargetWithInlineData::trace(visitor);
283 ActiveDOMObject::trace(visitor); 285 ActiveDOMObject::trace(visitor);
284 } 286 }
285 287
286 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce) 288 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce)
287 { 289 {
288 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); 290 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this);
289 ASSERT(webMediaSource); 291 DCHECK(webMediaSource);
290 ASSERT(!m_webMediaSource); 292 DCHECK(!m_webMediaSource);
291 ASSERT(m_attachedElement); 293 DCHECK(m_attachedElement);
292 m_webMediaSource = std::move(webMediaSource); 294 m_webMediaSource = std::move(webMediaSource);
293 setReadyState(openKeyword()); 295 setReadyState(openKeyword());
294 } 296 }
295 297
296 void MediaSource::addedToRegistry() 298 void MediaSource::addedToRegistry()
297 { 299 {
298 ASSERT(!m_isAddedToRegistry); 300 DCHECK(!m_isAddedToRegistry);
299 m_isAddedToRegistry = true; 301 m_isAddedToRegistry = true;
300 } 302 }
301 303
302 void MediaSource::removedFromRegistry() 304 void MediaSource::removedFromRegistry()
303 { 305 {
304 ASSERT(m_isAddedToRegistry); 306 DCHECK(m_isAddedToRegistry);
305 m_isAddedToRegistry = false; 307 m_isAddedToRegistry = false;
306 } 308 }
307 309
308 double MediaSource::duration() const 310 double MediaSource::duration() const
309 { 311 {
310 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration(); 312 return isClosed() ? std::numeric_limits<float>::quiet_NaN() : m_webMediaSour ce->duration();
311 } 313 }
312 314
313 TimeRanges* MediaSource::buffered() const 315 TimeRanges* MediaSource::buffered() const
314 { 316 {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // 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 // 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:
436 // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media 438 // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media
437 // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps. 439 // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps.
438 440
439 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm. 441 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm.
440 m_attachedElement->durationChanged(newDuration, requestSeek); 442 m_attachedElement->durationChanged(newDuration, requestSeek);
441 } 443 }
442 444
443 void MediaSource::setReadyState(const AtomicString& state) 445 void MediaSource::setReadyState(const AtomicString& state)
444 { 446 {
445 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 447 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
446 448
447 AtomicString oldState = readyState(); 449 AtomicString oldState = readyState();
448 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 450 DVLOG(MEDIA_SOURCE_LOG_LEVEL) << __FUNCTION__ << " : " << oldState << " -> " << state << " " << this;
449 451
450 if (state == closedKeyword()) { 452 if (state == closedKeyword()) {
451 m_webMediaSource.clear(); 453 m_webMediaSource.clear();
452 } 454 }
453 455
454 if (oldState == state) 456 if (oldState == state)
455 return; 457 return;
456 458
457 m_readyState = state; 459 m_readyState = state;
458 460
459 onReadyStateChange(oldState, state); 461 onReadyStateChange(oldState, state);
460 } 462 }
461 463
462 void MediaSource::endOfStream(const AtomicString& error, ExceptionState& excepti onState) 464 void MediaSource::endOfStream(const AtomicString& error, ExceptionState& excepti onState)
463 { 465 {
464 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network")); 466 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network"));
465 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode")); 467 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode"));
466 468
467 if (error == network) { 469 if (error == network) {
468 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNetworkError, excep tionState); 470 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNetworkError, excep tionState);
469 } else if (error == decode) { 471 } else if (error == decode) {
470 endOfStreamInternal(WebMediaSource::EndOfStreamStatusDecodeError, except ionState); 472 endOfStreamInternal(WebMediaSource::EndOfStreamStatusDecodeError, except ionState);
471 } else { 473 } else {
472 ASSERT_NOT_REACHED(); // IDL enforcement should prevent this case. 474 NOTREACHED(); // IDL enforcement should prevent this case.
473 } 475 }
474 } 476 }
475 477
476 void MediaSource::endOfStream(ExceptionState& exceptionState) 478 void MediaSource::endOfStream(ExceptionState& exceptionState)
477 { 479 {
478 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNoError, exceptionState ); 480 endOfStreamInternal(WebMediaSource::EndOfStreamStatusNoError, exceptionState );
479 } 481 }
480 482
481 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo sStatus, ExceptionState& exceptionState) 483 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo sStatus, ExceptionState& exceptionState)
482 { 484 {
(...skipping 14 matching lines...) Expand all
497 m_webMediaSource->markEndOfStream(eosStatus); 499 m_webMediaSource->markEndOfStream(eosStatus);
498 } 500 }
499 501
500 bool MediaSource::isOpen() const 502 bool MediaSource::isOpen() const
501 { 503 {
502 return readyState() == openKeyword(); 504 return readyState() == openKeyword();
503 } 505 }
504 506
505 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer) 507 void MediaSource::setSourceBufferActive(SourceBuffer* sourceBuffer)
506 { 508 {
507 ASSERT(!m_activeSourceBuffers->contains(sourceBuffer)); 509 DCHECK(!m_activeSourceBuffers->contains(sourceBuffer));
508 510
509 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers 511 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-activeSourceBuffers
510 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in 512 // SourceBuffer objects in SourceBuffer.activeSourceBuffers must appear in
511 // the same order as they appear in SourceBuffer.sourceBuffers. 513 // the same order as they appear in SourceBuffer.sourceBuffers.
512 // SourceBuffer transitions to active are not guaranteed to occur in the 514 // SourceBuffer transitions to active are not guaranteed to occur in the
513 // same order as buffers in |m_sourceBuffers|, so this method needs to 515 // same order as buffers in |m_sourceBuffers|, so this method needs to
514 // insert |sourceBuffer| into |m_activeSourceBuffers|. 516 // insert |sourceBuffer| into |m_activeSourceBuffers|.
515 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer); 517 size_t indexInSourceBuffers = m_sourceBuffers->find(sourceBuffer);
516 ASSERT(indexInSourceBuffers != kNotFound); 518 DCHECK(indexInSourceBuffers != kNotFound);
517 519
518 size_t insertPosition = 0; 520 size_t insertPosition = 0;
519 while (insertPosition < m_activeSourceBuffers->length() 521 while (insertPosition < m_activeSourceBuffers->length()
520 && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) { 522 && m_sourceBuffers->find(m_activeSourceBuffers->item(insertPosition)) < indexInSourceBuffers) {
521 ++insertPosition; 523 ++insertPosition;
522 } 524 }
523 525
524 m_activeSourceBuffers->insert(insertPosition, sourceBuffer); 526 m_activeSourceBuffers->insert(insertPosition, sourceBuffer);
525 } 527 }
526 528
(...skipping 10 matching lines...) Expand all
537 void MediaSource::close() 539 void MediaSource::close()
538 { 540 {
539 setReadyState(closedKeyword()); 541 setReadyState(closedKeyword());
540 } 542 }
541 543
542 bool MediaSource::attachToElement(HTMLMediaElement* element) 544 bool MediaSource::attachToElement(HTMLMediaElement* element)
543 { 545 {
544 if (m_attachedElement) 546 if (m_attachedElement)
545 return false; 547 return false;
546 548
547 ASSERT(isClosed()); 549 DCHECK(isClosed());
548 550
549 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSource::attachToElement", this); 551 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSource::attachToElement", this);
550 m_attachedElement = element; 552 m_attachedElement = element;
551 return true; 553 return true;
552 } 554 }
553 555
554 void MediaSource::openIfInEndedState() 556 void MediaSource::openIfInEndedState()
555 { 557 {
556 if (m_readyState != endedKeyword()) 558 if (m_readyState != endedKeyword())
557 return; 559 return;
(...skipping 18 matching lines...) Expand all
576 } 578 }
577 579
578 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ e, const String& codecs, ExceptionState& exceptionState) 580 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ e, const String& codecs, ExceptionState& exceptionState)
579 { 581 {
580 WebSourceBuffer* webSourceBuffer = 0; 582 WebSourceBuffer* webSourceBuffer = 0;
581 583
582 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { 584 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) {
583 case WebMediaSource::AddStatusOk: 585 case WebMediaSource::AddStatusOk:
584 return adoptPtr(webSourceBuffer); 586 return adoptPtr(webSourceBuffer);
585 case WebMediaSource::AddStatusNotSupported: 587 case WebMediaSource::AddStatusNotSupported:
586 ASSERT(!webSourceBuffer); 588 DCHECK(!webSourceBuffer);
587 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 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
588 // Step 2: If type contains a MIME type ... that is not supported with t he types 590 // Step 2: If type contains a MIME type ... that is not supported with t he types
589 // specified for the other SourceBuffer objects in sourceBuffers, then t hrow 591 // specified for the other SourceBuffer objects in sourceBuffers, then t hrow
590 // a NotSupportedError exception and abort these steps. 592 // a NotSupportedError exception and abort these steps.
591 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is not supported."); 593 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is not supported.");
592 return nullptr; 594 return nullptr;
593 case WebMediaSource::AddStatusReachedIdLimit: 595 case WebMediaSource::AddStatusReachedIdLimit:
594 ASSERT(!webSourceBuffer); 596 DCHECK(!webSourceBuffer);
595 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 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
596 // Step 3: If the user agent can't handle any more SourceBuffer objects then throw 598 // Step 3: If the user agent can't handle any more SourceBuffer objects then throw
597 // a QuotaExceededError exception and abort these steps. 599 // a QuotaExceededError exception and abort these steps.
598 logAndThrowDOMException(exceptionState, QuotaExceededError, "This MediaS ource has reached the limit of SourceBuffer objects it can handle. No additional SourceBuffer objects may be added."); 600 logAndThrowDOMException(exceptionState, QuotaExceededError, "This MediaS ource has reached the limit of SourceBuffer objects it can handle. No additional SourceBuffer objects may be added.");
599 return nullptr; 601 return nullptr;
600 } 602 }
601 603
602 ASSERT_NOT_REACHED(); 604 NOTREACHED();
603 return nullptr; 605 return nullptr;
604 } 606 }
605 607
606 void MediaSource::scheduleEvent(const AtomicString& eventName) 608 void MediaSource::scheduleEvent(const AtomicString& eventName)
607 { 609 {
608 ASSERT(m_asyncEventQueue); 610 DCHECK(m_asyncEventQueue);
609 611
610 Event* event = Event::create(eventName); 612 Event* event = Event::create(eventName);
611 event->setTarget(this); 613 event->setTarget(this);
612 614
613 m_asyncEventQueue->enqueueEvent(event); 615 m_asyncEventQueue->enqueueEvent(event);
614 } 616 }
615 617
616 URLRegistry& MediaSource::registry() const 618 URLRegistry& MediaSource::registry() const
617 { 619 {
618 return MediaSourceRegistry::registry(); 620 return MediaSourceRegistry::registry();
619 } 621 }
620 622
621 } // namespace blink 623 } // 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