| 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 #ifndef MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ |
| 6 #define MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ | 6 #define MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "media/cdm/aes_decryptor.h" | 16 #include "media/cdm/aes_decryptor.h" |
| 17 #include "media/cdm/ppapi/clear_key_cdm_common.h" | 17 #include "media/cdm/ppapi/clear_key_cdm_common.h" |
| 18 | 18 |
| 19 // Enable this to use the fake decoder for testing. | 19 // Enable this to use the fake decoder for testing. |
| 20 // TODO(tomfinegan): Move fake audio decoder into a separate class. | 20 // TODO(tomfinegan): Move fake audio decoder into a separate class. |
| 21 #if 0 | 21 #if 0 |
| 22 #define CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 22 #define CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 namespace media { | 25 namespace media { |
| 26 class CdmFileIOTest; |
| 26 class CdmVideoDecoder; | 27 class CdmVideoDecoder; |
| 27 class DecoderBuffer; | 28 class DecoderBuffer; |
| 28 class FFmpegCdmAudioDecoder; | 29 class FFmpegCdmAudioDecoder; |
| 29 | 30 |
| 30 // Clear key implementation of the cdm::ContentDecryptionModule interface. | 31 // Clear key implementation of the cdm::ContentDecryptionModule interface. |
| 31 class ClearKeyCdm : public ClearKeyCdmInterface { | 32 class ClearKeyCdm : public ClearKeyCdmInterface { |
| 32 public: | 33 public: |
| 33 explicit ClearKeyCdm(Host* host, bool is_decrypt_only); | 34 explicit ClearKeyCdm(Host* host, bool is_decrypt_only); |
| 34 virtual ~ClearKeyCdm(); | 35 virtual ~ClearKeyCdm(); |
| 35 | 36 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Returns the number of samples generated in the |audio_frames|. | 137 // Returns the number of samples generated in the |audio_frames|. |
| 137 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, | 138 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, |
| 138 cdm::AudioFrames* audio_frames) const; | 139 cdm::AudioFrames* audio_frames) const; |
| 139 | 140 |
| 140 // Generates fake video frames given |input_timestamp|. | 141 // Generates fake video frames given |input_timestamp|. |
| 141 // Returns cdm::kSuccess if any audio frame is successfully generated. | 142 // Returns cdm::kSuccess if any audio frame is successfully generated. |
| 142 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 143 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, |
| 143 cdm::AudioFrames* audio_frames); | 144 cdm::AudioFrames* audio_frames); |
| 144 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 145 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 145 | 146 |
| 147 void StartCdmFileIOTest(); |
| 148 |
| 149 // Callback for CDM File IO test. |
| 150 void OnFileIOTestComplete(bool success); |
| 151 |
| 146 Client client_; | 152 Client client_; |
| 147 AesDecryptor decryptor_; | 153 AesDecryptor decryptor_; |
| 148 | 154 |
| 149 // Protects the |client_| from being accessed by the |decryptor_| | 155 // Protects the |client_| from being accessed by the |decryptor_| |
| 150 // simultaneously. | 156 // simultaneously. |
| 151 base::Lock client_lock_; | 157 base::Lock client_lock_; |
| 152 | 158 |
| 153 ClearKeyCdmHost* host_; | 159 ClearKeyCdmHost* host_; |
| 154 | 160 |
| 155 const bool is_decrypt_only_; | 161 const bool is_decrypt_only_; |
| 156 | 162 |
| 157 std::string heartbeat_session_id_; | 163 std::string last_session_id_; |
| 164 |
| 158 std::string next_heartbeat_message_; | 165 std::string next_heartbeat_message_; |
| 159 | 166 |
| 160 // Timer delay in milliseconds for the next host_->SetTimer() call. | 167 // Timer delay in milliseconds for the next host_->SetTimer() call. |
| 161 int64 timer_delay_ms_; | 168 int64 timer_delay_ms_; |
| 162 | 169 |
| 163 // Indicates whether a timer has been set to prevent multiple timers from | 170 // Indicates whether a timer has been set to prevent multiple timers from |
| 164 // running. | 171 // running. |
| 165 bool timer_set_; | 172 bool timer_set_; |
| 166 | 173 |
| 167 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 174 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 168 int channel_count_; | 175 int channel_count_; |
| 169 int bits_per_channel_; | 176 int bits_per_channel_; |
| 170 int samples_per_second_; | 177 int samples_per_second_; |
| 171 int64 output_timestamp_base_in_microseconds_; | 178 int64 output_timestamp_base_in_microseconds_; |
| 172 int total_samples_generated_; | 179 int total_samples_generated_; |
| 173 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 180 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 174 | 181 |
| 175 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 182 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
| 176 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; | 183 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; |
| 177 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 184 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
| 178 | 185 |
| 179 scoped_ptr<CdmVideoDecoder> video_decoder_; | 186 scoped_ptr<CdmVideoDecoder> video_decoder_; |
| 180 | 187 |
| 188 scoped_ptr<CdmFileIOTest> cdm_file_io_test_; |
| 189 |
| 181 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 190 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
| 182 }; | 191 }; |
| 183 | 192 |
| 184 } // namespace media | 193 } // namespace media |
| 185 | 194 |
| 186 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ | 195 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ |
| OLD | NEW |