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

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

Issue 496143002: Update Pepper interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GetResolveParameterType Created 6 years, 3 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 24 matching lines...) Expand all
35 // (just a shim layer in most cases), everything is done in this header file. 35 // (just a shim layer in most cases), everything is done in this header file.
36 class CdmWrapper { 36 class CdmWrapper {
37 public: 37 public:
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 // TODO(jrummell): Remove return value when CDM4/5 are removed.
46 virtual bool SetServerCertificate(uint32_t promise_id,
47 const uint8_t* server_certificate_data,
48 uint32_t server_certificate_data_size) = 0;
45 virtual void CreateSession(uint32_t promise_id, 49 virtual void CreateSession(uint32_t promise_id,
46 const char* init_data_type, 50 const char* init_data_type,
47 uint32_t init_data_type_size, 51 uint32_t init_data_type_size,
48 const uint8_t* init_data, 52 const uint8_t* init_data,
49 uint32_t init_data_size, 53 uint32_t init_data_size,
50 cdm::SessionType session_type) = 0; 54 cdm::SessionType session_type) = 0;
51 virtual void LoadSession(uint32_t promise_id, 55 virtual void LoadSession(uint32_t promise_id,
52 const char* web_session_id, 56 const char* web_session_id,
53 uint32_t web_session_id_size) = 0; 57 uint32_t web_session_id_size) = 0;
54 virtual void UpdateSession(uint32_t promise_id, 58 virtual void UpdateSession(uint32_t promise_id,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 172
169 // Returns true if |data| is prefixed with |header| and has data after the 173 // Returns true if |data| is prefixed with |header| and has data after the
170 // |header|. 174 // |header|.
171 bool HasHeader(const uint8* data, 175 bool HasHeader(const uint8* data,
172 int data_length, 176 int data_length,
173 const std::string& header) { 177 const std::string& header) {
174 return static_cast<size_t>(data_length) > header.length() && 178 return static_cast<size_t>(data_length) > header.length() &&
175 std::equal(data, data + header.length(), header.begin()); 179 std::equal(data, data + header.length(), header.begin());
176 } 180 }
177 181
182 virtual bool SetServerCertificate(
183 uint32_t promise_id,
184 const uint8_t* server_certificate_data,
185 uint32_t server_certificate_data_size) OVERRIDE {
186 cdm_->SetServerCertificate(
187 promise_id, server_certificate_data, server_certificate_data_size);
188 return true;
189 }
190
178 virtual void CreateSession(uint32_t promise_id, 191 virtual void CreateSession(uint32_t promise_id,
179 const char* init_data_type, 192 const char* init_data_type,
180 uint32_t init_data_type_size, 193 uint32_t init_data_type_size,
181 const uint8_t* init_data, 194 const uint8_t* init_data,
182 uint32_t init_data_size, 195 uint32_t init_data_size,
183 cdm::SessionType session_type) OVERRIDE { 196 cdm::SessionType session_type) OVERRIDE {
184 // TODO(jrummell): Remove this code once |session_type| is passed through 197 // TODO(jrummell): Remove this code once |session_type| is passed through
185 // Pepper. When removing, add the header back in for CDM4. 198 // Pepper. When removing, add the header back in for CDM4.
186 PP_DCHECK(session_type == cdm::kTemporary); 199 PP_DCHECK(session_type == cdm::kTemporary);
187 const char kPersistentSessionHeader[] = "PERSISTENT|"; 200 const char kPersistentSessionHeader[] = "PERSISTENT|";
(...skipping 26 matching lines...) Expand all
214 uint32_t web_session_id_size, 227 uint32_t web_session_id_size,
215 const uint8_t* response, 228 const uint8_t* response,
216 uint32_t response_size) OVERRIDE { 229 uint32_t response_size) OVERRIDE {
217 cdm_->UpdateSession(promise_id, 230 cdm_->UpdateSession(promise_id,
218 web_session_id, 231 web_session_id,
219 web_session_id_size, 232 web_session_id_size,
220 response, 233 response,
221 response_size); 234 response_size);
222 } 235 }
223 236
224 virtual bool GetUsableKeyIds(uint32_t promise_id,
225 const char* web_session_id,
226 uint32_t web_session_id_size) OVERRIDE {
227 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
228 return true;
229 }
230
231 virtual bool CloseSession(uint32_t promise_id, 237 virtual bool CloseSession(uint32_t promise_id,
232 const char* web_session_id, 238 const char* web_session_id,
233 uint32_t web_session_id_size) OVERRIDE { 239 uint32_t web_session_id_size) OVERRIDE {
234 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); 240 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size);
235 return true; 241 return true;
236 } 242 }
237 243
238 virtual void RemoveSession(uint32_t promise_id, 244 virtual void RemoveSession(uint32_t promise_id,
239 const char* web_session_id, 245 const char* web_session_id,
240 uint32_t web_session_id_size) OVERRIDE { 246 uint32_t web_session_id_size) OVERRIDE {
241 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); 247 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
242 } 248 }
243 249
250 virtual bool GetUsableKeyIds(uint32_t promise_id,
251 const char* web_session_id,
252 uint32_t web_session_id_size) OVERRIDE {
253 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
254 return true;
255 }
256
244 virtual void TimerExpired(void* context) OVERRIDE { 257 virtual void TimerExpired(void* context) OVERRIDE {
245 cdm_->TimerExpired(context); 258 cdm_->TimerExpired(context);
246 } 259 }
247 260
248 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 261 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
249 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { 262 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE {
250 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 263 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer);
251 } 264 }
252 265
253 virtual cdm::Status InitializeAudioDecoder( 266 virtual cdm::Status InitializeAudioDecoder(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, 412 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids,
400 // but the CDM interface needs session ids. For create and load, we need to 413 // but the CDM interface needs session ids. For create and load, we need to
401 // create a new session_id to pass to the CDM. For update and release, we need 414 // create a new session_id to pass to the CDM. For update and release, we need
402 // to look up |web_session_id| and convert it into the existing |session_id|. 415 // to look up |web_session_id| and convert it into the existing |session_id|.
403 // Since the callbacks don't come through this interface, cdm_adapter needs to 416 // Since the callbacks don't come through this interface, cdm_adapter needs to
404 // create the mapping (and delete it on release). Finally, for create, we need 417 // create the mapping (and delete it on release). Finally, for create, we need
405 // to translate |init_data_type| to a MIME type. 418 // to translate |init_data_type| to a MIME type.
406 // TODO(jrummell): Remove these once Host_4 interface is removed. 419 // TODO(jrummell): Remove these once Host_4 interface is removed.
407 420
408 template <> 421 template <>
422 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::SetServerCertificate(
423 uint32_t promise_id,
424 const uint8_t* server_certificate_data,
425 uint32_t server_certificate_data_size) {
426 return false;
427 }
428
429 template <>
409 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession( 430 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession(
410 uint32_t promise_id, 431 uint32_t promise_id,
411 const char* init_data_type, 432 const char* init_data_type,
412 uint32_t init_data_type_size, 433 uint32_t init_data_type_size,
413 const uint8_t* init_data, 434 const uint8_t* init_data,
414 uint32_t init_data_size, 435 uint32_t init_data_size,
415 cdm::SessionType session_type) { 436 cdm::SessionType session_type) {
416 uint32_t session_id = CreateSessionId(); 437 uint32_t session_id = CreateSessionId();
417 RegisterPromise(session_id, promise_id); 438 RegisterPromise(session_id, promise_id);
418 std::string converted_init_data_type = ConvertInitDataTypeToContentType( 439 std::string converted_init_data_type = ConvertInitDataTypeToContentType(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 cdm::AudioFrames* audio_frames) { 529 cdm::AudioFrames* audio_frames) {
509 cdm::InputBuffer_1 buffer; 530 cdm::InputBuffer_1 buffer;
510 ConvertInputBuffer(encrypted_buffer, &buffer); 531 ConvertInputBuffer(encrypted_buffer, &buffer);
511 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); 532 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
512 } 533 }
513 534
514 // Overrides for the cdm::Host_5 methods. 535 // Overrides for the cdm::Host_5 methods.
515 // TODO(jrummell): Remove these once Host_5 interface is removed. 536 // TODO(jrummell): Remove these once Host_5 interface is removed.
516 537
517 template <> 538 template <>
539 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::SetServerCertificate(
540 uint32_t promise_id,
541 const uint8_t* server_certificate_data,
542 uint32_t server_certificate_data_size) {
543 return false;
544 }
545
546 template <>
518 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession( 547 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession(
519 uint32_t promise_id, 548 uint32_t promise_id,
520 const char* init_data_type, 549 const char* init_data_type,
521 uint32_t init_data_type_size, 550 uint32_t init_data_type_size,
522 const uint8_t* init_data, 551 const uint8_t* init_data,
523 uint32_t init_data_size, 552 uint32_t init_data_size,
524 cdm::SessionType session_type) { 553 cdm::SessionType session_type) {
525 std::string converted_init_data_type = ConvertInitDataTypeToContentType( 554 std::string converted_init_data_type = ConvertInitDataTypeToContentType(
526 std::string(init_data_type, init_data_type_size)); 555 std::string(init_data_type, init_data_type_size));
527 // TODO(jrummell): Remove this code once |session_type| is passed through 556 // TODO(jrummell): Remove this code once |session_type| is passed through
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // stub implementations for new or modified methods that the older CDM interface 699 // stub implementations for new or modified methods that the older CDM interface
671 // does not have. 700 // does not have.
672 // Also update supported_cdm_versions.h. 701 // Also update supported_cdm_versions.h.
673 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 702 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
674 cdm::ContentDecryptionModule_6::kVersion, 703 cdm::ContentDecryptionModule_6::kVersion,
675 ensure_cdm_wrapper_templates_have_old_version_support); 704 ensure_cdm_wrapper_templates_have_old_version_support);
676 705
677 } // namespace media 706 } // namespace media
678 707
679 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 708 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698