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 FileIOTestRunner; | |
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, bool test_file_io); |
34 virtual ~ClearKeyCdm(); | 35 virtual ~ClearKeyCdm(); |
35 | 36 |
36 // ContentDecryptionModule implementation. | 37 // ContentDecryptionModule implementation. |
37 virtual cdm::Status GenerateKeyRequest( | 38 virtual cdm::Status GenerateKeyRequest( |
38 const char* type, uint32_t type_size, | 39 const char* type, uint32_t type_size, |
39 const uint8_t* init_data, uint32_t init_data_size) OVERRIDE; | 40 const uint8_t* init_data, uint32_t init_data_size) OVERRIDE; |
40 virtual cdm::Status AddKey(const char* session_id, | 41 virtual cdm::Status AddKey(const char* session_id, |
41 uint32_t session_id_size, | 42 uint32_t session_id_size, |
42 const uint8_t* key, | 43 const uint8_t* key, |
43 uint32_t key_size, | 44 uint32_t key_size, |
(...skipping 92 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 StartFileIOTest(); | |
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_; |
162 const bool test_file_io_; | |
ddorwin
2013/12/14 20:44:04
should_ ?
is_file_io_test_?
xhwang
2013/12/16 23:04:29
Done.
| |
156 | 163 |
157 std::string heartbeat_session_id_; | 164 std::string last_session_id_; |
165 | |
158 std::string next_heartbeat_message_; | 166 std::string next_heartbeat_message_; |
159 | 167 |
160 // Timer delay in milliseconds for the next host_->SetTimer() call. | 168 // Timer delay in milliseconds for the next host_->SetTimer() call. |
161 int64 timer_delay_ms_; | 169 int64 timer_delay_ms_; |
162 | 170 |
163 // Indicates whether a timer has been set to prevent multiple timers from | 171 // Indicates whether a timer has been set to prevent multiple timers from |
164 // running. | 172 // running. |
165 bool timer_set_; | 173 bool timer_set_; |
166 | 174 |
167 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 175 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
168 int channel_count_; | 176 int channel_count_; |
169 int bits_per_channel_; | 177 int bits_per_channel_; |
170 int samples_per_second_; | 178 int samples_per_second_; |
171 int64 output_timestamp_base_in_microseconds_; | 179 int64 output_timestamp_base_in_microseconds_; |
172 int total_samples_generated_; | 180 int total_samples_generated_; |
173 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 181 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
174 | 182 |
175 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 183 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
176 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; | 184 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; |
177 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 185 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
178 | 186 |
179 scoped_ptr<CdmVideoDecoder> video_decoder_; | 187 scoped_ptr<CdmVideoDecoder> video_decoder_; |
180 | 188 |
189 scoped_ptr<FileIOTestRunner> cdm_file_io_test_; | |
ddorwin
2013/12/14 20:44:04
rename?
xhwang
2013/12/16 23:04:29
Done.
| |
190 | |
181 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 191 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
182 }; | 192 }; |
183 | 193 |
184 } // namespace media | 194 } // namespace media |
185 | 195 |
186 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ | 196 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ |
OLD | NEW |