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

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

Issue 2146203002: Add an option to make blink media logging verbose (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring back separate macros for MediaElement/MediaSource/SourceBuffer Created 4 years, 5 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
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/Logging.h" 44 #include "platform/Logging.h"
45 #include "platform/MIMETypeRegistry.h" 45 #include "platform/MIMETypeRegistry.h"
46 #include "platform/RuntimeEnabledFeatures.h" 46 #include "platform/RuntimeEnabledFeatures.h"
47 #include "platform/TraceEvent.h" 47 #include "platform/TraceEvent.h"
48 #include "public/platform/WebMediaSource.h" 48 #include "public/platform/WebMediaSource.h"
49 #include "public/platform/WebSourceBuffer.h" 49 #include "public/platform/WebSourceBuffer.h"
50 #include "wtf/PtrUtil.h" 50 #include "wtf/PtrUtil.h"
51 #include "wtf/text/CString.h" 51 #include "wtf/text/CString.h"
52 #include <memory> 52 #include <memory>
53 53
54 #ifndef BLINK_MSLOG
55 #define BLINK_MSLOG DVLOG(3)
56 #endif
57
54 using blink::WebMediaSource; 58 using blink::WebMediaSource;
55 using blink::WebSourceBuffer; 59 using blink::WebSourceBuffer;
56 60
57 #define MSLOG DVLOG(3)
58
59 namespace blink { 61 namespace blink {
60 62
61 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState) 63 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState)
62 { 64 {
63 if (!isOpen) { 65 if (!isOpen) {
64 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSource's readyState is not 'open'."); 66 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSource's readyState is not 'open'.");
65 return true; 67 return true;
66 } 68 }
67 if (isUpdating) { 69 if (isUpdating) {
68 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The 'updating' attribute is true on one or more of this MediaSource's SourceBuf fers."); 70 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError, "The 'updating' attribute is true on one or more of this MediaSource's SourceBuf fers.");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 : ActiveScriptWrappable(this) 103 : ActiveScriptWrappable(this)
102 , ActiveDOMObject(context) 104 , ActiveDOMObject(context)
103 , m_readyState(closedKeyword()) 105 , m_readyState(closedKeyword())
104 , m_asyncEventQueue(GenericEventQueue::create(this)) 106 , m_asyncEventQueue(GenericEventQueue::create(this))
105 , m_attachedElement(nullptr) 107 , m_attachedElement(nullptr)
106 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get())) 108 , m_sourceBuffers(SourceBufferList::create(getExecutionContext(), m_asyncEve ntQueue.get()))
107 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get())) 109 , m_activeSourceBuffers(SourceBufferList::create(getExecutionContext(), m_as yncEventQueue.get()))
108 , m_liveSeekableRange(TimeRanges::create()) 110 , m_liveSeekableRange(TimeRanges::create())
109 , m_isAddedToRegistry(false) 111 , m_isAddedToRegistry(false)
110 { 112 {
111 MSLOG << __FUNCTION__ << " this=" << this; 113 BLINK_MSLOG << __FUNCTION__ << " this=" << this;
112 } 114 }
113 115
114 MediaSource::~MediaSource() 116 MediaSource::~MediaSource()
115 { 117 {
116 MSLOG << __FUNCTION__ << " this=" << this; 118 BLINK_MSLOG << __FUNCTION__ << " this=" << this;
117 DCHECK(isClosed()); 119 DCHECK(isClosed());
118 } 120 }
119 121
120 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message) 122 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message)
121 { 123 {
122 MSLOG << __FUNCTION__ << " (error=" << error << ", message=" << message << " )"; 124 BLINK_MSLOG << __FUNCTION__ << " (error=" << error << ", message=" << messag e << ")";
123 exceptionState.throwDOMException(error, message); 125 exceptionState.throwDOMException(error, message);
124 } 126 }
125 127
126 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) 128 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState)
127 { 129 {
128 MSLOG << __FUNCTION__ << " this=" << this << " type=" << type; 130 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " type=" << type;
129 131
130 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 132 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
131 // 1. If type is an empty string then throw an InvalidAccessError exception 133 // 1. If type is an empty string then throw an InvalidAccessError exception
132 // and abort these steps. 134 // and abort these steps.
133 if (type.isEmpty()) { 135 if (type.isEmpty()) {
134 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr ovided is empty."); 136 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr ovided is empty.");
135 return 0; 137 return 0;
136 } 138 }
137 139
138 // 2. If type contains a MIME type that is not supported ..., then throw a 140 // 2. If type contains a MIME type that is not supported ..., then throw a
(...skipping 20 matching lines...) Expand all
159 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. 161 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps.
160 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps 162 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps
161 return 0; 163 return 0;
162 } 164 }
163 165
164 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this , m_asyncEventQueue.get()); 166 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this , m_asyncEventQueue.get());
165 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 167 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
166 m_sourceBuffers->add(buffer); 168 m_sourceBuffers->add(buffer);
167 169
168 // 7. Return the new object to the caller. 170 // 7. Return the new object to the caller.
169 MSLOG << __FUNCTION__ << " this=" << this << " type=" << type << " -> " << b uffer; 171 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " type=" << type << " -> " << buffer;
170 return buffer; 172 return buffer;
171 } 173 }
172 174
173 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState) 175 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep tionState)
174 { 176 {
175 MSLOG << __FUNCTION__ << " this=" << this << " buffer=" << buffer; 177 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " buffer=" << buffer;
176 178
177 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 179 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
178 180
179 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then 181 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then
180 // throw a NotFoundError exception and abort these steps. 182 // throw a NotFoundError exception and abort these steps.
181 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 183 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
182 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource."); 184 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource.");
183 return; 185 return;
184 } 186 }
185 187
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 235
234 return false; 236 return false;
235 } 237 }
236 238
237 bool MediaSource::isTypeSupported(const String& type) 239 bool MediaSource::isTypeSupported(const String& type)
238 { 240 {
239 // Section 2.2 isTypeSupported() method steps. 241 // Section 2.2 isTypeSupported() method steps.
240 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type 242 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
241 // 1. If type is an empty string, then return false. 243 // 1. If type is an empty string, then return false.
242 if (type.isEmpty()) { 244 if (type.isEmpty()) {
243 MSLOG << __FUNCTION__ << "(" << type << ") -> false (empty input)"; 245 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (empty input)" ;
244 return false; 246 return false;
245 } 247 }
246 248
247 ContentType contentType(type); 249 ContentType contentType(type);
248 String codecs = contentType.parameter("codecs"); 250 String codecs = contentType.parameter("codecs");
249 251
250 // 2. If type does not contain a valid MIME type string, then return false. 252 // 2. If type does not contain a valid MIME type string, then return false.
251 if (contentType.type().isEmpty()) { 253 if (contentType.type().isEmpty()) {
252 MSLOG << __FUNCTION__ << "(" << type << ") -> false (invalid mime type)" ; 254 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (invalid mime type)";
253 return false; 255 return false;
254 } 256 }
255 257
256 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably" 258 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMedia Element.canPlayType() will return "maybe" or "probably"
257 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play. 259 // since it does not make sense for a MediaSource to support a type the HTML MediaElement knows it cannot play.
258 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) { 260 if (HTMLMediaElement::supportsType(contentType) == WebMimeRegistry::IsNotSup ported) {
259 MSLOG << __FUNCTION__ << "(" << type << ") -> false (not supported by HT MLMediaElement)"; 261 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> false (not supported by HTMLMediaElement)";
260 return false; 262 return false;
261 } 263 }
262 264
263 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false. 265 // 3. If type contains a media type or media subtype that the MediaSource do es not support, then return false.
264 // 4. If type contains at a codec that the MediaSource does not support, the n return false. 266 // 4. If type contains at a codec that the MediaSource does not support, the n return false.
265 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false. 267 // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
266 // 6. Return true. 268 // 6. Return true.
267 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs); 269 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.t ype(), codecs);
268 MSLOG << __FUNCTION__ << "(" << type << ") -> " << (result ? "true" : "false "); 270 BLINK_MSLOG << __FUNCTION__ << "(" << type << ") -> " << (result ? "true" : "false");
269 return result; 271 return result;
270 } 272 }
271 273
272 const AtomicString& MediaSource::interfaceName() const 274 const AtomicString& MediaSource::interfaceName() const
273 { 275 {
274 return EventTargetNames::MediaSource; 276 return EventTargetNames::MediaSource;
275 } 277 }
276 278
277 ExecutionContext* MediaSource::getExecutionContext() const 279 ExecutionContext* MediaSource::getExecutionContext() const
278 { 280 {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 483
482 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm. 484 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm.
483 m_attachedElement->durationChanged(newDuration, requestSeek); 485 m_attachedElement->durationChanged(newDuration, requestSeek);
484 } 486 }
485 487
486 void MediaSource::setReadyState(const AtomicString& state) 488 void MediaSource::setReadyState(const AtomicString& state)
487 { 489 {
488 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 490 DCHECK(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
489 491
490 AtomicString oldState = readyState(); 492 AtomicString oldState = readyState();
491 MSLOG << __FUNCTION__ << " this=" << this << " : " << oldState << " -> " << state; 493 BLINK_MSLOG << __FUNCTION__ << " this=" << this << " : " << oldState << " -> " << state;
492 494
493 if (state == closedKeyword()) { 495 if (state == closedKeyword()) {
494 m_webMediaSource.reset(); 496 m_webMediaSource.reset();
495 } 497 }
496 498
497 if (oldState == state) 499 if (oldState == state)
498 return; 500 return;
499 501
500 m_readyState = state; 502 m_readyState = state;
501 503
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 698
697 m_asyncEventQueue->enqueueEvent(event); 699 m_asyncEventQueue->enqueueEvent(event);
698 } 700 }
699 701
700 URLRegistry& MediaSource::registry() const 702 URLRegistry& MediaSource::registry() const
701 { 703 {
702 return MediaSourceRegistry::registry(); 704 return MediaSourceRegistry::registry();
703 } 705 }
704 706
705 } // namespace blink 707 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698