| 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_IMAGE_PROCESSOR_H_ | 5 #ifndef MEDIA_GPU_V4L2_IMAGE_PROCESSOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_IMAGE_PROCESSOR_H_ | 6 #define MEDIA_GPU_V4L2_IMAGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "content/common/content_export.h" | |
| 20 #include "content/common/gpu/media/v4l2_device.h" | |
| 21 #include "media/base/video_frame.h" | 19 #include "media/base/video_frame.h" |
| 20 #include "media/gpu/media_gpu_export.h" |
| 21 #include "media/gpu/v4l2_device.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace media { |
| 24 | 24 |
| 25 // Handles image processing accelerators that expose a V4L2 memory-to-memory | 25 // Handles image processing accelerators that expose a V4L2 memory-to-memory |
| 26 // interface. The threading model of this class is the same as for other V4L2 | 26 // interface. The threading model of this class is the same as for other V4L2 |
| 27 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. | 27 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. |
| 28 class CONTENT_EXPORT V4L2ImageProcessor { | 28 class MEDIA_GPU_EXPORT V4L2ImageProcessor { |
| 29 public: | 29 public: |
| 30 explicit V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device); | 30 explicit V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device); |
| 31 virtual ~V4L2ImageProcessor(); | 31 virtual ~V4L2ImageProcessor(); |
| 32 | 32 |
| 33 // Initializes the processor to convert from |input_format| to |output_format| | 33 // Initializes the processor to convert from |input_format| to |output_format| |
| 34 // and/or scale from |input_visible_size| to |output_visible_size|. | 34 // and/or scale from |input_visible_size| to |output_visible_size|. |
| 35 // Request the output buffers to be of at least |output_allocated_size|. The | 35 // Request the output buffers to be of at least |output_allocated_size|. The |
| 36 // number of input buffers and output buffers will be |num_buffers|. Provided | 36 // number of input buffers and output buffers will be |num_buffers|. Provided |
| 37 // |error_cb| will be called if an error occurs. Return true if the requested | 37 // |error_cb| will be called if an error occurs. Return true if the requested |
| 38 // configuration is supported. | 38 // configuration is supported. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // V4L2 device in use. | 152 // V4L2 device in use. |
| 153 scoped_refptr<V4L2Device> device_; | 153 scoped_refptr<V4L2Device> device_; |
| 154 | 154 |
| 155 // Thread to communicate with the device on. | 155 // Thread to communicate with the device on. |
| 156 base::Thread device_thread_; | 156 base::Thread device_thread_; |
| 157 // Thread used to poll the V4L2 for events only. | 157 // Thread used to poll the V4L2 for events only. |
| 158 base::Thread device_poll_thread_; | 158 base::Thread device_poll_thread_; |
| 159 | 159 |
| 160 // All the below members are to be accessed from device_thread_ only | 160 // All the below members are to be accessed from device_thread_ only |
| 161 // (if it's running). | 161 // (if it's running). |
| 162 std::queue<linked_ptr<JobRecord> > input_queue_; | 162 std::queue<linked_ptr<JobRecord>> input_queue_; |
| 163 std::queue<linked_ptr<JobRecord> > running_jobs_; | 163 std::queue<linked_ptr<JobRecord>> running_jobs_; |
| 164 | 164 |
| 165 // Input queue state. | 165 // Input queue state. |
| 166 bool input_streamon_; | 166 bool input_streamon_; |
| 167 // Number of input buffers enqueued to the device. | 167 // Number of input buffers enqueued to the device. |
| 168 int input_buffer_queued_count_; | 168 int input_buffer_queued_count_; |
| 169 // Input buffers ready to use; LIFO since we don't care about ordering. | 169 // Input buffers ready to use; LIFO since we don't care about ordering. |
| 170 std::vector<int> free_input_buffers_; | 170 std::vector<int> free_input_buffers_; |
| 171 // Mapping of int index to an input buffer record. | 171 // Mapping of int index to an input buffer record. |
| 172 std::vector<InputRecord> input_buffer_map_; | 172 std::vector<InputRecord> input_buffer_map_; |
| 173 | 173 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 190 // thread to the device thread should use base::Unretained(this), | 190 // thread to the device thread should use base::Unretained(this), |
| 191 // and tasks posted the other way should use |weak_this_|. | 191 // and tasks posted the other way should use |weak_this_|. |
| 192 base::WeakPtr<V4L2ImageProcessor> weak_this_; | 192 base::WeakPtr<V4L2ImageProcessor> weak_this_; |
| 193 | 193 |
| 194 // Weak factory for producing weak pointers on the child thread. | 194 // Weak factory for producing weak pointers on the child thread. |
| 195 base::WeakPtrFactory<V4L2ImageProcessor> weak_this_factory_; | 195 base::WeakPtrFactory<V4L2ImageProcessor> weak_this_factory_; |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); | 197 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 } // namespace content | 200 } // namespace media |
| 201 | 201 |
| 202 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_IMAGE_PROCESSOR_H_ | 202 #endif // MEDIA_GPU_V4L2_IMAGE_PROCESSOR_H_ |
| OLD | NEW |