18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include <map> 9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include <queue> 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include <string> 11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h" 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/api/content_decryption_module.h" 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/cdm_helpers.h" 150f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "media/cdm/ppapi/supported_cdm_versions.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/logging.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace media { 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// CdmWrapper wraps different versions of ContentDecryptionModule interfaces and 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// exposes a common interface to the caller. 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// The caller should call CdmWrapper::Create() to create a CDM instance. 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// CdmWrapper will first try to create a CDM instance that supports the latest 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// CDM interface (ContentDecryptionModule). If such an instance cannot be 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// created (e.g. an older CDM was loaded), CdmWrapper will try to create a CDM 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// that supports an older version of CDM interface (e.g. 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// ContentDecryptionModule_*). Internally CdmWrapper converts the CdmWrapper 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// calls to corresponding ContentDecryptionModule calls. 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Note that CdmWrapper interface always reflects the latest state of content 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// decryption related PPAPI APIs (e.g. pp::ContentDecryptor_Private). 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Since this file is highly templated and default implementations are short 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// (just a shim layer in most cases), everything is done in this header file. 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class CdmWrapper { 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) static CdmWrapper* Create(const char* key_system, 391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t key_system_size, 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) GetCdmHostFunc get_cdm_host_func, 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* user_data); 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~CdmWrapper() {}; 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(jrummell): Remove return value when CDM4/5 are removed. 461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool SetServerCertificate(uint32_t promise_id, 471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const uint8_t* server_certificate_data, 481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t server_certificate_data_size) = 0; 49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void CreateSession(uint32_t promise_id, 50f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* init_data_type, 51f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_type_size, 52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const uint8_t* init_data, 53f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_size, 54f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::SessionType session_type) = 0; 55f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void LoadSession(uint32_t promise_id, 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const char* web_session_id, 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t web_session_id_size) = 0; 58f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void UpdateSession(uint32_t promise_id, 59f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 60f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size, 61c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const uint8_t* response, 62c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch uint32_t response_size) = 0; 631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(jrummell): Remove return value when CDM4/5 are removed. 641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool CloseSession(uint32_t promise_id, 656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) = 0; 671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void RemoveSession(uint32_t promise_id, 686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) = 0; 701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(jrummell): Remove return value when CDM4/5 are removed. 716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual bool GetUsableKeyIds(uint32_t promise_id, 726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) = 0; 748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void TimerExpired(void* context) = 0; 758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::DecryptedBlock* decrypted_buffer) = 0; 778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status InitializeAudioDecoder( 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::AudioDecoderConfig& audio_decoder_config) = 0; 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status InitializeVideoDecoder( 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::VideoDecoderConfig& video_decoder_config) = 0; 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; 828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; 838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status DecryptAndDecodeFrame( 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::VideoFrame* video_frame) = 0; 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status DecryptAndDecodeSamples( 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::AudioFrames* audio_frames) = 0; 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void OnPlatformChallengeResponse( 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::PlatformChallengeResponse& response) = 0; 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void OnQueryOutputProtectionStatus( 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t link_mask, 938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t output_protection_mask) = 0; 948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 95f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Helper function for the cdm::Host_4 methods. Calls to CreateSession(), 96f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, 97f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // but the CDM interface needs session ids. For create and load, we need to 98f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // create a new session_id to pass to the CDM. For update and release, we need 99f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // to look up |web_session_id| and convert it into the existing |session_id|. 100f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Since the callbacks don't come through this interface, cdm_adapter needs to 101f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // create the mapping (and delete it on release). 102f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // TODO(jrummell): Remove these once Host_4 interface is removed. 103f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual uint32_t LookupPromiseId(uint32_t session_id) = 0; 104f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void AssignWebSessionId(uint32_t session_id, 105f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 106f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size) = 0; 107f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual std::string LookupWebSessionId(uint32_t session_id) = 0; 108f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void DropWebSessionId(std::string web_session_id) = 0; 109f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Helper functions for the cdm::Host_4 methods. 1116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when 1126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // resolving LoadSession() and UpdateSession(). This needs to be simulated 1136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // for the older CDMs. These must not be called for cdm::Host_6 and later. 1141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(jrummell): Remove these once Host_4 interface is removed. 1156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Query whether a SessionUsableKeys event is necessary for the specified 1176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // |promise_id|. Returns true if needed and |web_session_id| is updated, 1186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // otherwise returns false. 1196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, 1206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::string* web_session_id) = 0; 1216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Used to indicate that a SessionUsableKeys event is required for the 1236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // specified |promise_id| and associated |web_session_id|. 1246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void SetSessionUsableKeysEventNeeded( 1256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t promise_id, 1266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 1276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) = 0; 1286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 1301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // methods still use InputBuffer_1, so this helper function 1316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // converts InputBuffer_2 to InputBuffer_1. 1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(jrummell): Remove these once Host_4 interfaces is removed. 1336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void ConvertInputBuffer(const cdm::InputBuffer& v2, 1346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::InputBuffer_1* v1) = 0; 1356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Prior to CDM_6, |init_data_type| was a content type. This helper convererts 1376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // an |init_data_type| to a content type. 1381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // TODO(sandersd): Remove once Host_4 interface is removed. 13903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual std::string ConvertInitDataTypeToContentType( 14003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const std::string& init_data_type) const = 0; 1416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 142a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) protected: 143c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch CdmWrapper() {} 1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 1478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Template class that does the CdmWrapper -> CdmInterface conversion. Default 1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// implementations are provided. Any methods that need special treatment should 1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// be specialized. 1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)template <class CdmInterface> 1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class CdmWrapperImpl : public CdmWrapper { 1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) static CdmWrapper* Create(const char* key_system, 1561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t key_system_size, 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) GetCdmHostFunc get_cdm_host_func, 1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* user_data) { 1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* cdm_instance = ::CreateCdmInstance( 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CdmInterface::kVersion, key_system, key_system_size, get_cdm_host_func, 1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) user_data); 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (!cdm_instance) 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return NULL; 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return new CdmWrapperImpl<CdmInterface>( 1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) static_cast<CdmInterface*>(cdm_instance)); 1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~CdmWrapperImpl() { 1708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->Destroy(); 1718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Returns true if |data| is prefixed with |header| and has data after the 1746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // |header|. 1756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool HasHeader(const uint8* data, 1766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int data_length, 1776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const std::string& header) { 1786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return static_cast<size_t>(data_length) > header.length() && 1796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::equal(data, data + header.length(), header.begin()); 1806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 1816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool SetServerCertificate( 1831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t promise_id, 1841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const uint8_t* server_certificate_data, 1851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t server_certificate_data_size) OVERRIDE { 1861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci cdm_->SetServerCertificate( 1871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci promise_id, server_certificate_data, server_certificate_data_size); 1881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return true; 1891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 191f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void CreateSession(uint32_t promise_id, 192f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* init_data_type, 193f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_type_size, 194a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const uint8_t* init_data, 195f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_size, 196f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::SessionType session_type) OVERRIDE { 1976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO(jrummell): Remove this code once |session_type| is passed through 1986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Pepper. When removing, add the header back in for CDM4. 1996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) PP_DCHECK(session_type == cdm::kTemporary); 2006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char kPersistentSessionHeader[] = "PERSISTENT|"; 2016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) if (HasHeader(init_data, init_data_size, kPersistentSessionHeader)) { 2026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm_->CreateSession(promise_id, 2036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) init_data_type, 2046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) init_data_type_size, 2056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) init_data + strlen(kPersistentSessionHeader), 2066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) init_data_size - strlen(kPersistentSessionHeader), 2076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::kPersistent); 2086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return; 2096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 2106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 211f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->CreateSession(promise_id, 212f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data_type, 213f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data_type_size, 214f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data, 215f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data_size, 216f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) session_type); 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 219f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void LoadSession(uint32_t promise_id, 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const char* web_session_id, 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t web_session_id_size) OVERRIDE { 222f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); 2238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 225f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void UpdateSession(uint32_t promise_id, 226f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 227f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size, 228c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const uint8_t* response, 229c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch uint32_t response_size) OVERRIDE { 230f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->UpdateSession(promise_id, 231f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) web_session_id, 232f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) web_session_id_size, 233f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) response, 234f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) response_size); 2358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool CloseSession(uint32_t promise_id, 2386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 2396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) OVERRIDE { 2406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); 2411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return true; 2426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 2436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 2441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void RemoveSession(uint32_t promise_id, 2456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 2466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) OVERRIDE { 2476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); 2481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 2491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool GetUsableKeyIds(uint32_t promise_id, 2511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const char* web_session_id, 2521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t web_session_id_size) OVERRIDE { 2531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size); 2546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return true; 2558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void TimerExpired(void* context) OVERRIDE { 2588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->TimerExpired(context); 2598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 2628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { 2638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 2648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status InitializeAudioDecoder( 2678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE { 2688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return cdm_->InitializeAudioDecoder(audio_decoder_config); 2698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status InitializeVideoDecoder( 2728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE { 2738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return cdm_->InitializeVideoDecoder(video_decoder_config); 2748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE { 2778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->DeinitializeDecoder(decoder_type); 2788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE { 2818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->ResetDecoder(decoder_type); 2828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status DecryptAndDecodeFrame( 2858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 2868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::VideoFrame* video_frame) OVERRIDE { 2878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return cdm_->DecryptAndDecodeFrame(encrypted_buffer, video_frame); 2888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual cdm::Status DecryptAndDecodeSamples( 2918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 2928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm::AudioFrames* audio_frames) OVERRIDE { 2938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames); 2948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void OnPlatformChallengeResponse( 2978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::PlatformChallengeResponse& response) OVERRIDE { 2988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->OnPlatformChallengeResponse(response); 2998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 3008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 3018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void OnQueryOutputProtectionStatus( 3028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t link_mask, 3038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t output_protection_mask) OVERRIDE { 3048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); 3058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 3068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 307f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t CreateSessionId() { 308f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return next_session_id_++; 309f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 310f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 311f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void RegisterPromise(uint32_t session_id, uint32_t promise_id) { 312f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) PP_DCHECK(promise_to_session_id_map_.find(session_id) == 313f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) promise_to_session_id_map_.end()); 314f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) promise_to_session_id_map_.insert(std::make_pair(session_id, promise_id)); 315f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 316f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 317f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual uint32_t LookupPromiseId(uint32_t session_id) { 318f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::map<uint32_t, uint32_t>::iterator it = 319f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) promise_to_session_id_map_.find(session_id); 320f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) if (it == promise_to_session_id_map_.end()) 321f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return 0; 322f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id = it->second; 323f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) promise_to_session_id_map_.erase(it); 324f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return promise_id; 325f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 326f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 327f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void AssignWebSessionId(uint32_t session_id, 328f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 329f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size) { 330f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) web_session_to_session_id_map_.insert(std::make_pair( 331f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::string(web_session_id, web_session_id_size), session_id)); 332f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 333f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 334f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t LookupSessionId(std::string web_session_id) { 335f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return web_session_to_session_id_map_.find(web_session_id)->second; 336f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 337f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 338f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual std::string LookupWebSessionId(uint32_t session_id) { 339f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::map<std::string, uint32_t>::iterator it; 340f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) for (it = web_session_to_session_id_map_.begin(); 341f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) it != web_session_to_session_id_map_.end(); 342f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ++it) { 343f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) if (it->second == session_id) 344f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return it->first; 345f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 346f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) PP_NOTREACHED(); 347f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return std::string(); 348f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 349f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 350f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void DropWebSessionId(std::string web_session_id) { 351f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) web_session_to_session_id_map_.erase(web_session_id); 352f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) } 353f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 3546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, 3556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::string* web_session_id) { 3566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::map<uint32_t, std::string>::iterator it = 3576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promises_needing_usable_keys_event_.find(promise_id); 3586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) if (it == promises_needing_usable_keys_event_.end()) 3596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return false; 3606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) web_session_id->swap(it->second); 3616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promises_needing_usable_keys_event_.erase(it); 3626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return true; 3636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 3646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void SetSessionUsableKeysEventNeeded(uint32_t promise_id, 3666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 3676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) { 3686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promises_needing_usable_keys_event_.insert(std::make_pair( 3696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promise_id, std::string(web_session_id, web_session_id_size))); 3706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 3716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void ConvertInputBuffer(const cdm::InputBuffer& v2, 3736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::InputBuffer_1* v1) { 3746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->data = v2.data; 3756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->data_size = v2.data_size; 3766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->data_offset = 0; 3776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->key_id = v2.key_id; 3786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->key_id_size = v2.key_id_size; 3796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->iv = v2.iv; 3806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->iv_size = v2.iv_size; 3816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->subsamples = v2.subsamples; 3826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->num_subsamples = v2.num_subsamples; 3836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) v1->timestamp = v2.timestamp; 3846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 3856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 38603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual std::string ConvertInitDataTypeToContentType( 38703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const std::string& init_data_type) const { 38803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) if (init_data_type == "cenc") 3896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return "video/mp4"; 39003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) if (init_data_type == "webm") 3916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return "video/webm"; 3926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return init_data_type; 3936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) } 3946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 396f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) { 3978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PP_DCHECK(cdm_); 3988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 3998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 4008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CdmInterface* cdm_; 4018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 402f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::map<uint32_t, uint32_t> promise_to_session_id_map_; 403f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t next_session_id_; 404f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::map<std::string, uint32_t> web_session_to_session_id_map_; 405f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 4066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::map<uint32_t, std::string> promises_needing_usable_keys_event_; 4076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); 4098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 4108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 411f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Overrides for the cdm::Host_4 methods. Calls to CreateSession(), 412f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, 413f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// but the CDM interface needs session ids. For create and load, we need to 414f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// create a new session_id to pass to the CDM. For update and release, we need 415f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// to look up |web_session_id| and convert it into the existing |session_id|. 416f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Since the callbacks don't come through this interface, cdm_adapter needs to 4176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// create the mapping (and delete it on release). Finally, for create, we need 4186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// to translate |init_data_type| to a MIME type. 419f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// TODO(jrummell): Remove these once Host_4 interface is removed. 420f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 421f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)template <> 4221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::SetServerCertificate( 4231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t promise_id, 4241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const uint8_t* server_certificate_data, 4251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t server_certificate_data_size) { 4261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return false; 4271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 4281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 4291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccitemplate <> 430f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession( 431f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 432f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* init_data_type, 433f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_type_size, 434f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const uint8_t* init_data, 435f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t init_data_size, 436f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::SessionType session_type) { 437f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t session_id = CreateSessionId(); 438f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) RegisterPromise(session_id, promise_id); 43903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) std::string converted_init_data_type = ConvertInitDataTypeToContentType( 44003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) std::string(init_data_type, init_data_type_size)); 441f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->CreateSession(session_id, 44203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) converted_init_data_type.data(), 44303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) converted_init_data_type.length(), 444f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data, 445f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) init_data_size); 446f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)} 447f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 448f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)template <> 449f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession( 450f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 451f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 452f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size) { 453f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t session_id = CreateSessionId(); 454f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) RegisterPromise(session_id, promise_id); 4556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate 4566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // one when the promise is resolved. This may be overly aggressive. 4576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SetSessionUsableKeysEventNeeded( 4586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promise_id, web_session_id, web_session_id_size); 459f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->LoadSession(session_id, web_session_id, web_session_id_size); 460f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)} 461f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 462f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)template <> 463f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession( 464f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 465f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 466f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size, 467f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const uint8_t* response, 468f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t response_size) { 469f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::string web_session_str(web_session_id, web_session_id_size); 470f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t session_id = LookupSessionId(web_session_str); 471f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) RegisterPromise(session_id, promise_id); 4726e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate 4736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // one when the promise is resolved. This may be overly aggressive. 4746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) SetSessionUsableKeysEventNeeded( 4756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) promise_id, web_session_id, web_session_id_size); 476f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_->UpdateSession(session_id, response, response_size); 477f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)} 478f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 479f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)template <> 4801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CloseSession( 481f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 482f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 483f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_size) { 4841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return false; 485f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)} 486f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 4876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)template <> 4881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid CdmWrapperImpl<cdm::ContentDecryptionModule_4>::RemoveSession( 4896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t promise_id, 4906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 4916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) { 4921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci std::string web_session_str(web_session_id, web_session_id_size); 4931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t session_id = LookupSessionId(web_session_str); 4941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci RegisterPromise(session_id, promise_id); 4951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci cdm_->ReleaseSession(session_id); 4966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 4976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 4986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)template <> 4996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::GetUsableKeyIds( 5006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t promise_id, 5016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 5026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_size) { 5036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return false; 5046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 5056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)template <> 5076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Decrypt( 5086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 5096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::DecryptedBlock* decrypted_buffer) { 5106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::InputBuffer_1 buffer; 5116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ConvertInputBuffer(encrypted_buffer, &buffer); 5126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return cdm_->Decrypt(buffer, decrypted_buffer); 5136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 5146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)template <> 5166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)cdm::Status 5176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeFrame( 5186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 5196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::VideoFrame* video_frame) { 5206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::InputBuffer_1 buffer; 5216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ConvertInputBuffer(encrypted_buffer, &buffer); 5226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return cdm_->DecryptAndDecodeFrame(buffer, video_frame); 5236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 5246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)template <> 5266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)cdm::Status 5276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples( 5286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const cdm::InputBuffer& encrypted_buffer, 5296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::AudioFrames* audio_frames) { 5306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::InputBuffer_1 buffer; 5316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) ConvertInputBuffer(encrypted_buffer, &buffer); 5326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); 5336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 5346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 5358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)CdmWrapper* CdmWrapper::Create(const char* key_system, 5361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t key_system_size, 5378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) GetCdmHostFunc get_cdm_host_func, 5388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* user_data) { 5390f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 5406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::ContentDecryptionModule_6::kVersion, 5410f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) update_code_below); 5420f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. 5440f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // Always update this DCHECK when updating this function. 5450f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // If this check fails, update this function and DCHECK or update 5465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // IsSupportedCdmInterfaceVersion(). 5470f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) PP_DCHECK( 548c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + 549c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 1) && 5500f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && 551f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) IsSupportedCdmInterfaceVersion( 552f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::ContentDecryptionModule_4::kVersion) && 553f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule_4::kVersion - 554c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 1)); 5550f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 5568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Try to create the CDM using the latest CDM interface version. 5570f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) CdmWrapper* cdm_wrapper = 5588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( 5598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) key_system, key_system_size, get_cdm_host_func, user_data); 560f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) if (cdm_wrapper) 561f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return cdm_wrapper; 5628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 563c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // If |cdm_wrapper| is NULL, try to create the CDM using older supported 564c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // versions of the CDM interface. 565f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create( 566f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) key_system, key_system_size, get_cdm_host_func, user_data); 5670f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) return cdm_wrapper; 5688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 5698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 5708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain 5711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// stub implementations for new or modified methods that the older CDM interface 5721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// does not have. 5730f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Also update supported_cdm_versions.h. 5741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 5756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::ContentDecryptionModule_6::kVersion, 5768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ensure_cdm_wrapper_templates_have_old_version_support); 5778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 5788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace media 5798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 5808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 581