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/public/common/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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 95 |
95 // Notify the strategy that a frame is available. This callback can happen | 96 // Notify the strategy that a frame is available. This callback can happen |
96 // on any thread at any time. | 97 // on any thread at any time. |
97 virtual void OnFrameAvailable() = 0; | 98 virtual void OnFrameAvailable() = 0; |
98 | 99 |
99 // Whether the pictures produced by this backing strategy are overlayable. | 100 // Whether the pictures produced by this backing strategy are overlayable. |
100 virtual bool ArePicturesOverlayable() = 0; | 101 virtual bool ArePicturesOverlayable() = 0; |
101 }; | 102 }; |
102 | 103 |
103 AndroidVideoDecodeAccelerator( | 104 AndroidVideoDecodeAccelerator( |
104 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, | 105 const gpu_vda_helpers::GetGLES2DecoderCb& get_gles2_decoder_cb, |
105 const base::Callback<bool(void)>& make_context_current); | 106 const gpu_vda_helpers::MakeGLContextCurrentCb& make_context_current_cb); |
106 | 107 |
107 ~AndroidVideoDecodeAccelerator() override; | 108 ~AndroidVideoDecodeAccelerator() override; |
108 | 109 |
109 // media::VideoDecodeAccelerator implementation: | 110 // media::VideoDecodeAccelerator implementation: |
110 bool Initialize(const Config& config, Client* client) override; | 111 bool Initialize(const Config& config, Client* client) override; |
111 void SetCdm(int cdm_id) override; | 112 void SetCdm(int cdm_id) override; |
112 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 113 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
113 void AssignPictureBuffers( | 114 void AssignPictureBuffers( |
114 const std::vector<media::PictureBuffer>& buffers) override; | 115 const std::vector<media::PictureBuffer>& buffers) override; |
115 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 116 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
116 void Flush() override; | 117 void Flush() override; |
117 void Reset() override; | 118 void Reset() override; |
118 void Destroy() override; | 119 void Destroy() override; |
119 bool CanDecodeOnIOThread() override; | 120 bool TryInitializeDecodeOnSeparateThread( |
| 121 const base::WeakPtr<Client>& decode_client, |
| 122 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 123 override; |
120 | 124 |
121 // AVDAStateProvider implementation: | 125 // AVDAStateProvider implementation: |
122 const gfx::Size& GetSize() const override; | 126 const gfx::Size& GetSize() const override; |
123 const base::ThreadChecker& ThreadChecker() const override; | 127 const base::ThreadChecker& ThreadChecker() const override; |
124 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; | 128 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; |
125 void PostError(const ::tracked_objects::Location& from_here, | 129 void PostError(const ::tracked_objects::Location& from_here, |
126 media::VideoDecodeAccelerator::Error error) override; | 130 media::VideoDecodeAccelerator::Error error) override; |
127 | 131 |
128 static media::VideoDecodeAccelerator::Capabilities GetCapabilities(); | 132 static media::VideoDecodeAccelerator::Capabilities GetCapabilities(); |
129 | 133 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // Return true if and only if we should use deferred rendering. | 224 // Return true if and only if we should use deferred rendering. |
221 static bool UseDeferredRenderingStrategy(); | 225 static bool UseDeferredRenderingStrategy(); |
222 | 226 |
223 // Used to DCHECK that we are called on the correct thread. | 227 // Used to DCHECK that we are called on the correct thread. |
224 base::ThreadChecker thread_checker_; | 228 base::ThreadChecker thread_checker_; |
225 | 229 |
226 // To expose client callbacks from VideoDecodeAccelerator. | 230 // To expose client callbacks from VideoDecodeAccelerator. |
227 Client* client_; | 231 Client* client_; |
228 | 232 |
229 // Callback to set the correct gl context. | 233 // Callback to set the correct gl context. |
230 base::Callback<bool(void)> make_context_current_; | 234 gpu_vda_helpers::MakeGLContextCurrentCb make_context_current_cb_; |
| 235 |
| 236 // Callback to get the GLES2Decoder instance. |
| 237 gpu_vda_helpers::GetGLES2DecoderCb get_gles2_decoder_cb_; |
231 | 238 |
232 // Codec type. Used when we configure media codec. | 239 // Codec type. Used when we configure media codec. |
233 media::VideoCodec codec_; | 240 media::VideoCodec codec_; |
234 | 241 |
235 // Whether the stream is encrypted. | 242 // Whether the stream is encrypted. |
236 bool is_encrypted_; | 243 bool is_encrypted_; |
237 | 244 |
238 // Whether encryption scheme requires to use protected surface. | 245 // Whether encryption scheme requires to use protected surface. |
239 bool needs_protected_surface_; | 246 bool needs_protected_surface_; |
240 | 247 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // A map of presentation timestamp to bitstream buffer id for the bitstream | 285 // A map of presentation timestamp to bitstream buffer id for the bitstream |
279 // buffers that have been submitted to the decoder but haven't yet produced an | 286 // buffers that have been submitted to the decoder but haven't yet produced an |
280 // output frame with the same timestamp. Note: there will only be one entry | 287 // output frame with the same timestamp. Note: there will only be one entry |
281 // for multiple bitstream buffers that have the same presentation timestamp. | 288 // for multiple bitstream buffers that have the same presentation timestamp. |
282 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; | 289 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; |
283 | 290 |
284 // Keeps track of bitstream ids notified to the client with | 291 // Keeps track of bitstream ids notified to the client with |
285 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. | 292 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. |
286 std::list<int32_t> bitstreams_notified_in_advance_; | 293 std::list<int32_t> bitstreams_notified_in_advance_; |
287 | 294 |
288 // Owner of the GL context. Used to restore the context state. | |
289 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_; | |
290 | |
291 // Backing strategy that we'll use to connect PictureBuffers to frames. | 295 // Backing strategy that we'll use to connect PictureBuffers to frames. |
292 scoped_ptr<BackingStrategy> strategy_; | 296 scoped_ptr<BackingStrategy> strategy_; |
293 | 297 |
294 // Helper class that manages asynchronous OnFrameAvailable callbacks. | 298 // Helper class that manages asynchronous OnFrameAvailable callbacks. |
295 class OnFrameAvailableHandler; | 299 class OnFrameAvailableHandler; |
296 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; | 300 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; |
297 | 301 |
298 // Time at which we last did useful work on io_timer_. | 302 // Time at which we last did useful work on io_timer_. |
299 base::TimeTicks most_recent_work_; | 303 base::TimeTicks most_recent_work_; |
300 | 304 |
(...skipping 23 matching lines...) Expand all Loading... |
324 | 328 |
325 // WeakPtrFactory for posting tasks back to |this|. | 329 // WeakPtrFactory for posting tasks back to |this|. |
326 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 330 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
327 | 331 |
328 friend class AndroidVideoDecodeAcceleratorTest; | 332 friend class AndroidVideoDecodeAcceleratorTest; |
329 }; | 333 }; |
330 | 334 |
331 } // namespace content | 335 } // namespace content |
332 | 336 |
333 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 337 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |