OLD | NEW |
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_ADAPTER_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
6 #define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace media { | 31 namespace media { |
32 | 32 |
33 // GetCdmHostFunc implementation. | 33 // GetCdmHostFunc implementation. |
34 void* GetCdmHost(int host_interface_version, void* user_data); | 34 void* GetCdmHost(int host_interface_version, void* user_data); |
35 | 35 |
36 // An adapter class for abstracting away PPAPI interaction and threading for a | 36 // An adapter class for abstracting away PPAPI interaction and threading for a |
37 // Content Decryption Module (CDM). | 37 // Content Decryption Module (CDM). |
38 class CdmAdapter : public pp::Instance, | 38 class CdmAdapter : public pp::Instance, |
39 public pp::ContentDecryptor_Private, | 39 public pp::ContentDecryptor_Private, |
40 public cdm::Host_4 { | 40 public cdm::Host_4, |
| 41 public cdm::Host_5 { |
41 public: | 42 public: |
42 CdmAdapter(PP_Instance instance, pp::Module* module); | 43 CdmAdapter(PP_Instance instance, pp::Module* module); |
43 virtual ~CdmAdapter(); | 44 virtual ~CdmAdapter(); |
44 | 45 |
45 // pp::Instance implementation. | 46 // pp::Instance implementation. |
46 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 47 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
47 return true; | 48 return true; |
48 } | 49 } |
49 | 50 |
50 // PPP_ContentDecryptor_Private implementation. | 51 // PPP_ContentDecryptor_Private implementation. |
51 // Note: Results of calls to these methods must be reported through the | 52 // Note: Results of calls to these methods must be reported through the |
52 // PPB_ContentDecryptor_Private interface. | 53 // PPB_ContentDecryptor_Private interface. |
53 virtual void Initialize(const std::string& key_system) OVERRIDE; | 54 virtual void Initialize(const std::string& key_system) OVERRIDE; |
54 virtual void CreateSession(uint32_t session_id, | 55 virtual void CreateSession(uint32_t promise_id, |
55 const std::string& content_type, | 56 const std::string& init_data_type, |
56 pp::VarArrayBuffer init_data) OVERRIDE; | 57 pp::VarArrayBuffer init_data, |
57 virtual void LoadSession(uint32_t session_id, | 58 PP_SessionType session_type) OVERRIDE; |
| 59 virtual void LoadSession(uint32_t promise_id, |
58 const std::string& web_session_id) OVERRIDE; | 60 const std::string& web_session_id) OVERRIDE; |
59 virtual void UpdateSession(uint32_t session_id, | 61 virtual void UpdateSession(uint32_t promise_id, |
| 62 const std::string& web_session_id, |
60 pp::VarArrayBuffer response) OVERRIDE; | 63 pp::VarArrayBuffer response) OVERRIDE; |
61 virtual void ReleaseSession(uint32_t session_id) OVERRIDE; | 64 virtual void ReleaseSession(uint32_t promise_id, |
| 65 const std::string& web_session_id) OVERRIDE; |
62 virtual void Decrypt( | 66 virtual void Decrypt( |
63 pp::Buffer_Dev encrypted_buffer, | 67 pp::Buffer_Dev encrypted_buffer, |
64 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 68 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
65 virtual void InitializeAudioDecoder( | 69 virtual void InitializeAudioDecoder( |
66 const PP_AudioDecoderConfig& decoder_config, | 70 const PP_AudioDecoderConfig& decoder_config, |
67 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 71 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
68 virtual void InitializeVideoDecoder( | 72 virtual void InitializeVideoDecoder( |
69 const PP_VideoDecoderConfig& decoder_config, | 73 const PP_VideoDecoderConfig& decoder_config, |
70 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 74 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
71 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, | 75 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
72 uint32_t request_id) OVERRIDE; | 76 uint32_t request_id) OVERRIDE; |
73 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 77 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
74 uint32_t request_id) OVERRIDE; | 78 uint32_t request_id) OVERRIDE; |
75 virtual void DecryptAndDecode( | 79 virtual void DecryptAndDecode( |
76 PP_DecryptorStreamType decoder_type, | 80 PP_DecryptorStreamType decoder_type, |
77 pp::Buffer_Dev encrypted_buffer, | 81 pp::Buffer_Dev encrypted_buffer, |
78 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 82 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
79 | 83 |
80 // cdm::Host implementation. | 84 // cdm::Host_5 implementation. |
81 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; | 85 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; |
82 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | 86 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; |
83 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; | 87 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
| 88 virtual void OnResolveNewSessionPromise( |
| 89 uint32_t promise_id, |
| 90 const char* web_session_id, |
| 91 uint32_t web_session_id_length) OVERRIDE; |
| 92 virtual void OnResolvePromise(uint32_t promise_id) OVERRIDE; |
| 93 virtual void OnRejectPromise(uint32_t promise_id, |
| 94 const char* error_name, |
| 95 uint32_t error_name_length, |
| 96 uint32_t system_code, |
| 97 const char* error_message, |
| 98 uint32_t error_message_length) OVERRIDE; |
| 99 virtual void OnSessionMessage(const char* web_session_id, |
| 100 uint32_t web_session_id_length, |
| 101 const char* message, |
| 102 uint32_t message_length, |
| 103 const char* destination_url, |
| 104 uint32_t destination_url_length) OVERRIDE; |
| 105 virtual void OnSessionReady(const char* web_session_id, |
| 106 uint32_t web_session_id_length) OVERRIDE; |
| 107 virtual void OnSessionClosed(const char* web_session_id, |
| 108 uint32_t web_session_id_length) OVERRIDE; |
| 109 virtual void OnSessionError(const char* web_session_id, |
| 110 uint32_t web_session_id_length, |
| 111 const char* error_name, |
| 112 uint32_t error_name_length, |
| 113 uint32_t system_code, |
| 114 const char* error_message, |
| 115 uint32_t error_message_length) OVERRIDE; |
| 116 virtual void SendPlatformChallenge(const char* service_id, |
| 117 uint32_t service_id_length, |
| 118 const char* challenge, |
| 119 uint32_t challenge_length) OVERRIDE; |
| 120 virtual void EnableOutputProtection( |
| 121 uint32_t desired_protection_mask) OVERRIDE; |
| 122 virtual void QueryOutputProtectionStatus() OVERRIDE; |
| 123 virtual void OnDeferredInitializationDone( |
| 124 cdm::StreamType stream_type, |
| 125 cdm::Status decoder_status) OVERRIDE; |
| 126 virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; |
| 127 |
| 128 // cdm::Host_4 extras |
84 virtual void OnSessionCreated(uint32_t session_id, | 129 virtual void OnSessionCreated(uint32_t session_id, |
85 const char* web_session_id, | 130 const char* web_session_id, |
86 uint32_t web_session_id_length) OVERRIDE; | 131 uint32_t web_session_id_length) OVERRIDE; |
87 virtual void OnSessionMessage(uint32_t session_id, | 132 virtual void OnSessionMessage(uint32_t session_id, |
88 const char* message, | 133 const char* message, |
89 uint32_t message_length, | 134 uint32_t message_length, |
90 const char* destination_url, | 135 const char* destination_url, |
91 uint32_t destination_url_length) OVERRIDE; | 136 uint32_t destination_url_length) OVERRIDE; |
92 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; | 137 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; |
93 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; | 138 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; |
94 virtual void OnSessionError(uint32_t session_id, | 139 virtual void OnSessionError(uint32_t session_id, |
95 cdm::MediaKeyError error_code, | 140 cdm::MediaKeyError error_code, |
96 uint32_t system_code) OVERRIDE; | 141 uint32_t system_code) OVERRIDE; |
97 virtual void SendPlatformChallenge( | |
98 const char* service_id, uint32_t service_id_length, | |
99 const char* challenge, uint32_t challenge_length) OVERRIDE; | |
100 virtual void EnableOutputProtection( | |
101 uint32_t desired_protection_mask) OVERRIDE; | |
102 virtual void QueryOutputProtectionStatus() OVERRIDE; | |
103 virtual void OnDeferredInitializationDone( | |
104 cdm::StreamType stream_type, | |
105 cdm::Status decoder_status) OVERRIDE; | |
106 virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; | |
107 | 142 |
108 private: | 143 private: |
109 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 144 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
110 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 145 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
111 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; | 146 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; |
112 | 147 |
| 148 struct SessionError { |
| 149 SessionError(std::string error_name, |
| 150 uint32_t system_code, |
| 151 std::string error_description); |
| 152 std::string error_name; |
| 153 uint32_t system_code; |
| 154 std::string error_description; |
| 155 }; |
| 156 |
113 bool CreateCdmInstance(const std::string& key_system); | 157 bool CreateCdmInstance(const std::string& key_system); |
114 | 158 |
115 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 159 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
116 // <code>callback_factory_</code> to ensure that calls into | 160 // <code>callback_factory_</code> to ensure that calls into |
117 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 161 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
118 void SendSessionCreatedInternal(int32_t result, | 162 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); |
119 uint32_t session_id, | 163 void SendPromiseResolvedWithSessionInternal( |
120 const std::string& web_session_id); | 164 int32_t result, |
| 165 uint32_t promise_id, |
| 166 const std::string& web_session_id); |
| 167 void SendPromiseRejectedInternal(int32_t result, |
| 168 uint32_t promise_id, |
| 169 const SessionError& error); |
121 void SendSessionMessageInternal(int32_t result, | 170 void SendSessionMessageInternal(int32_t result, |
122 uint32_t session_id, | 171 const std::string& web_session_id, |
123 const std::vector<uint8>& message, | 172 const std::vector<uint8>& message, |
124 const std::string& default_url); | 173 const std::string& destination_url); |
125 void SendSessionReadyInternal(int32_t result, uint32_t session_id); | 174 void SendSessionReadyInternal(int32_t result, |
126 void SendSessionClosedInternal(int32_t result, uint32_t session_id); | 175 const std::string& web_session_id); |
| 176 void SendSessionClosedInternal(int32_t result, |
| 177 const std::string& web_session_id); |
127 void SendSessionErrorInternal(int32_t result, | 178 void SendSessionErrorInternal(int32_t result, |
128 uint32_t session_id, | 179 const std::string& web_session_id, |
129 cdm::MediaKeyError error_code, | 180 const SessionError& error); |
130 uint32_t system_code); | 181 void RejectPromise(uint32_t promise_id, |
| 182 const std::string& error_name, |
| 183 uint32_t system_code, |
| 184 const std::string& error_message); |
131 | 185 |
132 void DeliverBlock(int32_t result, | 186 void DeliverBlock(int32_t result, |
133 const cdm::Status& status, | 187 const cdm::Status& status, |
134 const LinkedDecryptedBlock& decrypted_block, | 188 const LinkedDecryptedBlock& decrypted_block, |
135 const PP_DecryptTrackingInfo& tracking_info); | 189 const PP_DecryptTrackingInfo& tracking_info); |
136 void DecoderInitializeDone(int32_t result, | 190 void DecoderInitializeDone(int32_t result, |
137 PP_DecryptorStreamType decoder_type, | 191 PP_DecryptorStreamType decoder_type, |
138 uint32_t request_id, | 192 uint32_t request_id, |
139 bool success); | 193 bool success); |
140 void DecoderDeinitializeDone(int32_t result, | 194 void DecoderDeinitializeDone(int32_t result, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 uint32_t deferred_audio_decoder_config_id_; | 252 uint32_t deferred_audio_decoder_config_id_; |
199 bool deferred_initialize_video_decoder_; | 253 bool deferred_initialize_video_decoder_; |
200 uint32_t deferred_video_decoder_config_id_; | 254 uint32_t deferred_video_decoder_config_id_; |
201 | 255 |
202 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 256 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
203 }; | 257 }; |
204 | 258 |
205 } // namespace media | 259 } // namespace media |
206 | 260 |
207 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 261 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
OLD | NEW |