| 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 "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // 5.2.1 If the user agent or CDM do not support removing the | 159 // 5.2.1 If the user agent or CDM do not support removing the |
| 160 // association, let this object's attaching media keys | 160 // association, let this object's attaching media keys |
| 161 // value be false and reject promise with a NotSupportedError. | 161 // value be false and reject promise with a NotSupportedError. |
| 162 // 5.2.2 If the association cannot currently be removed, | 162 // 5.2.2 If the association cannot currently be removed, |
| 163 // let this object's attaching media keys value be false | 163 // let this object's attaching media keys value be false |
| 164 // and reject promise with an InvalidStateError. | 164 // and reject promise with an InvalidStateError. |
| 165 // 5.2.3 Stop using the CDM instance represented by the mediaKeys | 165 // 5.2.3 Stop using the CDM instance represented by the mediaKeys |
| 166 // attribute to decrypt media data and remove the association | 166 // attribute to decrypt media data and remove the association |
| 167 // with the media element. | 167 // with the media element. |
| 168 // (All 3 steps handled as needed in Chromium.) | 168 // (All 3 steps handled as needed in Chromium.) |
| 169 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:setNewMediaKeys, this); | 169 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:setNewMediaKeys, retainedRef(this)); |
| 170 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::clearFailed, this); | 170 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::clearFailed, retainedRef(this)); |
| 171 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); | 171 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); |
| 172 mediaPlayer->setContentDecryptionModule(nullptr, result->result()); | 172 mediaPlayer->setContentDecryptionModule(nullptr, result->result()); |
| 173 | 173 |
| 174 // Don't do anything more until |result| is resolved (or rejected). | 174 // Don't do anything more until |result| is resolved (or rejected). |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 // MediaKeys not currently set or no player connected, so continue on. | 179 // MediaKeys not currently set or no player connected, so continue on. |
| 180 setNewMediaKeys(); | 180 setNewMediaKeys(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SetMediaKeysHandler::setNewMediaKeys() | 183 void SetMediaKeysHandler::setNewMediaKeys() |
| 184 { | 184 { |
| 185 WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys"); | 185 WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys"); |
| 186 | 186 |
| 187 // 5.3 If mediaKeys is not null, run the following steps: | 187 // 5.3 If mediaKeys is not null, run the following steps: |
| 188 if (m_newMediaKeys) { | 188 if (m_newMediaKeys) { |
| 189 // 5.3.1 Associate the CDM instance represented by mediaKeys with the | 189 // 5.3.1 Associate the CDM instance represented by mediaKeys with the |
| 190 // media element for decrypting media data. | 190 // media element for decrypting media data. |
| 191 // 5.3.2 If the preceding step failed, run the following steps: | 191 // 5.3.2 If the preceding step failed, run the following steps: |
| 192 // (done in setFailed()). | 192 // (done in setFailed()). |
| 193 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary | 193 // 5.3.3 Queue a task to run the Attempt to Resume Playback If Necessary |
| 194 // algorithm on the media element. | 194 // algorithm on the media element. |
| 195 // (Handled in Chromium). | 195 // (Handled in Chromium). |
| 196 if (m_element->webMediaPlayer()) { | 196 if (m_element->webMediaPlayer()) { |
| 197 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:finish, this); | 197 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:finish, retainedRef(this)); |
| 198 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::setFailed, this); | 198 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::setFailed, retainedRef(this)); |
| 199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); | 199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); |
| 200 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe
ys->contentDecryptionModule(), result->result()); | 200 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe
ys->contentDecryptionModule(), result->result()); |
| 201 | 201 |
| 202 // Don't do anything more until |result| is resolved (or rejected). | 202 // Don't do anything more until |result| is resolved (or rejected). |
| 203 return; | 203 return; |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 // MediaKeys doesn't need to be set on the player, so continue on. | 207 // MediaKeys doesn't need to be set on the player, so continue on. |
| 208 finish(); | 208 finish(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 406 } |
| 407 | 407 |
| 408 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) | 408 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) |
| 409 { | 409 { |
| 410 visitor->trace(m_mediaElement); | 410 visitor->trace(m_mediaElement); |
| 411 visitor->trace(m_mediaKeys); | 411 visitor->trace(m_mediaKeys); |
| 412 Supplement<HTMLMediaElement>::trace(visitor); | 412 Supplement<HTMLMediaElement>::trace(visitor); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } // namespace blink | 415 } // namespace blink |
| OLD | NEW |