OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
6 #define MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 6 #define MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, | 48 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
49 int power_line_frequency); | 49 int power_line_frequency); |
50 | 50 |
51 // Forward-to versions of VideoCaptureDevice virtual methods. | 51 // Forward-to versions of VideoCaptureDevice virtual methods. |
52 void AllocateAndStart(int width, | 52 void AllocateAndStart(int width, |
53 int height, | 53 int height, |
54 float frame_rate, | 54 float frame_rate, |
55 std::unique_ptr<VideoCaptureDevice::Client> client); | 55 std::unique_ptr<VideoCaptureDevice::Client> client); |
56 void StopAndDeAllocate(); | 56 void StopAndDeAllocate(); |
57 | 57 |
| 58 void TakePhoto(VideoCaptureDevice::TakePhotoCallback callback); |
| 59 |
58 void SetRotation(int rotation); | 60 void SetRotation(int rotation); |
59 | 61 |
60 private: | 62 private: |
61 friend class base::RefCountedThreadSafe<V4L2CaptureDelegate>; | 63 friend class base::RefCountedThreadSafe<V4L2CaptureDelegate>; |
62 ~V4L2CaptureDelegate(); | 64 ~V4L2CaptureDelegate(); |
63 | 65 |
64 // VIDIOC_QUERYBUFs a buffer from V4L2, creates a BufferTracker for it and | 66 // VIDIOC_QUERYBUFs a buffer from V4L2, creates a BufferTracker for it and |
65 // enqueues it (VIDIOC_QBUF) back into V4L2. | 67 // enqueues it (VIDIOC_QBUF) back into V4L2. |
66 bool MapAndQueueBuffer(int index); | 68 bool MapAndQueueBuffer(int index); |
67 | 69 |
68 void DoCapture(); | 70 void DoCapture(); |
69 | 71 |
| 72 class BufferTracker; |
| 73 mojom::BlobPtr GetPhotoBlob( |
| 74 const scoped_refptr<BufferTracker>& buffer_tracker, |
| 75 const uint32_t bytesused); |
| 76 |
70 void SetErrorState(const tracked_objects::Location& from_here, | 77 void SetErrorState(const tracked_objects::Location& from_here, |
71 const std::string& reason); | 78 const std::string& reason); |
72 | 79 |
73 const scoped_refptr<base::SingleThreadTaskRunner> v4l2_task_runner_; | 80 const scoped_refptr<base::SingleThreadTaskRunner> v4l2_task_runner_; |
74 const VideoCaptureDeviceDescriptor device_descriptor_; | 81 const VideoCaptureDeviceDescriptor device_descriptor_; |
75 const int power_line_frequency_; | 82 const int power_line_frequency_; |
76 | 83 |
77 // The following members are only known on AllocateAndStart(). | 84 // The following members are only known on AllocateAndStart(). |
78 VideoCaptureFormat capture_format_; | 85 VideoCaptureFormat capture_format_; |
79 v4l2_format video_fmt_; | 86 v4l2_format video_fmt_; |
80 std::unique_ptr<VideoCaptureDevice::Client> client_; | 87 std::unique_ptr<VideoCaptureDevice::Client> client_; |
81 base::ScopedFD device_fd_; | 88 base::ScopedFD device_fd_; |
82 | 89 |
| 90 std::queue<VideoCaptureDevice::TakePhotoCallback> take_photo_callbacks_; |
| 91 |
83 // Vector of BufferTracker to keep track of mmap()ed pointers and their use. | 92 // Vector of BufferTracker to keep track of mmap()ed pointers and their use. |
84 class BufferTracker; | |
85 std::vector<scoped_refptr<BufferTracker>> buffer_tracker_pool_; | 93 std::vector<scoped_refptr<BufferTracker>> buffer_tracker_pool_; |
86 | 94 |
87 bool is_capturing_; | 95 bool is_capturing_; |
88 int timeout_count_; | 96 int timeout_count_; |
89 | 97 |
90 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. | 98 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. |
91 int rotation_; | 99 int rotation_; |
92 | 100 |
93 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); |
94 }; | 102 }; |
95 | 103 |
96 } // namespace media | 104 } // namespace media |
97 | 105 |
98 #endif // MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 106 #endif // MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
OLD | NEW |