| 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 24 matching lines...) Expand all Loading... |
| 35 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" | 35 #include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
| 36 #include "modules/encryptedmedia/MediaKeySession.h" | 36 #include "modules/encryptedmedia/MediaKeySession.h" |
| 37 #include "modules/encryptedmedia/MediaKeysController.h" | 37 #include "modules/encryptedmedia/MediaKeysController.h" |
| 38 #include "platform/ContentType.h" | 38 #include "platform/ContentType.h" |
| 39 #include "platform/Logging.h" | 39 #include "platform/Logging.h" |
| 40 #include "platform/MIMETypeRegistry.h" | 40 #include "platform/MIMETypeRegistry.h" |
| 41 #include "platform/Timer.h" | 41 #include "platform/Timer.h" |
| 42 #include "platform/UUID.h" | 42 #include "platform/UUID.h" |
| 43 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
| 44 #include "public/platform/WebContentDecryptionModule.h" | 44 #include "public/platform/WebContentDecryptionModule.h" |
| 45 #include "wtf/ArrayBuffer.h" |
| 46 #include "wtf/ArrayBufferView.h" |
| 45 #include "wtf/RefPtr.h" | 47 #include "wtf/RefPtr.h" |
| 46 #include "wtf/Uint8Array.h" | |
| 47 | 48 |
| 48 #if ASSERT_ENABLED | 49 #if ASSERT_ENABLED |
| 49 namespace { | 50 namespace { |
| 50 | 51 |
| 51 // The list of possible values for |sessionType| passed to createSession(). | 52 // The list of possible values for |sessionType| passed to createSession(). |
| 52 const char* kTemporary = "temporary"; | 53 const char* kTemporary = "temporary"; |
| 53 const char* kPersistent = "persistent"; | 54 const char* kPersistent = "persistent"; |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 #endif | 57 #endif |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Step 4.4 of MediaKeys::create(): | 191 // Step 4.4 of MediaKeys::create(): |
| 191 // 4.4.1 Set the keySystem attribute to keySystem. | 192 // 4.4.1 Set the keySystem attribute to keySystem. |
| 192 ASSERT(!m_keySystem.isEmpty()); | 193 ASSERT(!m_keySystem.isEmpty()); |
| 193 } | 194 } |
| 194 | 195 |
| 195 MediaKeys::~MediaKeys() | 196 MediaKeys::~MediaKeys() |
| 196 { | 197 { |
| 197 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); | 198 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); |
| 198 } | 199 } |
| 199 | 200 |
| 200 ScriptPromise MediaKeys::createSession(ScriptState* scriptState, const String& i
nitDataType, Uint8Array* initData, const String& sessionType) | 201 ScriptPromise MediaKeys::createSession(ScriptState* scriptState, const String& i
nitDataType, ArrayBufferView* initData, const String& sessionType) |
| 201 { | 202 { |
| 202 WTF_LOG(Media, "MediaKeys(%p)::createSession(%s, %d)", this, initDataType.as
cii().data(), initData->length()); | 203 WTF_LOG(Media, "MediaKeys(%p)::createSession(%s, %d)", this, initDataType.as
cii().data(), initData->byteLength()); |
| 203 | 204 |
| 204 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-createsession>: | 205 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-createsession>: |
| 205 // The createSession(initDataType, initData, sessionType) method creates a | 206 // The createSession(initDataType, initData, sessionType) method creates a |
| 206 // new MediaKeySession object for the initData. It must run the following st
eps: | 207 // new MediaKeySession object for the initData. It must run the following st
eps: |
| 207 | 208 |
| 208 // 1. If initDataType is an empty string, return a promise rejected with a | 209 // 1. If initDataType is an empty string, return a promise rejected with a |
| 209 // new DOMException whose name is "InvalidAccessError". | 210 // new DOMException whose name is "InvalidAccessError". |
| 210 if (initDataType.isEmpty()) { | 211 if (initDataType.isEmpty()) { |
| 211 return createRejectedPromise(scriptState, InvalidAccessError, "The initD
ataType parameter is empty."); | 212 return createRejectedPromise(scriptState, InvalidAccessError, "The initD
ataType parameter is empty."); |
| 212 } | 213 } |
| 213 | 214 |
| 214 // 2. If initData is an empty array, return a promise rejected with a new | 215 // 2. If initData is an empty array, return a promise rejected with a new |
| 215 // DOMException whose name is"InvalidAccessError". | 216 // DOMException whose name is"InvalidAccessError". |
| 216 if (!initData->length()) { | 217 if (!initData->byteLength()) { |
| 217 return createRejectedPromise(scriptState, InvalidAccessError, "The initD
ata parameter is empty."); | 218 return createRejectedPromise(scriptState, InvalidAccessError, "The initD
ata parameter is empty."); |
| 218 } | 219 } |
| 219 | 220 |
| 220 // 3. If initDataType is not an initialization data type supported by the | 221 // 3. If initDataType is not an initialization data type supported by the |
| 221 // content decryption module corresponding to the keySystem, return a | 222 // content decryption module corresponding to the keySystem, return a |
| 222 // promise rejected with a new DOMException whose name is | 223 // promise rejected with a new DOMException whose name is |
| 223 // "NotSupportedError". String comparison is case-sensitive. | 224 // "NotSupportedError". String comparison is case-sensitive. |
| 224 if (!isKeySystemSupportedWithInitDataType(m_keySystem, initDataType)) { | 225 if (!isKeySystemSupportedWithInitDataType(m_keySystem, initDataType)) { |
| 225 return createRejectedPromise(scriptState, NotSupportedError, "The initia
lization data type '" + initDataType + "' is not supported by the key system."); | 226 return createRejectedPromise(scriptState, NotSupportedError, "The initia
lization data type '" + initDataType + "' is not supported by the key system."); |
| 226 } | 227 } |
| 227 | 228 |
| 228 // 4. If sessionType is not supported by the content decryption module | 229 // 4. If sessionType is not supported by the content decryption module |
| 229 // corresponding to the keySystem, return a promise rejected with a new | 230 // corresponding to the keySystem, return a promise rejected with a new |
| 230 // DOMException whose name is "NotSupportedError". | 231 // DOMException whose name is "NotSupportedError". |
| 231 // Since this is typed by the IDL, we should not see any invalid values. | 232 // Since this is typed by the IDL, we should not see any invalid values. |
| 232 // FIXME: Check whether sessionType is actually supported by the CDM. | 233 // FIXME: Check whether sessionType is actually supported by the CDM. |
| 233 ASSERT(sessionType == kTemporary || sessionType == kPersistent); | 234 ASSERT(sessionType == kTemporary || sessionType == kPersistent); |
| 234 | 235 |
| 235 // 5. Let init data be a copy of the contents of the initData parameter. | 236 // 5. Let init data be a copy of the contents of the initData parameter. |
| 236 RefPtr<Uint8Array> initDataCopy = Uint8Array::create(initData->data(), initD
ata->length()); | 237 RefPtr<ArrayBuffer> initDataCopy = ArrayBuffer::create(initData->baseAddress
(), initData->byteLength()); |
| 237 | 238 |
| 238 // 6. Let promise be a new promise. | 239 // 6. Let promise be a new promise. |
| 239 // 7. Asynchronously create and initialize the session. | 240 // 7. Asynchronously create and initialize the session. |
| 240 // 8. Return promise. | 241 // 8. Return promise. |
| 241 return MediaKeySession::create(scriptState, this, initDataType, initDataCopy
.release(), sessionType); | 242 return MediaKeySession::create(scriptState, this, initDataType, initDataCopy
.release(), sessionType); |
| 242 } | 243 } |
| 243 | 244 |
| 244 bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
pe) | 245 bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
pe) |
| 245 { | 246 { |
| 246 WTF_LOG(Media, "MediaKeys::isTypeSupported(%s, %s)", keySystem.ascii().data(
), contentType.ascii().data()); | 247 WTF_LOG(Media, "MediaKeys::isTypeSupported(%s, %s)", keySystem.ascii().data(
), contentType.ascii().data()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 274 | 275 |
| 275 void MediaKeys::contextDestroyed() | 276 void MediaKeys::contextDestroyed() |
| 276 { | 277 { |
| 277 ContextLifecycleObserver::contextDestroyed(); | 278 ContextLifecycleObserver::contextDestroyed(); |
| 278 | 279 |
| 279 // We don't need the CDM anymore. | 280 // We don't need the CDM anymore. |
| 280 m_cdm.clear(); | 281 m_cdm.clear(); |
| 281 } | 282 } |
| 282 | 283 |
| 283 } | 284 } |
| OLD | NEW |