OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <queue> | 12 #include <queue> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "content/common/gpu/media/avda_state_provider.h" | 20 #include "content/common/gpu/media/avda_state_provider.h" |
| 21 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h" |
21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
22 #include "media/base/android/media_drm_bridge.h" | 23 #include "media/base/android/media_drm_bridge.h" |
23 #include "media/base/android/sdk_media_codec_bridge.h" | 24 #include "media/base/android/sdk_media_codec_bridge.h" |
24 #include "media/base/media_keys.h" | 25 #include "media/base/media_keys.h" |
25 #include "media/video/video_decode_accelerator.h" | 26 #include "media/video/video_decode_accelerator.h" |
26 #include "ui/gl/android/scoped_java_surface.h" | 27 #include "ui/gl/android/scoped_java_surface.h" |
27 | 28 |
28 namespace gfx { | 29 namespace gfx { |
29 class SurfaceTexture; | 30 class SurfaceTexture; |
30 } | 31 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Size may have changed due to resolution change since the last time this | 103 // Size may have changed due to resolution change since the last time this |
103 // PictureBuffer was used. Update the size of the picture buffer to | 104 // PictureBuffer was used. Update the size of the picture buffer to |
104 // |new_size| and also update any size-dependent state (e.g. size of | 105 // |new_size| and also update any size-dependent state (e.g. size of |
105 // associated texture). Callers should set the correct GL context prior to | 106 // associated texture). Callers should set the correct GL context prior to |
106 // calling. | 107 // calling. |
107 virtual void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer, | 108 virtual void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer, |
108 const gfx::Size& new_size) = 0; | 109 const gfx::Size& new_size) = 0; |
109 }; | 110 }; |
110 | 111 |
111 AndroidVideoDecodeAccelerator( | 112 AndroidVideoDecodeAccelerator( |
112 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, | 113 const MakeGLContextCurrentCallback& make_context_current_cb, |
113 const base::Callback<bool(void)>& make_context_current); | 114 const GetGLES2DecoderCallback& get_gles2_decoder_cb); |
114 | 115 |
115 ~AndroidVideoDecodeAccelerator() override; | 116 ~AndroidVideoDecodeAccelerator() override; |
116 | 117 |
117 // media::VideoDecodeAccelerator implementation: | 118 // media::VideoDecodeAccelerator implementation: |
118 bool Initialize(const Config& config, Client* client) override; | 119 bool Initialize(const Config& config, Client* client) override; |
119 void SetCdm(int cdm_id) override; | 120 void SetCdm(int cdm_id) override; |
120 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 121 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
121 void AssignPictureBuffers( | 122 void AssignPictureBuffers( |
122 const std::vector<media::PictureBuffer>& buffers) override; | 123 const std::vector<media::PictureBuffer>& buffers) override; |
123 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 124 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
124 void Flush() override; | 125 void Flush() override; |
125 void Reset() override; | 126 void Reset() override; |
126 void Destroy() override; | 127 void Destroy() override; |
127 bool CanDecodeOnIOThread() override; | 128 bool TryToSetupDecodeOnSeparateThread( |
| 129 const base::WeakPtr<Client>& decode_client, |
| 130 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 131 override; |
128 | 132 |
129 // AVDAStateProvider implementation: | 133 // AVDAStateProvider implementation: |
130 const gfx::Size& GetSize() const override; | 134 const gfx::Size& GetSize() const override; |
131 const base::ThreadChecker& ThreadChecker() const override; | 135 const base::ThreadChecker& ThreadChecker() const override; |
132 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; | 136 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; |
133 gpu::gles2::TextureRef* GetTextureForPicture( | 137 gpu::gles2::TextureRef* GetTextureForPicture( |
134 const media::PictureBuffer& picture_buffer) override; | 138 const media::PictureBuffer& picture_buffer) override; |
135 void PostError(const ::tracked_objects::Location& from_here, | 139 void PostError(const ::tracked_objects::Location& from_here, |
136 media::VideoDecodeAccelerator::Error error) override; | 140 media::VideoDecodeAccelerator::Error error) override; |
137 | 141 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Return true if and only if we should use deferred rendering. | 234 // Return true if and only if we should use deferred rendering. |
231 static bool UseDeferredRenderingStrategy(); | 235 static bool UseDeferredRenderingStrategy(); |
232 | 236 |
233 // Used to DCHECK that we are called on the correct thread. | 237 // Used to DCHECK that we are called on the correct thread. |
234 base::ThreadChecker thread_checker_; | 238 base::ThreadChecker thread_checker_; |
235 | 239 |
236 // To expose client callbacks from VideoDecodeAccelerator. | 240 // To expose client callbacks from VideoDecodeAccelerator. |
237 Client* client_; | 241 Client* client_; |
238 | 242 |
239 // Callback to set the correct gl context. | 243 // Callback to set the correct gl context. |
240 base::Callback<bool(void)> make_context_current_; | 244 MakeGLContextCurrentCallback make_context_current_cb_; |
| 245 |
| 246 // Callback to get the GLES2Decoder instance. |
| 247 GetGLES2DecoderCallback get_gles2_decoder_cb_; |
241 | 248 |
242 // Codec type. Used when we configure media codec. | 249 // Codec type. Used when we configure media codec. |
243 media::VideoCodec codec_; | 250 media::VideoCodec codec_; |
244 | 251 |
245 // Whether the stream is encrypted. | 252 // Whether the stream is encrypted. |
246 bool is_encrypted_; | 253 bool is_encrypted_; |
247 | 254 |
248 // Whether encryption scheme requires to use protected surface. | 255 // Whether encryption scheme requires to use protected surface. |
249 bool needs_protected_surface_; | 256 bool needs_protected_surface_; |
250 | 257 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // A map of presentation timestamp to bitstream buffer id for the bitstream | 295 // A map of presentation timestamp to bitstream buffer id for the bitstream |
289 // buffers that have been submitted to the decoder but haven't yet produced an | 296 // buffers that have been submitted to the decoder but haven't yet produced an |
290 // output frame with the same timestamp. Note: there will only be one entry | 297 // output frame with the same timestamp. Note: there will only be one entry |
291 // for multiple bitstream buffers that have the same presentation timestamp. | 298 // for multiple bitstream buffers that have the same presentation timestamp. |
292 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; | 299 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; |
293 | 300 |
294 // Keeps track of bitstream ids notified to the client with | 301 // Keeps track of bitstream ids notified to the client with |
295 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. | 302 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. |
296 std::list<int32_t> bitstreams_notified_in_advance_; | 303 std::list<int32_t> bitstreams_notified_in_advance_; |
297 | 304 |
298 // Owner of the GL context. Used to restore the context state. | |
299 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_; | |
300 | |
301 // Backing strategy that we'll use to connect PictureBuffers to frames. | 305 // Backing strategy that we'll use to connect PictureBuffers to frames. |
302 scoped_ptr<BackingStrategy> strategy_; | 306 scoped_ptr<BackingStrategy> strategy_; |
303 | 307 |
304 // Helper class that manages asynchronous OnFrameAvailable callbacks. | 308 // Helper class that manages asynchronous OnFrameAvailable callbacks. |
305 class OnFrameAvailableHandler; | 309 class OnFrameAvailableHandler; |
306 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; | 310 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; |
307 | 311 |
308 // Time at which we last did useful work on io_timer_. | 312 // Time at which we last did useful work on io_timer_. |
309 base::TimeTicks most_recent_work_; | 313 base::TimeTicks most_recent_work_; |
310 | 314 |
(...skipping 23 matching lines...) Expand all Loading... |
334 | 338 |
335 // WeakPtrFactory for posting tasks back to |this|. | 339 // WeakPtrFactory for posting tasks back to |this|. |
336 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 340 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
337 | 341 |
338 friend class AndroidVideoDecodeAcceleratorTest; | 342 friend class AndroidVideoDecodeAcceleratorTest; |
339 }; | 343 }; |
340 | 344 |
341 } // namespace content | 345 } // namespace content |
342 | 346 |
343 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 347 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |