| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class DecoderBuffer; | 28 class DecoderBuffer; |
| 29 class FFmpegCdmAudioDecoder; | 29 class FFmpegCdmAudioDecoder; |
| 30 | 30 |
| 31 // Clear key implementation of the cdm::ContentDecryptionModule interface. | 31 // Clear key implementation of the cdm::ContentDecryptionModule interface. |
| 32 class ClearKeyCdm : public ClearKeyCdmInterface { | 32 class ClearKeyCdm : public ClearKeyCdmInterface { |
| 33 public: | 33 public: |
| 34 ClearKeyCdm(Host* host, const std::string& key_system); | 34 ClearKeyCdm(Host* host, const std::string& key_system); |
| 35 virtual ~ClearKeyCdm(); | 35 virtual ~ClearKeyCdm(); |
| 36 | 36 |
| 37 // ContentDecryptionModule implementation. | 37 // ContentDecryptionModule implementation. |
| 38 virtual void CreateSession( | 38 virtual void CreateSession(uint32 promise_id, |
| 39 uint32 session_id, | 39 const char* init_data_type, |
| 40 const char* type, uint32 type_size, | 40 uint32 init_data_type_size, |
| 41 const uint8* init_data, uint32 init_data_size) OVERRIDE; | 41 const uint8* init_data, |
| 42 virtual void LoadSession( | 42 uint32 init_data_size, |
| 43 uint32_t session_id, | 43 cdm::SessionType session_type) OVERRIDE; |
| 44 const char* web_session_id, uint32_t web_session_id_length) OVERRIDE; | 44 virtual void LoadSession(uint32 promise_id, |
| 45 virtual void UpdateSession( | 45 const char* web_session_id, |
| 46 uint32 session_id, | 46 uint32_t web_session_id_length) OVERRIDE; |
| 47 const uint8* response, uint32 response_size) OVERRIDE; | 47 virtual void UpdateSession(uint32 promise_id, |
| 48 virtual void ReleaseSession(uint32 session_id) OVERRIDE; | 48 const char* web_session_id, |
| 49 uint32_t web_session_id_length, |
| 50 const uint8* response, |
| 51 uint32 response_size) OVERRIDE; |
| 52 virtual void ReleaseSession(uint32 promise_id, |
| 53 const char* web_session_id, |
| 54 uint32_t web_session_id_length) OVERRIDE; |
| 55 virtual void SetServerCertificate( |
| 56 uint32 promise_id, |
| 57 const uint8_t* server_certificate_data, |
| 58 uint32_t server_certificate_data_size) OVERRIDE; |
| 49 virtual void TimerExpired(void* context) OVERRIDE; | 59 virtual void TimerExpired(void* context) OVERRIDE; |
| 50 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, | 60 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
| 51 cdm::DecryptedBlock* decrypted_block) OVERRIDE; | 61 cdm::DecryptedBlock* decrypted_block) OVERRIDE; |
| 52 virtual cdm::Status InitializeAudioDecoder( | 62 virtual cdm::Status InitializeAudioDecoder( |
| 53 const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE; | 63 const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE; |
| 54 virtual cdm::Status InitializeVideoDecoder( | 64 virtual cdm::Status InitializeVideoDecoder( |
| 55 const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE; | 65 const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE; |
| 56 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE; | 66 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE; |
| 57 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE; | 67 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE; |
| 58 virtual cdm::Status DecryptAndDecodeFrame( | 68 virtual cdm::Status DecryptAndDecodeFrame( |
| 59 const cdm::InputBuffer& encrypted_buffer, | 69 const cdm::InputBuffer& encrypted_buffer, |
| 60 cdm::VideoFrame* video_frame) OVERRIDE; | 70 cdm::VideoFrame* video_frame) OVERRIDE; |
| 61 virtual cdm::Status DecryptAndDecodeSamples( | 71 virtual cdm::Status DecryptAndDecodeSamples( |
| 62 const cdm::InputBuffer& encrypted_buffer, | 72 const cdm::InputBuffer& encrypted_buffer, |
| 63 cdm::AudioFrames* audio_frames) OVERRIDE; | 73 cdm::AudioFrames* audio_frames) OVERRIDE; |
| 64 virtual void Destroy() OVERRIDE; | 74 virtual void Destroy() OVERRIDE; |
| 65 virtual void OnPlatformChallengeResponse( | 75 virtual void OnPlatformChallengeResponse( |
| 66 const cdm::PlatformChallengeResponse& response) OVERRIDE; | 76 const cdm::PlatformChallengeResponse& response) OVERRIDE; |
| 67 virtual void OnQueryOutputProtectionStatus( | 77 virtual void OnQueryOutputProtectionStatus( |
| 68 uint32_t link_mask, uint32_t output_protection_mask) OVERRIDE; | 78 uint32_t link_mask, uint32_t output_protection_mask) OVERRIDE; |
| 69 | 79 |
| 70 private: | 80 private: |
| 71 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This | 81 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This |
| 72 // is necessary since aes_decryptor.cc does not support storing sessions. | 82 // is necessary since aes_decryptor.cc does not support storing sessions. |
| 73 void LoadLoadableSession(); | 83 void LoadLoadableSession(); |
| 74 | 84 |
| 75 // ContentDecryptionModule callbacks. | 85 // ContentDecryptionModule callbacks. |
| 76 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); | 86 void OnSessionMessage(const std::string& web_session_id, |
| 77 void OnSessionMessage(uint32 session_id, | |
| 78 const std::vector<uint8>& message, | 87 const std::vector<uint8>& message, |
| 79 const std::string& destination_url); | 88 const std::string& destination_url); |
| 80 void OnSessionReady(uint32 session_id); | 89 |
| 81 void OnSessionClosed(uint32 session_id); | 90 // Handle the success/failure of a promise. These methods are responsible for |
| 82 void OnSessionError(uint32 session_id, | 91 // calling |host_| to resolve or reject the promise. |
| 83 MediaKeys::KeyError error_code, | 92 void OnSessionCreated(uint32 promise_id, const std::string& web_session_id); |
| 84 uint32 system_code); | 93 void OnSessionCreateFailed(uint32 promise_id, |
| 94 MediaKeys::MediaKeysException exception_code, |
| 95 uint32 system_code, |
| 96 const std::string& error_message); |
| 97 void OnSessionLoaded(uint32 promise_id, const std::string& web_session_id); |
| 98 void OnSessionLoadFailed(uint32 promise_id, |
| 99 MediaKeys::MediaKeysException exception_code, |
| 100 uint32 system_code, |
| 101 const std::string& error_message); |
| 102 void OnSessionUpdated(uint32 promise_id, const std::string& web_session_id); |
| 103 void OnSessionUpdateFailed(uint32 promise_id, |
| 104 MediaKeys::MediaKeysException exception_code, |
| 105 uint32 system_code, |
| 106 const std::string& error_message); |
| 107 void OnSessionReleased(uint32 promise_id, const std::string& web_session_id); |
| 108 void OnSessionReleaseFailed(uint32 promise_id, |
| 109 MediaKeys::MediaKeysException exception_code, |
| 110 uint32 system_code, |
| 111 const std::string& error_message); |
| 112 void RejectPromise(uint32 promise_id, |
| 113 MediaKeys::MediaKeysException exception_code, |
| 114 uint32 system_code, |
| 115 const std::string& error_message); |
| 85 | 116 |
| 86 // Prepares next heartbeat message and sets a timer for it. | 117 // Prepares next heartbeat message and sets a timer for it. |
| 87 void ScheduleNextHeartBeat(); | 118 void ScheduleNextHeartBeat(); |
| 88 | 119 |
| 89 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. | 120 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. |
| 90 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is | 121 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is |
| 91 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the | 122 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the |
| 92 // |decrypted_buffer| is set to an empty (EOS) buffer. | 123 // |decrypted_buffer| is set to an empty (EOS) buffer. |
| 93 // Returns cdm::kNoKey if no decryption key was available. In this case | 124 // Returns cdm::kNoKey if no decryption key was available. In this case |
| 94 // |decrypted_buffer| should be ignored by the caller. | 125 // |decrypted_buffer| should be ignored by the caller. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 // Returns cdm::kSuccess if any audio frame is successfully generated. | 141 // Returns cdm::kSuccess if any audio frame is successfully generated. |
| 111 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 142 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, |
| 112 cdm::AudioFrames* audio_frames); | 143 cdm::AudioFrames* audio_frames); |
| 113 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 144 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 114 | 145 |
| 115 void StartFileIOTest(); | 146 void StartFileIOTest(); |
| 116 | 147 |
| 117 // Callback for CDM File IO test. | 148 // Callback for CDM File IO test. |
| 118 void OnFileIOTestComplete(bool success); | 149 void OnFileIOTestComplete(bool success); |
| 119 | 150 |
| 151 // Keep track of the last session created. |
| 152 void SetSessionId(const std::string& web_session_id); |
| 153 |
| 120 AesDecryptor decryptor_; | 154 AesDecryptor decryptor_; |
| 121 | 155 |
| 122 ClearKeyCdmHost* host_; | 156 ClearKeyCdmHost* host_; |
| 123 | 157 |
| 124 const std::string key_system_; | 158 const std::string key_system_; |
| 125 | 159 |
| 126 uint32 last_session_id_; | 160 std::string last_session_id_; |
| 127 std::string next_heartbeat_message_; | 161 std::string next_heartbeat_message_; |
| 128 | 162 |
| 129 // TODO(xhwang): Extract testing code from main implementation. | 163 // TODO(xhwang): Extract testing code from main implementation. |
| 130 // See http://crbug.com/341751 | 164 // See http://crbug.com/341751 |
| 131 uint32 session_id_for_emulated_loadsession_; | 165 std::string session_id_for_emulated_loadsession_; |
| 166 uint32_t promise_id_for_emulated_loadsession_; |
| 132 | 167 |
| 133 // Timer delay in milliseconds for the next host_->SetTimer() call. | 168 // Timer delay in milliseconds for the next host_->SetTimer() call. |
| 134 int64 timer_delay_ms_; | 169 int64 timer_delay_ms_; |
| 135 | 170 |
| 136 // Indicates whether a heartbeat timer has been set to prevent multiple timers | 171 // Indicates whether a heartbeat timer has been set to prevent multiple timers |
| 137 // from running. | 172 // from running. |
| 138 bool heartbeat_timer_set_; | 173 bool heartbeat_timer_set_; |
| 139 | 174 |
| 140 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 175 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 141 int channel_count_; | 176 int channel_count_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 152 scoped_ptr<CdmVideoDecoder> video_decoder_; | 187 scoped_ptr<CdmVideoDecoder> video_decoder_; |
| 153 | 188 |
| 154 scoped_ptr<FileIOTestRunner> file_io_test_runner_; | 189 scoped_ptr<FileIOTestRunner> file_io_test_runner_; |
| 155 | 190 |
| 156 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 191 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
| 157 }; | 192 }; |
| 158 | 193 |
| 159 } // namespace media | 194 } // namespace media |
| 160 | 195 |
| 161 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ | 196 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ |
| OLD | NEW |