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_4 implementation. |
81 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; | |
82 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | |
83 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; | 85 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
84 virtual void OnSessionCreated(uint32_t session_id, | 86 virtual void OnSessionCreated(uint32_t session_id, |
85 const char* web_session_id, | 87 const char* web_session_id, |
86 uint32_t web_session_id_length) OVERRIDE; | 88 uint32_t web_session_id_length) OVERRIDE; |
87 virtual void OnSessionMessage(uint32_t session_id, | 89 virtual void OnSessionMessage(uint32_t session_id, |
88 const char* message, | 90 const char* message, |
89 uint32_t message_length, | 91 uint32_t message_length, |
90 const char* destination_url, | 92 const char* destination_url, |
91 uint32_t destination_url_length) OVERRIDE; | 93 uint32_t destination_url_length) OVERRIDE; |
92 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; | 94 virtual void OnSessionReady(uint32_t session_id) OVERRIDE; |
93 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; | 95 virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; |
94 virtual void OnSessionError(uint32_t session_id, | 96 virtual void OnSessionError(uint32_t session_id, |
95 cdm::MediaKeyError error_code, | 97 cdm::MediaKeyError error_code, |
96 uint32_t system_code) OVERRIDE; | 98 uint32_t system_code) OVERRIDE; |
97 virtual void SendPlatformChallenge( | 99 |
98 const char* service_id, uint32_t service_id_length, | 100 // cdm::Host_5 implementation. |
99 const char* challenge, uint32_t challenge_length) OVERRIDE; | 101 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; |
102 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | |
xhwang
2014/05/29 23:44:38
These are shared by HOST4 and HOST5?
jrummell
2014/05/30 18:04:25
Correct. I did it this way so that removing suppor
| |
103 virtual cdm::Time GetCurrentTime() OVERRIDE; | |
104 virtual void OnResolveNewSessionPromise( | |
105 uint32_t promise_id, | |
106 const char* web_session_id, | |
107 uint32_t web_session_id_length) OVERRIDE; | |
108 virtual void OnResolvePromise(uint32_t promise_id) OVERRIDE; | |
109 virtual void OnRejectPromise(uint32_t promise_id, | |
110 cdm::Error error, | |
111 uint32_t system_code, | |
112 const char* error_message, | |
113 uint32_t error_message_length) OVERRIDE; | |
114 virtual void OnSessionMessage(const char* web_session_id, | |
115 uint32_t web_session_id_length, | |
116 const char* message, | |
117 uint32_t message_length, | |
118 const char* destination_url, | |
119 uint32_t destination_url_length) OVERRIDE; | |
120 virtual void OnSessionKeysChange(const char* web_session_id, | |
121 uint32_t web_session_id_length, | |
122 bool has_additional_usable_key); | |
123 virtual void OnExpirationChange(const char* web_session_id, | |
124 uint32_t web_session_id_length, | |
125 cdm::Time new_expiry_time); | |
126 virtual void OnSessionReady(const char* web_session_id, | |
127 uint32_t web_session_id_length) OVERRIDE; | |
128 virtual void OnSessionClosed(const char* web_session_id, | |
129 uint32_t web_session_id_length) OVERRIDE; | |
130 virtual void OnSessionError(const char* web_session_id, | |
131 uint32_t web_session_id_length, | |
132 cdm::Error error, | |
133 uint32_t system_code, | |
134 const char* error_message, | |
135 uint32_t error_message_length) OVERRIDE; | |
136 virtual void SendPlatformChallenge(const char* service_id, | |
137 uint32_t service_id_length, | |
138 const char* challenge, | |
139 uint32_t challenge_length) OVERRIDE; | |
100 virtual void EnableOutputProtection( | 140 virtual void EnableOutputProtection( |
101 uint32_t desired_protection_mask) OVERRIDE; | 141 uint32_t desired_protection_mask) OVERRIDE; |
102 virtual void QueryOutputProtectionStatus() OVERRIDE; | 142 virtual void QueryOutputProtectionStatus() OVERRIDE; |
103 virtual void OnDeferredInitializationDone( | 143 virtual void OnDeferredInitializationDone( |
104 cdm::StreamType stream_type, | 144 cdm::StreamType stream_type, |
105 cdm::Status decoder_status) OVERRIDE; | 145 cdm::Status decoder_status) OVERRIDE; |
106 virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; | 146 virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE; |
107 | 147 |
108 private: | 148 private: |
109 // These are reported to UMA server. Do not change the existing values! | 149 // These are reported to UMA server. Do not change the existing values! |
110 enum OutputProtectionStatus { | 150 enum OutputProtectionStatus { |
111 OUTPUT_PROTECTION_QUERIED = 0, | 151 OUTPUT_PROTECTION_QUERIED = 0, |
112 OUTPUT_PROTECTION_NO_EXTERNAL_LINK = 1, | 152 OUTPUT_PROTECTION_NO_EXTERNAL_LINK = 1, |
113 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED = 2, | 153 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED = 2, |
114 OUTPUT_PROTECTION_MAX = 3 | 154 OUTPUT_PROTECTION_MAX = 3 |
115 }; | 155 }; |
116 | 156 |
117 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 157 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
118 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 158 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
119 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; | 159 typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames; |
120 | 160 |
161 struct SessionError { | |
162 SessionError(cdm::Error error, | |
163 uint32_t system_code, | |
164 std::string error_description); | |
165 cdm::Error error; | |
166 uint32_t system_code; | |
167 std::string error_description; | |
168 }; | |
169 | |
121 bool CreateCdmInstance(const std::string& key_system); | 170 bool CreateCdmInstance(const std::string& key_system); |
122 | 171 |
123 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 172 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
124 // <code>callback_factory_</code> to ensure that calls into | 173 // <code>callback_factory_</code> to ensure that calls into |
125 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 174 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
126 void SendSessionCreatedInternal(int32_t result, | 175 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); |
127 uint32_t session_id, | 176 void SendPromiseResolvedWithSessionInternal( |
128 const std::string& web_session_id); | 177 int32_t result, |
178 uint32_t promise_id, | |
179 const std::string& web_session_id); | |
180 void SendPromiseRejectedInternal(int32_t result, | |
181 uint32_t promise_id, | |
182 const SessionError& error); | |
129 void SendSessionMessageInternal(int32_t result, | 183 void SendSessionMessageInternal(int32_t result, |
130 uint32_t session_id, | 184 const std::string& web_session_id, |
131 const std::vector<uint8>& message, | 185 const std::vector<uint8>& message, |
132 const std::string& default_url); | 186 const std::string& destination_url); |
133 void SendSessionReadyInternal(int32_t result, uint32_t session_id); | 187 void SendSessionReadyInternal(int32_t result, |
134 void SendSessionClosedInternal(int32_t result, uint32_t session_id); | 188 const std::string& web_session_id); |
189 void SendSessionClosedInternal(int32_t result, | |
190 const std::string& web_session_id); | |
135 void SendSessionErrorInternal(int32_t result, | 191 void SendSessionErrorInternal(int32_t result, |
136 uint32_t session_id, | 192 const std::string& web_session_id, |
137 cdm::MediaKeyError error_code, | 193 const SessionError& error); |
138 uint32_t system_code); | 194 void RejectPromise(uint32_t promise_id, |
195 cdm::Error error, | |
196 uint32_t system_code, | |
197 const std::string& error_message); | |
139 | 198 |
140 void DeliverBlock(int32_t result, | 199 void DeliverBlock(int32_t result, |
141 const cdm::Status& status, | 200 const cdm::Status& status, |
142 const LinkedDecryptedBlock& decrypted_block, | 201 const LinkedDecryptedBlock& decrypted_block, |
143 const PP_DecryptTrackingInfo& tracking_info); | 202 const PP_DecryptTrackingInfo& tracking_info); |
144 void DecoderInitializeDone(int32_t result, | 203 void DecoderInitializeDone(int32_t result, |
145 PP_DecryptorStreamType decoder_type, | 204 PP_DecryptorStreamType decoder_type, |
146 uint32_t request_id, | 205 uint32_t request_id, |
147 bool success); | 206 bool success); |
148 void DecoderDeinitializeDone(int32_t result, | 207 void DecoderDeinitializeDone(int32_t result, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 uint32_t deferred_audio_decoder_config_id_; | 274 uint32_t deferred_audio_decoder_config_id_; |
216 bool deferred_initialize_video_decoder_; | 275 bool deferred_initialize_video_decoder_; |
217 uint32_t deferred_video_decoder_config_id_; | 276 uint32_t deferred_video_decoder_config_id_; |
218 | 277 |
219 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 278 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
220 }; | 279 }; |
221 | 280 |
222 } // namespace media | 281 } // namespace media |
223 | 282 |
224 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 283 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
OLD | NEW |