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" |
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/WebContentDecryptionModule.h" | 19 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" |
20 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 20 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 22 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
23 | 23 |
24 using blink::WebMediaPlayer; | 24 using blink::WebMediaPlayer; |
25 using blink::WebMediaPlayerClient; | 25 using blink::WebMediaPlayerEncryptedMediaClient; |
26 using blink::WebString; | 26 using blink::WebString; |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
30 #define BIND_TO_RENDER_LOOP(function) \ | 30 #define BIND_TO_RENDER_LOOP(function) \ |
31 (BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) | 31 (BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) |
32 | 32 |
33 #define BIND_TO_RENDER_LOOP1(function, arg1) \ | 33 #define BIND_TO_RENDER_LOOP1(function, arg1) \ |
34 (BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) | 34 (BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) |
35 | 35 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 unsigned init_data_length) { | 107 unsigned init_data_length) { |
108 // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. | 108 // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. |
109 if (init_data_length == 16) | 109 if (init_data_length == 16) |
110 return EmeInitDataType::WEBM; | 110 return EmeInitDataType::WEBM; |
111 | 111 |
112 return EmeInitDataType::CENC; | 112 return EmeInitDataType::CENC; |
113 } | 113 } |
114 | 114 |
115 EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( | 115 EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( |
116 CdmFactory* cdm_factory, | 116 CdmFactory* cdm_factory, |
117 blink::WebMediaPlayerClient* client, | 117 WebMediaPlayerEncryptedMediaClient* client, |
118 MediaPermission* media_permission, | 118 MediaPermission* media_permission, |
119 const CdmContextReadyCB& cdm_context_ready_cb) | 119 const CdmContextReadyCB& cdm_context_ready_cb) |
120 : cdm_factory_(cdm_factory), | 120 : cdm_factory_(cdm_factory), |
121 client_(client), | 121 client_(client), |
122 media_permission_(media_permission), | 122 media_permission_(media_permission), |
123 init_data_type_(EmeInitDataType::UNKNOWN), | 123 init_data_type_(EmeInitDataType::UNKNOWN), |
124 cdm_context_ready_cb_(cdm_context_ready_cb) { | 124 cdm_context_ready_cb_(cdm_context_ready_cb) { |
125 } | 125 } |
126 | 126 |
127 EncryptedMediaPlayerSupport::~EncryptedMediaPlayerSupport() { | 127 EncryptedMediaPlayerSupport::~EncryptedMediaPlayerSupport() { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 if (system_code > std::numeric_limits<uint16>::max()) { | 297 if (system_code > std::numeric_limits<uint16>::max()) { |
298 LOG(WARNING) << "system_code exceeds unsigned short limit."; | 298 LOG(WARNING) << "system_code exceeds unsigned short limit."; |
299 short_system_code = std::numeric_limits<uint16>::max(); | 299 short_system_code = std::numeric_limits<uint16>::max(); |
300 } else { | 300 } else { |
301 short_system_code = static_cast<uint16>(system_code); | 301 short_system_code = static_cast<uint16>(system_code); |
302 } | 302 } |
303 | 303 |
304 client_->keyError( | 304 client_->keyError( |
305 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 305 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
306 WebString::fromUTF8(session_id), | 306 WebString::fromUTF8(session_id), |
307 static_cast<WebMediaPlayerClient::MediaKeyErrorCode>(error_code), | 307 static_cast<WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCode>( |
| 308 error_code), |
308 short_system_code); | 309 short_system_code); |
309 } | 310 } |
310 | 311 |
311 void EncryptedMediaPlayerSupport::OnKeyMessage( | 312 void EncryptedMediaPlayerSupport::OnKeyMessage( |
312 const std::string& session_id, | 313 const std::string& session_id, |
313 const std::vector<uint8>& message, | 314 const std::vector<uint8>& message, |
314 const GURL& destination_url) { | 315 const GURL& destination_url) { |
315 DCHECK(destination_url.is_empty() || destination_url.is_valid()); | 316 DCHECK(destination_url.is_empty() || destination_url.is_valid()); |
316 | 317 |
317 client_->keyMessage( | 318 client_->keyMessage( |
318 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 319 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
319 WebString::fromUTF8(session_id), | 320 WebString::fromUTF8(session_id), |
320 message.empty() ? NULL : &message[0], | 321 message.empty() ? NULL : &message[0], |
321 base::saturated_cast<unsigned int>(message.size()), | 322 base::saturated_cast<unsigned int>(message.size()), |
322 destination_url); | 323 destination_url); |
323 } | 324 } |
324 | 325 |
325 } // namespace media | 326 } // namespace media |
OLD | NEW |