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

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: 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
Srirama 2016/05/19 15:00:22 Is 3 fine to make it less verbose? or should we ma
wolenetz 2016/05/19 17:53:33 3 is fine. It's what I use personally when debuggi
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) << "MediaSource " << this;
wolenetz 2016/05/19 17:53:33 Just double-checking: does "this" not need the (vo
Srirama 2016/05/20 08:31:48 It doesn't need, I verified and it is printing the
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) << "~MediaSource " << this;
111 ASSERT(isClosed()); 113 ASSERT(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) << "throwDOMException: error=" << error << " m sg=" << message;
wolenetz 2016/05/19 17:53:33 Is __FUNCTION__ usable here as a replacement (here
Srirama 2016/05/20 08:31:48 Not able to print "this" here as it is a static fu
wolenetz 2016/05/20 19:58:15 Acknowledged.
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) << "addSourceBuffer(" << 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
(...skipping 20 matching lines...) Expand all
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) << "addSourceBuffer(" << type << ") " << this << " -> " << buffer;
wolenetz 2016/05/19 17:53:33 Ditto on the double-check for |buffer| here please
Srirama 2016/05/20 08:31:48 I think you want the buffer pointer to be printed
wolenetz 2016/05/20 19:58:15 Acknowledged.
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) << "removeSourceBuffer() " << this;
wolenetz 2016/05/19 17:53:33 nit: now seems like a good time to add |buffer| to
Srirama 2016/05/20 08:31:48 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) << "isTypeSupported(" << type << ") -> fal se (empty input)";
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) << "isTypeSupported(" << type << ") -> fal se (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) << "isTypeSupported(" << type << ") -> fal se (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) << "isTypeSupported(" << type << ") -> " << (r esult ? "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 {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ASSERT(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) << "setReadyState() " << this << " : " << oldS tate << " -> " << 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 ASSERT_NOT_REACHED(); // IDL enforcement should prevent this case.
wolenetz 2016/05/19 17:53:33 NOTREACHED() ?
Srirama 2016/05/20 08:31:49 Done.
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return nullptr; 596 return nullptr;
595 case WebMediaSource::AddStatusReachedIdLimit: 597 case WebMediaSource::AddStatusReachedIdLimit:
596 ASSERT(!webSourceBuffer); 598 ASSERT(!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 ASSERT_NOT_REACHED();
wolenetz 2016/05/19 17:53:33 nit: NOTREACHED() ?
Srirama 2016/05/20 08:31:48 Done.
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 ASSERT(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