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 cdm::MediaKeyException exception_code, |
| 95 uint32_t system_code, |
| 96 const char* error_message, |
| 97 uint32_t error_message_length) OVERRIDE; |
| 98 virtual void OnSessionMessage(const char* web_session_id, |
| 99 uint32_t web_session_id_length, |
| 100 const char* message, |
| 101 uint32_t message_length, |
| 102 const char* destination_url, |
| 103 uint32_t destination_url_length) OVERRIDE; |
| 104 virtual void OnSessionReady(const char* web_session_id, |
| 105 uint32_t web_session_id_length) OVERRIDE; |
| 106 virtual void OnSessionClosed(const char* web_session_id, |
| 107 uint32_t web_session_id_length) OVERRIDE; |
| 108 virtual void OnSessionError(const char* web_session_id, |
| 109 uint32_t web_session_id_length, |
| 110 cdm::MediaKeyException exception_code, |
| 111 uint32_t system_code, |
| 112 const char* error_message, |
| 113 uint32_t error_message_length) OVERRIDE; |
| 114 virtual void SendPlatformChallenge(const char* service_id, |
| 115 uint32_t service_id_length, |
| 116 const char* challenge, |
| 117 uint32_t challenge_length) OVERRIDE; |
| 118 virtual void EnableOutputProtection( |
| 119 uint32_t desired_protection_mask) OVERRIDE; |
| 120 virtual void QueryOutputProtectionStatus() OVERRIDE; |
| 121 virtual void OnDeferredInitializationDone( |
| 122 cdm::StreamType stream_type, |
| 123 cdm::Status decoder_status) OVERRIDE; |
| 124 virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; |
| 125 |
| 126 // cdm::Host_4 extras |
84 virtual void OnSessionCreated(uint32_t session_id, | 127 virtual void OnSessionCreated(uint32_t session_id, |
85 const char* web_session_id, | 128 const char* web_session_id, |
86 uint32_t web_session_id_length) OVERRIDE; | 129 uint32_t web_session_id_length) OVERRIDE; |
87 virtual void OnSessionMessage(uint32_t session_id, | 130 virtual void OnSessionMessage(uint32_t session_id, |
88 const char* message, | 131 const char* message, |
89 uint32_t message_length, | 132 uint32_t message_length, |
90 const char* destination_url, | 133 const char* destination_url, |
91 uint32_t destination_url_length) OVERRIDE; | 134 uint32_t destination_url_length) OVERRIDE; |
92 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; | 135 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; |
93 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; | 136 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; |
94 virtual void OnSessionError(uint32_t session_id, | 137 virtual void OnSessionError(uint32_t session_id, |
95 cdm::MediaKeyError error_code, | 138 cdm::MediaKeyError error_code, |
96 uint32_t system_code) OVERRIDE; | 139 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 | 140 |
108 private: | 141 private: |
109 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 142 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
110 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 143 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
111 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; | 144 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; |
112 | 145 |
| 146 struct SessionError { |
| 147 SessionError(cdm::MediaKeyException exception_code, |
| 148 uint32_t system_code, |
| 149 std::string error_description); |
| 150 cdm::MediaKeyException exception_code; |
| 151 uint32_t system_code; |
| 152 std::string error_description; |
| 153 }; |
| 154 |
113 bool CreateCdmInstance(const std::string& key_system); | 155 bool CreateCdmInstance(const std::string& key_system); |
114 | 156 |
115 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 157 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
116 // <code>callback_factory_</code> to ensure that calls into | 158 // <code>callback_factory_</code> to ensure that calls into |
117 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 159 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
118 void SendSessionCreatedInternal(int32_t result, | 160 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); |
119 uint32_t session_id, | 161 void SendPromiseResolvedWithSessionInternal( |
120 const std::string& web_session_id); | 162 int32_t result, |
| 163 uint32_t promise_id, |
| 164 const std::string& web_session_id); |
| 165 void SendPromiseRejectedInternal(int32_t result, |
| 166 uint32_t promise_id, |
| 167 const SessionError& error); |
121 void SendSessionMessageInternal(int32_t result, | 168 void SendSessionMessageInternal(int32_t result, |
122 uint32_t session_id, | 169 const std::string& web_session_id, |
123 const std::vector<uint8>& message, | 170 const std::vector<uint8>& message, |
124 const std::string& default_url); | 171 const std::string& destination_url); |
125 void SendSessionReadyInternal(int32_t result, uint32_t session_id); | 172 void SendSessionReadyInternal(int32_t result, |
126 void SendSessionClosedInternal(int32_t result, uint32_t session_id); | 173 const std::string& web_session_id); |
| 174 void SendSessionClosedInternal(int32_t result, |
| 175 const std::string& web_session_id); |
127 void SendSessionErrorInternal(int32_t result, | 176 void SendSessionErrorInternal(int32_t result, |
128 uint32_t session_id, | 177 const std::string& web_session_id, |
129 cdm::MediaKeyError error_code, | 178 const SessionError& error); |
130 uint32_t system_code); | 179 void RejectPromise(uint32_t promise_id, |
| 180 cdm::MediaKeyException exception_code, |
| 181 uint32_t system_code, |
| 182 const std::string& error_message); |
131 | 183 |
132 void DeliverBlock(int32_t result, | 184 void DeliverBlock(int32_t result, |
133 const cdm::Status& status, | 185 const cdm::Status& status, |
134 const LinkedDecryptedBlock& decrypted_block, | 186 const LinkedDecryptedBlock& decrypted_block, |
135 const PP_DecryptTrackingInfo& tracking_info); | 187 const PP_DecryptTrackingInfo& tracking_info); |
136 void DecoderInitializeDone(int32_t result, | 188 void DecoderInitializeDone(int32_t result, |
137 PP_DecryptorStreamType decoder_type, | 189 PP_DecryptorStreamType decoder_type, |
138 uint32_t request_id, | 190 uint32_t request_id, |
139 bool success); | 191 bool success); |
140 void DecoderDeinitializeDone(int32_t result, | 192 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_; | 250 uint32_t deferred_audio_decoder_config_id_; |
199 bool deferred_initialize_video_decoder_; | 251 bool deferred_initialize_video_decoder_; |
200 uint32_t deferred_video_decoder_config_id_; | 252 uint32_t deferred_video_decoder_config_id_; |
201 | 253 |
202 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 254 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
203 }; | 255 }; |
204 | 256 |
205 } // namespace media | 257 } // namespace media |
206 | 258 |
207 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 259 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
OLD | NEW |