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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_helpers.h" | |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
| 16 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
| 17 #include "media/base/sample_format.h" | 18 #include "media/base/sample_format.h" |
| 18 #include "ppapi/c/private/pp_content_decryptor.h" | 19 #include "ppapi/c/private/pp_content_decryptor.h" |
| 19 #include "ppapi/c/private/ppp_content_decryptor_private.h" | 20 #include "ppapi/c/private/ppp_content_decryptor_private.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type, | 98 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type, |
| 98 uint32_t request_id); | 99 uint32_t request_id); |
| 99 void DecoderResetDone(PP_DecryptorStreamType decoder_type, | 100 void DecoderResetDone(PP_DecryptorStreamType decoder_type, |
| 100 uint32_t request_id); | 101 uint32_t request_id); |
| 101 void DeliverFrame(PP_Resource decrypted_frame, | 102 void DeliverFrame(PP_Resource decrypted_frame, |
| 102 const PP_DecryptedFrameInfo* frame_info); | 103 const PP_DecryptedFrameInfo* frame_info); |
| 103 void DeliverSamples(PP_Resource audio_frames, | 104 void DeliverSamples(PP_Resource audio_frames, |
| 104 const PP_DecryptedSampleInfo* sample_info); | 105 const PP_DecryptedSampleInfo* sample_info); |
| 105 | 106 |
| 106 private: | 107 private: |
| 108 template <typename Callback> | |
| 109 class TrackableCallback { | |
| 110 public: | |
| 111 TrackableCallback() : id_(0u) {} | |
| 112 // TODO(xhwang): Check that no callback is pending in dtor. | |
|
dmichael (off chromium)
2014/01/03 18:44:43
That should be an easy check to add if you want it
xhwang
2014/01/07 19:53:31
I can't do this now because we didn't always satis
| |
| 113 ~TrackableCallback() {}; | |
| 114 | |
| 115 bool Matches(uint32_t id) const { return id == id_; } | |
| 116 | |
| 117 bool is_null() const { return cb_.is_null(); } | |
| 118 | |
| 119 void Set(uint32_t id, const Callback& cb) { | |
| 120 DCHECK_EQ(id_, 0u); | |
| 121 DCHECK(cb_.is_null()); | |
| 122 id_ = id; | |
| 123 cb_ = cb; | |
| 124 } | |
| 125 | |
| 126 Callback ResetAndReturn() { | |
| 127 id_ = 0; | |
| 128 return base::ResetAndReturn(&cb_); | |
| 129 } | |
| 130 | |
| 131 private: | |
| 132 uint32_t id_; | |
| 133 Callback cb_; | |
| 134 }; | |
| 135 | |
| 107 // Cancels the pending decrypt-and-decode callback for |stream_type|. | 136 // Cancels the pending decrypt-and-decode callback for |stream_type|. |
| 108 void CancelDecode(media::Decryptor::StreamType stream_type); | 137 void CancelDecode(media::Decryptor::StreamType stream_type); |
| 109 | 138 |
| 110 // Fills |resource| with a PPB_Buffer_Impl and copies the data from | 139 // Fills |resource| with a PPB_Buffer_Impl and copies the data from |
| 111 // |encrypted_buffer| into the buffer resource. This method reuses | 140 // |encrypted_buffer| into the buffer resource. This method reuses |
| 112 // |audio_input_resource_| and |video_input_resource_| to reduce the latency | 141 // |audio_input_resource_| and |video_input_resource_| to reduce the latency |
| 113 // in requesting new PPB_Buffer_Impl resources. The caller must make sure that | 142 // in requesting new PPB_Buffer_Impl resources. The caller must make sure that |
| 114 // |audio_input_resource_| or |video_input_resource_| is available before | 143 // |audio_input_resource_| or |video_input_resource_| is available before |
| 115 // calling this method. | 144 // calling this method. |
| 116 // | 145 // |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 147 media::SessionErrorCB session_error_cb_; | 176 media::SessionErrorCB session_error_cb_; |
| 148 | 177 |
| 149 gfx::Size natural_size_; | 178 gfx::Size natural_size_; |
| 150 | 179 |
| 151 // Request ID for tracking pending content decryption callbacks. | 180 // Request ID for tracking pending content decryption callbacks. |
| 152 // Note that zero indicates an invalid request ID. | 181 // Note that zero indicates an invalid request ID. |
| 153 // TODO(xhwang): Add completion callbacks for Reset/Stop and remove the use | 182 // TODO(xhwang): Add completion callbacks for Reset/Stop and remove the use |
| 154 // of request IDs. | 183 // of request IDs. |
| 155 uint32_t next_decryption_request_id_; | 184 uint32_t next_decryption_request_id_; |
| 156 | 185 |
| 157 uint32_t pending_audio_decrypt_request_id_; | 186 TrackableCallback<media::Decryptor::DecryptCB> audio_decrypt_cb_; |
| 158 media::Decryptor::DecryptCB pending_audio_decrypt_cb_; | 187 TrackableCallback<media::Decryptor::DecryptCB> video_decrypt_cb_; |
| 159 | 188 TrackableCallback<media::Decryptor::DecoderInitCB> audio_decoder_init_cb_; |
| 160 uint32_t pending_video_decrypt_request_id_; | 189 TrackableCallback<media::Decryptor::DecoderInitCB> video_decoder_init_cb_; |
| 161 media::Decryptor::DecryptCB pending_video_decrypt_cb_; | 190 TrackableCallback<media::Decryptor::AudioDecodeCB> audio_decode_cb_; |
| 162 | 191 TrackableCallback<media::Decryptor::VideoDecodeCB> video_decode_cb_; |
| 163 uint32_t pending_audio_decoder_init_request_id_; | |
| 164 media::Decryptor::DecoderInitCB pending_audio_decoder_init_cb_; | |
| 165 | |
| 166 uint32_t pending_video_decoder_init_request_id_; | |
| 167 media::Decryptor::DecoderInitCB pending_video_decoder_init_cb_; | |
| 168 | |
| 169 uint32_t pending_audio_decode_request_id_; | |
| 170 media::Decryptor::AudioDecodeCB pending_audio_decode_cb_; | |
| 171 | |
| 172 uint32_t pending_video_decode_request_id_; | |
| 173 media::Decryptor::VideoDecodeCB pending_video_decode_cb_; | |
| 174 | 192 |
| 175 // Cached audio and video input buffers. See MakeMediaBufferResource. | 193 // Cached audio and video input buffers. See MakeMediaBufferResource. |
| 176 scoped_refptr<PPB_Buffer_Impl> audio_input_resource_; | 194 scoped_refptr<PPB_Buffer_Impl> audio_input_resource_; |
| 177 scoped_refptr<PPB_Buffer_Impl> video_input_resource_; | 195 scoped_refptr<PPB_Buffer_Impl> video_input_resource_; |
| 178 | 196 |
| 179 std::queue<uint32_t> free_buffers_; | 197 std::queue<uint32_t> free_buffers_; |
| 180 | 198 |
| 181 // Keep track of audio parameters. | 199 // Keep track of audio parameters. |
| 182 int audio_samples_per_second_; | 200 int audio_samples_per_second_; |
| 183 int audio_channel_count_; | 201 int audio_channel_count_; |
| 184 | 202 |
| 185 base::WeakPtr<ContentDecryptorDelegate> weak_this_; | 203 base::WeakPtr<ContentDecryptorDelegate> weak_this_; |
| 186 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; | 204 base::WeakPtrFactory<ContentDecryptorDelegate> weak_ptr_factory_; |
| 187 | 205 |
| 188 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); | 206 DISALLOW_COPY_AND_ASSIGN(ContentDecryptorDelegate); |
| 189 }; | 207 }; |
| 190 | 208 |
| 191 } // namespace content | 209 } // namespace content |
| 192 | 210 |
| 193 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ | 211 #endif // CONTENT_RENDERER_PEPPER_CONTENT_DECRYPTOR_DELEGATE_H_ |
| OLD | NEW |