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