OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cdm/ppapi/external_clear_key/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/file.h" | |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
17 #include "media/base/cdm_callback_promise.h" | 18 #include "media/base/cdm_callback_promise.h" |
18 #include "media/base/cdm_key_information.h" | 19 #include "media/base/cdm_key_information.h" |
19 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
20 #include "media/base/decrypt_config.h" | 21 #include "media/base/decrypt_config.h" |
22 #include "media/cdm/content_decryption_module_ext.h" | |
21 #include "media/cdm/json_web_key.h" | 23 #include "media/cdm/json_web_key.h" |
22 #include "media/cdm/ppapi/cdm_file_io_test.h" | 24 #include "media/cdm/ppapi/cdm_file_io_test.h" |
23 #include "media/cdm/ppapi/external_clear_key/cdm_video_decoder.h" | 25 #include "media/cdm/ppapi/external_clear_key/cdm_video_decoder.h" |
24 #include "url/gurl.h" | 26 #include "url/gurl.h" |
25 | 27 |
26 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 28 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
27 const int64_t kNoTimestamp = INT64_MIN; | 29 const int64_t kNoTimestamp = INT64_MIN; |
28 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 30 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
29 | 31 |
30 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 32 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 | 252 |
251 // TODO(jrummell): Obtain the proper origin for this instance. | 253 // TODO(jrummell): Obtain the proper origin for this instance. |
252 GURL empty_origin; | 254 GURL empty_origin; |
253 return new media::ClearKeyCdm(host, key_system_string, empty_origin); | 255 return new media::ClearKeyCdm(host, key_system_string, empty_origin); |
254 } | 256 } |
255 | 257 |
256 const char* GetCdmVersion() { | 258 const char* GetCdmVersion() { |
257 return kClearKeyCdmVersion; | 259 return kClearKeyCdmVersion; |
258 } | 260 } |
259 | 261 |
262 // TODO(xhwang): Add a browser test to cover this path. | |
263 void VerifyHostFiles(const cdm::CdmHostFile* cdm_host_files, | |
264 uint32_t num_files) { | |
265 DVLOG(1) << __FUNCTION__; | |
266 | |
267 LOG(ERROR) << "num_files: " << num_files; | |
268 for (uint32_t i = 0; i < num_files; ++i) { | |
269 LOG(ERROR) << "Path " << i << ": " << cdm_host_files[i].file_path; | |
tinskip1
2017/01/09 23:49:30
Why is this necessary? Let the CDM figure out if t
xhwang
2017/01/12 20:15:02
This is only for my own logging. Will remove.
xhwang
2017/01/18 06:03:59
Done.
| |
270 std::vector<char> buffer(10); | |
271 | |
272 base::File file(static_cast<base::PlatformFile>(cdm_host_files[i].file)); | |
273 int bytes_read = file.Read(0, buffer.data(), buffer.size()); | |
274 LOG(ERROR) << "File bytes read: " << bytes_read; | |
275 DCHECK_EQ(10, bytes_read) << "Read failed."; | |
276 | |
277 base::File sig_file( | |
278 static_cast<base::PlatformFile>(cdm_host_files[i].sig_file)); | |
279 bytes_read = sig_file.Read(0, buffer.data(), buffer.size()); | |
280 LOG(ERROR) << "Sig file bytes read: " << bytes_read; | |
281 DCHECK_EQ(10, bytes_read) << "Read failed."; | |
282 } | |
jrummell
2016/12/16 20:21:30
How about trying write() and checking that it fail
xhwang
2017/01/12 20:15:02
Good point. Will do.
xhwang
2017/01/18 06:03:59
Done.
| |
283 | |
284 // TODO(xhwang): Close all files. | |
285 } | |
286 | |
260 namespace media { | 287 namespace media { |
261 | 288 |
262 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, | 289 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, |
263 const std::string& key_system, | 290 const std::string& key_system, |
264 const GURL& origin) | 291 const GURL& origin) |
265 : decryptor_(new AesDecryptor( | 292 : decryptor_(new AesDecryptor( |
266 origin, | 293 origin, |
267 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)), | 294 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)), |
268 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this)), | 295 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this)), |
269 base::Bind(&ClearKeyCdm::OnSessionKeysChange, | 296 base::Bind(&ClearKeyCdm::OnSessionKeysChange, |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 is_running_platform_verification_test_ = true; | 1004 is_running_platform_verification_test_ = true; |
978 | 1005 |
979 std::string service_id = "test_service_id"; | 1006 std::string service_id = "test_service_id"; |
980 std::string challenge = "test_challenge"; | 1007 std::string challenge = "test_challenge"; |
981 | 1008 |
982 host_->SendPlatformChallenge(service_id.data(), service_id.size(), | 1009 host_->SendPlatformChallenge(service_id.data(), service_id.size(), |
983 challenge.data(), challenge.size()); | 1010 challenge.data(), challenge.size()); |
984 } | 1011 } |
985 | 1012 |
986 } // namespace media | 1013 } // namespace media |
OLD | NEW |