Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: content/renderer/pepper/content_decryptor_delegate.h

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::NewSessionCdmPromise> promise);
61 void LoadSession(const std::string& web_session_id,
62 scoped_ptr<media::NewSessionCdmPromise> 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::SimpleCdmPromise> promise);
67 void ReleaseSession(const std::string& web_session_id,
68 scoped_ptr<media::SimpleCdmPromise> 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_ExceptionCode exception_code,
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_ExceptionCode exception_code,
106 uint32 system_code,
107 PP_Var error_description_var);
xhwang 2014/05/23 06:01:23 OOC, is it a convention to use foo_var for PP_VAR
jrummell 2014/05/29 00:54:40 Nope. Just means I have to come up with better nam
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
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 SaveSimplePromise(scoped_ptr<media::SimpleCdmPromise> promise);
188 uint32_t SaveNewSessionPromise(
189 scoped_ptr<media::NewSessionCdmPromise> promise);
190
191 // Find the promise for a specified |promise_id|. Caller is responsible to
192 // delete the CdmPromise<> once done with it.
193 scoped_ptr<media::SimpleCdmPromise> TakeSimplePromise(uint32_t promise_id);
194 scoped_ptr<media::NewSessionCdmPromise> TakeNewSessionPromise(
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
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::SimpleCdmPromise*> simple_promises_;
243 std::map<uint32_t, media::NewSessionCdmPromise*> new_session_promises_;
xhwang 2014/05/23 06:01:23 Use ScopedPtrHashMap.
jrummell 2014/05/29 00:54:40 Done.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698