OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file contains an implementation of VideoDecodeAccelerator | 5 // This file contains an implementation of VideoDecodeAccelerator |
6 // that utilizes hardware video decoders, which expose Video4Linux 2 API | 6 // that utilizes hardware video decoders, which expose Video4Linux 2 API |
7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). | 7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). |
8 | 8 |
9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // the required number of output buffers from the device and that cannot be done | 70 // the required number of output buffers from the device and that cannot be done |
71 // unless we free the previous set of buffers, leaving the decoding in a | 71 // unless we free the previous set of buffers, leaving the decoding in a |
72 // inoperable state for the duration of the wait for Pictures. So to prevent | 72 // inoperable state for the duration of the wait for Pictures. So to prevent |
73 // subtle races (esp. if we get Reset() in the meantime), we block the decoder | 73 // subtle races (esp. if we get Reset() in the meantime), we block the decoder |
74 // thread while we wait for AssignPictureBuffers from the client. | 74 // thread while we wait for AssignPictureBuffers from the client. |
75 class CONTENT_EXPORT V4L2VideoDecodeAccelerator | 75 class CONTENT_EXPORT V4L2VideoDecodeAccelerator |
76 : public VideoDecodeAcceleratorImpl { | 76 : public VideoDecodeAcceleratorImpl { |
77 public: | 77 public: |
78 V4L2VideoDecodeAccelerator( | 78 V4L2VideoDecodeAccelerator( |
79 EGLDisplay egl_display, | 79 EGLDisplay egl_display, |
80 Client* client, | |
81 const base::WeakPtr<Client>& io_client_, | 80 const base::WeakPtr<Client>& io_client_, |
82 const base::Callback<bool(void)>& make_context_current, | 81 const base::Callback<bool(void)>& make_context_current, |
83 scoped_ptr<V4L2Device> device, | 82 scoped_ptr<V4L2Device> device, |
84 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); | 83 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); |
85 virtual ~V4L2VideoDecodeAccelerator(); | 84 virtual ~V4L2VideoDecodeAccelerator(); |
86 | 85 |
87 // media::VideoDecodeAccelerator implementation. | 86 // media::VideoDecodeAccelerator implementation. |
88 // Note: Initialize() and Destroy() are synchronous. | 87 // Note: Initialize() and Destroy() are synchronous. |
89 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | 88 virtual bool Initialize(media::VideoCodecProfile profile, |
| 89 Client* client) OVERRIDE; |
90 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 90 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
91 virtual void AssignPictureBuffers( | 91 virtual void AssignPictureBuffers( |
92 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 92 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
93 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 93 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
94 virtual void Flush() OVERRIDE; | 94 virtual void Flush() OVERRIDE; |
95 virtual void Reset() OVERRIDE; | 95 virtual void Reset() OVERRIDE; |
96 virtual void Destroy() OVERRIDE; | 96 virtual void Destroy() OVERRIDE; |
97 | 97 |
98 // VideoDecodeAcceleratorImpl implementation. | 98 // VideoDecodeAcceleratorImpl implementation. |
99 virtual bool CanDecodeOnIOThread() OVERRIDE; | 99 virtual bool CanDecodeOnIOThread() OVERRIDE; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // device worker threads back to the child thread. Because the worker threads | 304 // device worker threads back to the child thread. Because the worker threads |
305 // are members of this class, any task running on those threads is guaranteed | 305 // are members of this class, any task running on those threads is guaranteed |
306 // that this object is still alive. As a result, tasks posted from the child | 306 // that this object is still alive. As a result, tasks posted from the child |
307 // thread to the decoder or device thread should use base::Unretained(this), | 307 // thread to the decoder or device thread should use base::Unretained(this), |
308 // and tasks posted the other way should use |weak_this_|. | 308 // and tasks posted the other way should use |weak_this_|. |
309 base::WeakPtr<V4L2VideoDecodeAccelerator> weak_this_; | 309 base::WeakPtr<V4L2VideoDecodeAccelerator> weak_this_; |
310 | 310 |
311 // To expose client callbacks from VideoDecodeAccelerator. | 311 // To expose client callbacks from VideoDecodeAccelerator. |
312 // NOTE: all calls to these objects *MUST* be executed on | 312 // NOTE: all calls to these objects *MUST* be executed on |
313 // child_message_loop_proxy_. | 313 // child_message_loop_proxy_. |
314 base::WeakPtrFactory<Client> client_ptr_factory_; | 314 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; |
315 base::WeakPtr<Client> client_; | 315 base::WeakPtr<Client> client_; |
316 // Callbacks to |io_client_| must be executed on |io_message_loop_proxy_|. | 316 // Callbacks to |io_client_| must be executed on |io_message_loop_proxy_|. |
317 base::WeakPtr<Client> io_client_; | 317 base::WeakPtr<Client> io_client_; |
318 | 318 |
319 // | 319 // |
320 // Decoder state, owned and operated by decoder_thread_. | 320 // Decoder state, owned and operated by decoder_thread_. |
321 // Before decoder_thread_ has started, the decoder state is managed by | 321 // Before decoder_thread_ has started, the decoder state is managed by |
322 // the child (main) thread. After decoder_thread_ has started, the decoder | 322 // the child (main) thread. After decoder_thread_ has started, the decoder |
323 // thread should be the only one managing these. | 323 // thread should be the only one managing these. |
324 // | 324 // |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 425 |
426 // The codec we'll be decoding for. | 426 // The codec we'll be decoding for. |
427 media::VideoCodecProfile video_profile_; | 427 media::VideoCodecProfile video_profile_; |
428 | 428 |
429 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); | 429 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); |
430 }; | 430 }; |
431 | 431 |
432 } // namespace content | 432 } // namespace content |
433 | 433 |
434 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 434 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |