Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: media/cdm/ppapi/cdm_wrapper.h

Issue 811923002: Changes to support CDM_7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass array Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_CDM_WRAPPER_H_ 5 #ifndef MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 27 matching lines...) Expand all
38 static CdmWrapper* Create(const char* key_system, 38 static CdmWrapper* Create(const char* key_system,
39 uint32_t key_system_size, 39 uint32_t key_system_size,
40 GetCdmHostFunc get_cdm_host_func, 40 GetCdmHostFunc get_cdm_host_func,
41 void* user_data); 41 void* user_data);
42 42
43 virtual ~CdmWrapper() {}; 43 virtual ~CdmWrapper() {};
44 44
45 virtual void SetServerCertificate(uint32_t promise_id, 45 virtual void SetServerCertificate(uint32_t promise_id,
46 const uint8_t* server_certificate_data, 46 const uint8_t* server_certificate_data,
47 uint32_t server_certificate_data_size) = 0; 47 uint32_t server_certificate_data_size) = 0;
48 virtual void CreateSession(uint32_t promise_id, 48 virtual void CreateSessionAndGenerateRequest(uint32_t promise_id,
49 const char* init_data_type, 49 cdm::SessionType session_type,
50 uint32_t init_data_type_size, 50 const char* init_data_type,
51 const uint8_t* init_data, 51 uint32_t init_data_type_size,
52 uint32_t init_data_size, 52 const uint8_t* init_data,
53 cdm::SessionType session_type) = 0; 53 uint32_t init_data_size) = 0;
54 virtual void LoadSession(uint32_t promise_id, 54 virtual void LoadSession(uint32_t promise_id,
55 cdm::SessionType session_type,
55 const char* web_session_id, 56 const char* web_session_id,
56 uint32_t web_session_id_size) = 0; 57 uint32_t web_session_id_size) = 0;
57 virtual void UpdateSession(uint32_t promise_id, 58 virtual void UpdateSession(uint32_t promise_id,
58 const char* web_session_id, 59 const char* web_session_id,
59 uint32_t web_session_id_size, 60 uint32_t web_session_id_size,
60 const uint8_t* response, 61 const uint8_t* response,
61 uint32_t response_size) = 0; 62 uint32_t response_size) = 0;
62 virtual void CloseSession(uint32_t promise_id, 63 virtual void CloseSession(uint32_t promise_id,
63 const char* web_session_id, 64 const char* web_session_id,
64 uint32_t web_session_id_size) = 0; 65 uint32_t web_session_id_size) = 0;
65 virtual void RemoveSession(uint32_t promise_id, 66 virtual void RemoveSession(uint32_t promise_id,
66 const char* web_session_id, 67 const char* web_session_id,
67 uint32_t web_session_id_size) = 0; 68 uint32_t web_session_id_size) = 0;
68 virtual void GetUsableKeyIds(uint32_t promise_id,
69 const char* web_session_id,
70 uint32_t web_session_id_size) = 0;
71 virtual void TimerExpired(void* context) = 0; 69 virtual void TimerExpired(void* context) = 0;
72 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 70 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
73 cdm::DecryptedBlock* decrypted_buffer) = 0; 71 cdm::DecryptedBlock* decrypted_buffer) = 0;
74 virtual cdm::Status InitializeAudioDecoder( 72 virtual cdm::Status InitializeAudioDecoder(
75 const cdm::AudioDecoderConfig& audio_decoder_config) = 0; 73 const cdm::AudioDecoderConfig& audio_decoder_config) = 0;
76 virtual cdm::Status InitializeVideoDecoder( 74 virtual cdm::Status InitializeVideoDecoder(
77 const cdm::VideoDecoderConfig& video_decoder_config) = 0; 75 const cdm::VideoDecoderConfig& video_decoder_config) = 0;
78 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; 76 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0;
79 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; 77 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0;
80 virtual cdm::Status DecryptAndDecodeFrame( 78 virtual cdm::Status DecryptAndDecodeFrame(
81 const cdm::InputBuffer& encrypted_buffer, 79 const cdm::InputBuffer& encrypted_buffer,
82 cdm::VideoFrame* video_frame) = 0; 80 cdm::VideoFrame* video_frame) = 0;
83 virtual cdm::Status DecryptAndDecodeSamples( 81 virtual cdm::Status DecryptAndDecodeSamples(
84 const cdm::InputBuffer& encrypted_buffer, 82 const cdm::InputBuffer& encrypted_buffer,
85 cdm::AudioFrames* audio_frames) = 0; 83 cdm::AudioFrames* audio_frames) = 0;
86 virtual void OnPlatformChallengeResponse( 84 virtual void OnPlatformChallengeResponse(
87 const cdm::PlatformChallengeResponse& response) = 0; 85 const cdm::PlatformChallengeResponse& response) = 0;
88 virtual void OnQueryOutputProtectionStatus( 86 virtual void OnQueryOutputProtectionStatus(
87 cdm::QueryResult result,
89 uint32_t link_mask, 88 uint32_t link_mask,
90 uint32_t output_protection_mask) = 0; 89 uint32_t output_protection_mask) = 0;
91 90
92 protected: 91 protected:
93 CdmWrapper() {} 92 CdmWrapper() {}
94 93
95 private: 94 private:
96 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 95 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
97 }; 96 };
98 97
(...skipping 22 matching lines...) Expand all
121 } 120 }
122 121
123 virtual void SetServerCertificate( 122 virtual void SetServerCertificate(
124 uint32_t promise_id, 123 uint32_t promise_id,
125 const uint8_t* server_certificate_data, 124 const uint8_t* server_certificate_data,
126 uint32_t server_certificate_data_size) override { 125 uint32_t server_certificate_data_size) override {
127 cdm_->SetServerCertificate( 126 cdm_->SetServerCertificate(
128 promise_id, server_certificate_data, server_certificate_data_size); 127 promise_id, server_certificate_data, server_certificate_data_size);
129 } 128 }
130 129
131 virtual void CreateSession(uint32_t promise_id, 130 virtual void CreateSessionAndGenerateRequest(
132 const char* init_data_type, 131 uint32_t promise_id,
133 uint32_t init_data_type_size, 132 cdm::SessionType session_type,
134 const uint8_t* init_data, 133 const char* init_data_type,
135 uint32_t init_data_size, 134 uint32_t init_data_type_size,
136 cdm::SessionType session_type) override { 135 const uint8_t* init_data,
137 cdm_->CreateSession(promise_id, 136 uint32_t init_data_size) override {
138 init_data_type, 137 cdm_->CreateSessionAndGenerateRequest(promise_id, session_type,
139 init_data_type_size, 138 init_data_type, init_data_type_size,
140 init_data, 139 init_data, init_data_size);
141 init_data_size,
142 session_type);
143 } 140 }
144 141
145 virtual void LoadSession(uint32_t promise_id, 142 virtual void LoadSession(uint32_t promise_id,
143 cdm::SessionType session_type,
146 const char* web_session_id, 144 const char* web_session_id,
147 uint32_t web_session_id_size) override { 145 uint32_t web_session_id_size) override {
148 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); 146 cdm_->LoadSession(promise_id, session_type, web_session_id,
147 web_session_id_size);
149 } 148 }
150 149
151 virtual void UpdateSession(uint32_t promise_id, 150 virtual void UpdateSession(uint32_t promise_id,
152 const char* web_session_id, 151 const char* web_session_id,
153 uint32_t web_session_id_size, 152 uint32_t web_session_id_size,
154 const uint8_t* response, 153 const uint8_t* response,
155 uint32_t response_size) override { 154 uint32_t response_size) override {
156 cdm_->UpdateSession(promise_id, 155 cdm_->UpdateSession(promise_id,
157 web_session_id, 156 web_session_id,
158 web_session_id_size, 157 web_session_id_size,
159 response, 158 response,
160 response_size); 159 response_size);
161 } 160 }
162 161
163 virtual void CloseSession(uint32_t promise_id, 162 virtual void CloseSession(uint32_t promise_id,
164 const char* web_session_id, 163 const char* web_session_id,
165 uint32_t web_session_id_size) override { 164 uint32_t web_session_id_size) override {
166 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); 165 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size);
167 } 166 }
168 167
169 virtual void RemoveSession(uint32_t promise_id, 168 virtual void RemoveSession(uint32_t promise_id,
170 const char* web_session_id, 169 const char* web_session_id,
171 uint32_t web_session_id_size) override { 170 uint32_t web_session_id_size) override {
172 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); 171 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
173 } 172 }
174 173
175 virtual void GetUsableKeyIds(uint32_t promise_id,
176 const char* web_session_id,
177 uint32_t web_session_id_size) override {
178 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
179 }
180
181 virtual void TimerExpired(void* context) override { 174 virtual void TimerExpired(void* context) override {
182 cdm_->TimerExpired(context); 175 cdm_->TimerExpired(context);
183 } 176 }
184 177
185 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 178 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
186 cdm::DecryptedBlock* decrypted_buffer) override { 179 cdm::DecryptedBlock* decrypted_buffer) override {
187 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 180 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer);
188 } 181 }
189 182
190 virtual cdm::Status InitializeAudioDecoder( 183 virtual cdm::Status InitializeAudioDecoder(
(...skipping 25 matching lines...) Expand all
216 cdm::AudioFrames* audio_frames) override { 209 cdm::AudioFrames* audio_frames) override {
217 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames); 210 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames);
218 } 211 }
219 212
220 virtual void OnPlatformChallengeResponse( 213 virtual void OnPlatformChallengeResponse(
221 const cdm::PlatformChallengeResponse& response) override { 214 const cdm::PlatformChallengeResponse& response) override {
222 cdm_->OnPlatformChallengeResponse(response); 215 cdm_->OnPlatformChallengeResponse(response);
223 } 216 }
224 217
225 virtual void OnQueryOutputProtectionStatus( 218 virtual void OnQueryOutputProtectionStatus(
219 cdm::QueryResult result,
226 uint32_t link_mask, 220 uint32_t link_mask,
227 uint32_t output_protection_mask) override { 221 uint32_t output_protection_mask) override {
228 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); 222 cdm_->OnQueryOutputProtectionStatus(result, link_mask,
223 output_protection_mask);
229 } 224 }
230 225
231 private: 226 private:
232 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) { 227 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) {
233 PP_DCHECK(cdm_); 228 PP_DCHECK(cdm_);
234 } 229 }
235 230
236 CdmInterface* cdm_; 231 CdmInterface* cdm_;
237 232
238 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); 233 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
239 }; 234 };
240 235
236 // Overrides for the cdm::Host_6 methods.
237 // TODO(jrummell): Remove these once Host_6 interface is removed.
238
239 template <>
240 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::
241 CreateSessionAndGenerateRequest(uint32_t promise_id,
242 cdm::SessionType session_type,
243 const char* init_data_type,
244 uint32_t init_data_type_size,
245 const uint8_t* init_data,
246 uint32_t init_data_size) {
247 cdm_->CreateSession(promise_id, init_data_type, init_data_type_size,
248 init_data, init_data_size, session_type);
249 }
250
251 template <>
252 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::LoadSession(
253 uint32_t promise_id,
254 cdm::SessionType session_type,
255 const char* web_session_id,
256 uint32_t web_session_id_size) {
257 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
258 }
259
260 template <>
261 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::
262 OnQueryOutputProtectionStatus(cdm::QueryResult result,
263 uint32_t link_mask,
264 uint32_t output_protection_mask) {
265 if (result == cdm::kQuerySucceeded) {
266 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask);
267 return;
268 }
269
270 // Invalid results, so return 0, 0 to indicate failure.
271 cdm_->OnQueryOutputProtectionStatus(0, 0);
272 }
273
241 CdmWrapper* CdmWrapper::Create(const char* key_system, 274 CdmWrapper* CdmWrapper::Create(const char* key_system,
242 uint32_t key_system_size, 275 uint32_t key_system_size,
243 GetCdmHostFunc get_cdm_host_func, 276 GetCdmHostFunc get_cdm_host_func,
244 void* user_data) { 277 void* user_data) {
245 static_assert(cdm::ContentDecryptionModule::kVersion == 278 static_assert(cdm::ContentDecryptionModule::kVersion ==
246 cdm::ContentDecryptionModule_6::kVersion, 279 cdm::ContentDecryptionModule_7::kVersion,
247 "update the code below"); 280 "update the code below");
248 281
249 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. 282 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation.
250 // Always update this DCHECK when updating this function. 283 // Always update this DCHECK when updating this function.
251 // If this check fails, update this function and DCHECK or update 284 // If this check fails, update this function and DCHECK or update
252 // IsSupportedCdmInterfaceVersion(). 285 // IsSupportedCdmInterfaceVersion().
253 PP_DCHECK( 286 PP_DCHECK(!IsSupportedCdmInterfaceVersion(
254 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + 287 cdm::ContentDecryptionModule_7::kVersion + 1) &&
255 1) && 288 IsSupportedCdmInterfaceVersion(
256 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && 289 cdm::ContentDecryptionModule_7::kVersion) &&
257 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion - 290 IsSupportedCdmInterfaceVersion(
258 1)); 291 cdm::ContentDecryptionModule_6::kVersion) &&
292 !IsSupportedCdmInterfaceVersion(
293 cdm::ContentDecryptionModule_6::kVersion - 1));
259 294
260 // Try to create the CDM using the latest CDM interface version. 295 // Try to create the CDM using the latest CDM interface version.
261 CdmWrapper* cdm_wrapper = 296 CdmWrapper* cdm_wrapper =
262 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( 297 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create(
263 key_system, key_system_size, get_cdm_host_func, user_data); 298 key_system, key_system_size, get_cdm_host_func, user_data);
264 299
265 // If |cdm_wrapper| is NULL, try to create the CDM using older supported 300 // If |cdm_wrapper| is NULL, try to create the CDM using older supported
266 // versions of the CDM interface here. 301 // versions of the CDM interface here.
302 if (!cdm_wrapper) {
303 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_6>::Create(
304 key_system, key_system_size, get_cdm_host_func, user_data);
305 }
267 306
268 return cdm_wrapper; 307 return cdm_wrapper;
269 } 308 }
270 309
271 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain 310 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain
272 // stub implementations for new or modified methods that the older CDM interface 311 // stub implementations for new or modified methods that the older CDM interface
273 // does not have. 312 // does not have.
274 // Also update supported_cdm_versions.h. 313 // Also update supported_cdm_versions.h.
275 static_assert(cdm::ContentDecryptionModule::kVersion == 314 static_assert(cdm::ContentDecryptionModule::kVersion ==
276 cdm::ContentDecryptionModule_6::kVersion, 315 cdm::ContentDecryptionModule_7::kVersion,
277 "ensure cdm wrapper templates have old version support"); 316 "ensure cdm wrapper templates have old version support");
278 317
279 } // namespace media 318 } // namespace media
280 319
281 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 320 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698