OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
12 #include "core/dom/DOMException.h" | 12 #include "core/dom/DOMException.h" |
13 #include "core/dom/DOMTypedArray.h" | 13 #include "core/dom/DOMTypedArray.h" |
14 #include "core/dom/ExceptionCode.h" | 14 #include "core/dom/ExceptionCode.h" |
15 #include "core/html/HTMLMediaElement.h" | 15 #include "core/html/HTMLMediaElement.h" |
16 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" | 16 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
17 #include "modules/encryptedmedia/EncryptedMediaUtils.h" | 17 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
18 #include "modules/encryptedmedia/MediaEncryptedEvent.h" | 18 #include "modules/encryptedmedia/MediaEncryptedEvent.h" |
19 #include "modules/encryptedmedia/MediaKeys.h" | 19 #include "modules/encryptedmedia/MediaKeys.h" |
20 #include "platform/ContentDecryptionModuleResult.h" | 20 #include "platform/ContentDecryptionModuleResult.h" |
21 #include "platform/Logging.h" | 21 #include "platform/Logging.h" |
22 #include "wtf/Functional.h" | 22 #include "wtf/Functional.h" |
23 | 23 |
| 24 #define EME_LOG_LEVEL 3 |
| 25 |
24 namespace blink { | 26 namespace blink { |
25 | 27 |
26 // This class allows MediaKeys to be set asynchronously. | 28 // This class allows MediaKeys to be set asynchronously. |
27 class SetMediaKeysHandler : public ScriptPromiseResolver { | 29 class SetMediaKeysHandler : public ScriptPromiseResolver { |
28 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); | 30 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); |
29 public: | 31 public: |
30 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); | 32 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); |
31 ~SetMediaKeysHandler() override; | 33 ~SetMediaKeysHandler() override; |
32 | 34 |
33 DECLARE_VIRTUAL_TRACE(); | 35 DECLARE_VIRTUAL_TRACE(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 68 } |
67 | 69 |
68 // ContentDecryptionModuleResult implementation. | 70 // ContentDecryptionModuleResult implementation. |
69 void complete() override | 71 void complete() override |
70 { | 72 { |
71 (*m_successCallback)(); | 73 (*m_successCallback)(); |
72 } | 74 } |
73 | 75 |
74 void completeWithContentDecryptionModule(WebContentDecryptionModule*) overri
de | 76 void completeWithContentDecryptionModule(WebContentDecryptionModule*) overri
de |
75 { | 77 { |
76 ASSERT_NOT_REACHED(); | 78 NOTREACHED(); |
77 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); | 79 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); |
78 } | 80 } |
79 | 81 |
80 void completeWithSession(WebContentDecryptionModuleResult::SessionStatus sta
tus) override | 82 void completeWithSession(WebContentDecryptionModuleResult::SessionStatus sta
tus) override |
81 { | 83 { |
82 ASSERT_NOT_REACHED(); | 84 NOTREACHED(); |
83 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); | 85 (*m_failureCallback)(InvalidStateError, "Unexpected completion."); |
84 } | 86 } |
85 | 87 |
86 void completeWithError(WebContentDecryptionModuleException code, unsigned lo
ng systemCode, const WebString& message) override | 88 void completeWithError(WebContentDecryptionModuleException code, unsigned lo
ng systemCode, const WebString& message) override |
87 { | 89 { |
88 // Non-zero |systemCode| is appended to the |message|. If the |message| | 90 // Non-zero |systemCode| is appended to the |message|. If the |message| |
89 // is empty, we'll report "Rejected with system code (systemCode)". | 91 // is empty, we'll report "Rejected with system code (systemCode)". |
90 String errorString = message; | 92 String errorString = message; |
91 if (systemCode != 0) { | 93 if (systemCode != 0) { |
92 if (errorString.isEmpty()) | 94 if (errorString.isEmpty()) |
(...skipping 16 matching lines...) Expand all Loading... |
109 return handler->promise(); | 111 return handler->promise(); |
110 } | 112 } |
111 | 113 |
112 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem
ent& element, MediaKeys* mediaKeys) | 114 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem
ent& element, MediaKeys* mediaKeys) |
113 : ScriptPromiseResolver(scriptState) | 115 : ScriptPromiseResolver(scriptState) |
114 , m_element(element) | 116 , m_element(element) |
115 , m_newMediaKeys(mediaKeys) | 117 , m_newMediaKeys(mediaKeys) |
116 , m_madeReservation(false) | 118 , m_madeReservation(false) |
117 , m_timer(this, &SetMediaKeysHandler::timerFired) | 119 , m_timer(this, &SetMediaKeysHandler::timerFired) |
118 { | 120 { |
119 WTF_LOG(Media, "SetMediaKeysHandler::SetMediaKeysHandler"); | 121 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
120 | 122 |
121 // 5. Run the following steps in parallel. | 123 // 5. Run the following steps in parallel. |
122 m_timer.startOneShot(0, BLINK_FROM_HERE); | 124 m_timer.startOneShot(0, BLINK_FROM_HERE); |
123 } | 125 } |
124 | 126 |
125 SetMediaKeysHandler::~SetMediaKeysHandler() | 127 SetMediaKeysHandler::~SetMediaKeysHandler() |
126 { | 128 { |
127 } | 129 } |
128 | 130 |
129 void SetMediaKeysHandler::timerFired(Timer<SetMediaKeysHandler>*) | 131 void SetMediaKeysHandler::timerFired(Timer<SetMediaKeysHandler>*) |
130 { | 132 { |
131 clearExistingMediaKeys(); | 133 clearExistingMediaKeys(); |
132 } | 134 } |
133 | 135 |
134 void SetMediaKeysHandler::clearExistingMediaKeys() | 136 void SetMediaKeysHandler::clearExistingMediaKeys() |
135 { | 137 { |
136 WTF_LOG(Media, "SetMediaKeysHandler::clearExistingMediaKeys"); | 138 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
137 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); | 139 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); |
138 | 140 |
139 // 5.1 If mediaKeys is not null, the CDM instance represented by | 141 // 5.1 If mediaKeys is not null, the CDM instance represented by |
140 // mediaKeys is already in use by another media element, and | 142 // mediaKeys is already in use by another media element, and |
141 // the user agent is unable to use it with this element, let | 143 // the user agent is unable to use it with this element, let |
142 // this object's attaching media keys value be false and | 144 // this object's attaching media keys value be false and |
143 // reject promise with a QuotaExceededError. | 145 // reject promise with a QuotaExceededError. |
144 if (m_newMediaKeys) { | 146 if (m_newMediaKeys) { |
145 if (!m_newMediaKeys->reserveForMediaElement(m_element.get())) { | 147 if (!m_newMediaKeys->reserveForMediaElement(m_element.get())) { |
146 thisElement.m_isAttachingMediaKeys = false; | 148 thisElement.m_isAttachingMediaKeys = false; |
(...skipping 28 matching lines...) Expand all Loading... |
175 return; | 177 return; |
176 } | 178 } |
177 } | 179 } |
178 | 180 |
179 // MediaKeys not currently set or no player connected, so continue on. | 181 // MediaKeys not currently set or no player connected, so continue on. |
180 setNewMediaKeys(); | 182 setNewMediaKeys(); |
181 } | 183 } |
182 | 184 |
183 void SetMediaKeysHandler::setNewMediaKeys() | 185 void SetMediaKeysHandler::setNewMediaKeys() |
184 { | 186 { |
185 WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys"); | 187 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
186 | 188 |
187 // 5.3 If mediaKeys is not null, run the following steps: | 189 // 5.3 If mediaKeys is not null, run the following steps: |
188 if (m_newMediaKeys) { | 190 if (m_newMediaKeys) { |
189 // 5.3.1 Associate the CDM instance represented by mediaKeys with the | 191 // 5.3.1 Associate the CDM instance represented by mediaKeys with the |
190 // media element for decrypting media data. | 192 // media element for decrypting media data. |
191 // 5.3.2 If the preceding step failed, run the following steps: | 193 // 5.3.2 If the preceding step failed, run the following steps: |
192 // (done in setFailed()). | 194 // (done in setFailed()). |
193 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary | 195 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary |
194 // algorithm on the media element. | 196 // algorithm on the media element. |
195 // (Handled in Chromium). | 197 // (Handled in Chromium). |
196 if (m_element->webMediaPlayer()) { | 198 if (m_element->webMediaPlayer()) { |
197 std::unique_ptr<SuccessCallback> successCallback = bind(&SetMediaKey
sHandler::finish, this); | 199 std::unique_ptr<SuccessCallback> successCallback = bind(&SetMediaKey
sHandler::finish, this); |
198 std::unique_ptr<FailureCallback> failureCallback = bind<ExceptionCod
e, const String&>(&SetMediaKeysHandler::setFailed, this); | 200 std::unique_ptr<FailureCallback> failureCallback = bind<ExceptionCod
e, const String&>(&SetMediaKeysHandler::setFailed, this); |
199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(std::move(successCallback), std::move(failureCallback)); | 201 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(std::move(successCallback), std::move(failureCallback)); |
200 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe
ys->contentDecryptionModule(), result->result()); | 202 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe
ys->contentDecryptionModule(), result->result()); |
201 | 203 |
202 // Don't do anything more until |result| is resolved (or rejected). | 204 // Don't do anything more until |result| is resolved (or rejected). |
203 return; | 205 return; |
204 } | 206 } |
205 } | 207 } |
206 | 208 |
207 // MediaKeys doesn't need to be set on the player, so continue on. | 209 // MediaKeys doesn't need to be set on the player, so continue on. |
208 finish(); | 210 finish(); |
209 } | 211 } |
210 | 212 |
211 void SetMediaKeysHandler::finish() | 213 void SetMediaKeysHandler::finish() |
212 { | 214 { |
213 WTF_LOG(Media, "SetMediaKeysHandler::finish"); | 215 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
214 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); | 216 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); |
215 | 217 |
216 // 5.4 Set the mediaKeys attribute to mediaKeys. | 218 // 5.4 Set the mediaKeys attribute to mediaKeys. |
217 if (thisElement.m_mediaKeys) | 219 if (thisElement.m_mediaKeys) |
218 thisElement.m_mediaKeys->clearMediaElement(); | 220 thisElement.m_mediaKeys->clearMediaElement(); |
219 thisElement.m_mediaKeys = m_newMediaKeys; | 221 thisElement.m_mediaKeys = m_newMediaKeys; |
220 if (m_madeReservation) | 222 if (m_madeReservation) |
221 m_newMediaKeys->acceptReservation(); | 223 m_newMediaKeys->acceptReservation(); |
222 | 224 |
223 // 5.5 Let this object's attaching media keys value be false. | 225 // 5.5 Let this object's attaching media keys value be false. |
(...skipping 11 matching lines...) Expand all Loading... |
235 | 237 |
236 // Make sure attaching media keys value is false. | 238 // Make sure attaching media keys value is false. |
237 DCHECK(!HTMLMediaElementEncryptedMedia::from(*m_element).m_isAttachingMediaK
eys); | 239 DCHECK(!HTMLMediaElementEncryptedMedia::from(*m_element).m_isAttachingMediaK
eys); |
238 | 240 |
239 // Reject promise with an appropriate error. | 241 // Reject promise with an appropriate error. |
240 reject(DOMException::create(code, errorMessage)); | 242 reject(DOMException::create(code, errorMessage)); |
241 } | 243 } |
242 | 244 |
243 void SetMediaKeysHandler::clearFailed(ExceptionCode code, const String& errorMes
sage) | 245 void SetMediaKeysHandler::clearFailed(ExceptionCode code, const String& errorMes
sage) |
244 { | 246 { |
245 WTF_LOG(Media, "SetMediaKeysHandler::clearFailed (%d, %s)", code, errorMessa
ge.ascii().data()); | 247 DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << "(" << code << ", " << errorMessage
<< ")"; |
246 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); | 248 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); |
247 | 249 |
248 // 5.2.4 If the preceding step failed, let this object's attaching media | 250 // 5.2.4 If the preceding step failed, let this object's attaching media |
249 // keys value be false and reject promise with an appropriate | 251 // keys value be false and reject promise with an appropriate |
250 // error name. | 252 // error name. |
251 thisElement.m_isAttachingMediaKeys = false; | 253 thisElement.m_isAttachingMediaKeys = false; |
252 fail(code, errorMessage); | 254 fail(code, errorMessage); |
253 } | 255 } |
254 | 256 |
255 void SetMediaKeysHandler::setFailed(ExceptionCode code, const String& errorMessa
ge) | 257 void SetMediaKeysHandler::setFailed(ExceptionCode code, const String& errorMessa
ge) |
256 { | 258 { |
257 WTF_LOG(Media, "SetMediaKeysHandler::setFailed (%d, %s)", code, errorMessage
.ascii().data()); | 259 DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << "(" << code << ", " << errorMessage
<< ")"; |
258 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); | 260 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(*m_element); |
259 | 261 |
260 // 5.3.2 If the preceding step failed (in setContentDecryptionModule() | 262 // 5.3.2 If the preceding step failed (in setContentDecryptionModule() |
261 // called from setNewMediaKeys()), run the following steps: | 263 // called from setNewMediaKeys()), run the following steps: |
262 // 5.3.2.1 Set the mediaKeys attribute to null. | 264 // 5.3.2.1 Set the mediaKeys attribute to null. |
263 thisElement.m_mediaKeys.clear(); | 265 thisElement.m_mediaKeys.clear(); |
264 | 266 |
265 // 5.3.2.2 Let this object's attaching media keys value be false. | 267 // 5.3.2.2 Let this object's attaching media keys value be false. |
266 thisElement.m_isAttachingMediaKeys = false; | 268 thisElement.m_isAttachingMediaKeys = false; |
267 | 269 |
(...skipping 11 matching lines...) Expand all Loading... |
279 | 281 |
280 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia(HTMLMediaElement&
element) | 282 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia(HTMLMediaElement&
element) |
281 : m_mediaElement(&element) | 283 : m_mediaElement(&element) |
282 , m_isWaitingForKey(false) | 284 , m_isWaitingForKey(false) |
283 , m_isAttachingMediaKeys(false) | 285 , m_isAttachingMediaKeys(false) |
284 { | 286 { |
285 } | 287 } |
286 | 288 |
287 HTMLMediaElementEncryptedMedia::~HTMLMediaElementEncryptedMedia() | 289 HTMLMediaElementEncryptedMedia::~HTMLMediaElementEncryptedMedia() |
288 { | 290 { |
289 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::~HTMLMediaElementEncryptedMe
dia"); | 291 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
290 } | 292 } |
291 | 293 |
292 const char* HTMLMediaElementEncryptedMedia::supplementName() | 294 const char* HTMLMediaElementEncryptedMedia::supplementName() |
293 { | 295 { |
294 return "HTMLMediaElementEncryptedMedia"; | 296 return "HTMLMediaElementEncryptedMedia"; |
295 } | 297 } |
296 | 298 |
297 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl
ement& element) | 299 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl
ement& element) |
298 { | 300 { |
299 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc
ryptedMedia*>(Supplement<HTMLMediaElement>::from(element, supplementName())); | 301 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc
ryptedMedia*>(Supplement<HTMLMediaElement>::from(element, supplementName())); |
300 if (!supplement) { | 302 if (!supplement) { |
301 supplement = new HTMLMediaElementEncryptedMedia(element); | 303 supplement = new HTMLMediaElementEncryptedMedia(element); |
302 provideTo(element, supplementName(), supplement); | 304 provideTo(element, supplementName(), supplement); |
303 } | 305 } |
304 return *supplement; | 306 return *supplement; |
305 } | 307 } |
306 | 308 |
307 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) | 309 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) |
308 { | 310 { |
309 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(element); | 311 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(element); |
310 return thisElement.m_mediaKeys.get(); | 312 return thisElement.m_mediaKeys.get(); |
311 } | 313 } |
312 | 314 |
313 ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt
ate, HTMLMediaElement& element, MediaKeys* mediaKeys) | 315 ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt
ate, HTMLMediaElement& element, MediaKeys* mediaKeys) |
314 { | 316 { |
315 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(element); | 317 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia
::from(element); |
316 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys current(%p), ne
w(%p)", thisElement.m_mediaKeys.get(), mediaKeys); | 318 DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << " current(" << thisElement.m_mediaKe
ys.get() << "), new(" << mediaKeys << ")"; |
317 | 319 |
318 // From http://w3c.github.io/encrypted-media/#setMediaKeys | 320 // From http://w3c.github.io/encrypted-media/#setMediaKeys |
319 | 321 |
320 // 1. If mediaKeys and the mediaKeys attribute are the same object, | 322 // 1. If mediaKeys and the mediaKeys attribute are the same object, |
321 // return a resolved promise. | 323 // return a resolved promise. |
322 if (thisElement.m_mediaKeys == mediaKeys) | 324 if (thisElement.m_mediaKeys == mediaKeys) |
323 return ScriptPromise::castUndefined(scriptState); | 325 return ScriptPromise::castUndefined(scriptState); |
324 | 326 |
325 // 2. If this object's attaching media keys value is true, return a | 327 // 2. If this object's attaching media keys value is true, return a |
326 // promise rejected with an InvalidStateError. | 328 // promise rejected with an InvalidStateError. |
(...skipping 16 matching lines...) Expand all Loading... |
343 initializer.setInitDataType(EncryptedMediaUtils::convertFromInitDataType(ini
tDataType)); | 345 initializer.setInitDataType(EncryptedMediaUtils::convertFromInitDataType(ini
tDataType)); |
344 initializer.setInitData(DOMArrayBuffer::create(initData, initDataLength)); | 346 initializer.setInitData(DOMArrayBuffer::create(initData, initDataLength)); |
345 initializer.setBubbles(false); | 347 initializer.setBubbles(false); |
346 initializer.setCancelable(false); | 348 initializer.setCancelable(false); |
347 | 349 |
348 return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer); | 350 return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer); |
349 } | 351 } |
350 | 352 |
351 void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType ini
tDataType, const unsigned char* initData, unsigned initDataLength) | 353 void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType ini
tDataType, const unsigned char* initData, unsigned initDataLength) |
352 { | 354 { |
353 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted"); | 355 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
354 | 356 |
355 Event* event; | 357 Event* event; |
356 if (m_mediaElement->isMediaDataCORSSameOrigin(m_mediaElement->getExecutionCo
ntext()->getSecurityOrigin())) { | 358 if (m_mediaElement->isMediaDataCORSSameOrigin(m_mediaElement->getExecutionCo
ntext()->getSecurityOrigin())) { |
357 event = createEncryptedEvent(initDataType, initData, initDataLength); | 359 event = createEncryptedEvent(initDataType, initData, initDataLength); |
358 } else { | 360 } else { |
359 // Current page is not allowed to see content from the media file, | 361 // Current page is not allowed to see content from the media file, |
360 // so don't return the initData. However, they still get an event. | 362 // so don't return the initData. However, they still get an event. |
361 event = createEncryptedEvent(WebEncryptedMediaInitDataType::Unknown, nul
lptr, 0); | 363 event = createEncryptedEvent(WebEncryptedMediaInitDataType::Unknown, nul
lptr, 0); |
362 } | 364 } |
363 | 365 |
364 event->setTarget(m_mediaElement); | 366 event->setTarget(m_mediaElement); |
365 m_mediaElement->scheduleEvent(event); | 367 m_mediaElement->scheduleEvent(event); |
366 } | 368 } |
367 | 369 |
368 void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey() | 370 void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey() |
369 { | 371 { |
370 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKe
y"); | 372 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
371 | 373 |
372 // From https://w3c.github.io/encrypted-media/#queue-waitingforkey: | 374 // From https://w3c.github.io/encrypted-media/#queue-waitingforkey: |
373 // It should only be called when the HTMLMediaElement object is potentially | 375 // It should only be called when the HTMLMediaElement object is potentially |
374 // playing and its readyState is equal to HAVE_FUTURE_DATA or greater. | 376 // playing and its readyState is equal to HAVE_FUTURE_DATA or greater. |
375 // FIXME: Is this really required? | 377 // FIXME: Is this really required? |
376 | 378 |
377 // 1. Let the media element be the specified HTMLMediaElement object. | 379 // 1. Let the media element be the specified HTMLMediaElement object. |
378 // 2. If the media element's waiting for key value is false, queue a task | 380 // 2. If the media element's waiting for key value is false, queue a task |
379 // to fire a simple event named waitingforkey at the media element. | 381 // to fire a simple event named waitingforkey at the media element. |
380 if (!m_isWaitingForKey) { | 382 if (!m_isWaitingForKey) { |
381 Event* event = Event::create(EventTypeNames::waitingforkey); | 383 Event* event = Event::create(EventTypeNames::waitingforkey); |
382 event->setTarget(m_mediaElement); | 384 event->setTarget(m_mediaElement); |
383 m_mediaElement->scheduleEvent(event); | 385 m_mediaElement->scheduleEvent(event); |
384 } | 386 } |
385 | 387 |
386 // 3. Set the media element's waiting for key value to true. | 388 // 3. Set the media element's waiting for key value to true. |
387 m_isWaitingForKey = true; | 389 m_isWaitingForKey = true; |
388 | 390 |
389 // 4. Suspend playback. | 391 // 4. Suspend playback. |
390 // (Already done on the Chromium side by the decryptors.) | 392 // (Already done on the Chromium side by the decryptors.) |
391 } | 393 } |
392 | 394 |
393 void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey() | 395 void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey() |
394 { | 396 { |
395 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForK
ey"); | 397 DVLOG(EME_LOG_LEVEL) << __FUNCTION__; |
396 | 398 |
397 // Logic is on the Chromium side to attempt to resume playback when a new | 399 // Logic is on the Chromium side to attempt to resume playback when a new |
398 // key is available. However, |m_isWaitingForKey| needs to be cleared so | 400 // key is available. However, |m_isWaitingForKey| needs to be cleared so |
399 // that a later waitingForKey() call can generate the event. | 401 // that a later waitingForKey() call can generate the event. |
400 m_isWaitingForKey = false; | 402 m_isWaitingForKey = false; |
401 } | 403 } |
402 | 404 |
403 WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionMod
ule() | 405 WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionMod
ule() |
404 { | 406 { |
405 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | 407 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
406 } | 408 } |
407 | 409 |
408 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) | 410 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) |
409 { | 411 { |
410 visitor->trace(m_mediaElement); | 412 visitor->trace(m_mediaElement); |
411 visitor->trace(m_mediaKeys); | 413 visitor->trace(m_mediaKeys); |
412 Supplement<HTMLMediaElement>::trace(visitor); | 414 Supplement<HTMLMediaElement>::trace(visitor); |
413 } | 415 } |
414 | 416 |
415 } // namespace blink | 417 } // namespace blink |
OLD | NEW |