| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "media/base/bind_to_current_loop.h" | 16 #include "media/base/bind_to_current_loop.h" |
| 17 #include "media/base/key_systems.h" | 17 #include "media/base/key_systems.h" |
| 18 #include "media/blink/webcontentdecryptionmodule_impl.h" | 18 #include "media/blink/webcontentdecryptionmodule_impl.h" |
| 19 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 19 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" | 20 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" |
| 20 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" | 21 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" |
| 21 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 23 | 24 |
| 24 using blink::WebMediaPlayer; | 25 using blink::WebMediaPlayer; |
| 25 using blink::WebMediaPlayerEncryptedMediaClient; | 26 using blink::WebMediaPlayerEncryptedMediaClient; |
| 26 using blink::WebString; | 27 using blink::WebString; |
| 27 | 28 |
| 28 namespace media { | 29 namespace media { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 165 |
| 165 if (!proxy_decryptor_) { | 166 if (!proxy_decryptor_) { |
| 166 DCHECK(current_key_system_.empty()); | 167 DCHECK(current_key_system_.empty()); |
| 167 DCHECK(!cdm_context_ready_cb_.is_null()); | 168 DCHECK(!cdm_context_ready_cb_.is_null()); |
| 168 proxy_decryptor_.reset(new ProxyDecryptor( | 169 proxy_decryptor_.reset(new ProxyDecryptor( |
| 169 media_permission_, use_hw_secure_codecs, | 170 media_permission_, use_hw_secure_codecs, |
| 170 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), | 171 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), |
| 171 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), | 172 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), |
| 172 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); | 173 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); |
| 173 | 174 |
| 174 GURL security_origin(frame->document().securityOrigin().toString()); | 175 GURL security_origin( |
| 176 blink::WebStringToGURL(frame->document().securityOrigin().toString())); |
| 175 proxy_decryptor_->CreateCdm(cdm_factory_, key_system, security_origin, | 177 proxy_decryptor_->CreateCdm(cdm_factory_, key_system, security_origin, |
| 176 cdm_context_ready_cb_); | 178 cdm_context_ready_cb_); |
| 177 current_key_system_ = key_system; | 179 current_key_system_ = key_system; |
| 178 } | 180 } |
| 179 | 181 |
| 180 // We do not support run-time switching between key systems for now. | 182 // We do not support run-time switching between key systems for now. |
| 181 DCHECK(!current_key_system_.empty()); | 183 DCHECK(!current_key_system_.empty()); |
| 182 if (key_system != current_key_system_) | 184 if (key_system != current_key_system_) |
| 183 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 185 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 184 | 186 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 322 |
| 321 client_->keyMessage( | 323 client_->keyMessage( |
| 322 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 324 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
| 323 WebString::fromUTF8(session_id), | 325 WebString::fromUTF8(session_id), |
| 324 message.empty() ? NULL : &message[0], | 326 message.empty() ? NULL : &message[0], |
| 325 base::saturated_cast<unsigned int>(message.size()), | 327 base::saturated_cast<unsigned int>(message.size()), |
| 326 destination_url); | 328 destination_url); |
| 327 } | 329 } |
| 328 | 330 |
| 329 } // namespace media | 331 } // namespace media |
| OLD | NEW |