| 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_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ | 5 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ |
| 6 #define MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ | 6 #define MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ |
| 7 | 7 |
| 8 #if defined(OS_OPENBSD) | 8 #if defined(OS_OPENBSD) |
| 9 #include <sys/videoio.h> | 9 #include <sys/videoio.h> |
| 10 #else | 10 #else |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 BufferTracker(); | 59 BufferTracker(); |
| 60 // Abstract method to mmap() given |fd| according to |buffer|, planarity | 60 // Abstract method to mmap() given |fd| according to |buffer|, planarity |
| 61 // specific. | 61 // specific. |
| 62 virtual bool Init(int fd, const v4l2_buffer& buffer) = 0; | 62 virtual bool Init(int fd, const v4l2_buffer& buffer) = 0; |
| 63 | 63 |
| 64 uint8_t* const GetPlaneStart(size_t plane) const { | 64 uint8_t* const GetPlaneStart(size_t plane) const { |
| 65 DCHECK_LT(plane, planes_.size()); | 65 DCHECK_LT(plane, planes_.size()); |
| 66 return planes_[plane].start; | 66 return planes_[plane].start; |
| 67 } | 67 } |
| 68 | 68 |
| 69 size_t GetPlanePayloadSize(size_t plane) const { |
| 70 DCHECK_LT(plane, planes_.size()); |
| 71 return planes_[plane].payload_size; |
| 72 } |
| 73 |
| 74 void SetPlanePayloadSize(size_t plane, size_t payload_size) { |
| 75 DCHECK_LT(plane, planes_.size()); |
| 76 DCHECK_LE(payload_size, planes_[plane].length); |
| 77 planes_[plane].payload_size = payload_size; |
| 78 } |
| 79 |
| 69 protected: | 80 protected: |
| 70 friend class base::RefCounted<BufferTracker>; | 81 friend class base::RefCounted<BufferTracker>; |
| 71 virtual ~BufferTracker(); | 82 virtual ~BufferTracker(); |
| 72 // Adds a given mmap()ed plane to |planes_|. | 83 // Adds a given mmap()ed plane to |planes_|. |
| 73 void AddMmapedPlane(uint8_t* const start, size_t length); | 84 void AddMmapedPlane(uint8_t* const start, size_t length); |
| 74 | 85 |
| 75 private: | 86 private: |
| 76 struct Plane { | 87 struct Plane { |
| 77 uint8_t* start; | 88 uint8_t* start; |
| 78 size_t length; | 89 size_t length; |
| 90 size_t payload_size; |
| 79 }; | 91 }; |
| 80 std::vector<Plane> planes_; | 92 std::vector<Plane> planes_; |
| 81 }; | 93 }; |
| 82 | 94 |
| 83 V4L2CaptureDelegate( | 95 V4L2CaptureDelegate( |
| 84 const VideoCaptureDevice::Name& device_name, | 96 const VideoCaptureDevice::Name& device_name, |
| 85 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, | 97 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
| 86 int power_line_frequency); | 98 int power_line_frequency); |
| 87 virtual ~V4L2CaptureDelegate(); | 99 virtual ~V4L2CaptureDelegate(); |
| 88 | 100 |
| 89 // Creates the necessary, planarity-specific, internal tracking schemes, | 101 // Creates the necessary, planarity-specific, internal tracking schemes, |
| 90 virtual scoped_refptr<BufferTracker> CreateBufferTracker() const = 0; | 102 virtual scoped_refptr<BufferTracker> CreateBufferTracker() const = 0; |
| 91 | 103 |
| 92 // Fill in |format| with the given parameters, in a planarity dependent way. | 104 // Fill in |format| with the given parameters, in a planarity dependent way. |
| 93 virtual bool FillV4L2Format(v4l2_format* format, | 105 virtual bool FillV4L2Format(v4l2_format* format, |
| 94 uint32_t width, | 106 uint32_t width, |
| 95 uint32_t height, | 107 uint32_t height, |
| 96 uint32_t pixelformat_fourcc) const = 0; | 108 uint32_t pixelformat_fourcc) const = 0; |
| 97 | 109 |
| 98 // Finish filling |buffer| struct with planarity-dependent data. | 110 // Finish filling |buffer| struct with planarity-dependent data. |
| 99 virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer) const = 0; | 111 virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer) const = 0; |
| 100 | 112 |
| 113 // Fetch the number of bytes occupied by data in |buffer| and set to |
| 114 // |buffer_tracker|. |
| 115 virtual void SetPayloadSize( |
| 116 const scoped_refptr<BufferTracker>& buffer_tracker, |
| 117 const v4l2_buffer& buffer) const = 0; |
| 118 |
| 101 // Sends the captured |buffer| to the |client_|, synchronously. | 119 // Sends the captured |buffer| to the |client_|, synchronously. |
| 102 virtual void SendBuffer( | 120 virtual void SendBuffer( |
| 103 const scoped_refptr<BufferTracker>& buffer_tracker, | 121 const scoped_refptr<BufferTracker>& buffer_tracker, |
| 104 const v4l2_format& format) const = 0; | 122 const v4l2_format& format) const = 0; |
| 105 | 123 |
| 106 // A few accessors for SendBuffer()'s to access private member variables. | 124 // A few accessors for SendBuffer()'s to access private member variables. |
| 107 VideoCaptureFormat capture_format() const { return capture_format_; } | 125 VideoCaptureFormat capture_format() const { return capture_format_; } |
| 108 VideoCaptureDevice::Client* client() const { return client_.get(); } | 126 VideoCaptureDevice::Client* client() const { return client_.get(); } |
| 109 int rotation() const { return rotation_; } | 127 int rotation() const { return rotation_; } |
| 110 | 128 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 141 | 159 |
| 142 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. | 160 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. |
| 143 int rotation_; | 161 int rotation_; |
| 144 | 162 |
| 145 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); | 163 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); |
| 146 }; | 164 }; |
| 147 | 165 |
| 148 } // namespace media | 166 } // namespace media |
| 149 | 167 |
| 150 #endif // MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ | 168 #endif // MEDIA_VIDEO_CAPTURE_LINUX_V4L2_VIDEO_CAPTURE_DELEGATE_H_ |
| OLD | NEW |