Chromium Code Reviews| 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 "media/blink/encrypted_media_player_support.h" | 5 #include "media/blink/encrypted_media_player_support.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 148 |
| 149 WebMediaPlayer::MediaKeyException | 149 WebMediaPlayer::MediaKeyException |
| 150 EncryptedMediaPlayerSupport::GenerateKeyRequestInternal( | 150 EncryptedMediaPlayerSupport::GenerateKeyRequestInternal( |
| 151 blink::WebLocalFrame* frame, | 151 blink::WebLocalFrame* frame, |
| 152 const std::string& key_system, | 152 const std::string& key_system, |
| 153 const unsigned char* init_data, | 153 const unsigned char* init_data, |
| 154 unsigned init_data_length) { | 154 unsigned init_data_length) { |
| 155 if (!PrefixedIsSupportedConcreteKeySystem(key_system)) | 155 if (!PrefixedIsSupportedConcreteKeySystem(key_system)) |
| 156 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 156 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 157 | 157 |
| 158 // We do not support run-time switching between key systems for now. | 158 if (!proxy_decryptor_) { |
| 159 if (current_key_system_.empty()) { | 159 DCHECK(current_key_system_.empty()); |
| 160 if (!proxy_decryptor_) { | 160 DCHECK(!set_cdm_context_cb_.is_null()); |
| 161 proxy_decryptor_.reset(new ProxyDecryptor( | 161 proxy_decryptor_.reset(new ProxyDecryptor( |
| 162 media_permission_, | 162 media_permission_, |
| 163 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), | 163 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), |
| 164 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), | 164 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), |
| 165 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); | 165 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); |
| 166 } | |
| 167 | 166 |
| 168 GURL security_origin(frame->document().securityOrigin().toString()); | 167 GURL security_origin(frame->document().securityOrigin().toString()); |
| 168 proxy_decryptor_->CreateCdm(cdm_factory_, key_system, security_origin, | |
| 169 set_cdm_context_cb_); | |
| 170 current_key_system_ = key_system; | |
| 171 } | |
| 169 | 172 |
| 170 if (!proxy_decryptor_->InitializeCDM(cdm_factory_, key_system, | 173 // We do not support run-time switching between key systems for now. |
|
ddorwin
2015/04/10 00:59:43
Be sure this passes layout tests. I think there wa
xhwang
2015/04/10 17:41:17
This has always been the case and just confirmed t
| |
| 171 security_origin)) { | 174 DCHECK(!current_key_system_.empty()); |
| 172 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 175 if (key_system != current_key_system_) |
| 173 } | |
| 174 | |
| 175 if (proxy_decryptor_ && !set_cdm_context_cb_.is_null()) { | |
| 176 base::ResetAndReturn(&set_cdm_context_cb_) | |
| 177 .Run(proxy_decryptor_->GetCdmContext(), | |
| 178 base::Bind(&IgnoreCdmAttached)); | |
| 179 } | |
| 180 | |
| 181 current_key_system_ = key_system; | |
| 182 } else if (key_system != current_key_system_) { | |
| 183 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 176 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 184 } | |
| 185 | 177 |
| 186 EmeInitDataType init_data_type = init_data_type_; | 178 EmeInitDataType init_data_type = init_data_type_; |
| 187 if (init_data_type == EmeInitDataType::UNKNOWN) | 179 if (init_data_type == EmeInitDataType::UNKNOWN) |
| 188 init_data_type = GuessInitDataType(init_data, init_data_length); | 180 init_data_type = GuessInitDataType(init_data, init_data_length); |
| 189 | 181 |
| 190 if (!proxy_decryptor_->GenerateKeyRequest(init_data_type, init_data, | 182 proxy_decryptor_->GenerateKeyRequest(init_data_type, init_data, |
|
ddorwin
2015/04/10 00:59:43
Can this no longer fail? Is everything in an Initi
xhwang
2015/04/10 17:41:17
Since we added RequestPermission, this path is alr
| |
| 191 init_data_length)) { | 183 init_data_length); |
| 192 current_key_system_.clear(); | |
| 193 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | |
| 194 } | |
| 195 | 184 |
| 196 return WebMediaPlayer::MediaKeyExceptionNoError; | 185 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 197 } | 186 } |
| 198 | 187 |
| 199 WebMediaPlayer::MediaKeyException EncryptedMediaPlayerSupport::AddKey( | 188 WebMediaPlayer::MediaKeyException EncryptedMediaPlayerSupport::AddKey( |
| 200 const WebString& key_system, | 189 const WebString& key_system, |
| 201 const unsigned char* key, | 190 const unsigned char* key, |
| 202 unsigned key_length, | 191 unsigned key_length, |
| 203 const unsigned char* init_data, | 192 const unsigned char* init_data, |
| 204 unsigned init_data_length, | 193 unsigned init_data_length, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 | 316 |
| 328 client_->keyMessage( | 317 client_->keyMessage( |
| 329 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 318 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
| 330 WebString::fromUTF8(session_id), | 319 WebString::fromUTF8(session_id), |
| 331 message.empty() ? NULL : &message[0], | 320 message.empty() ? NULL : &message[0], |
| 332 base::saturated_cast<unsigned int>(message.size()), | 321 base::saturated_cast<unsigned int>(message.size()), |
| 333 destination_url); | 322 destination_url); |
| 334 } | 323 } |
| 335 | 324 |
| 336 } // namespace media | 325 } // namespace media |
| OLD | NEW |