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 "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" | |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
11 #include "bindings/core/v8/ScriptState.h" | |
12 #include "core/dom/DOMException.h" | |
9 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
10 #include "core/html/HTMLMediaElement.h" | 14 #include "core/html/HTMLMediaElement.h" |
11 #include "core/html/MediaKeyError.h" | 15 #include "core/html/MediaKeyError.h" |
12 #include "core/html/MediaKeyEvent.h" | 16 #include "core/html/MediaKeyEvent.h" |
13 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" | 17 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" |
14 #include "modules/encryptedmedia/MediaKeys.h" | 18 #include "modules/encryptedmedia/MediaKeys.h" |
19 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" | |
20 #include "platform/ContentDecryptionModuleResult.h" | |
15 #include "platform/Logging.h" | 21 #include "platform/Logging.h" |
16 #include "platform/RuntimeEnabledFeatures.h" | 22 #include "platform/RuntimeEnabledFeatures.h" |
23 #include "wtf/Functional.h" | |
17 #include "wtf/Uint8Array.h" | 24 #include "wtf/Uint8Array.h" |
18 | 25 |
19 namespace blink { | 26 namespace blink { |
20 | 27 |
21 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, blink::WebMediaPlayer::MediaKeyException exception, Exce ptionState& exceptionState) | 28 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, blink::WebMediaPlayer::MediaKeyException exception, Exce ptionState& exceptionState) |
22 { | 29 { |
23 switch (exception) { | 30 switch (exception) { |
24 case blink::WebMediaPlayer::MediaKeyExceptionNoError: | 31 case blink::WebMediaPlayer::MediaKeyExceptionNoError: |
25 return; | 32 return; |
26 case blink::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState: | 33 case blink::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState: |
27 exceptionState.throwDOMException(InvalidStateError, "The player is in an invalid state."); | 34 exceptionState.throwDOMException(InvalidStateError, "The player is in an invalid state."); |
28 return; | 35 return; |
29 case blink::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported: | 36 case blink::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported: |
30 exceptionState.throwDOMException(NotSupportedError, "The key system prov ided ('" + keySystem +"') is not supported."); | 37 exceptionState.throwDOMException(NotSupportedError, "The key system prov ided ('" + keySystem +"') is not supported."); |
31 return; | 38 return; |
32 case blink::WebMediaPlayer::MediaKeyExceptionInvalidAccess: | 39 case blink::WebMediaPlayer::MediaKeyExceptionInvalidAccess: |
33 exceptionState.throwDOMException(InvalidAccessError, "The session ID pro vided ('" + sessionId + "') is invalid."); | 40 exceptionState.throwDOMException(InvalidAccessError, "The session ID pro vided ('" + sessionId + "') is invalid."); |
34 return; | 41 return; |
35 } | 42 } |
36 | 43 |
37 ASSERT_NOT_REACHED(); | 44 ASSERT_NOT_REACHED(); |
38 return; | 45 return; |
39 } | 46 } |
40 | 47 |
48 // This class allows MediaKeys to be set asynchronously. | |
49 class SetMediaKeysHandler : public ScriptPromiseResolver { | |
50 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); | |
51 | |
52 public: | |
53 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); | |
54 virtual ~SetMediaKeysHandler(); | |
55 | |
56 private: | |
57 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*); | |
58 void timerFired(Timer<SetMediaKeysHandler>*); | |
59 | |
60 void ClearExistingMediaKeys(); | |
61 void SetNewMediaKeys(); | |
62 void Finish(); | |
63 | |
64 void ReportSetFailed(ExceptionCode, const String& errorMessage); | |
65 | |
66 RawPtrWillBeMember<HTMLMediaElement> m_element; | |
67 Persistent<MediaKeys> m_newMediaKeys; | |
68 Timer<SetMediaKeysHandler> m_timer; | |
69 }; | |
70 | |
71 typedef Function<void()> SuccessCallback; | |
72 typedef Function<void(ExceptionCode, const String&)> FailureCallback; | |
73 | |
74 // Represents the result used when setContentDecryptionModule() is called. | |
75 // Calls |success| if result is resolved, |failure| is result is rejected. | |
76 class SetContentDecryptionModuleResult FINAL : public ContentDecryptionModuleRes ult { | |
77 public: | |
78 SetContentDecryptionModuleResult(SuccessCallback success, FailureCallback fa ilure) | |
79 : m_successCallback(success) | |
80 , m_failureCallback(failure) | |
81 { | |
82 } | |
83 | |
84 // ContentDecryptionModuleResult implementation. | |
85 virtual void complete() OVERRIDE | |
86 { | |
87 m_successCallback(); | |
88 } | |
89 | |
90 virtual void completeWithSession(blink::WebContentDecryptionModuleResult::Se ssionStatus status) OVERRIDE | |
91 { | |
92 ASSERT_NOT_REACHED(); | |
93 m_failureCallback(InvalidStateError, "Unexpected completion."); | |
94 } | |
95 | |
96 virtual void completeWithError(blink::WebContentDecryptionModuleException co de, unsigned long systemCode, const blink::WebString& message) OVERRIDE | |
97 { | |
98 m_failureCallback(WebCdmExceptionToExceptionCode(code), message); | |
99 } | |
100 | |
101 private: | |
102 SuccessCallback m_successCallback; | |
103 FailureCallback m_failureCallback; | |
104 }; | |
105 | |
106 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys) | |
107 { | |
108 RefPtr<SetMediaKeysHandler> handler = adoptRef(new SetMediaKeysHandler(scrip tState, element, mediaKeys)); | |
109 handler->suspendIfNeeded(); | |
110 handler->keepAliveWhilePending(); | |
111 return handler->promise(); | |
112 } | |
113 | |
114 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem ent& element, MediaKeys* mediaKeys) | |
115 : ScriptPromiseResolver(scriptState) | |
116 , m_element(element) | |
117 , m_newMediaKeys(mediaKeys) | |
118 , m_timer(this, &SetMediaKeysHandler::timerFired) | |
119 { | |
120 WTF_LOG(Media, "SetMediaKeysHandler::SetMediaKeysHandler"); | |
121 | |
122 // 3. Run the remaining steps asynchronously. | |
123 m_timer.startOneShot(0, FROM_HERE); | |
124 } | |
125 | |
126 SetMediaKeysHandler::~SetMediaKeysHandler() | |
127 { | |
128 } | |
129 | |
130 void SetMediaKeysHandler::timerFired(Timer<SetMediaKeysHandler>*) | |
131 { | |
132 ClearExistingMediaKeys(); | |
133 } | |
134 | |
135 void SetMediaKeysHandler::ClearExistingMediaKeys() | |
136 { | |
137 WTF_LOG(Media, "SetMediaKeysHandler::ClearExistingMediaKeys"); | |
138 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
139 | |
140 // 3.1 If mediaKeys is not null, it is already in use by another media | |
141 // element, and the user agent is unable to use it with this element, | |
142 // reject promise with a new DOMException whose name is | |
143 // "QuotaExceededError". | |
144 // FIXME: Need to check whether mediaKeys is already in use by another | |
145 // media element. | |
146 // 3.2 If the mediaKeys attribute is not null, run the following steps: | |
147 if (thisElement.m_mediaKeys) { | |
148 // 3.2.1 If the user agent or CDM do not support removing the | |
149 // association, return a promise rejected with a new DOMException | |
150 // whose name is "NotSupportedError". | |
151 // (supported by blink). | |
152 // 3.2.2 If the association cannot currently be removed (i.e. during | |
153 // playback), return a promise rejected with a new DOMException | |
154 // whose name is "InvalidStateError". | |
155 if (m_element->webMediaPlayer()) { | |
156 reject(DOMException::create(InvalidStateError, "The existing MediaKe ys object cannot be removed while a media resource is loaded.")); | |
157 return; | |
158 } | |
159 | |
160 // (next 2 steps not required as there is no player connected). | |
161 // 3.2.3 Stop using the CDM instance represented by the mediaKeys | |
162 // attribute to decrypt media data and remove the association | |
163 // with the media element. | |
164 // 3.2.4 If the preceding step failed, ... | |
ddorwin
2014/08/14 01:26:34
You might as well include the full text since it's
jrummell
2014/08/14 18:30:25
Done.
| |
165 } | |
166 | |
167 // MediaKeys not currently set or no player connected, so continue on. | |
168 SetNewMediaKeys(); | |
169 } | |
170 | |
171 void SetMediaKeysHandler::SetNewMediaKeys() | |
172 { | |
173 WTF_LOG(Media, "SetMediaKeysHandler::SetNewMediaKeys"); | |
174 | |
175 // 3.3 If mediaKeys is not null, run the following steps: | |
176 if (m_newMediaKeys) { | |
177 // 3.3.1 Associate the CDM instance represented by mediaKeys with the | |
178 // media element for decrypting media data. | |
179 // 3.3.2 If the preceding step failed, run the following steps: | |
180 // (done in ReportSetFailed()). | |
181 // 3.3.3 Run the Attempt to Resume Playback If Necessary algorithm on | |
182 // the media element. The user agent may choose to skip this | |
183 // step if it knows resuming will fail (i.e. mediaKeys has no | |
184 // sessions). | |
185 // (Handled in Chromium). | |
186 if (m_element->webMediaPlayer()) { | |
187 SuccessCallback successCallback = bind(&SetMediaKeysHandler::Finish, this); | |
188 FailureCallback failureCallback = bind<ExceptionCode, const String&> (&SetMediaKeysHandler::ReportSetFailed, this); | |
189 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback, failureCallback); | |
190 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result()); | |
191 | |
192 // Don't do anything more until |result| is resolved (or rejected). | |
193 return; | |
194 } | |
195 } | |
196 | |
197 // MediaKeys doesn't need to be set on the player, so continue on. | |
198 Finish(); | |
199 } | |
200 | |
201 void SetMediaKeysHandler::Finish() | |
202 { | |
203 WTF_LOG(Media, "SetMediaKeysHandler::Finish"); | |
204 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
205 | |
206 // 3.4 Set the mediaKeys attribute to mediaKeys. | |
207 thisElement.m_mediaKeys = m_newMediaKeys; | |
208 | |
209 // 3.5 Resolve promise with undefined. | |
210 resolve(); | |
211 } | |
212 | |
213 void SetMediaKeysHandler::ReportSetFailed(ExceptionCode code, const String& erro rMessage) | |
214 { | |
215 WTF_LOG(Media, "SetMediaKeysHandler::ReportSetFailed"); | |
216 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
217 | |
218 // 3.3.2 If the preceding step failed, run the following steps: | |
219 // 3.3.2.1 Set the mediaKeys attribute to null. | |
220 thisElement.m_mediaKeys.clear(); | |
221 | |
222 // 3.3.2.2 Reject promise with a new DOMException whose name is the | |
223 // appropriate error name and that has an appropriate message. | |
224 reject(DOMException::create(code, errorMessage)); | |
225 } | |
226 | |
41 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() | 227 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() |
42 : m_emeMode(EmeModeNotSelected) | 228 : m_emeMode(EmeModeNotSelected) |
43 { | 229 { |
44 } | 230 } |
45 | 231 |
46 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia) | 232 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia) |
47 | 233 |
48 const char* HTMLMediaElementEncryptedMedia::supplementName() | 234 const char* HTMLMediaElementEncryptedMedia::supplementName() |
49 { | 235 { |
50 return "HTMLMediaElementEncryptedMedia"; | 236 return "HTMLMediaElementEncryptedMedia"; |
51 } | 237 } |
52 | 238 |
53 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl ement& element) | 239 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl ement& element) |
54 { | 240 { |
55 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc ryptedMedia*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supplementNa me())); | 241 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc ryptedMedia*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supplementNa me())); |
56 if (!supplement) { | 242 if (!supplement) { |
57 supplement = new HTMLMediaElementEncryptedMedia(); | 243 supplement = new HTMLMediaElementEncryptedMedia(); |
58 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); | 244 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); |
59 } | 245 } |
60 return *supplement; | 246 return *supplement; |
61 } | 247 } |
62 | 248 |
63 bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode, ExceptionState& exceptionState) | 249 bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode) |
64 { | 250 { |
65 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) { | 251 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) |
66 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
67 return false; | 252 return false; |
68 } | 253 |
69 m_emeMode = emeMode; | 254 m_emeMode = emeMode; |
70 return true; | 255 return true; |
71 } | 256 } |
72 | 257 |
73 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule() | 258 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule() |
74 { | 259 { |
75 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | 260 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
76 } | 261 } |
77 | 262 |
78 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) | 263 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) |
79 { | 264 { |
80 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 265 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
81 return thisElement.m_mediaKeys.get(); | 266 return thisElement.m_mediaKeys.get(); |
82 } | 267 } |
83 | 268 |
84 void HTMLMediaElementEncryptedMedia::setMediaKeysInternal(HTMLMediaElement& elem ent, MediaKeys* mediaKeys) | 269 ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt ate, HTMLMediaElement& element, MediaKeys* mediaKeys) |
85 { | 270 { |
86 if (m_mediaKeys == mediaKeys) | 271 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
87 return; | 272 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys current(%p), ne w(%p)", thisElement.m_mediaKeys.get(), mediaKeys); |
88 | 273 |
89 ASSERT(m_emeMode == EmeModeUnprefixed); | 274 if (!thisElement.setEmeMode(EmeModeUnprefixed)) |
90 m_mediaKeys = mediaKeys; | 275 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allo wed.")); |
91 | 276 |
92 // If a player is connected, tell it that the CDM has changed. | 277 // 1. If mediaKeys and the mediaKeys attribute are the same object, return |
93 if (element.webMediaPlayer()) | 278 // a promise resolved with undefined. |
94 element.webMediaPlayer()->setContentDecryptionModule(contentDecryptionMo dule()); | 279 if (thisElement.m_mediaKeys == mediaKeys) |
95 } | 280 return ScriptPromise::cast(scriptState, V8ValueTraits<V8UndefinedType>:: toV8Value(V8UndefinedType(), scriptState->context()->Global(), scriptState->isol ate())); |
96 | 281 |
97 void HTMLMediaElementEncryptedMedia::setMediaKeys(HTMLMediaElement& element, Med iaKeys* mediaKeys, ExceptionState& exceptionState) | 282 // 2. Let promise be a new promise. Remaining steps done in handler. |
98 { | 283 return SetMediaKeysHandler::create(scriptState, element, mediaKeys); |
99 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys"); | |
100 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | |
101 | |
102 if (!thisElement.setEmeMode(EmeModeUnprefixed, exceptionState)) | |
103 return; | |
104 | |
105 thisElement.setMediaKeysInternal(element, mediaKeys); | |
106 } | 284 } |
107 | 285 |
108 // Create a MediaKeyNeededEvent for WD EME. | 286 // Create a MediaKeyNeededEvent for WD EME. |
109 static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentTyp e, const unsigned char* initData, unsigned initDataLength) | 287 static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentTyp e, const unsigned char* initData, unsigned initDataLength) |
110 { | 288 { |
111 MediaKeyNeededEventInit initializer; | 289 MediaKeyNeededEventInit initializer; |
112 initializer.contentType = contentType; | 290 initializer.contentType = contentType; |
113 initializer.initData = Uint8Array::create(initData, initDataLength); | 291 initializer.initData = Uint8Array::create(initData, initDataLength); |
114 initializer.bubbles = false; | 292 initializer.bubbles = false; |
115 initializer.cancelable = false; | 293 initializer.cancelable = false; |
(...skipping 16 matching lines...) Expand all Loading... | |
132 | 310 |
133 void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& element, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionStat e& exceptionState) | 311 void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& element, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionStat e& exceptionState) |
134 { | 312 { |
135 HTMLMediaElementEncryptedMedia::from(element).generateKeyRequest(element.web MediaPlayer(), keySystem, initData, exceptionState); | 313 HTMLMediaElementEncryptedMedia::from(element).generateKeyRequest(element.web MediaPlayer(), keySystem, initData, exceptionState); |
136 } | 314 } |
137 | 315 |
138 void HTMLMediaElementEncryptedMedia::generateKeyRequest(blink::WebMediaPlayer* w ebMediaPlayer, const String& keySystem, PassRefPtr<Uint8Array> initData, Excepti onState& exceptionState) | 316 void HTMLMediaElementEncryptedMedia::generateKeyRequest(blink::WebMediaPlayer* w ebMediaPlayer, const String& keySystem, PassRefPtr<Uint8Array> initData, Excepti onState& exceptionState) |
139 { | 317 { |
140 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest"); | 318 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest"); |
141 | 319 |
142 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 320 if (!setEmeMode(EmeModePrefixed)) { |
321 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
143 return; | 322 return; |
323 } | |
144 | 324 |
145 if (keySystem.isEmpty()) { | 325 if (keySystem.isEmpty()) { |
146 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 326 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
147 return; | 327 return; |
148 } | 328 } |
149 | 329 |
150 if (!webMediaPlayer) { | 330 if (!webMediaPlayer) { |
151 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); | 331 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); |
152 return; | 332 return; |
153 } | 333 } |
(...skipping 16 matching lines...) Expand all Loading... | |
170 | 350 |
171 void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& element, con st String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initDat a, const String& sessionId, ExceptionState& exceptionState) | 351 void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& element, con st String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initDat a, const String& sessionId, ExceptionState& exceptionState) |
172 { | 352 { |
173 HTMLMediaElementEncryptedMedia::from(element).addKey(element.webMediaPlayer( ), keySystem, key, initData, sessionId, exceptionState); | 353 HTMLMediaElementEncryptedMedia::from(element).addKey(element.webMediaPlayer( ), keySystem, key, initData, sessionId, exceptionState); |
174 } | 354 } |
175 | 355 |
176 void HTMLMediaElementEncryptedMedia::addKey(blink::WebMediaPlayer* webMediaPlaye r, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> i nitData, const String& sessionId, ExceptionState& exceptionState) | 356 void HTMLMediaElementEncryptedMedia::addKey(blink::WebMediaPlayer* webMediaPlaye r, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> i nitData, const String& sessionId, ExceptionState& exceptionState) |
177 { | 357 { |
178 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitAddKey"); | 358 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitAddKey"); |
179 | 359 |
180 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 360 if (!setEmeMode(EmeModePrefixed)) { |
361 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
181 return; | 362 return; |
363 } | |
182 | 364 |
183 if (keySystem.isEmpty()) { | 365 if (keySystem.isEmpty()) { |
184 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 366 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
185 return; | 367 return; |
186 } | 368 } |
187 | 369 |
188 if (!key) { | 370 if (!key) { |
189 exceptionState.throwDOMException(SyntaxError, "The key provided is inval id."); | 371 exceptionState.throwDOMException(SyntaxError, "The key provided is inval id."); |
190 return; | 372 return; |
191 } | 373 } |
(...skipping 26 matching lines...) Expand all Loading... | |
218 | 400 |
219 void HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest(HTMLMediaElement& el ement, const String& keySystem, const String& sessionId, ExceptionState& excepti onState) | 401 void HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest(HTMLMediaElement& el ement, const String& keySystem, const String& sessionId, ExceptionState& excepti onState) |
220 { | 402 { |
221 HTMLMediaElementEncryptedMedia::from(element).cancelKeyRequest(element.webMe diaPlayer(), keySystem, sessionId, exceptionState); | 403 HTMLMediaElementEncryptedMedia::from(element).cancelKeyRequest(element.webMe diaPlayer(), keySystem, sessionId, exceptionState); |
222 } | 404 } |
223 | 405 |
224 void HTMLMediaElementEncryptedMedia::cancelKeyRequest(blink::WebMediaPlayer* web MediaPlayer, const String& keySystem, const String& sessionId, ExceptionState& e xceptionState) | 406 void HTMLMediaElementEncryptedMedia::cancelKeyRequest(blink::WebMediaPlayer* web MediaPlayer, const String& keySystem, const String& sessionId, ExceptionState& e xceptionState) |
225 { | 407 { |
226 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest"); | 408 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest"); |
227 | 409 |
228 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 410 if (!setEmeMode(EmeModePrefixed)) { |
411 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
229 return; | 412 return; |
413 } | |
230 | 414 |
231 if (keySystem.isEmpty()) { | 415 if (keySystem.isEmpty()) { |
232 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 416 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
233 return; | 417 return; |
234 } | 418 } |
235 | 419 |
236 if (!webMediaPlayer) { | 420 if (!webMediaPlayer) { |
237 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); | 421 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); |
238 return; | 422 return; |
239 } | 423 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 518 |
335 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) | 519 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) |
336 { | 520 { |
337 #if ENABLE(OILPAN) | 521 #if ENABLE(OILPAN) |
338 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 | 522 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 |
339 if (element.isFinalizing()) | 523 if (element.isFinalizing()) |
340 return; | 524 return; |
341 #endif | 525 #endif |
342 | 526 |
343 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 527 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
344 thisElement.setMediaKeysInternal(element, 0); | 528 if (!thisElement.m_mediaKeys) |
529 return; | |
530 | |
531 ASSERT(thisElement.m_emeMode == EmeModeUnprefixed); | |
532 thisElement.m_mediaKeys.clear(); | |
345 } | 533 } |
346 | 534 |
347 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule(HTMLMediaElement& element) | 535 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule(HTMLMediaElement& element) |
348 { | 536 { |
349 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 537 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
350 return thisElement.contentDecryptionModule(); | 538 return thisElement.contentDecryptionModule(); |
351 } | 539 } |
352 | 540 |
353 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) | 541 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) |
354 { | 542 { |
355 visitor->trace(m_mediaKeys); | 543 visitor->trace(m_mediaKeys); |
356 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 544 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
357 } | 545 } |
358 | 546 |
359 } // namespace blink | 547 } // namespace blink |
OLD | NEW |