OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "media/base/decryptor_client.h" | 15 #include "media/base/decryptor_client.h" |
16 #include "media/crypto/aes_decryptor.h" | 16 #include "media/crypto/aes_decryptor.h" |
17 #include "webkit/media/crypto/ppapi/content_decryption_module.h" | 17 #include "webkit/media/crypto/ppapi/content_decryption_module.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(xhwang): Move fake decoders into separate classes. | 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 #if 0 | |
26 #define CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | |
27 #endif | |
28 | |
29 #if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) | |
30 #undef CLEAR_KEY_CDM_USE_FFMPEG_DECODER | |
31 #endif | |
32 | |
33 namespace media { | 25 namespace media { |
34 class DecoderBuffer; | 26 class DecoderBuffer; |
35 } | 27 } |
36 | 28 |
37 namespace webkit_media { | 29 namespace webkit_media { |
38 | 30 |
| 31 class CdmVideoDecoder; |
39 class FFmpegCdmAudioDecoder; | 32 class FFmpegCdmAudioDecoder; |
40 class FFmpegCdmVideoDecoder; | |
41 | 33 |
42 // Clear key implementation of the cdm::ContentDecryptionModule interface. | 34 // Clear key implementation of the cdm::ContentDecryptionModule interface. |
43 class ClearKeyCdm : public cdm::ContentDecryptionModule { | 35 class ClearKeyCdm : public cdm::ContentDecryptionModule { |
44 public: | 36 public: |
45 ClearKeyCdm(cdm::Allocator* allocator, cdm::CdmHost* cdm_host); | 37 ClearKeyCdm(cdm::Allocator* allocator, cdm::CdmHost* cdm_host); |
46 virtual ~ClearKeyCdm(); | 38 virtual ~ClearKeyCdm(); |
47 | 39 |
48 // ContentDecryptionModule implementation. | 40 // ContentDecryptionModule implementation. |
49 virtual cdm::Status GenerateKeyRequest( | 41 virtual cdm::Status GenerateKeyRequest( |
50 const char* type, int type_size, | 42 const char* type, int type_size, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 128 |
137 // Generates fake video frames with |duration_in_microseconds|. | 129 // Generates fake video frames with |duration_in_microseconds|. |
138 // Returns the number of samples generated in the |audio_frames|. | 130 // Returns the number of samples generated in the |audio_frames|. |
139 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, | 131 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, |
140 cdm::AudioFrames* audio_frames) const; | 132 cdm::AudioFrames* audio_frames) const; |
141 | 133 |
142 // Generates fake video frames given |input_timestamp|. | 134 // Generates fake video frames given |input_timestamp|. |
143 // Returns cdm::kSuccess if any audio frame is successfully generated. | 135 // Returns cdm::kSuccess if any audio frame is successfully generated. |
144 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 136 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, |
145 cdm::AudioFrames* audio_frames); | 137 cdm::AudioFrames* audio_frames); |
146 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | 138 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
147 | |
148 #if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) | |
149 // Generates a fake video frame with |video_size_| and |timestamp|. | |
150 void GenerateFakeVideoFrame(base::TimeDelta timestamp, | |
151 cdm::VideoFrame* video_frame); | |
152 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | |
153 | 139 |
154 Client client_; | 140 Client client_; |
155 media::AesDecryptor decryptor_; | 141 media::AesDecryptor decryptor_; |
156 | 142 |
157 // Protects the |client_| from being accessed by the |decryptor_| | 143 // Protects the |client_| from being accessed by the |decryptor_| |
158 // simultaneously. | 144 // simultaneously. |
159 base::Lock client_lock_; | 145 base::Lock client_lock_; |
160 | 146 |
161 cdm::Allocator* const allocator_; | 147 cdm::Allocator* const allocator_; |
162 cdm::CdmHost* cdm_host_; | 148 cdm::CdmHost* cdm_host_; |
(...skipping 10 matching lines...) Expand all Loading... |
173 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 159 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
174 int channel_count_; | 160 int channel_count_; |
175 int bits_per_channel_; | 161 int bits_per_channel_; |
176 int samples_per_second_; | 162 int samples_per_second_; |
177 int64 output_timestamp_base_in_microseconds_; | 163 int64 output_timestamp_base_in_microseconds_; |
178 int total_samples_generated_; | 164 int total_samples_generated_; |
179 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 165 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
180 | 166 |
181 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 167 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
182 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; | 168 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; |
183 scoped_ptr<FFmpegCdmVideoDecoder> video_decoder_; | |
184 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 169 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
185 | 170 |
186 #if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) | 171 scoped_ptr<CdmVideoDecoder> video_decoder_; |
187 cdm::Size video_size_; | 172 |
188 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | 173 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
189 }; | 174 }; |
190 | 175 |
191 } // namespace webkit_media | 176 } // namespace webkit_media |
192 | 177 |
193 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ | 178 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
OLD | NEW |