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 GURL& destination_url); | 88 const GURL& 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 OnSessionLoaded(uint32 promise_id, const std::string& web_session_id); |
| 94 void OnSessionUpdated(uint32 promise_id, const std::string& web_session_id); |
| 95 void OnSessionReleased(uint32 promise_id, const std::string& web_session_id); |
| 96 void OnPromiseFailed(uint32 promise_id, |
| 97 MediaKeys::Exception exception_code, |
| 98 uint32 system_code, |
| 99 const std::string& error_message); |
85 | 100 |
86 // Prepares next heartbeat message and sets a timer for it. | 101 // Prepares next heartbeat message and sets a timer for it. |
87 void ScheduleNextHeartBeat(); | 102 void ScheduleNextHeartBeat(); |
88 | 103 |
89 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. | 104 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. |
90 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is | 105 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is |
91 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the | 106 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the |
92 // |decrypted_buffer| is set to an empty (EOS) buffer. | 107 // |decrypted_buffer| is set to an empty (EOS) buffer. |
93 // Returns cdm::kNoKey if no decryption key was available. In this case | 108 // Returns cdm::kNoKey if no decryption key was available. In this case |
94 // |decrypted_buffer| should be ignored by the caller. | 109 // |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. | 125 // Returns cdm::kSuccess if any audio frame is successfully generated. |
111 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, | 126 cdm::Status GenerateFakeAudioFrames(int64 timestamp_in_microseconds, |
112 cdm::AudioFrames* audio_frames); | 127 cdm::AudioFrames* audio_frames); |
113 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 128 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
114 | 129 |
115 void StartFileIOTest(); | 130 void StartFileIOTest(); |
116 | 131 |
117 // Callback for CDM File IO test. | 132 // Callback for CDM File IO test. |
118 void OnFileIOTestComplete(bool success); | 133 void OnFileIOTestComplete(bool success); |
119 | 134 |
| 135 // Keep track of the last session created. |
| 136 void SetSessionId(const std::string& web_session_id); |
| 137 |
120 AesDecryptor decryptor_; | 138 AesDecryptor decryptor_; |
121 | 139 |
122 ClearKeyCdmHost* host_; | 140 ClearKeyCdmHost* host_; |
123 | 141 |
124 const std::string key_system_; | 142 const std::string key_system_; |
125 | 143 |
126 uint32 last_session_id_; | 144 std::string last_session_id_; |
127 std::string next_heartbeat_message_; | 145 std::string next_heartbeat_message_; |
128 | 146 |
129 // TODO(xhwang): Extract testing code from main implementation. | 147 // TODO(xhwang): Extract testing code from main implementation. |
130 // See http://crbug.com/341751 | 148 // See http://crbug.com/341751 |
131 uint32 session_id_for_emulated_loadsession_; | 149 std::string session_id_for_emulated_loadsession_; |
| 150 uint32_t promise_id_for_emulated_loadsession_; |
132 | 151 |
133 // Timer delay in milliseconds for the next host_->SetTimer() call. | 152 // Timer delay in milliseconds for the next host_->SetTimer() call. |
134 int64 timer_delay_ms_; | 153 int64 timer_delay_ms_; |
135 | 154 |
136 // Indicates whether a heartbeat timer has been set to prevent multiple timers | 155 // Indicates whether a heartbeat timer has been set to prevent multiple timers |
137 // from running. | 156 // from running. |
138 bool heartbeat_timer_set_; | 157 bool heartbeat_timer_set_; |
139 | 158 |
140 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 159 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
141 int channel_count_; | 160 int channel_count_; |
(...skipping 10 matching lines...) Expand all Loading... |
152 scoped_ptr<CdmVideoDecoder> video_decoder_; | 171 scoped_ptr<CdmVideoDecoder> video_decoder_; |
153 | 172 |
154 scoped_ptr<FileIOTestRunner> file_io_test_runner_; | 173 scoped_ptr<FileIOTestRunner> file_io_test_runner_; |
155 | 174 |
156 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 175 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
157 }; | 176 }; |
158 | 177 |
159 } // namespace media | 178 } // namespace media |
160 | 179 |
161 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ | 180 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ |
OLD | NEW |