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_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ | 5 #ifndef MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ |
6 #define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ | 6 #define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
15 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
16 #include "media/cdm/aes_decryptor.h" | 18 #include "media/cdm/aes_decryptor.h" |
17 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm_common.h" | 19 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm_common.h" |
(...skipping 14 matching lines...) Expand all Loading... |
32 | 34 |
33 // Clear key implementation of the cdm::ContentDecryptionModule interface. | 35 // Clear key implementation of the cdm::ContentDecryptionModule interface. |
34 class ClearKeyCdm : public ClearKeyCdmInterface { | 36 class ClearKeyCdm : public ClearKeyCdmInterface { |
35 public: | 37 public: |
36 ClearKeyCdm(Host* host, const std::string& key_system, const GURL& origin); | 38 ClearKeyCdm(Host* host, const std::string& key_system, const GURL& origin); |
37 ~ClearKeyCdm() override; | 39 ~ClearKeyCdm() override; |
38 | 40 |
39 // ContentDecryptionModule implementation. | 41 // ContentDecryptionModule implementation. |
40 void Initialize(bool allow_distinctive_identifier, | 42 void Initialize(bool allow_distinctive_identifier, |
41 bool allow_persistent_state) override; | 43 bool allow_persistent_state) override; |
42 void CreateSessionAndGenerateRequest(uint32 promise_id, | 44 void CreateSessionAndGenerateRequest(uint32_t promise_id, |
43 cdm::SessionType session_type, | 45 cdm::SessionType session_type, |
44 cdm::InitDataType init_data_type, | 46 cdm::InitDataType init_data_type, |
45 const uint8* init_data, | 47 const uint8_t* init_data, |
46 uint32 init_data_size) override; | 48 uint32_t init_data_size) override; |
47 void LoadSession(uint32 promise_id, | 49 void LoadSession(uint32_t promise_id, |
48 cdm::SessionType session_type, | 50 cdm::SessionType session_type, |
49 const char* session_id, | 51 const char* session_id, |
50 uint32_t session_id_length) override; | 52 uint32_t session_id_length) override; |
51 void UpdateSession(uint32 promise_id, | 53 void UpdateSession(uint32_t promise_id, |
52 const char* session_id, | 54 const char* session_id, |
53 uint32_t session_id_length, | 55 uint32_t session_id_length, |
54 const uint8* response, | 56 const uint8_t* response, |
55 uint32 response_size) override; | 57 uint32_t response_size) override; |
56 void CloseSession(uint32 promise_id, | 58 void CloseSession(uint32_t promise_id, |
57 const char* session_id, | 59 const char* session_id, |
58 uint32_t session_id_length) override; | 60 uint32_t session_id_length) override; |
59 void RemoveSession(uint32 promise_id, | 61 void RemoveSession(uint32_t promise_id, |
60 const char* session_id, | 62 const char* session_id, |
61 uint32_t session_id_length) override; | 63 uint32_t session_id_length) override; |
62 void SetServerCertificate(uint32 promise_id, | 64 void SetServerCertificate(uint32_t promise_id, |
63 const uint8_t* server_certificate_data, | 65 const uint8_t* server_certificate_data, |
64 uint32_t server_certificate_data_size) override; | 66 uint32_t server_certificate_data_size) override; |
65 void TimerExpired(void* context) override; | 67 void TimerExpired(void* context) override; |
66 cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, | 68 cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
67 cdm::DecryptedBlock* decrypted_block) override; | 69 cdm::DecryptedBlock* decrypted_block) override; |
68 cdm::Status InitializeAudioDecoder( | 70 cdm::Status InitializeAudioDecoder( |
69 const cdm::AudioDecoderConfig& audio_decoder_config) override; | 71 const cdm::AudioDecoderConfig& audio_decoder_config) override; |
70 cdm::Status InitializeVideoDecoder( | 72 cdm::Status InitializeVideoDecoder( |
71 const cdm::VideoDecoderConfig& video_decoder_config) override; | 73 const cdm::VideoDecoderConfig& video_decoder_config) override; |
72 void DeinitializeDecoder(cdm::StreamType decoder_type) override; | 74 void DeinitializeDecoder(cdm::StreamType decoder_type) override; |
(...skipping 11 matching lines...) Expand all Loading... |
84 | 86 |
85 private: | 87 private: |
86 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This | 88 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This |
87 // is necessary since aes_decryptor.cc does not support storing sessions. | 89 // is necessary since aes_decryptor.cc does not support storing sessions. |
88 void LoadLoadableSession(); | 90 void LoadLoadableSession(); |
89 void OnLoadSessionUpdated(); | 91 void OnLoadSessionUpdated(); |
90 | 92 |
91 // ContentDecryptionModule callbacks. | 93 // ContentDecryptionModule callbacks. |
92 void OnSessionMessage(const std::string& session_id, | 94 void OnSessionMessage(const std::string& session_id, |
93 MediaKeys::MessageType message_type, | 95 MediaKeys::MessageType message_type, |
94 const std::vector<uint8>& message, | 96 const std::vector<uint8_t>& message, |
95 const GURL& legacy_destination_url); | 97 const GURL& legacy_destination_url); |
96 void OnSessionKeysChange(const std::string& session_id, | 98 void OnSessionKeysChange(const std::string& session_id, |
97 bool has_additional_usable_key, | 99 bool has_additional_usable_key, |
98 CdmKeysInfo keys_info); | 100 CdmKeysInfo keys_info); |
99 void OnSessionClosed(const std::string& session_id); | 101 void OnSessionClosed(const std::string& session_id); |
100 | 102 |
101 // Handle the success/failure of a promise. These methods are responsible for | 103 // Handle the success/failure of a promise. These methods are responsible for |
102 // calling |host_| to resolve or reject the promise. | 104 // calling |host_| to resolve or reject the promise. |
103 void OnSessionCreated(uint32 promise_id, const std::string& session_id); | 105 void OnSessionCreated(uint32_t promise_id, const std::string& session_id); |
104 void OnSessionLoaded(uint32 promise_id, const std::string& session_id); | 106 void OnSessionLoaded(uint32_t promise_id, const std::string& session_id); |
105 void OnPromiseResolved(uint32 promise_id); | 107 void OnPromiseResolved(uint32_t promise_id); |
106 void OnPromiseFailed(uint32 promise_id, | 108 void OnPromiseFailed(uint32_t promise_id, |
107 MediaKeys::Exception exception_code, | 109 MediaKeys::Exception exception_code, |
108 uint32 system_code, | 110 uint32_t system_code, |
109 const std::string& error_message); | 111 const std::string& error_message); |
110 | 112 |
111 // Prepares next renewal message and sets a timer for it. | 113 // Prepares next renewal message and sets a timer for it. |
112 void ScheduleNextRenewal(); | 114 void ScheduleNextRenewal(); |
113 | 115 |
114 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. | 116 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. |
115 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is | 117 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is |
116 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the | 118 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the |
117 // |decrypted_buffer| is set to an empty (EOS) buffer. | 119 // |decrypted_buffer| is set to an empty (EOS) buffer. |
118 // Returns cdm::kNoKey if no decryption key was available. In this case | 120 // Returns cdm::kNoKey if no decryption key was available. In this case |
119 // |decrypted_buffer| should be ignored by the caller. | 121 // |decrypted_buffer| should be ignored by the caller. |
120 // Returns cdm::kDecryptError if any decryption error occurred. In this case | 122 // Returns cdm::kDecryptError if any decryption error occurred. In this case |
121 // |decrypted_buffer| should be ignored by the caller. | 123 // |decrypted_buffer| should be ignored by the caller. |
122 cdm::Status DecryptToMediaDecoderBuffer( | 124 cdm::Status DecryptToMediaDecoderBuffer( |
123 const cdm::InputBuffer& encrypted_buffer, | 125 const cdm::InputBuffer& encrypted_buffer, |
124 scoped_refptr<DecoderBuffer>* decrypted_buffer); | 126 scoped_refptr<DecoderBuffer>* decrypted_buffer); |
125 | 127 |
126 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 128 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
127 int64 CurrentTimeStampInMicroseconds() const; | 129 int64_t CurrentTimeStampInMicroseconds() const; |
128 | 130 |
129 // Generates fake video frames with |duration_in_microseconds|. | 131 // Generates fake video frames with |duration_in_microseconds|. |
130 // Returns the number of samples generated in the |audio_frames|. | 132 // Returns the number of samples generated in the |audio_frames|. |
131 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, | 133 int GenerateFakeAudioFramesFromDuration(int64_t duration_in_microseconds, |
132 cdm::AudioFrames* audio_frames) const; | 134 cdm::AudioFrames* audio_frames) const; |
133 | 135 |
134 // Generates fake video frames given |input_timestamp|. | 136 // Generates fake video frames given |input_timestamp|. |
135 // Returns cdm::kSuccess if any audio frame is successfully generated. | 137 // Returns cdm::kSuccess if any audio frame is successfully generated. |
136 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 138 cdm::Status GenerateFakeAudioFrames(int64_t timestamp_in_microseconds, |
137 cdm::AudioFrames* audio_frames); | 139 cdm::AudioFrames* audio_frames); |
138 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 140 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
139 | 141 |
140 void StartFileIOTest(); | 142 void StartFileIOTest(); |
141 | 143 |
142 // Callback for CDM File IO test. | 144 // Callback for CDM File IO test. |
143 void OnFileIOTestComplete(bool success); | 145 void OnFileIOTestComplete(bool success); |
144 | 146 |
145 // Keep track of the last session created. | 147 // Keep track of the last session created. |
146 void SetSessionId(const std::string& session_id); | 148 void SetSessionId(const std::string& session_id); |
(...skipping 30 matching lines...) Expand all Loading... |
177 // |has_received_keys_change_event_for_emulated_loadsession_| should be | 179 // |has_received_keys_change_event_for_emulated_loadsession_| should be |
178 // removed (the event should have either happened or never happened). | 180 // removed (the event should have either happened or never happened). |
179 // |keys_info_for_emulated_loadsession_| may also go away if the event is | 181 // |keys_info_for_emulated_loadsession_| may also go away if the event is |
180 // not expected. See http://crbug.com/448225 | 182 // not expected. See http://crbug.com/448225 |
181 std::string session_id_for_emulated_loadsession_; | 183 std::string session_id_for_emulated_loadsession_; |
182 uint32_t promise_id_for_emulated_loadsession_; | 184 uint32_t promise_id_for_emulated_loadsession_; |
183 bool has_received_keys_change_event_for_emulated_loadsession_; | 185 bool has_received_keys_change_event_for_emulated_loadsession_; |
184 CdmKeysInfo keys_info_for_emulated_loadsession_; | 186 CdmKeysInfo keys_info_for_emulated_loadsession_; |
185 | 187 |
186 // Timer delay in milliseconds for the next host_->SetTimer() call. | 188 // Timer delay in milliseconds for the next host_->SetTimer() call. |
187 int64 timer_delay_ms_; | 189 int64_t timer_delay_ms_; |
188 | 190 |
189 // Indicates whether a renewal timer has been set to prevent multiple timers | 191 // Indicates whether a renewal timer has been set to prevent multiple timers |
190 // from running. | 192 // from running. |
191 bool renewal_timer_set_; | 193 bool renewal_timer_set_; |
192 | 194 |
193 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 195 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
194 int channel_count_; | 196 int channel_count_; |
195 int bits_per_channel_; | 197 int bits_per_channel_; |
196 int samples_per_second_; | 198 int samples_per_second_; |
197 int64 output_timestamp_base_in_microseconds_; | 199 int64_t output_timestamp_base_in_microseconds_; |
198 int total_samples_generated_; | 200 int total_samples_generated_; |
199 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 201 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
200 | 202 |
201 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 203 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
202 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; | 204 scoped_ptr<FFmpegCdmAudioDecoder> audio_decoder_; |
203 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 205 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
204 | 206 |
205 scoped_ptr<CdmVideoDecoder> video_decoder_; | 207 scoped_ptr<CdmVideoDecoder> video_decoder_; |
206 | 208 |
207 scoped_ptr<FileIOTestRunner> file_io_test_runner_; | 209 scoped_ptr<FileIOTestRunner> file_io_test_runner_; |
208 | 210 |
209 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 211 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
210 }; | 212 }; |
211 | 213 |
212 } // namespace media | 214 } // namespace media |
213 | 215 |
214 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ | 216 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ |
OLD | NEW |