| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 30 #include "core/dom/ContextLifecycleObserver.h" | 30 #include "core/dom/ContextLifecycleObserver.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/ThreadLocalEventNames.h" | 32 #include "core/events/ThreadLocalEventNames.h" |
| 33 #include "core/html/HTMLMediaElement.h" | 33 #include "core/html/HTMLMediaElement.h" |
| 34 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" | 34 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
| 35 #include "platform/ContentType.h" | 35 #include "platform/ContentType.h" |
| 36 #include "platform/Logging.h" | 36 #include "platform/Logging.h" |
| 37 #include "platform/MIMETypeRegistry.h" | 37 #include "platform/MIMETypeRegistry.h" |
| 38 #include "platform/UUID.h" | 38 #include "platform/UUID.h" |
| 39 #include "platform/drm/ContentDecryptionModule.h" | 39 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebContentDecryptionModule.h" |
| 40 #include "wtf/HashSet.h" | 41 #include "wtf/HashSet.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S
tring& contentType) | 45 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S
tring& contentType) |
| 45 { | 46 { |
| 46 ASSERT(!keySystem.isEmpty()); | 47 ASSERT(!keySystem.isEmpty()); |
| 47 | 48 |
| 48 ContentType type(contentType); | 49 ContentType type(contentType); |
| 49 String codecs = type.parameter("codecs"); | 50 String codecs = type.parameter("codecs"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 } | 63 } |
| 63 | 64 |
| 64 // 2. If keySystem is not one of the user agent's supported Key Systems, thr
ow a NotSupportedError and abort these steps. | 65 // 2. If keySystem is not one of the user agent's supported Key Systems, thr
ow a NotSupportedError and abort these steps. |
| 65 if (!isKeySystemSupportedWithContentType(keySystem, "")) { | 66 if (!isKeySystemSupportedWithContentType(keySystem, "")) { |
| 66 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem
+ "' key system is not supported."); | 67 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem
+ "' key system is not supported."); |
| 67 return nullptr; | 68 return nullptr; |
| 68 } | 69 } |
| 69 | 70 |
| 70 // 3. Let cdm be the content decryption module corresponding to keySystem. | 71 // 3. Let cdm be the content decryption module corresponding to keySystem. |
| 71 // 4. Load cdm if necessary. | 72 // 4. Load cdm if necessary. |
| 72 OwnPtr<ContentDecryptionModule> cdm = ContentDecryptionModule::create(keySys
tem); | 73 OwnPtr<blink::WebContentDecryptionModule> cdm = adoptPtr(blink::Platform::cu
rrent()->createContentDecryptionModule(keySystem)); |
| 73 if (!cdm) { | 74 if (!cdm) { |
| 74 exceptionState.throwDOMException(NotSupportedError, "A content decryptio
n module could not be loaded for the '" + keySystem + "' key system."); | 75 exceptionState.throwDOMException(NotSupportedError, "A content decryptio
n module could not be loaded for the '" + keySystem + "' key system."); |
| 75 return nullptr; | 76 return nullptr; |
| 76 } | 77 } |
| 77 | 78 |
| 78 // 5. Create a new MediaKeys object. | 79 // 5. Create a new MediaKeys object. |
| 79 // 5.1 Let the keySystem attribute be keySystem. | 80 // 5.1 Let the keySystem attribute be keySystem. |
| 80 // 6. Return the new object to the caller. | 81 // 6. Return the new object to the caller. |
| 81 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); | 82 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); |
| 82 } | 83 } |
| 83 | 84 |
| 84 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn
Ptr<ContentDecryptionModule> cdm) | 85 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn
Ptr<blink::WebContentDecryptionModule> cdm) |
| 85 : ContextLifecycleObserver(context) | 86 : ContextLifecycleObserver(context) |
| 86 , m_mediaElement(0) | 87 , m_mediaElement(0) |
| 87 , m_keySystem(keySystem) | 88 , m_keySystem(keySystem) |
| 88 , m_cdm(cdm) | 89 , m_cdm(cdm) |
| 89 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir
ed) | 90 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir
ed) |
| 90 , m_weakFactory(this) | 91 , m_weakFactory(this) |
| 91 { | 92 { |
| 92 WTF_LOG(Media, "MediaKeys::MediaKeys"); | 93 WTF_LOG(Media, "MediaKeys::MediaKeys"); |
| 93 ScriptWrappable::init(this); | 94 ScriptWrappable::init(this); |
| 94 } | 95 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void MediaKeys::setMediaElement(HTMLMediaElement* element) | 166 void MediaKeys::setMediaElement(HTMLMediaElement* element) |
| 166 { | 167 { |
| 167 // FIXME: Cause HTMLMediaElement::setMediaKeys() to throw an exception if m_
mediaElement is not 0 | 168 // FIXME: Cause HTMLMediaElement::setMediaKeys() to throw an exception if m_
mediaElement is not 0 |
| 168 // and remove the code that prevents the assert below in HTMLMediaElement. | 169 // and remove the code that prevents the assert below in HTMLMediaElement. |
| 169 ASSERT(!m_mediaElement != !element); | 170 ASSERT(!m_mediaElement != !element); |
| 170 m_mediaElement = element; | 171 m_mediaElement = element; |
| 171 } | 172 } |
| 172 | 173 |
| 173 blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule() | 174 blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule() |
| 174 { | 175 { |
| 175 return m_cdm ? m_cdm->contentDecryptionModule() : 0; | 176 return m_cdm.get(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void MediaKeys::initializeNewSessionTimerFired(Timer<MediaKeys>*) | 179 void MediaKeys::initializeNewSessionTimerFired(Timer<MediaKeys>*) |
| 179 { | 180 { |
| 180 ASSERT(m_pendingInitializeNewSessionData.size()); | 181 ASSERT(m_pendingInitializeNewSessionData.size()); |
| 181 | 182 |
| 182 while (!m_pendingInitializeNewSessionData.isEmpty()) { | 183 while (!m_pendingInitializeNewSessionData.isEmpty()) { |
| 183 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi
rst(); | 184 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi
rst(); |
| 184 // FIXME: Refer to the spec to see what needs to be done in blink. | 185 // FIXME: Refer to the spec to see what needs to be done in blink. |
| 185 data.session->initializeNewSession(data.contentType, *data.initData); | 186 data.session->initializeNewSession(data.contentType, *data.initData); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 198 | 199 |
| 199 void MediaKeys::contextDestroyed() | 200 void MediaKeys::contextDestroyed() |
| 200 { | 201 { |
| 201 ContextLifecycleObserver::contextDestroyed(); | 202 ContextLifecycleObserver::contextDestroyed(); |
| 202 | 203 |
| 203 // We don't need the CDM anymore. | 204 // We don't need the CDM anymore. |
| 204 m_cdm.clear(); | 205 m_cdm.clear(); |
| 205 } | 206 } |
| 206 | 207 |
| 207 } | 208 } |
| OLD | NEW |