cdm_adapter.h revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
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_ADAPTER_H_ 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <string> 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <vector> 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h" 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/compiler_specific.h" 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "build/build_config.h" 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/api/content_decryption_module.h" 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/cdm_helpers.h" 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/cdm_wrapper.h" 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/linked_ptr.h" 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/pp_stdint.h" 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/private/pp_content_decryptor.h" 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/completion_callback.h" 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/content_decryptor_private.h" 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/var.h" 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/var_array_buffer.h" 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/utility/completion_callback_factory.h" 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#if defined(OS_CHROMEOS) 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/output_protection_private.h" 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/platform_verification.h" 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 31f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if defined(GetCurrentTime) 32f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// winbase.h defines this which messes up calls to Host_5::GetCurrentTime. 33f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#undef GetCurrentTime 34f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif 35f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace media { 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// GetCdmHostFunc implementation. 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void* GetCdmHost(int host_interface_version, void* user_data); 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// An adapter class for abstracting away PPAPI interaction and threading for a 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Content Decryption Module (CDM). 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class CdmAdapter : public pp::Instance, 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public pp::ContentDecryptor_Private, 45f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) public cdm::Host_4, 466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public cdm::Host_5, 476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public cdm::Host_6 { 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) CdmAdapter(PP_Instance instance, pp::Module* module); 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ~CdmAdapter(); 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // pp::Instance implementation. 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { 548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return true; 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // PPP_ContentDecryptor_Private implementation. 588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Note: Results of calls to these methods must be reported through the 598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // PPB_ContentDecryptor_Private interface. 60f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void Initialize(const std::string& key_system) OVERRIDE; 61f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void CreateSession(uint32_t promise_id, 62f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& init_data_type, 63f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) pp::VarArrayBuffer init_data, 64f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) PP_SessionType session_type) OVERRIDE; 65f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void LoadSession(uint32_t promise_id, 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& web_session_id) OVERRIDE; 67f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void UpdateSession(uint32_t promise_id, 68f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id, 69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) pp::VarArrayBuffer response) OVERRIDE; 706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO(jrummell): Rename to CloseSession(). 71f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void ReleaseSession(uint32_t promise_id, 72f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id) OVERRIDE; 736e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // TODO(jrummell): Pass these 2 functions through Pepper and add OVERRIDE. 746e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void RemoveSession(uint32_t promise_id, 756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const std::string& web_session_id); 766e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void GetUsableKeyIds(uint32_t promise_id, 776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const std::string& web_session_id); 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void Decrypt( 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Buffer_Dev encrypted_buffer, 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void InitializeAudioDecoder( 828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_AudioDecoderConfig& decoder_config, 838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Buffer_Dev extra_data_buffer) OVERRIDE; 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void InitializeVideoDecoder( 858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_VideoDecoderConfig& decoder_config, 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Buffer_Dev extra_data_buffer) OVERRIDE; 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, 888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t request_id) OVERRIDE; 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t request_id) OVERRIDE; 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void DecryptAndDecode( 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PP_DecryptorStreamType decoder_type, 938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::Buffer_Dev encrypted_buffer, 948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; 958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation. 971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; 988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; 99f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 100f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // cdm::Host_4 implementation. 1018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual double GetCurrentWallTimeInSeconds() OVERRIDE; 102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnSessionCreated(uint32_t session_id, 103a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const char* web_session_id, 104a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) uint32_t web_session_id_length) OVERRIDE; 105a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnSessionMessage(uint32_t session_id, 106a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const char* message, 107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) uint32_t message_length, 108a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const char* destination_url, 109a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) uint32_t destination_url_length) OVERRIDE; 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnSessionReady(uint32_t session_id) OVERRIDE; 111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; 112a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnSessionError(uint32_t session_id, 113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) cdm::MediaKeyError error_code, 114a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) uint32_t system_code) OVERRIDE; 115f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 116f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // cdm::Host_5 implementation. 117f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual cdm::Time GetCurrentTime() OVERRIDE; 118f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnResolveNewSessionPromise( 119f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 120f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* web_session_id, 121f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length) OVERRIDE; 122f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnResolvePromise(uint32_t promise_id) OVERRIDE; 123f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnRejectPromise(uint32_t promise_id, 124f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::Error error, 125f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t system_code, 126f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* error_message, 127f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t error_message_length) OVERRIDE; 128f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnSessionMessage(const char* web_session_id, 129f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length, 130f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* message, 131f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t message_length, 132f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* destination_url, 133f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t destination_url_length) OVERRIDE; 134f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnSessionKeysChange(const char* web_session_id, 135f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length, 1366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool has_additional_usable_key) OVERRIDE; 137f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnExpirationChange(const char* web_session_id, 138f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length, 1396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::Time new_expiry_time) OVERRIDE; 140f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnSessionReady(const char* web_session_id, 141f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length) OVERRIDE; 142f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnSessionClosed(const char* web_session_id, 143f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length) OVERRIDE; 144f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void OnSessionError(const char* web_session_id, 145f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t web_session_id_length, 146f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::Error error, 147f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t system_code, 148f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* error_message, 149f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t error_message_length) OVERRIDE; 150f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 1516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // cdm::Host_6 implementation. 1526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual cdm::Time GetCurrentWallTime() OVERRIDE; 1536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void OnResolveKeyIdsPromise(uint32_t promise_id, 1546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const cdm::BinaryData* usable_key_ids, 1556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t usable_key_ids_length) OVERRIDE; 1566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual void OnSessionUsableKeysChange( 1576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const char* web_session_id, 1586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t web_session_id_length, 1596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool has_additional_usable_key) OVERRIDE; 1606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation. 162f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void SendPlatformChallenge(const char* service_id, 163f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t service_id_length, 164f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const char* challenge, 165f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t challenge_length) OVERRIDE; 166c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void EnableOutputProtection( 167c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch uint32_t desired_protection_mask) OVERRIDE; 168c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void QueryOutputProtectionStatus() OVERRIDE; 169c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void OnDeferredInitializationDone( 170c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch cdm::StreamType stream_type, 171c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch cdm::Status decoder_status) OVERRIDE; 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; 173a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 175010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // These are reported to UMA server. Do not change the existing values! 176010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) enum OutputProtectionStatus { 177010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) OUTPUT_PROTECTION_QUERIED = 0, 178010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) OUTPUT_PROTECTION_NO_EXTERNAL_LINK = 1, 179010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED = 2, 180010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) OUTPUT_PROTECTION_MAX = 3 181010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) }; 182010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 1838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; 1848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; 1858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; 1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 187f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) struct SessionError { 188f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) SessionError(cdm::Error error, 189f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t system_code, 190f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::string error_description); 191f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::Error error; 192f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t system_code; 193f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) std::string error_description; 194f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) }; 195f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 1968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool CreateCdmInstance(const std::string& key_system); 1978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to 1998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // <code>callback_factory_</code> to ensure that calls into 2008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // <code>PPP_ContentDecryptor_Private</code> are asynchronous. 201f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); 202f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SendPromiseResolvedWithSessionInternal( 203f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) int32_t result, 204f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 205f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id); 2066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void SendPromiseResolvedWithUsableKeyIdsInternal( 2076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int32_t result, 2086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) uint32_t promise_id, 2096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::vector<std::vector<uint8> > key_ids); 210f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SendPromiseRejectedInternal(int32_t result, 211f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t promise_id, 212f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const SessionError& error); 213a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SendSessionMessageInternal(int32_t result, 214f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id, 215a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::vector<uint8>& message, 21646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) const std::string& destination_url); 217f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SendSessionReadyInternal(int32_t result, 218f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id); 219f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SendSessionClosedInternal(int32_t result, 220f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id); 221a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SendSessionErrorInternal(int32_t result, 222f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& web_session_id, 223f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const SessionError& error); 2246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void SendSessionUsableKeysChangeInternal(int32_t result, 2256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const std::string& web_session_id, 2266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool has_additional_usable_key); 2276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void SendExpirationChangeInternal(int32_t result, 2286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const std::string& web_session_id, 2296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) cdm::Time new_expiry_time); 230f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void RejectPromise(uint32_t promise_id, 231f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) cdm::Error error, 232f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) uint32_t system_code, 233f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const std::string& error_message); 234a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 2358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DeliverBlock(int32_t result, 2368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::Status& status, 2378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const LinkedDecryptedBlock& decrypted_block, 2388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_DecryptTrackingInfo& tracking_info); 2398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DecoderInitializeDone(int32_t result, 2408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PP_DecryptorStreamType decoder_type, 2418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t request_id, 2428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool success); 2438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DecoderDeinitializeDone(int32_t result, 2448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PP_DecryptorStreamType decoder_type, 2458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t request_id); 2468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DecoderResetDone(int32_t result, 2478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PP_DecryptorStreamType decoder_type, 2488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t request_id); 2498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DeliverFrame(int32_t result, 2508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::Status& status, 2518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const LinkedVideoFrame& video_frame, 2528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_DecryptTrackingInfo& tracking_info); 2538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void DeliverSamples(int32_t result, 2548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const cdm::Status& status, 2558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const LinkedAudioFrames& audio_frames, 2568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const PP_DecryptTrackingInfo& tracking_info); 2578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Helper for SetTimer(). 2598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void TimerExpired(int32_t result, void* context); 2608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool IsValidVideoFrame(const LinkedVideoFrame& video_frame); 2628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if !defined(NDEBUG) 2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Logs the given message to the JavaScript console associated with the 2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // CDM adapter instance. The name of the CDM adapter issuing the log message 2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // will be automatically prepended to the message. 2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void LogToConsole(const pp::Var& value); 2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // !defined(NDEBUG) 2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#if defined(OS_CHROMEOS) 271010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void ReportOutputProtectionUMA(OutputProtectionStatus status); 272010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void ReportOutputProtectionQuery(); 273010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void ReportOutputProtectionQueryResult(); 274010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 275116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch struct PepperPlatformChallengeResponse { 276116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch pp::Var signed_data; 277116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch pp::Var signed_data_signature; 278116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch pp::Var platform_key_certificate; 279116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch }; 280116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 281116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void SendPlatformChallengeDone( 282116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int32_t result, 283116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const linked_ptr<PepperPlatformChallengeResponse>& response); 2848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void EnableProtectionDone(int32_t result); 2858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void QueryOutputProtectionStatusDone(int32_t result); 2868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::OutputProtection_Private output_protection_; 2888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::PlatformVerification platform_verification_; 2898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Same as above, these are only read by QueryOutputProtectionStatusDone(). 2918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t output_link_mask_; 2928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t output_protection_mask_; 2938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool query_output_protection_in_progress_; 294010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 295010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // Tracks whether an output protection query and a positive query result (no 296010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // unprotected external link) have been reported to UMA. 297010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) bool uma_for_output_protection_query_reported_; 298010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) bool uma_for_output_protection_positive_result_reported_; 2998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif 3008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 3018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) PpbBufferAllocator allocator_; 3028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) pp::CompletionCallbackFactory<CdmAdapter> callback_factory_; 3038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) linked_ptr<CdmWrapper> cdm_; 3048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) std::string key_system_; 3058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 3061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // If the CDM returned kDeferredInitialization during InitializeAudioDecoder() 3071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // or InitializeVideoDecoder(), the (Audio|Video)DecoderConfig.request_id is 3081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // saved for the future call to OnDeferredInitializationDone(). 3091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) bool deferred_initialize_audio_decoder_; 3101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t deferred_audio_decoder_config_id_; 3111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) bool deferred_initialize_video_decoder_; 3121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t deferred_video_decoder_config_id_; 3131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 3148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(CdmAdapter); 3158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 3168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 3178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace media 3188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 3198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ 320