Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: media/cdm/ppapi/clear_key_cdm.h

Issue 93243003: Add CDM FileIO tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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,
35 bool is_decrypt_only,
36 bool should_test_file_io);
34 virtual ~ClearKeyCdm(); 37 virtual ~ClearKeyCdm();
35 38
36 // ContentDecryptionModule implementation. 39 // ContentDecryptionModule implementation.
37 virtual cdm::Status GenerateKeyRequest( 40 virtual cdm::Status GenerateKeyRequest(
38 const char* type, uint32_t type_size, 41 const char* type, uint32_t type_size,
39 const uint8_t* init_data, uint32_t init_data_size) OVERRIDE; 42 const uint8_t* init_data, uint32_t init_data_size) OVERRIDE;
40 virtual cdm::Status AddKey(const char* session_id, 43 virtual cdm::Status AddKey(const char* session_id,
41 uint32_t session_id_size, 44 uint32_t session_id_size,
42 const uint8_t* key, 45 const uint8_t* key,
43 uint32_t key_size, 46 uint32_t key_size,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Returns the number of samples generated in the |audio_frames|. 139 // Returns the number of samples generated in the |audio_frames|.
137 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, 140 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds,
138 cdm::AudioFrames* audio_frames) const; 141 cdm::AudioFrames* audio_frames) const;
139 142
140 // Generates fake video frames given |input_timestamp|. 143 // Generates fake video frames given |input_timestamp|.
141 // Returns cdm::kSuccess if any audio frame is successfully generated. 144 // Returns cdm::kSuccess if any audio frame is successfully generated.
142 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, 145 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds,
143 cdm::AudioFrames* audio_frames); 146 cdm::AudioFrames* audio_frames);
144 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 147 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
145 148
149 void StartFileIOTest();
150
151 // Callback for CDM File IO test.
152 void OnFileIOTestComplete(bool success);
153
146 Client client_; 154 Client client_;
147 AesDecryptor decryptor_; 155 AesDecryptor decryptor_;
148 156
149 // Protects the |client_| from being accessed by the |decryptor_| 157 // Protects the |client_| from being accessed by the |decryptor_|
150 // simultaneously. 158 // simultaneously.
151 base::Lock client_lock_; 159 base::Lock client_lock_;
152 160
153 ClearKeyCdmHost* host_; 161 ClearKeyCdmHost* host_;
154 162
155 const bool is_decrypt_only_; 163 const bool is_decrypt_only_;
164 const bool should_test_file_io_;
156 165
157 std::string heartbeat_session_id_; 166 std::string last_session_id_;
167
158 std::string next_heartbeat_message_; 168 std::string next_heartbeat_message_;
159 169
160 // Timer delay in milliseconds for the next host_->SetTimer() call. 170 // Timer delay in milliseconds for the next host_->SetTimer() call.
161 int64 timer_delay_ms_; 171 int64 timer_delay_ms_;
162 172
163 // Indicates whether a timer has been set to prevent multiple timers from 173 // Indicates whether a timer has been set to prevent multiple timers from
164 // running. 174 // running.
165 bool timer_set_; 175 bool timer_set_;
166 176
167 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 177 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
168 int channel_count_; 178 int channel_count_;
169 int bits_per_channel_; 179 int bits_per_channel_;
170 int samples_per_second_; 180 int samples_per_second_;
171 int64 output_timestamp_base_in_microseconds_; 181 int64 output_timestamp_base_in_microseconds_;
172 int total_samples_generated_; 182 int total_samples_generated_;
173 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 183 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
174 184
175 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 185 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
176 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; 186 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_;
177 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER 187 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
178 188
179 scoped_ptr<CdmVideoDecoder> video_decoder_; 189 scoped_ptr<CdmVideoDecoder> video_decoder_;
180 190
191 scoped_ptr<FileIOTestRunner> file_io_test_runner_;
192
181 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); 193 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm);
182 }; 194 };
183 195
184 } // namespace media 196 } // namespace media
185 197
186 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ 198 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698