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 15 matching lines...) Expand all Loading... |
26 #include "config.h" | 26 #include "config.h" |
27 #include "modules/encryptedmedia/MediaKeys.h" | 27 #include "modules/encryptedmedia/MediaKeys.h" |
28 | 28 |
29 #include "bindings/core/v8/ScriptState.h" | 29 #include "bindings/core/v8/ScriptState.h" |
30 #include "core/dom/DOMArrayBuffer.h" | 30 #include "core/dom/DOMArrayBuffer.h" |
31 #include "core/dom/DOMException.h" | 31 #include "core/dom/DOMException.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 #include "core/dom/ExecutionContext.h" | 33 #include "core/dom/ExecutionContext.h" |
34 #include "modules/encryptedmedia/MediaKeySession.h" | 34 #include "modules/encryptedmedia/MediaKeySession.h" |
35 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResultPromise.h" | 35 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResultPromise.h" |
| 36 #include "platform/ContentType.h" |
36 #include "platform/Logging.h" | 37 #include "platform/Logging.h" |
| 38 #include "platform/MIMETypeRegistry.h" |
37 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
38 #include "public/platform/WebContentDecryptionModule.h" | 40 #include "public/platform/WebContentDecryptionModule.h" |
39 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
40 | 42 |
41 namespace blink { | 43 namespace blink { |
42 | 44 |
| 45 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S
tring& contentType) |
| 46 { |
| 47 ASSERT(!keySystem.isEmpty()); |
| 48 |
| 49 ContentType type(contentType); |
| 50 String codecs = type.parameter("codecs"); |
| 51 return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.t
ype(), codecs); |
| 52 } |
| 53 |
43 // A class holding a pending action. | 54 // A class holding a pending action. |
44 class MediaKeys::PendingAction : public GarbageCollectedFinalized<MediaKeys::Pen
dingAction> { | 55 class MediaKeys::PendingAction : public GarbageCollectedFinalized<MediaKeys::Pen
dingAction> { |
45 public: | 56 public: |
46 const Persistent<ContentDecryptionModuleResult> result() const | 57 const Persistent<ContentDecryptionModuleResult> result() const |
47 { | 58 { |
48 return m_result; | 59 return m_result; |
49 } | 60 } |
50 | 61 |
51 const RefPtr<DOMArrayBuffer> data() const | 62 const RefPtr<DOMArrayBuffer> data() const |
52 { | 63 { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 157 |
147 // 5. Run the following steps asynchronously (documented in timerFired()). | 158 // 5. Run the following steps asynchronously (documented in timerFired()). |
148 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res
ult, serverCertificateBuffer.release())); | 159 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res
ult, serverCertificateBuffer.release())); |
149 if (!m_timer.isActive()) | 160 if (!m_timer.isActive()) |
150 m_timer.startOneShot(0, FROM_HERE); | 161 m_timer.startOneShot(0, FROM_HERE); |
151 | 162 |
152 // 6. Return promise. | 163 // 6. Return promise. |
153 return promise; | 164 return promise; |
154 } | 165 } |
155 | 166 |
| 167 bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
pe) |
| 168 { |
| 169 WTF_LOG(Media, "MediaKeys::isTypeSupported(%s, %s)", keySystem.ascii().data(
), contentType.ascii().data()); |
| 170 |
| 171 // 1. If keySystem is an empty string, return false and abort these steps. |
| 172 if (keySystem.isEmpty()) |
| 173 return false; |
| 174 |
| 175 // 2. If keySystem contains an unrecognized or unsupported Key System, retur
n false and abort |
| 176 // these steps. Key system string comparison is case-sensitive. |
| 177 if (!isKeySystemSupportedWithContentType(keySystem, "")) |
| 178 return false; |
| 179 |
| 180 // 3. If contentType is an empty string, return true and abort these steps. |
| 181 if (contentType.isEmpty()) |
| 182 return true; |
| 183 |
| 184 // 4. If the Key System specified by keySystem does not support decrypting t
he container and/or |
| 185 // codec specified by contentType, return false and abort these steps. |
| 186 return isKeySystemSupportedWithContentType(keySystem, contentType); |
| 187 } |
| 188 |
156 void MediaKeys::timerFired(Timer<MediaKeys>*) | 189 void MediaKeys::timerFired(Timer<MediaKeys>*) |
157 { | 190 { |
158 ASSERT(m_pendingActions.size()); | 191 ASSERT(m_pendingActions.size()); |
159 | 192 |
160 // Swap the queue to a local copy to avoid problems if resolving promises | 193 // Swap the queue to a local copy to avoid problems if resolving promises |
161 // run synchronously. | 194 // run synchronously. |
162 HeapDeque<Member<PendingAction> > pendingActions; | 195 HeapDeque<Member<PendingAction> > pendingActions; |
163 pendingActions.swap(m_pendingActions); | 196 pendingActions.swap(m_pendingActions); |
164 | 197 |
165 while (!pendingActions.isEmpty()) { | 198 while (!pendingActions.isEmpty()) { |
(...skipping 24 matching lines...) Expand all Loading... |
190 | 223 |
191 void MediaKeys::contextDestroyed() | 224 void MediaKeys::contextDestroyed() |
192 { | 225 { |
193 ContextLifecycleObserver::contextDestroyed(); | 226 ContextLifecycleObserver::contextDestroyed(); |
194 | 227 |
195 // We don't need the CDM anymore. | 228 // We don't need the CDM anymore. |
196 m_cdm.clear(); | 229 m_cdm.clear(); |
197 } | 230 } |
198 | 231 |
199 } // namespace blink | 232 } // namespace blink |
OLD | NEW |