| 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 <memory> | 11 #include <memory> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "content/common/content_export.h" | |
| 21 #include "content/common/gpu/media/v4l2_device.h" | |
| 22 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
| 21 #include "media/gpu/media_gpu_export.h" |
| 22 #include "media/gpu/v4l2_device.h" |
| 23 | 23 |
| 24 namespace content { | 24 namespace media { |
| 25 | 25 |
| 26 // Handles image processing accelerators that expose a V4L2 memory-to-memory | 26 // Handles image processing accelerators that expose a V4L2 memory-to-memory |
| 27 // interface. The threading model of this class is the same as for other V4L2 | 27 // interface. The threading model of this class is the same as for other V4L2 |
| 28 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. | 28 // hardware accelerators (see V4L2VideoDecodeAccelerator) for more details. |
| 29 class CONTENT_EXPORT V4L2ImageProcessor { | 29 class MEDIA_GPU_EXPORT V4L2ImageProcessor { |
| 30 public: | 30 public: |
| 31 explicit V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device); | 31 explicit V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device); |
| 32 virtual ~V4L2ImageProcessor(); | 32 virtual ~V4L2ImageProcessor(); |
| 33 | 33 |
| 34 // Initializes the processor to convert from |input_format| to |output_format| | 34 // Initializes the processor to convert from |input_format| to |output_format| |
| 35 // and/or scale from |input_visible_size| to |output_visible_size|. | 35 // and/or scale from |input_visible_size| to |output_visible_size|. |
| 36 // Request the input buffers to be of at least |input_allocated_size| and the | 36 // Request the input buffers to be of at least |input_allocated_size| and the |
| 37 // output buffers to be of at least |output_allocated_size|. The number of | 37 // output buffers to be of at least |output_allocated_size|. The number of |
| 38 // input buffers and output buffers will be |num_buffers|. Provided |error_cb| | 38 // input buffers and output buffers will be |num_buffers|. Provided |error_cb| |
| 39 // will be called if an error occurs. Return true if the requested | 39 // will be called if an error occurs. Return true if the requested |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // V4L2 device in use. | 173 // V4L2 device in use. |
| 174 scoped_refptr<V4L2Device> device_; | 174 scoped_refptr<V4L2Device> device_; |
| 175 | 175 |
| 176 // Thread to communicate with the device on. | 176 // Thread to communicate with the device on. |
| 177 base::Thread device_thread_; | 177 base::Thread device_thread_; |
| 178 // Thread used to poll the V4L2 for events only. | 178 // Thread used to poll the V4L2 for events only. |
| 179 base::Thread device_poll_thread_; | 179 base::Thread device_poll_thread_; |
| 180 | 180 |
| 181 // All the below members are to be accessed from device_thread_ only | 181 // All the below members are to be accessed from device_thread_ only |
| 182 // (if it's running). | 182 // (if it's running). |
| 183 std::queue<linked_ptr<JobRecord> > input_queue_; | 183 std::queue<linked_ptr<JobRecord>> input_queue_; |
| 184 std::queue<linked_ptr<JobRecord> > running_jobs_; | 184 std::queue<linked_ptr<JobRecord>> running_jobs_; |
| 185 | 185 |
| 186 // Input queue state. | 186 // Input queue state. |
| 187 bool input_streamon_; | 187 bool input_streamon_; |
| 188 // Number of input buffers enqueued to the device. | 188 // Number of input buffers enqueued to the device. |
| 189 int input_buffer_queued_count_; | 189 int input_buffer_queued_count_; |
| 190 // Input buffers ready to use; LIFO since we don't care about ordering. | 190 // Input buffers ready to use; LIFO since we don't care about ordering. |
| 191 std::vector<int> free_input_buffers_; | 191 std::vector<int> free_input_buffers_; |
| 192 // Mapping of int index to an input buffer record. | 192 // Mapping of int index to an input buffer record. |
| 193 std::vector<InputRecord> input_buffer_map_; | 193 std::vector<InputRecord> input_buffer_map_; |
| 194 | 194 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 211 // thread to the device thread should use base::Unretained(this), | 211 // thread to the device thread should use base::Unretained(this), |
| 212 // and tasks posted the other way should use |weak_this_|. | 212 // and tasks posted the other way should use |weak_this_|. |
| 213 base::WeakPtr<V4L2ImageProcessor> weak_this_; | 213 base::WeakPtr<V4L2ImageProcessor> weak_this_; |
| 214 | 214 |
| 215 // Weak factory for producing weak pointers on the child thread. | 215 // Weak factory for producing weak pointers on the child thread. |
| 216 base::WeakPtrFactory<V4L2ImageProcessor> weak_this_factory_; | 216 base::WeakPtrFactory<V4L2ImageProcessor> weak_this_factory_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); | 218 DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 } // namespace content | 221 } // namespace media |
| 222 | 222 |
| 223 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_IMAGE_PROCESSOR_H_ | 223 #endif // MEDIA_GPU_V4L2_IMAGE_PROCESSOR_H_ |
| OLD | NEW |