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_ENCODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
9 #include <list> | 9 #include <list> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/common/gpu/media/v4l2_device.h" | 16 #include "content/common/gpu/media/v4l2_device.h" |
17 #include "content/common/gpu/media/v4l2_image_processor.h" | 17 #include "content/common/gpu/media/v4l2_image_processor.h" |
18 #include "media/video/video_encode_accelerator.h" | 18 #include "media/video/video_encode_accelerator.h" |
19 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
20 | 20 |
21 namespace base { | |
22 | |
23 class MessageLoopProxy; | |
24 | |
25 } // namespace base | |
26 | |
27 namespace media { | 21 namespace media { |
28 | 22 |
29 class BitstreamBuffer; | 23 class BitstreamBuffer; |
30 | 24 |
31 } // namespace media | 25 } // namespace media |
32 | 26 |
33 namespace content { | 27 namespace content { |
34 | 28 |
35 // This class handles video encode acceleration by interfacing with a V4L2 | 29 // This class handles video encode acceleration by interfacing with a V4L2 |
36 // device exposed by the codec hardware driver. The threading model of this | 30 // device exposed by the codec hardware driver. The threading model of this |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 bool CreateInputBuffers(); | 179 bool CreateInputBuffers(); |
186 bool CreateOutputBuffers(); | 180 bool CreateOutputBuffers(); |
187 | 181 |
188 // Destroy these buffers. | 182 // Destroy these buffers. |
189 void DestroyInputBuffers(); | 183 void DestroyInputBuffers(); |
190 void DestroyOutputBuffers(); | 184 void DestroyOutputBuffers(); |
191 | 185 |
192 // Set controls in |ctrls| and return true if successful. | 186 // Set controls in |ctrls| and return true if successful. |
193 bool SetExtCtrls(std::vector<struct v4l2_ext_control> ctrls); | 187 bool SetExtCtrls(std::vector<struct v4l2_ext_control> ctrls); |
194 | 188 |
195 // Our original calling message loop for the child thread. | 189 // Our original calling task runner for the child thread. |
196 const scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; | 190 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
197 | 191 |
198 gfx::Size visible_size_; | 192 gfx::Size visible_size_; |
199 // Input allocated size required by the device. | 193 // Input allocated size required by the device. |
200 gfx::Size input_allocated_size_; | 194 gfx::Size input_allocated_size_; |
201 size_t output_buffer_byte_size_; | 195 size_t output_buffer_byte_size_; |
202 | 196 |
203 // Formats for input frames and the output stream. | 197 // Formats for input frames and the output stream. |
204 media::VideoFrame::Format device_input_format_; | 198 media::VideoFrame::Format device_input_format_; |
205 size_t input_planes_count_; | 199 size_t input_planes_count_; |
206 uint32 output_format_fourcc_; | 200 uint32 output_format_fourcc_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // This thread services tasks posted from the VEA API entry points by the | 249 // This thread services tasks posted from the VEA API entry points by the |
256 // child thread and device service callbacks posted from the device thread. | 250 // child thread and device service callbacks posted from the device thread. |
257 base::Thread encoder_thread_; | 251 base::Thread encoder_thread_; |
258 | 252 |
259 // The device polling thread handles notifications of V4L2 device changes. | 253 // The device polling thread handles notifications of V4L2 device changes. |
260 // TODO(sheu): replace this thread with an TYPE_IO encoder_thread_. | 254 // TODO(sheu): replace this thread with an TYPE_IO encoder_thread_. |
261 base::Thread device_poll_thread_; | 255 base::Thread device_poll_thread_; |
262 | 256 |
263 // To expose client callbacks from VideoEncodeAccelerator. | 257 // To expose client callbacks from VideoEncodeAccelerator. |
264 // NOTE: all calls to these objects *MUST* be executed on | 258 // NOTE: all calls to these objects *MUST* be executed on |
265 // child_message_loop_proxy_. | 259 // child_task_runner_. |
266 base::WeakPtr<Client> client_; | 260 base::WeakPtr<Client> client_; |
267 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; | 261 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; |
268 | 262 |
269 // WeakPtr<> pointing to |this| for use in posting tasks from the | 263 // WeakPtr<> pointing to |this| for use in posting tasks from the |
270 // image_processor_ back to the child thread. | 264 // image_processor_ back to the child thread. |
271 // Tasks posted onto encoder and poll threads can use base::Unretained(this), | 265 // Tasks posted onto encoder and poll threads can use base::Unretained(this), |
272 // as both threads will not outlive this object. | 266 // as both threads will not outlive this object. |
273 base::WeakPtr<V4L2VideoEncodeAccelerator> weak_this_; | 267 base::WeakPtr<V4L2VideoEncodeAccelerator> weak_this_; |
274 base::WeakPtrFactory<V4L2VideoEncodeAccelerator> weak_this_ptr_factory_; | 268 base::WeakPtrFactory<V4L2VideoEncodeAccelerator> weak_this_ptr_factory_; |
275 | 269 |
276 DISALLOW_COPY_AND_ASSIGN(V4L2VideoEncodeAccelerator); | 270 DISALLOW_COPY_AND_ASSIGN(V4L2VideoEncodeAccelerator); |
277 }; | 271 }; |
278 | 272 |
279 } // namespace content | 273 } // namespace content |
280 | 274 |
281 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ | 275 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ |
OLD | NEW |