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

Side by Side Diff: Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp

Issue 946503003: Add HTMLMediaElement.waitingforkey event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename Created 5 years, 10 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 // 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 "config.h" 5 #include "config.h"
6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 void SetMediaKeysHandler::trace(Visitor* visitor) 242 void SetMediaKeysHandler::trace(Visitor* visitor)
243 { 243 {
244 visitor->trace(m_element); 244 visitor->trace(m_element);
245 visitor->trace(m_newMediaKeys); 245 visitor->trace(m_newMediaKeys);
246 ScriptPromiseResolver::trace(visitor); 246 ScriptPromiseResolver::trace(visitor);
247 } 247 }
248 248
249 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() 249 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia()
250 : m_emeMode(EmeModeNotSelected) 250 : m_emeMode(EmeModeNotSelected)
251 , m_isWaitingForKey(false)
251 { 252 {
252 } 253 }
253 254
254 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia) 255 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia)
255 256
256 const char* HTMLMediaElementEncryptedMedia::supplementName() 257 const char* HTMLMediaElementEncryptedMedia::supplementName()
257 { 258 {
258 return "HTMLMediaElementEncryptedMedia"; 259 return "HTMLMediaElementEncryptedMedia";
259 } 260 }
260 261
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 530 }
530 531
531 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { 532 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) {
532 // Send event for v0.1b EME. 533 // Send event for v0.1b EME.
533 RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, ini tDataLength); 534 RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, ini tDataLength);
534 event->setTarget(&element); 535 event->setTarget(&element);
535 element.scheduleEvent(event.release()); 536 element.scheduleEvent(event.release());
536 } 537 }
537 } 538 }
538 539
540 void HTMLMediaElementEncryptedMedia::waitingForKey(HTMLMediaElement& element)
541 {
542 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::waitingForKey");
543
544 // From https://w3c.github.io/encrypted-media/#queue-waitingforkey:
545 // It should only be called when the HTMLMediaElement object is potentially
546 // playing and its readyState is equal to HAVE_FUTURE_DATA or greater.
547 // FIXME: Is this really required?
548
549 // 1. Let the media element be the specified HTMLMediaElement object.
550 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element);
551
552 // 2. If the media element's waiting for key value is false, queue a task
553 // to fire a simple event named waitingforkey at the media element.
554 if (!thisElement.m_isWaitingForKey) {
555 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::waitingf orkey);
556 event->setTarget(&element);
557 element.scheduleEvent(event.release());
558 }
559
560 // 3. Set the media element's waiting for key value to true.
561 thisElement.m_isWaitingForKey = true;
562
563 // 4. Suspend playback.
564 // (Already done on the Chromium side by the decryptors.)
565 }
566
567 void HTMLMediaElementEncryptedMedia::noLongerWaitingForKey(HTMLMediaElement& ele ment)
568 {
569 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::noLongerWaitingForKey");
570
571 // Logic is on the Chromium side to attempt to resume playback when a new
572 // key is available. However, |m_isWaitingForKey| needs to be cleared so
573 // that a later waitingForKey() call can generate the event.
574 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element);
575 thisElement.m_isWaitingForKey = false;
576 }
577
539 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) 578 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element)
540 { 579 {
541 #if ENABLE(OILPAN) 580 #if ENABLE(OILPAN)
542 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 581 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229
543 if (element.isFinalizing()) 582 if (element.isFinalizing())
544 return; 583 return;
545 #endif 584 #endif
546 585
547 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); 586 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element);
548 if (!thisElement.m_mediaKeys) 587 if (!thisElement.m_mediaKeys)
549 return; 588 return;
550 589
551 ASSERT(thisElement.m_emeMode == EmeModeUnprefixed); 590 ASSERT(thisElement.m_emeMode == EmeModeUnprefixed);
552 thisElement.m_mediaKeys.clear(); 591 thisElement.m_mediaKeys.clear();
553 } 592 }
554 593
555 WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionMod ule(HTMLMediaElement& element) 594 WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryptionMod ule(HTMLMediaElement& element)
556 { 595 {
557 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); 596 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element);
558 return thisElement.contentDecryptionModule(); 597 return thisElement.contentDecryptionModule();
559 } 598 }
560 599
561 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) 600 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor)
562 { 601 {
563 visitor->trace(m_mediaKeys); 602 visitor->trace(m_mediaKeys);
564 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); 603 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor);
565 } 604 }
566 605
567 } // namespace blink 606 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698