| 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); | 34 explicit ClearKeyCdm(Host* host); |
| 34 virtual ~ClearKeyCdm(); | 35 virtual ~ClearKeyCdm(); |
| 35 | 36 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Returns the number of samples generated in the |audio_frames|. | 135 // Returns the number of samples generated in the |audio_frames|. |
| 135 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, | 136 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, |
| 136 cdm::AudioFrames* audio_frames) const; | 137 cdm::AudioFrames* audio_frames) const; |
| 137 | 138 |
| 138 // Generates fake video frames given |input_timestamp|. | 139 // Generates fake video frames given |input_timestamp|. |
| 139 // Returns cdm::kSuccess if any audio frame is successfully generated. | 140 // Returns cdm::kSuccess if any audio frame is successfully generated. |
| 140 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 141 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, |
| 141 cdm::AudioFrames* audio_frames); | 142 cdm::AudioFrames* audio_frames); |
| 142 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 143 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 143 | 144 |
| 145 void StartCdmFileIOTest(); |
| 146 |
| 147 // Callback for CDM File IO test. |
| 148 void OnCdmFileIOTestComplete(bool success); |
| 149 |
| 144 Client client_; | 150 Client client_; |
| 145 AesDecryptor decryptor_; | 151 AesDecryptor decryptor_; |
| 146 | 152 |
| 147 // Protects the |client_| from being accessed by the |decryptor_| | 153 // Protects the |client_| from being accessed by the |decryptor_| |
| 148 // simultaneously. | 154 // simultaneously. |
| 149 base::Lock client_lock_; | 155 base::Lock client_lock_; |
| 150 | 156 |
| 151 ClearKeyCdmHost* host_; | 157 ClearKeyCdmHost* host_; |
| 152 | 158 |
| 153 std::string heartbeat_session_id_; | 159 std::string last_session_id_; |
| 160 |
| 154 std::string next_heartbeat_message_; | 161 std::string next_heartbeat_message_; |
| 155 | 162 |
| 156 // Timer delay in milliseconds for the next host_->SetTimer() call. | 163 // Timer delay in milliseconds for the next host_->SetTimer() call. |
| 157 int64 timer_delay_ms_; | 164 int64 timer_delay_ms_; |
| 158 | 165 |
| 159 // Indicates whether a timer has been set to prevent multiple timers from | 166 // Indicates whether a timer has been set to prevent multiple timers from |
| 160 // running. | 167 // running. |
| 161 bool timer_set_; | 168 bool timer_set_; |
| 162 | 169 |
| 163 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 170 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 164 int channel_count_; | 171 int channel_count_; |
| 165 int bits_per_channel_; | 172 int bits_per_channel_; |
| 166 int samples_per_second_; | 173 int samples_per_second_; |
| 167 int64 output_timestamp_base_in_microseconds_; | 174 int64 output_timestamp_base_in_microseconds_; |
| 168 int total_samples_generated_; | 175 int total_samples_generated_; |
| 169 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 176 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 170 | 177 |
| 171 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 178 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
| 172 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; | 179 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; |
| 173 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 180 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
| 174 | 181 |
| 175 scoped_ptr<CdmVideoDecoder> video_decoder_; | 182 scoped_ptr<CdmVideoDecoder> video_decoder_; |
| 176 | 183 |
| 184 scoped_ptr<CdmFileIOTest> cdm_file_io_test_; |
| 185 |
| 177 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 186 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
| 178 }; | 187 }; |
| 179 | 188 |
| 180 } // namespace media | 189 } // namespace media |
| 181 | 190 |
| 182 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ | 191 #endif // MEDIA_CDM_PPAPI_CLEAR_KEY_CDM_H_ |
| OLD | NEW |