| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e); | 144 ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e); |
| 145 return e; | 145 return e; |
| 146 } | 146 } |
| 147 | 147 |
| 148 WebMediaPlayer::MediaKeyException | 148 WebMediaPlayer::MediaKeyException |
| 149 EncryptedMediaPlayerSupport::GenerateKeyRequestInternal( | 149 EncryptedMediaPlayerSupport::GenerateKeyRequestInternal( |
| 150 blink::WebLocalFrame* frame, | 150 blink::WebLocalFrame* frame, |
| 151 const std::string& key_system, | 151 const std::string& key_system, |
| 152 const unsigned char* init_data, | 152 const unsigned char* init_data, |
| 153 unsigned init_data_length) { | 153 unsigned init_data_length) { |
| 154 if (!IsConcreteSupportedKeySystem(key_system)) | 154 if (!PrefixedIsSupportedConcreteKeySystem(key_system)) |
| 155 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 155 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 156 | 156 |
| 157 // We do not support run-time switching between key systems for now. | 157 // We do not support run-time switching between key systems for now. |
| 158 if (current_key_system_.empty()) { | 158 if (current_key_system_.empty()) { |
| 159 if (!proxy_decryptor_) { | 159 if (!proxy_decryptor_) { |
| 160 proxy_decryptor_.reset(new ProxyDecryptor( | 160 proxy_decryptor_.reset(new ProxyDecryptor( |
| 161 media_permission_, | 161 media_permission_, |
| 162 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), | 162 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), |
| 163 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), | 163 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), |
| 164 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); | 164 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 EncryptedMediaPlayerSupport::AddKeyInternal( | 227 EncryptedMediaPlayerSupport::AddKeyInternal( |
| 228 const std::string& key_system, | 228 const std::string& key_system, |
| 229 const unsigned char* key, | 229 const unsigned char* key, |
| 230 unsigned key_length, | 230 unsigned key_length, |
| 231 const unsigned char* init_data, | 231 const unsigned char* init_data, |
| 232 unsigned init_data_length, | 232 unsigned init_data_length, |
| 233 const std::string& session_id) { | 233 const std::string& session_id) { |
| 234 DCHECK(key); | 234 DCHECK(key); |
| 235 DCHECK_GT(key_length, 0u); | 235 DCHECK_GT(key_length, 0u); |
| 236 | 236 |
| 237 if (!IsConcreteSupportedKeySystem(key_system)) | 237 if (!PrefixedIsSupportedConcreteKeySystem(key_system)) |
| 238 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 238 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 239 | 239 |
| 240 if (current_key_system_.empty() || key_system != current_key_system_) | 240 if (current_key_system_.empty() || key_system != current_key_system_) |
| 241 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 241 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 242 | 242 |
| 243 proxy_decryptor_->AddKey( | 243 proxy_decryptor_->AddKey( |
| 244 key, key_length, init_data, init_data_length, session_id); | 244 key, key_length, init_data, init_data_length, session_id); |
| 245 return WebMediaPlayer::MediaKeyExceptionNoError; | 245 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 246 } | 246 } |
| 247 | 247 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 259 WebMediaPlayer::MediaKeyException e = | 259 WebMediaPlayer::MediaKeyException e = |
| 260 CancelKeyRequestInternal(ascii_key_system, ascii_session_id); | 260 CancelKeyRequestInternal(ascii_key_system, ascii_session_id); |
| 261 ReportMediaKeyExceptionToUMA("cancelKeyRequest", ascii_key_system, e); | 261 ReportMediaKeyExceptionToUMA("cancelKeyRequest", ascii_key_system, e); |
| 262 return e; | 262 return e; |
| 263 } | 263 } |
| 264 | 264 |
| 265 WebMediaPlayer::MediaKeyException | 265 WebMediaPlayer::MediaKeyException |
| 266 EncryptedMediaPlayerSupport::CancelKeyRequestInternal( | 266 EncryptedMediaPlayerSupport::CancelKeyRequestInternal( |
| 267 const std::string& key_system, | 267 const std::string& key_system, |
| 268 const std::string& session_id) { | 268 const std::string& session_id) { |
| 269 if (!IsConcreteSupportedKeySystem(key_system)) | 269 if (!PrefixedIsSupportedConcreteKeySystem(key_system)) |
| 270 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 270 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 271 | 271 |
| 272 if (current_key_system_.empty() || key_system != current_key_system_) | 272 if (current_key_system_.empty() || key_system != current_key_system_) |
| 273 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 273 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 274 | 274 |
| 275 proxy_decryptor_->CancelKeyRequest(session_id); | 275 proxy_decryptor_->CancelKeyRequest(session_id); |
| 276 return WebMediaPlayer::MediaKeyExceptionNoError; | 276 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 277 } | 277 } |
| 278 | 278 |
| 279 void EncryptedMediaPlayerSupport::SetInitDataType( | 279 void EncryptedMediaPlayerSupport::SetInitDataType( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 client_->keyMessage( | 327 client_->keyMessage( |
| 328 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 328 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
| 329 WebString::fromUTF8(session_id), | 329 WebString::fromUTF8(session_id), |
| 330 message.empty() ? NULL : &message[0], | 330 message.empty() ? NULL : &message[0], |
| 331 base::saturated_cast<unsigned int>(message.size()), | 331 base::saturated_cast<unsigned int>(message.size()), |
| 332 destination_url); | 332 destination_url); |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace media | 335 } // namespace media |
| OLD | NEW |