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

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: Changes Created 6 years 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(uint32_t link_mask,
89 uint32_t link_mask, 87 uint32_t output_protection_mask,
90 uint32_t output_protection_mask) = 0; 88 uint32_t error_code) = 0;
91 89
92 protected: 90 protected:
93 CdmWrapper() {} 91 CdmWrapper() {}
94 92
95 private: 93 private:
96 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 94 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
97 }; 95 };
98 96
99 // Template class that does the CdmWrapper -> CdmInterface conversion. Default 97 // Template class that does the CdmWrapper -> CdmInterface conversion. Default
100 // implementations are provided. Any methods that need special treatment should 98 // implementations are provided. Any methods that need special treatment should
(...skipping 20 matching lines...) Expand all
121 } 119 }
122 120
123 virtual void SetServerCertificate( 121 virtual void SetServerCertificate(
124 uint32_t promise_id, 122 uint32_t promise_id,
125 const uint8_t* server_certificate_data, 123 const uint8_t* server_certificate_data,
126 uint32_t server_certificate_data_size) override { 124 uint32_t server_certificate_data_size) override {
127 cdm_->SetServerCertificate( 125 cdm_->SetServerCertificate(
128 promise_id, server_certificate_data, server_certificate_data_size); 126 promise_id, server_certificate_data, server_certificate_data_size);
129 } 127 }
130 128
131 virtual void CreateSession(uint32_t promise_id, 129 virtual void CreateSessionAndGenerateRequest(
132 const char* init_data_type, 130 uint32_t promise_id,
133 uint32_t init_data_type_size, 131 cdm::SessionType session_type,
134 const uint8_t* init_data, 132 const char* init_data_type,
135 uint32_t init_data_size, 133 uint32_t init_data_type_size,
136 cdm::SessionType session_type) override { 134 const uint8_t* init_data,
137 cdm_->CreateSession(promise_id, 135 uint32_t init_data_size) override {
138 init_data_type, 136 cdm_->CreateSessionAndGenerateRequest(promise_id, session_type,
139 init_data_type_size, 137 init_data_type, init_data_type_size,
140 init_data, 138 init_data, init_data_size);
141 init_data_size,
142 session_type);
143 } 139 }
144 140
145 virtual void LoadSession(uint32_t promise_id, 141 virtual void LoadSession(uint32_t promise_id,
142 cdm::SessionType session_type,
146 const char* web_session_id, 143 const char* web_session_id,
147 uint32_t web_session_id_size) override { 144 uint32_t web_session_id_size) override {
148 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); 145 cdm_->LoadSession(promise_id, session_type, web_session_id,
146 web_session_id_size);
149 } 147 }
150 148
151 virtual void UpdateSession(uint32_t promise_id, 149 virtual void UpdateSession(uint32_t promise_id,
152 const char* web_session_id, 150 const char* web_session_id,
153 uint32_t web_session_id_size, 151 uint32_t web_session_id_size,
154 const uint8_t* response, 152 const uint8_t* response,
155 uint32_t response_size) override { 153 uint32_t response_size) override {
156 cdm_->UpdateSession(promise_id, 154 cdm_->UpdateSession(promise_id,
157 web_session_id, 155 web_session_id,
158 web_session_id_size, 156 web_session_id_size,
159 response, 157 response,
160 response_size); 158 response_size);
161 } 159 }
162 160
163 virtual void CloseSession(uint32_t promise_id, 161 virtual void CloseSession(uint32_t promise_id,
164 const char* web_session_id, 162 const char* web_session_id,
165 uint32_t web_session_id_size) override { 163 uint32_t web_session_id_size) override {
166 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); 164 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size);
167 } 165 }
168 166
169 virtual void RemoveSession(uint32_t promise_id, 167 virtual void RemoveSession(uint32_t promise_id,
170 const char* web_session_id, 168 const char* web_session_id,
171 uint32_t web_session_id_size) override { 169 uint32_t web_session_id_size) override {
172 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); 170 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
173 } 171 }
174 172
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 { 173 virtual void TimerExpired(void* context) override {
182 cdm_->TimerExpired(context); 174 cdm_->TimerExpired(context);
183 } 175 }
184 176
185 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 177 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
186 cdm::DecryptedBlock* decrypted_buffer) override { 178 cdm::DecryptedBlock* decrypted_buffer) override {
187 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 179 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer);
188 } 180 }
189 181
190 virtual cdm::Status InitializeAudioDecoder( 182 virtual cdm::Status InitializeAudioDecoder(
(...skipping 24 matching lines...) Expand all
215 const cdm::InputBuffer& encrypted_buffer, 207 const cdm::InputBuffer& encrypted_buffer,
216 cdm::AudioFrames* audio_frames) override { 208 cdm::AudioFrames* audio_frames) override {
217 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames); 209 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames);
218 } 210 }
219 211
220 virtual void OnPlatformChallengeResponse( 212 virtual void OnPlatformChallengeResponse(
221 const cdm::PlatformChallengeResponse& response) override { 213 const cdm::PlatformChallengeResponse& response) override {
222 cdm_->OnPlatformChallengeResponse(response); 214 cdm_->OnPlatformChallengeResponse(response);
223 } 215 }
224 216
225 virtual void OnQueryOutputProtectionStatus( 217 virtual void OnQueryOutputProtectionStatus(uint32_t link_mask,
226 uint32_t link_mask, 218 uint32_t output_protection_mask,
227 uint32_t output_protection_mask) override { 219 uint32_t error_code) override {
228 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); 220 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask,
221 error_code);
229 } 222 }
230 223
231 private: 224 private:
232 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) { 225 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) {
233 PP_DCHECK(cdm_); 226 PP_DCHECK(cdm_);
234 } 227 }
235 228
236 CdmInterface* cdm_; 229 CdmInterface* cdm_;
237 230
238 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); 231 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
239 }; 232 };
240 233
234 // Overrides for the cdm::Host_6 methods.
235 // TODO(jrummell): Remove these once Host_6 interface is removed.
236
237 template <>
238 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::
239 CreateSessionAndGenerateRequest(uint32_t promise_id,
240 cdm::SessionType session_type,
241 const char* init_data_type,
242 uint32_t init_data_type_size,
243 const uint8_t* init_data,
244 uint32_t init_data_size) {
245 cdm_->CreateSession(promise_id, init_data_type, init_data_type_size,
246 init_data, init_data_size, session_type);
247 }
248
249 template <>
250 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::LoadSession(
251 uint32_t promise_id,
252 cdm::SessionType session_type,
253 const char* web_session_id,
254 uint32_t web_session_id_size) {
255 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
256 }
257
258 template <>
259 void CdmWrapperImpl<cdm::ContentDecryptionModule_6>::
260 OnQueryOutputProtectionStatus(uint32_t link_mask,
261 uint32_t output_protection_mask,
262 uint32_t error_code) {
263 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask);
264 }
265
241 CdmWrapper* CdmWrapper::Create(const char* key_system, 266 CdmWrapper* CdmWrapper::Create(const char* key_system,
242 uint32_t key_system_size, 267 uint32_t key_system_size,
243 GetCdmHostFunc get_cdm_host_func, 268 GetCdmHostFunc get_cdm_host_func,
244 void* user_data) { 269 void* user_data) {
245 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 270 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
246 cdm::ContentDecryptionModule_6::kVersion, 271 cdm::ContentDecryptionModule_7::kVersion,
247 update_code_below); 272 update_code_below);
248 273
249 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. 274 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation.
250 // Always update this DCHECK when updating this function. 275 // Always update this DCHECK when updating this function.
251 // If this check fails, update this function and DCHECK or update 276 // If this check fails, update this function and DCHECK or update
252 // IsSupportedCdmInterfaceVersion(). 277 // IsSupportedCdmInterfaceVersion().
253 PP_DCHECK( 278 PP_DCHECK(!IsSupportedCdmInterfaceVersion(
254 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + 279 cdm::ContentDecryptionModule_7::kVersion + 1) &&
255 1) && 280 IsSupportedCdmInterfaceVersion(
256 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && 281 cdm::ContentDecryptionModule_7::kVersion) &&
257 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion - 282 IsSupportedCdmInterfaceVersion(
258 1)); 283 cdm::ContentDecryptionModule_6::kVersion) &&
284 !IsSupportedCdmInterfaceVersion(
285 cdm::ContentDecryptionModule_6::kVersion - 1));
259 286
260 // Try to create the CDM using the latest CDM interface version. 287 // Try to create the CDM using the latest CDM interface version.
261 CdmWrapper* cdm_wrapper = 288 CdmWrapper* cdm_wrapper =
262 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( 289 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create(
263 key_system, key_system_size, get_cdm_host_func, user_data); 290 key_system, key_system_size, get_cdm_host_func, user_data);
264 291
265 // If |cdm_wrapper| is NULL, try to create the CDM using older supported 292 // If |cdm_wrapper| is NULL, try to create the CDM using older supported
266 // versions of the CDM interface here. 293 // versions of the CDM interface here.
294 if (!cdm_wrapper) {
295 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_6>::Create(
296 key_system, key_system_size, get_cdm_host_func, user_data);
297 }
267 298
268 return cdm_wrapper; 299 return cdm_wrapper;
269 } 300 }
270 301
271 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain 302 // 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 303 // stub implementations for new or modified methods that the older CDM interface
273 // does not have. 304 // does not have.
274 // Also update supported_cdm_versions.h. 305 // Also update supported_cdm_versions.h.
275 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 306 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
276 cdm::ContentDecryptionModule_6::kVersion, 307 cdm::ContentDecryptionModule_7::kVersion,
277 ensure_cdm_wrapper_templates_have_old_version_support); 308 ensure_cdm_wrapper_templates_have_old_version_support);
278 309
279 } // namespace media 310 } // namespace media
280 311
281 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 312 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698