Chromium Code Reviews| 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 <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 class ContentDecryptorDelegate { | 33 class ContentDecryptorDelegate { |
| 34 public: | 34 public: |
| 35 // ContentDecryptorDelegate does not take ownership of | 35 // ContentDecryptorDelegate does not take ownership of |
| 36 // |plugin_decryption_interface|. Therefore |plugin_decryption_interface| | 36 // |plugin_decryption_interface|. Therefore |plugin_decryption_interface| |
| 37 // must outlive this object. | 37 // must outlive this object. |
| 38 ContentDecryptorDelegate( | 38 ContentDecryptorDelegate( |
| 39 PP_Instance pp_instance, | 39 PP_Instance pp_instance, |
| 40 const PPP_ContentDecryptor_Private* plugin_decryption_interface); | 40 const PPP_ContentDecryptor_Private* plugin_decryption_interface); |
| 41 ~ContentDecryptorDelegate(); | 41 ~ContentDecryptorDelegate(); |
| 42 | 42 |
| 43 void Initialize(const std::string& key_system); | 43 void Initialize(const std::string& key_system, |
|
ddorwin
2014/01/08 23:40:32
Should we document in this public interface that p
xhwang
2014/01/09 01:58:49
Done.
| |
| 44 const media::SessionCreatedCB& session_created_cb, | |
| 45 const media::SessionMessageCB& session_message_cb, | |
| 46 const media::SessionReadyCB& session_ready_cb, | |
| 47 const media::SessionClosedCB& session_closed_cb, | |
| 48 const media::SessionErrorCB& session_error_cb, | |
| 49 const base::Closure& plugin_error_cb); | |
| 44 | 50 |
| 45 void SetSessionEventCallbacks( | 51 void InstanceCrashed(); |
| 46 const media::SessionCreatedCB& session_created_cb, | |
| 47 const media::SessionMessageCB& session_message_cb, | |
| 48 const media::SessionReadyCB& session_ready_cb, | |
| 49 const media::SessionClosedCB& session_closed_cb, | |
| 50 const media::SessionErrorCB& session_error_cb); | |
| 51 | 52 |
| 52 // Provides access to PPP_ContentDecryptor_Private. | 53 // Provides access to PPP_ContentDecryptor_Private. |
| 53 bool CreateSession(uint32 session_id, | 54 bool CreateSession(uint32 session_id, |
| 54 const std::string& type, | 55 const std::string& type, |
| 55 const uint8* init_data, | 56 const uint8* init_data, |
| 56 int init_data_length); | 57 int init_data_length); |
| 57 bool UpdateSession(uint32 session_id, | 58 bool UpdateSession(uint32 session_id, |
| 58 const uint8* response, | 59 const uint8* response, |
| 59 int response_length); | 60 int response_length); |
| 60 bool ReleaseSession(uint32 session_id); | 61 bool ReleaseSession(uint32 session_id); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 void DeliverFrame(PP_Resource decrypted_frame, | 103 void DeliverFrame(PP_Resource decrypted_frame, |
| 103 const PP_DecryptedFrameInfo* frame_info); | 104 const PP_DecryptedFrameInfo* frame_info); |
| 104 void DeliverSamples(PP_Resource audio_frames, | 105 void DeliverSamples(PP_Resource audio_frames, |
| 105 const PP_DecryptedSampleInfo* sample_info); | 106 const PP_DecryptedSampleInfo* sample_info); |
| 106 | 107 |
| 107 private: | 108 private: |
| 108 template <typename Callback> | 109 template <typename Callback> |
| 109 class TrackableCallback { | 110 class TrackableCallback { |
| 110 public: | 111 public: |
| 111 TrackableCallback() : id_(0u) {} | 112 TrackableCallback() : id_(0u) {} |
| 112 // TODO(xhwang): Check that no callback is pending in dtor. | 113 ~TrackableCallback() { |
| 113 ~TrackableCallback() {}; | 114 // Callbacks must be satisfied. |
| 115 DCHECK_EQ(id_, 0u); | |
| 116 DCHECK(is_null()); | |
| 117 }; | |
| 114 | 118 |
| 115 bool Matches(uint32_t id) const { return id == id_; } | 119 bool Matches(uint32_t id) const { return id == id_; } |
| 116 | 120 |
| 117 bool is_null() const { return cb_.is_null(); } | 121 bool is_null() const { return cb_.is_null(); } |
| 118 | 122 |
| 119 void Set(uint32_t id, const Callback& cb) { | 123 void Set(uint32_t id, const Callback& cb) { |
| 120 DCHECK_EQ(id_, 0u); | 124 DCHECK_EQ(id_, 0u); |
| 121 DCHECK(cb_.is_null()); | 125 DCHECK(cb_.is_null()); |
| 122 id_ = id; | 126 id_ = id; |
| 123 cb_ = cb; | 127 cb_ = cb; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 159 |
| 156 void SetBufferToFreeInTrackingInfo(PP_DecryptTrackingInfo* tracking_info); | 160 void SetBufferToFreeInTrackingInfo(PP_DecryptTrackingInfo* tracking_info); |
| 157 | 161 |
| 158 // Deserializes audio data stored in |audio_frames| into individual audio | 162 // Deserializes audio data stored in |audio_frames| into individual audio |
| 159 // buffers in |frames|. Returns true upon success. | 163 // buffers in |frames|. Returns true upon success. |
| 160 bool DeserializeAudioFrames(PP_Resource audio_frames, | 164 bool DeserializeAudioFrames(PP_Resource audio_frames, |
| 161 size_t data_size, | 165 size_t data_size, |
| 162 media::SampleFormat sample_format, | 166 media::SampleFormat sample_format, |
| 163 media::Decryptor::AudioBuffers* frames); | 167 media::Decryptor::AudioBuffers* frames); |
| 164 | 168 |
| 169 void SatisfyAllPendingCallbacksOnError(); | |
| 170 | |
| 165 const PP_Instance pp_instance_; | 171 const PP_Instance pp_instance_; |
| 166 const PPP_ContentDecryptor_Private* const plugin_decryption_interface_; | 172 const PPP_ContentDecryptor_Private* const plugin_decryption_interface_; |
| 167 | 173 |
| 168 // TODO(ddorwin): Remove after updating the Pepper API to not use key system. | 174 // TODO(ddorwin): Remove after updating the Pepper API to not use key system. |
| 169 std::string key_system_; | 175 std::string key_system_; |
| 170 | 176 |
| 171 // Callbacks for firing session events. | 177 // Callbacks for firing session events. |
| 172 media::SessionCreatedCB session_created_cb_; | 178 media::SessionCreatedCB session_created_cb_; |
| 173 media::SessionMessageCB session_message_cb_; | 179 media::SessionMessageCB session_message_cb_; |
| 174 media::SessionReadyCB session_ready_cb_; | 180 media::SessionReadyCB session_ready_cb_; |
| 175 media::SessionClosedCB session_closed_cb_; | 181 media::SessionClosedCB session_closed_cb_; |
| 176 media::SessionErrorCB session_error_cb_; | 182 media::SessionErrorCB session_error_cb_; |
| 177 | 183 |
| 184 // Callback to notify that unexpected error happened and |this| should not | |
| 185 // be used anymore. | |
| 186 base::Closure plugin_error_cb_; | |
| 187 | |
| 178 gfx::Size natural_size_; | 188 gfx::Size natural_size_; |
| 179 | 189 |
| 180 // Request ID for tracking pending content decryption callbacks. | 190 // Request ID for tracking pending content decryption callbacks. |
| 181 // Note that zero indicates an invalid request ID. | 191 // Note that zero indicates an invalid request ID. |
| 182 // TODO(xhwang): Add completion callbacks for Reset/Stop and remove the use | 192 // TODO(xhwang): Add completion callbacks for Reset/Stop and remove the use |
| 183 // of request IDs. | 193 // of request IDs. |
| 184 uint32_t next_decryption_request_id_; | 194 uint32_t next_decryption_request_id_; |
| 185 | 195 |
| 186 TrackableCallback<media::Decryptor::DecryptCB> audio_decrypt_cb_; | 196 TrackableCallback<media::Decryptor::DecryptCB> audio_decrypt_cb_; |
| 187 TrackableCallback<media::Decryptor::DecryptCB> video_decrypt_cb_; | 197 TrackableCallback<media::Decryptor::DecryptCB> video_decrypt_cb_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 202 | 212 |
| 203 base::WeakPtr<ContentDecryptorDelegate> weak_this_; | 213 base::WeakPtr<ContentDecryptorDelegate> weak_this_; |
| 204 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; | 214 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; |
| 205 | 215 |
| 206 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); | 216 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); |
| 207 }; | 217 }; |
| 208 | 218 |
| 209 } // namespace content | 219 } // namespace content |
| 210 | 220 |
| 211 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ | 221 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ |
| OLD | NEW |