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 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "content/common/gpu/media/v4l2_video_device.h" | 16 #include "content/common/gpu/media/v4l2_video_device.h" |
16 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 // Handles image processing accelerators that expose a V4L2 memory-to-memory | 21 // Handles image processing accelerators that expose a V4L2 memory-to-memory |
21 // interface. The threading model of this class is the same as for other V4L2 | 22 // interface. The threading model of this class is the same as for other V4L2 |
22 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. | 23 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. |
23 class CONTENT_EXPORT V4L2ImageProcessor { | 24 class CONTENT_EXPORT V4L2ImageProcessor { |
24 public: | 25 public: |
25 explicit V4L2ImageProcessor(scoped_ptr<V4L2Device> device); | 26 explicit V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device); |
26 virtual ~V4L2ImageProcessor(); | 27 virtual ~V4L2ImageProcessor(); |
27 | 28 |
28 // Initializes the processor to convert from |input_format| to |output_format| | 29 // Initializes the processor to convert from |input_format| to |output_format| |
29 // and/or scale from |input_visible_size| to |output_visible_size|. | 30 // and/or scale from |input_visible_size| to |output_visible_size|. |
30 // Request the output buffers to be of at least |output_allocated_size|. | 31 // Request the output buffers to be of at least |output_allocated_size|. |
31 // Provided |error_cb| will be called if an error occurs. | 32 // Provided |error_cb| will be called if an error occurs. |
32 // Return true if the requested configuration is supported. | 33 // Return true if the requested configuration is supported. |
33 bool Initialize(media::VideoFrame::Format input_format, | 34 bool Initialize(media::VideoFrame::Format input_format, |
34 media::VideoFrame::Format output_format, | 35 media::VideoFrame::Format output_format, |
35 gfx::Size input_visible_size, | 36 gfx::Size input_visible_size, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 uint32 input_format_fourcc_; | 130 uint32 input_format_fourcc_; |
130 uint32 output_format_fourcc_; | 131 uint32 output_format_fourcc_; |
131 | 132 |
132 size_t input_planes_count_; | 133 size_t input_planes_count_; |
133 size_t output_planes_count_; | 134 size_t output_planes_count_; |
134 | 135 |
135 // Our original calling message loop for the child thread. | 136 // Our original calling message loop for the child thread. |
136 const scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; | 137 const scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; |
137 | 138 |
138 // V4L2 device in use. | 139 // V4L2 device in use. |
139 scoped_ptr<V4L2Device> device_; | 140 scoped_refptr<V4L2Device> device_; |
140 | 141 |
141 // Thread to communicate with the device on. | 142 // Thread to communicate with the device on. |
142 base::Thread device_thread_; | 143 base::Thread device_thread_; |
143 // Thread used to poll the V4L2 for events only. | 144 // Thread used to poll the V4L2 for events only. |
144 base::Thread device_poll_thread_; | 145 base::Thread device_poll_thread_; |
145 | 146 |
146 // All the below members are to be accessed from device_thread_ only | 147 // All the below members are to be accessed from device_thread_ only |
147 // (if it's running). | 148 // (if it's running). |
148 std::queue<linked_ptr<JobRecord> > input_queue_; | 149 std::queue<linked_ptr<JobRecord> > input_queue_; |
149 std::queue<linked_ptr<JobRecord> > running_jobs_; | 150 std::queue<linked_ptr<JobRecord> > running_jobs_; |
(...skipping 21 matching lines...) Expand all Loading... |
171 | 172 |
172 // Weak factory for producing weak pointers on the device_thread_ | 173 // Weak factory for producing weak pointers on the device_thread_ |
173 base::WeakPtrFactory<V4L2ImageProcessor> device_weak_factory_; | 174 base::WeakPtrFactory<V4L2ImageProcessor> device_weak_factory_; |
174 | 175 |
175 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); | 176 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); |
176 }; | 177 }; |
177 | 178 |
178 } // namespace content | 179 } // namespace content |
179 | 180 |
180 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ | 181 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_PROCESSOR_H_ |
OLD | NEW |