OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ |
6 #define CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ | 6 #define CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ |
7 | 7 |
8 #include <map> | |
8 #include <queue> | 9 #include <queue> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "media/base/channel_layout.h" | 17 #include "media/base/channel_layout.h" |
17 #include "media/base/decryptor.h" | 18 #include "media/base/decryptor.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
36 // ContentDecryptorDelegate does not take ownership of | 37 // ContentDecryptorDelegate does not take ownership of |
37 // |plugin_decryption_interface|. Therefore |plugin_decryption_interface| | 38 // |plugin_decryption_interface|. Therefore |plugin_decryption_interface| |
38 // must outlive this object. | 39 // must outlive this object. |
39 ContentDecryptorDelegate( | 40 ContentDecryptorDelegate( |
40 PP_Instance pp_instance, | 41 PP_Instance pp_instance, |
41 const PPP_ContentDecryptor_Private* plugin_decryption_interface); | 42 const PPP_ContentDecryptor_Private* plugin_decryption_interface); |
42 ~ContentDecryptorDelegate(); | 43 ~ContentDecryptorDelegate(); |
43 | 44 |
44 // This object should not be accessed after |fatal_plugin_error_cb| is called. | 45 // This object should not be accessed after |fatal_plugin_error_cb| is called. |
45 void Initialize(const std::string& key_system, | 46 void Initialize(const std::string& key_system, |
46 const media::SessionCreatedCB& session_created_cb, | |
47 const media::SessionMessageCB& session_message_cb, | 47 const media::SessionMessageCB& session_message_cb, |
48 const media::SessionReadyCB& session_ready_cb, | 48 const media::SessionReadyCB& session_ready_cb, |
49 const media::SessionClosedCB& session_closed_cb, | 49 const media::SessionClosedCB& session_closed_cb, |
50 const media::SessionErrorCB& session_error_cb, | 50 const media::SessionErrorCB& session_error_cb, |
51 const base::Closure& fatal_plugin_error_cb); | 51 const base::Closure& fatal_plugin_error_cb); |
52 | 52 |
53 void InstanceCrashed(); | 53 void InstanceCrashed(); |
54 | 54 |
55 // Provides access to PPP_ContentDecryptor_Private. | 55 // Provides access to PPP_ContentDecryptor_Private. |
56 bool CreateSession(uint32 session_id, | 56 void CreateSession(const std::string& init_data_type, |
57 const std::string& content_type, | |
58 const uint8* init_data, | 57 const uint8* init_data, |
59 int init_data_length); | 58 int init_data_length, |
60 void LoadSession(uint32 session_id, const std::string& web_session_id); | 59 media::MediaKeys::SessionType session_type, |
61 bool UpdateSession(uint32 session_id, | 60 scoped_ptr<media::CdmNewSessionPromise> promise); |
61 void LoadSession(const std::string& web_session_id, | |
62 scoped_ptr<media::CdmNewSessionPromise> promise); | |
63 void UpdateSession(const std::string& web_session_id, | |
62 const uint8* response, | 64 const uint8* response, |
63 int response_length); | 65 int response_length, |
64 bool ReleaseSession(uint32 session_id); | 66 scoped_ptr<media::CdmChangeSessionPromise> promise); |
67 void ReleaseSession(const std::string& web_session_id, | |
68 scoped_ptr<media::CdmChangeSessionPromise> promise); | |
65 bool Decrypt(media::Decryptor::StreamType stream_type, | 69 bool Decrypt(media::Decryptor::StreamType stream_type, |
66 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 70 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
67 const media::Decryptor::DecryptCB& decrypt_cb); | 71 const media::Decryptor::DecryptCB& decrypt_cb); |
68 bool CancelDecrypt(media::Decryptor::StreamType stream_type); | 72 bool CancelDecrypt(media::Decryptor::StreamType stream_type); |
69 bool InitializeAudioDecoder( | 73 bool InitializeAudioDecoder( |
70 const media::AudioDecoderConfig& decoder_config, | 74 const media::AudioDecoderConfig& decoder_config, |
71 const media::Decryptor::DecoderInitCB& decoder_init_cb); | 75 const media::Decryptor::DecoderInitCB& decoder_init_cb); |
72 bool InitializeVideoDecoder( | 76 bool InitializeVideoDecoder( |
73 const media::VideoDecoderConfig& decoder_config, | 77 const media::VideoDecoderConfig& decoder_config, |
74 const media::Decryptor::DecoderInitCB& decoder_init_cb); | 78 const media::Decryptor::DecoderInitCB& decoder_init_cb); |
75 // TODO(tomfinegan): Add callback args for DeinitializeDecoder() and | 79 // TODO(tomfinegan): Add callback args for DeinitializeDecoder() and |
76 // ResetDecoder() | 80 // ResetDecoder() |
77 bool DeinitializeDecoder(media::Decryptor::StreamType stream_type); | 81 bool DeinitializeDecoder(media::Decryptor::StreamType stream_type); |
78 bool ResetDecoder(media::Decryptor::StreamType stream_type); | 82 bool ResetDecoder(media::Decryptor::StreamType stream_type); |
79 // Note: These methods can be used with unencrypted data. | 83 // Note: These methods can be used with unencrypted data. |
80 bool DecryptAndDecodeAudio( | 84 bool DecryptAndDecodeAudio( |
81 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 85 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
82 const media::Decryptor::AudioDecodeCB& audio_decode_cb); | 86 const media::Decryptor::AudioDecodeCB& audio_decode_cb); |
83 bool DecryptAndDecodeVideo( | 87 bool DecryptAndDecodeVideo( |
84 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 88 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
85 const media::Decryptor::VideoDecodeCB& video_decode_cb); | 89 const media::Decryptor::VideoDecodeCB& video_decode_cb); |
86 | 90 |
87 // PPB_ContentDecryptor_Private dispatching methods. | 91 // PPB_ContentDecryptor_Private dispatching methods. |
88 void OnSessionCreated(uint32 session_id, PP_Var web_session_id_var); | 92 void OnPromiseResolved(uint32 promise_id); |
89 void OnSessionMessage(uint32 session_id, | 93 void OnPromiseResolvedWithSession(uint32 promise_id, |
90 PP_Var message, | 94 PP_Var web_session_id_var); |
91 PP_Var destination_url); | 95 void OnPromiseRejected(uint32 promise_id, |
92 void OnSessionReady(uint32 session_id); | 96 PP_ExceptionCodeType exception_code, |
ddorwin
2014/05/13 22:44:02
Is there a reason this has "Type"?
jrummell
2014/05/15 22:38:09
I just looked at the last entry in pp_content_decr
| |
93 void OnSessionClosed(uint32 session_id); | 97 uint32 system_code, |
94 void OnSessionError(uint32 session_id, | 98 PP_Var error_description_var); |
95 int32_t media_error, | 99 void OnSessionMessage(PP_Var web_session_id_var, |
96 uint32_t system_code); | 100 PP_Var message_var, |
101 PP_Var destination_url_var); | |
102 void OnSessionReady(PP_Var web_session_id_var); | |
103 void OnSessionClosed(PP_Var web_session_id_var); | |
104 void OnSessionError(PP_Var web_session_id_var, | |
105 PP_ExceptionCodeType exception_code, | |
106 uint32 system_code, | |
107 PP_Var error_description_var); | |
97 void DeliverBlock(PP_Resource decrypted_block, | 108 void DeliverBlock(PP_Resource decrypted_block, |
98 const PP_DecryptedBlockInfo* block_info); | 109 const PP_DecryptedBlockInfo* block_info); |
99 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type, | 110 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type, |
100 uint32_t request_id, | 111 uint32_t request_id, |
101 PP_Bool success); | 112 PP_Bool success); |
102 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type, | 113 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type, |
103 uint32_t request_id); | 114 uint32_t request_id); |
104 void DecoderResetDone(PP_DecryptorStreamType decoder_type, | 115 void DecoderResetDone(PP_DecryptorStreamType decoder_type, |
105 uint32_t request_id); | 116 uint32_t request_id); |
106 void DeliverFrame(PP_Resource decrypted_frame, | 117 void DeliverFrame(PP_Resource decrypted_frame, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 | 175 |
165 // Deserializes audio data stored in |audio_frames| into individual audio | 176 // Deserializes audio data stored in |audio_frames| into individual audio |
166 // buffers in |frames|. Returns true upon success. | 177 // buffers in |frames|. Returns true upon success. |
167 bool DeserializeAudioFrames(PP_Resource audio_frames, | 178 bool DeserializeAudioFrames(PP_Resource audio_frames, |
168 size_t data_size, | 179 size_t data_size, |
169 media::SampleFormat sample_format, | 180 media::SampleFormat sample_format, |
170 media::Decryptor::AudioBuffers* frames); | 181 media::Decryptor::AudioBuffers* frames); |
171 | 182 |
172 void SatisfyAllPendingCallbacksOnError(); | 183 void SatisfyAllPendingCallbacksOnError(); |
173 | 184 |
185 // Takes ownership of |promise| and returns an identifier to be passed via | |
186 // Pepper. | |
187 uint32_t SaveVoidPromise(scoped_ptr<media::CdmChangeSessionPromise> promise); | |
188 uint32_t SaveSessionPromise(scoped_ptr<media::CdmNewSessionPromise> promise); | |
189 | |
190 // Find the promise for a specified |promise_id|. Caller is responsible to | |
191 // delete the CdmPromise<> once done with it. | |
192 scoped_ptr<media::CdmChangeSessionPromise> RetrieveVoidPromise( | |
ddorwin
2014/05/13 22:44:02
"Take" is probably a better term (and used elsewhe
jrummell
2014/05/15 22:38:09
Done.
| |
193 uint32_t promise_id); | |
194 scoped_ptr<media::CdmNewSessionPromise> RetrieveSessionPromise( | |
195 uint32_t promise_id); | |
196 | |
174 const PP_Instance pp_instance_; | 197 const PP_Instance pp_instance_; |
175 const PPP_ContentDecryptor_Private* const plugin_decryption_interface_; | 198 const PPP_ContentDecryptor_Private* const plugin_decryption_interface_; |
176 | 199 |
177 // TODO(ddorwin): Remove after updating the Pepper API to not use key system. | 200 // TODO(ddorwin): Remove after updating the Pepper API to not use key system. |
178 std::string key_system_; | 201 std::string key_system_; |
179 | 202 |
180 // Callbacks for firing session events. | 203 // Callbacks for firing session events. |
181 media::SessionCreatedCB session_created_cb_; | |
182 media::SessionMessageCB session_message_cb_; | 204 media::SessionMessageCB session_message_cb_; |
183 media::SessionReadyCB session_ready_cb_; | 205 media::SessionReadyCB session_ready_cb_; |
184 media::SessionClosedCB session_closed_cb_; | 206 media::SessionClosedCB session_closed_cb_; |
185 media::SessionErrorCB session_error_cb_; | 207 media::SessionErrorCB session_error_cb_; |
186 | 208 |
187 // Callback to notify that unexpected error happened and |this| should not | 209 // Callback to notify that unexpected error happened and |this| should not |
188 // be used anymore. | 210 // be used anymore. |
189 base::Closure fatal_plugin_error_cb_; | 211 base::Closure fatal_plugin_error_cb_; |
190 | 212 |
191 gfx::Size natural_size_; | 213 gfx::Size natural_size_; |
(...skipping 15 matching lines...) Expand all Loading... | |
207 scoped_refptr<PPB_Buffer_Impl> audio_input_resource_; | 229 scoped_refptr<PPB_Buffer_Impl> audio_input_resource_; |
208 scoped_refptr<PPB_Buffer_Impl> video_input_resource_; | 230 scoped_refptr<PPB_Buffer_Impl> video_input_resource_; |
209 | 231 |
210 std::queue<uint32_t> free_buffers_; | 232 std::queue<uint32_t> free_buffers_; |
211 | 233 |
212 // Keep track of audio parameters. | 234 // Keep track of audio parameters. |
213 int audio_samples_per_second_; | 235 int audio_samples_per_second_; |
214 int audio_channel_count_; | 236 int audio_channel_count_; |
215 media::ChannelLayout audio_channel_layout_; | 237 media::ChannelLayout audio_channel_layout_; |
216 | 238 |
239 // Keep track of outstanding promises. |promises_| has ownership of the | |
240 // promise. | |
241 uint32_t next_promise_id_; | |
242 std::map<uint32_t, media::CdmChangeSessionPromise*> void_promises_; | |
243 std::map<uint32_t, media::CdmNewSessionPromise*> session_promises_; | |
244 | |
217 base::WeakPtr<ContentDecryptorDelegate> weak_this_; | 245 base::WeakPtr<ContentDecryptorDelegate> weak_this_; |
218 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; | 246 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; |
219 | 247 |
220 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); | 248 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); |
221 }; | 249 }; |
222 | 250 |
223 } // namespace content | 251 } // namespace content |
224 | 252 |
225 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ | 253 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ |
OLD | NEW |