Chromium Code Reviews| 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 |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "media/capture/video/video_capture_device.h" | 15 #include "media/capture/video/video_capture_device.h" |
| 16 #include "third_party/libyuv/include/libyuv.h" | |
| 17 #include "third_party/skia/include/core/SkImage.h" | |
| 18 #include "third_party/skia/include/core/SkSurface.h" | |
| 19 #include "ui/gfx/codec/png_codec.h" | |
|
mcasas
2016/09/16 03:50:37
The skia includes are unnecessary since
we don't u
xianglu
2016/09/16 18:22:34
kN32_SkColorType is from SkImage.
| |
| 16 | 20 |
| 17 #if defined(OS_OPENBSD) | 21 #if defined(OS_OPENBSD) |
| 18 #include <sys/videoio.h> | 22 #include <sys/videoio.h> |
| 19 #else | 23 #else |
| 20 #include <linux/videodev2.h> | 24 #include <linux/videodev2.h> |
| 21 #endif | 25 #endif |
| 22 | 26 |
| 23 namespace tracked_objects { | 27 namespace tracked_objects { |
| 24 class Location; | 28 class Location; |
| 25 } // namespace tracked_objects | 29 } // namespace tracked_objects |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 48 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, | 52 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
| 49 int power_line_frequency); | 53 int power_line_frequency); |
| 50 | 54 |
| 51 // Forward-to versions of VideoCaptureDevice virtual methods. | 55 // Forward-to versions of VideoCaptureDevice virtual methods. |
| 52 void AllocateAndStart(int width, | 56 void AllocateAndStart(int width, |
| 53 int height, | 57 int height, |
| 54 float frame_rate, | 58 float frame_rate, |
| 55 std::unique_ptr<VideoCaptureDevice::Client> client); | 59 std::unique_ptr<VideoCaptureDevice::Client> client); |
| 56 void StopAndDeAllocate(); | 60 void StopAndDeAllocate(); |
| 57 | 61 |
| 62 void TakePhoto(VideoCaptureDevice::TakePhotoCallback callback); | |
| 63 | |
| 58 void SetRotation(int rotation); | 64 void SetRotation(int rotation); |
| 59 | 65 |
| 60 private: | 66 private: |
| 61 friend class base::RefCountedThreadSafe<V4L2CaptureDelegate>; | 67 friend class base::RefCountedThreadSafe<V4L2CaptureDelegate>; |
| 62 ~V4L2CaptureDelegate(); | 68 ~V4L2CaptureDelegate(); |
| 63 | 69 |
| 64 // VIDIOC_QUERYBUFs a buffer from V4L2, creates a BufferTracker for it and | 70 // VIDIOC_QUERYBUFs a buffer from V4L2, creates a BufferTracker for it and |
| 65 // enqueues it (VIDIOC_QBUF) back into V4L2. | 71 // enqueues it (VIDIOC_QBUF) back into V4L2. |
| 66 bool MapAndQueueBuffer(int index); | 72 bool MapAndQueueBuffer(int index); |
| 67 | 73 |
| 68 void DoCapture(); | 74 void DoCapture(); |
| 69 | 75 |
| 76 class BufferTracker; | |
| 77 mojom::BlobPtr GetPhotoBlob( | |
| 78 const scoped_refptr<BufferTracker>& buffer_tracker, | |
| 79 const v4l2_buffer& buffer); | |
| 80 | |
| 70 void SetErrorState(const tracked_objects::Location& from_here, | 81 void SetErrorState(const tracked_objects::Location& from_here, |
| 71 const std::string& reason); | 82 const std::string& reason); |
| 72 | 83 |
| 73 const scoped_refptr<base::SingleThreadTaskRunner> v4l2_task_runner_; | 84 const scoped_refptr<base::SingleThreadTaskRunner> v4l2_task_runner_; |
| 74 const VideoCaptureDeviceDescriptor device_descriptor_; | 85 const VideoCaptureDeviceDescriptor device_descriptor_; |
| 75 const int power_line_frequency_; | 86 const int power_line_frequency_; |
| 76 | 87 |
| 77 // The following members are only known on AllocateAndStart(). | 88 // The following members are only known on AllocateAndStart(). |
| 78 VideoCaptureFormat capture_format_; | 89 VideoCaptureFormat capture_format_; |
| 79 v4l2_format video_fmt_; | 90 v4l2_format video_fmt_; |
| 80 std::unique_ptr<VideoCaptureDevice::Client> client_; | 91 std::unique_ptr<VideoCaptureDevice::Client> client_; |
| 92 std::queue<VideoCaptureDevice::TakePhotoCallback> take_photo_callbacks_; | |
|
mcasas
2016/09/16 03:50:36
The comment in l.88 would affect this member as
we
xianglu
2016/09/16 18:22:33
Done.
| |
| 81 base::ScopedFD device_fd_; | 93 base::ScopedFD device_fd_; |
| 82 | 94 |
| 83 // Vector of BufferTracker to keep track of mmap()ed pointers and their use. | 95 // 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_; | 96 std::vector<scoped_refptr<BufferTracker>> buffer_tracker_pool_; |
| 86 | 97 |
| 87 bool is_capturing_; | 98 bool is_capturing_; |
| 88 int timeout_count_; | 99 int timeout_count_; |
| 89 | 100 |
| 90 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. | 101 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. |
| 91 int rotation_; | 102 int rotation_; |
| 92 | 103 |
| 93 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); | 104 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); |
| 94 }; | 105 }; |
| 95 | 106 |
| 96 } // namespace media | 107 } // namespace media |
| 97 | 108 |
| 98 #endif // MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 109 #endif // MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
| OLD | NEW |