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/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/clear_key_cdm.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 int cdm_interface_version, | 129 int cdm_interface_version, |
130 const char* key_system, int key_system_size, | 130 const char* key_system, int key_system_size, |
131 GetCdmHostFunc get_cdm_host_func, void* user_data) { | 131 GetCdmHostFunc get_cdm_host_func, void* user_data) { |
132 DVLOG(1) << "CreateCdmInstance()"; | 132 DVLOG(1) << "CreateCdmInstance()"; |
133 | 133 |
134 if (std::string(key_system, key_system_size) != kExternalClearKeyKeySystem) { | 134 if (std::string(key_system, key_system_size) != kExternalClearKeyKeySystem) { |
135 DVLOG(1) << "Unsupported key system."; | 135 DVLOG(1) << "Unsupported key system."; |
136 return NULL; | 136 return NULL; |
137 } | 137 } |
138 | 138 |
139 if (cdm_interface_version != cdm::ContentDecryptionModule_1::kVersion) | 139 if (cdm_interface_version != cdm::ContentDecryptionModule_2::kVersion) |
140 return NULL; | 140 return NULL; |
141 | 141 |
142 cdm::Host* host = static_cast<cdm::Host*>( | 142 cdm::Host* host = static_cast<cdm::Host*>( |
143 get_cdm_host_func(cdm::ContentDecryptionModule_1::kVersion, user_data)); | 143 get_cdm_host_func(cdm::ContentDecryptionModule_2::kVersion, user_data)); |
144 if (!host) | 144 if (!host) |
145 return NULL; | 145 return NULL; |
146 | 146 |
147 return new media::ClearKeyCdm(host); | 147 return new media::ClearKeyCdm(host); |
148 } | 148 } |
149 | 149 |
150 const char* GetCdmVersion() { | 150 const char* GetCdmVersion() { |
151 return kClearKeyCdmVersion; | 151 return kClearKeyCdmVersion; |
152 } | 152 } |
153 | 153 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 data = buffer->data(); | 410 data = buffer->data(); |
411 size = buffer->data_size(); | 411 size = buffer->data_size(); |
412 timestamp = encrypted_buffer.timestamp; | 412 timestamp = encrypted_buffer.timestamp; |
413 } | 413 } |
414 | 414 |
415 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); | 415 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); |
416 } | 416 } |
417 | 417 |
418 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( | 418 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( |
419 const cdm::InputBuffer& encrypted_buffer, | 419 const cdm::InputBuffer& encrypted_buffer, |
420 cdm::AudioFrames_1* audio_frames) { | 420 cdm::AudioFrames* audio_frames) { |
421 DVLOG(1) << "DecryptAndDecodeSamples()"; | 421 DVLOG(1) << "DecryptAndDecodeSamples()"; |
422 | 422 |
423 scoped_refptr<media::DecoderBuffer> buffer; | 423 scoped_refptr<media::DecoderBuffer> buffer; |
424 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); | 424 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); |
425 | 425 |
426 if (status != cdm::kSuccess) | 426 if (status != cdm::kSuccess) |
427 return status; | 427 return status; |
428 | 428 |
429 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 429 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
430 const uint8_t* data = NULL; | 430 const uint8_t* data = NULL; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 if (status == media::Decryptor::kError) | 493 if (status == media::Decryptor::kError) |
494 return cdm::kDecryptError; | 494 return cdm::kDecryptError; |
495 | 495 |
496 if (status == media::Decryptor::kNoKey) | 496 if (status == media::Decryptor::kNoKey) |
497 return cdm::kNoKey; | 497 return cdm::kNoKey; |
498 | 498 |
499 DCHECK_EQ(status, media::Decryptor::kSuccess); | 499 DCHECK_EQ(status, media::Decryptor::kSuccess); |
500 return cdm::kSuccess; | 500 return cdm::kSuccess; |
501 } | 501 } |
502 | 502 |
| 503 void ClearKeyCdm::OnPlatformChallengeResponse( |
| 504 const cdm::PlatformChallengeResponse& response) { |
| 505 NOTIMPLEMENTED(); |
| 506 } |
| 507 |
| 508 void ClearKeyCdm::OnQueryOutputProtectionStatus( |
| 509 uint32_t link_mask, uint32_t output_protection_mask) { |
| 510 NOTIMPLEMENTED(); |
| 511 }; |
| 512 |
503 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 513 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
504 int64 ClearKeyCdm::CurrentTimeStampInMicroseconds() const { | 514 int64 ClearKeyCdm::CurrentTimeStampInMicroseconds() const { |
505 return output_timestamp_base_in_microseconds_ + | 515 return output_timestamp_base_in_microseconds_ + |
506 base::Time::kMicrosecondsPerSecond * | 516 base::Time::kMicrosecondsPerSecond * |
507 total_samples_generated_ / samples_per_second_; | 517 total_samples_generated_ / samples_per_second_; |
508 } | 518 } |
509 | 519 |
510 int ClearKeyCdm::GenerateFakeAudioFramesFromDuration( | 520 int ClearKeyCdm::GenerateFakeAudioFramesFromDuration( |
511 int64 duration_in_microseconds, | 521 int64 duration_in_microseconds, |
512 cdm::AudioFrames* audio_frames) const { | 522 cdm::AudioFrames* audio_frames) const { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 int samples_generated = GenerateFakeAudioFramesFromDuration( | 563 int samples_generated = GenerateFakeAudioFramesFromDuration( |
554 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), | 564 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), |
555 audio_frames); | 565 audio_frames); |
556 total_samples_generated_ += samples_generated; | 566 total_samples_generated_ += samples_generated; |
557 | 567 |
558 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; | 568 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; |
559 } | 569 } |
560 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 570 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
561 | 571 |
562 } // namespace media | 572 } // namespace media |
OLD | NEW |