Chromium Code Reviews| Index: media/video/capture/linux/v4l2_capture_delegate.h |
| diff --git a/media/video/capture/linux/v4l2_capture_delegate.h b/media/video/capture/linux/v4l2_capture_delegate.h |
| index 9d65bb248539d708bd794e883d152810fe113fd1..1814d400390b6a460aa7b554f1e778d310adccbd 100644 |
| --- a/media/video/capture/linux/v4l2_capture_delegate.h |
| +++ b/media/video/capture/linux/v4l2_capture_delegate.h |
| @@ -28,6 +28,7 @@ class V4L2CaptureDelegate |
| static scoped_refptr<V4L2CaptureDelegate> CreateV4L2CaptureDelegate( |
| const VideoCaptureDevice::Name& device_name, |
| const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
| + VideoCaptureDevice::Client* client, |
| int power_line_frequency); |
| // Retrieves the #planes for a given |fourcc|, or 0 if unknown. |
| @@ -49,22 +50,27 @@ class V4L2CaptureDelegate |
| void SetRotation(int rotation); |
| protected: |
| - // Class keeping track of SPLANE/MPLANE V4L2 buffers, mmap()ed on construction |
| - // and munmap()ed on destruction. Destruction is syntactically equal for |
| - // S/MPLANE but not construction, so this is implemented in derived classes. |
| + // Class keeping track of SPLANE/MPLANE V4L2 buffers, mappable or not. Non |
| + // mappable buffer keep track of the associated |fd|. |
| + // Mappable buffers are mmap()ed on Init() and munmap()ed on destruction. |
| + // Destruction is syntactically equal for S/MPLANE but not construction, so |
| + // this must be implemented in derived classes. |
| // Internally it has a vector of planes, which for SPLANE will contain only |
| // one element. |
| class BufferTracker : public base::RefCounted<BufferTracker> { |
| public: |
| BufferTracker(); |
| - // Abstract method to mmap() given |fd| according to |buffer|, planarity |
| - // specific. |
| + // Abstract method to init the BufferTracker according to |buffer|. |
| virtual bool Init(int fd, const v4l2_buffer& buffer) = 0; |
| uint8_t* const GetPlaneStart(size_t plane) const { |
| DCHECK_LT(plane, planes_.size()); |
| return planes_[plane].start; |
| } |
| + int const GetFd(size_t plane) const { |
|
Pawel Osciak
2015/06/15 10:34:55
GetPlaneFd()
Also, please add an empty line above
mcasas
2015/06/17 01:30:53
Done.
|
| + DCHECK_LT(plane, planes_.size()); |
| + return planes_[plane].fd; |
| + } |
| size_t GetPlanePayloadSize(size_t plane) const { |
| DCHECK_LT(plane, planes_.size()); |
| @@ -82,12 +88,16 @@ class V4L2CaptureDelegate |
| virtual ~BufferTracker(); |
| // Adds a given mmap()ed plane to |planes_|. |
| void AddMmapedPlane(uint8_t* const start, size_t length); |
| + void AddNonMmapedPlane(int fd); |
| private: |
| + // A Plane can be composed of |start| and |length|, for mappable resources |
| + // (basically, memory), or by a |fd|, for non mappable resources (dma-buf). |
| struct Plane { |
| uint8_t* start; |
| size_t length; |
| size_t payload_size; |
| + int fd; |
| }; |
| std::vector<Plane> planes_; |
| }; |
| @@ -107,8 +117,15 @@ class V4L2CaptureDelegate |
| uint32_t height, |
| uint32_t pixelformat_fourcc) const = 0; |
| - // Finish filling |buffer| struct with planarity-dependent data. |
| - virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer) const = 0; |
| + // Finish filling |buffer| struct with planarity-dependent data. Underlying |
| + // implementation might need to know if it's for enqueueing, to allocate |
| + // resources. |
| + virtual void FinishFillingV4L2Buffer(v4l2_buffer* buffer, |
| + bool for_enqueue) const = 0; |
| + |
| + // Finish filling in |request| with DmaBuf or normal buffers. |
| + virtual void FinishFillingV4L2RequestBuffers( |
|
Pawel Osciak
2015/06/15 10:34:55
This could just be a simple memory_type() const ge
mcasas
2015/06/17 01:30:53
Done.
|
| + v4l2_requestbuffers* request) const = 0; |
| // Fetch the number of bytes occupied by data in |buffer| and set to |
| // |buffer_tracker|. |
| @@ -136,7 +153,7 @@ class V4L2CaptureDelegate |
| bool MapAndQueueBuffer(int index); |
| // Fills all common parts of |buffer|. Delegates to FinishFillingV4L2Buffer() |
| // for filling in the planar-dependent parts. |
| - void FillV4L2Buffer(v4l2_buffer* buffer, int i) const; |
| + void FillV4L2Buffer(v4l2_buffer* buffer, int i, bool for_enqueue) const; |
| void DoCapture(); |
| void SetErrorState(const std::string& reason); |