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_ |
11 | 11 |
12 #include <queue> | 12 #include <queue> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/ref_counted.h" | |
18 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
19 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
20 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
21 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
22 #include "content/common/gpu/media/v4l2_video_device.h" | 21 #include "content/common/gpu/media/v4l2_video_device.h" |
23 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
24 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
25 #include "media/video/picture.h" | 24 #include "media/video/picture.h" |
26 #include "media/video/video_decode_accelerator.h" | 25 #include "media/video/video_decode_accelerator.h" |
27 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // 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 |
75 // thread while we wait for AssignPictureBuffers from the client. | 74 // thread while we wait for AssignPictureBuffers from the client. |
76 class CONTENT_EXPORT V4L2VideoDecodeAccelerator | 75 class CONTENT_EXPORT V4L2VideoDecodeAccelerator |
77 : public media::VideoDecodeAccelerator { | 76 : public media::VideoDecodeAccelerator { |
78 public: | 77 public: |
79 V4L2VideoDecodeAccelerator( | 78 V4L2VideoDecodeAccelerator( |
80 EGLDisplay egl_display, | 79 EGLDisplay egl_display, |
81 EGLContext egl_context, | 80 EGLContext egl_context, |
82 const base::WeakPtr<Client>& io_client_, | 81 const base::WeakPtr<Client>& io_client_, |
83 const base::Callback<bool(void)>& make_context_current, | 82 const base::Callback<bool(void)>& make_context_current, |
84 const scoped_refptr<V4L2Device>& device, | 83 scoped_ptr<V4L2Device> device, |
85 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); | 84 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); |
86 virtual ~V4L2VideoDecodeAccelerator(); | 85 virtual ~V4L2VideoDecodeAccelerator(); |
87 | 86 |
88 // media::VideoDecodeAccelerator implementation. | 87 // media::VideoDecodeAccelerator implementation. |
89 // Note: Initialize() and Destroy() are synchronous. | 88 // Note: Initialize() and Destroy() are synchronous. |
90 virtual bool Initialize(media::VideoCodecProfile profile, | 89 virtual bool Initialize(media::VideoCodecProfile profile, |
91 Client* client) override; | 90 Client* client) override; |
92 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 91 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
93 virtual void AssignPictureBuffers( | 92 virtual void AssignPictureBuffers( |
94 const std::vector<media::PictureBuffer>& buffers) override; | 93 const std::vector<media::PictureBuffer>& buffers) override; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // | 333 // |
335 | 334 |
336 // This thread services tasks posted from the VDA API entry points by the | 335 // This thread services tasks posted from the VDA API entry points by the |
337 // child thread and device service callbacks posted from the device thread. | 336 // child thread and device service callbacks posted from the device thread. |
338 base::Thread decoder_thread_; | 337 base::Thread decoder_thread_; |
339 // Decoder state machine state. | 338 // Decoder state machine state. |
340 State decoder_state_; | 339 State decoder_state_; |
341 // BitstreamBuffer we're presently reading. | 340 // BitstreamBuffer we're presently reading. |
342 scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; | 341 scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; |
343 // The V4L2Device this class is operating upon. | 342 // The V4L2Device this class is operating upon. |
344 scoped_refptr<V4L2Device> device_; | 343 scoped_ptr<V4L2Device> device_; |
345 // FlushTask() and ResetTask() should not affect buffers that have been | 344 // FlushTask() and ResetTask() should not affect buffers that have been |
346 // queued afterwards. For flushing or resetting the pipeline then, we will | 345 // queued afterwards. For flushing or resetting the pipeline then, we will |
347 // delay these buffers until after the flush or reset completes. | 346 // delay these buffers until after the flush or reset completes. |
348 int decoder_delay_bitstream_buffer_id_; | 347 int decoder_delay_bitstream_buffer_id_; |
349 // Input buffer we're presently filling. | 348 // Input buffer we're presently filling. |
350 int decoder_current_input_buffer_; | 349 int decoder_current_input_buffer_; |
351 // We track the number of buffer decode tasks we have scheduled, since each | 350 // We track the number of buffer decode tasks we have scheduled, since each |
352 // task execution should complete one buffer. If we fall behind (due to | 351 // task execution should complete one buffer. If we fall behind (due to |
353 // resource backpressure, etc.), we'll have to schedule more to catch up. | 352 // resource backpressure, etc.), we'll have to schedule more to catch up. |
354 int decoder_decode_buffer_tasks_scheduled_; | 353 int decoder_decode_buffer_tasks_scheduled_; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 442 |
444 // The WeakPtrFactory for |weak_this_|. | 443 // The WeakPtrFactory for |weak_this_|. |
445 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; | 444 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; |
446 | 445 |
447 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); | 446 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); |
448 }; | 447 }; |
449 | 448 |
450 } // namespace content | 449 } // namespace content |
451 | 450 |
452 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 451 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |