summaryrefslogtreecommitdiff
path: root/src/gstreamer/gstlibcameraallocator.cpp
AgeCommit message (Collapse)Author
2021-08-30gstreamer: gstlibcameraallocator: Use offset in creating a bufferHirokazu Honda
The plane length is the length of the plane size. The buffer length to be allocated for a plane is the offset and the length of FrameBuffer::Plane. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26gstreamer: Fix deadlock when last allocator ref is held by bufferNicolas Dufresne
This deadlock occurs when a buffer is holding the last reference on the allocator. In gst_libcamera_allocator_release() we must drop the object lock before dropping the last ref of that object since the destructor will lock it again causing deadlock. This was notice while switching camera or resolution in Cheese software. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-15gst: Use the streams of CameraConfiguration when allocating buffersDafna Hirschfeld
Currently, when allocating buffers, the streams of the Camera object are used. Instead the streams of the CameraConfiguration object should be used. This is because the Camera object holds all available streams while the CameraConfiguration holds only the streams associated with the current configuration. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-20gstreamer: Omit extra semicolonsHirokazu Honda
Macros used in gstreamer (e.g. G_DEFINE_TYPE) are functions. The end semicolons with the macros are unnecessary. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-25libcamera: Remove void specifier for functions that take no argumentsLaurent Pinchart
In C++, unlike in C, a function that takes no argument doesn't need to specify void in the arguments list. Drop the unnecessary specifiers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: framebuffer_allocator: Lift camera restrictions on allocatorLaurent Pinchart
The Camera class currently requires the allocator to have no allocated buffer before the camera is reconfigured, and the allocator to be destroyed before the camera is released. There's no basis for these restrictions anymore, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-07gst: Add getters for Stream and FrameBufferNicolas Dufresne
This adds getters on pad/pool/allocator so that we can retrieve the Stream or FrameBuffer. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-07gst: Add a pool and an allocator implementationNicolas Dufresne
This is needed to track the lifetime of the FrameBufferAllocator in relation to the GstBuffer/GstMemory objects travelling inside GStreamer. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
lass="hl kwa">if (camera_->start() != -EACCES) return TestFail; Request request(camera_.get()); if (camera_->queueRequest(&request) != -EACCES) return TestFail; /* Test operations which should pass. */ if (camera_->release()) return TestFail; if (camera_->stop()) return TestFail; /* Test valid state transitions, end in Acquired state. */ if (camera_->acquire()) return TestFail; return TestPass; } int testAcquired() { /* Test operations which should fail. */ if (camera_->acquire() != -EBUSY) return TestFail; if (camera_->createRequest()) return TestFail; if (camera_->start() != -EACCES) return TestFail; Request request(camera_.get()); if (camera_->queueRequest(&request) != -EACCES) return TestFail; /* Test operations which should pass. */ if (camera_->stop()) return TestFail; /* Test valid state transitions, end in Configured state. */ if (camera_->release()) return TestFail; if (camera_->acquire()) return TestFail; if (camera_->configure(defconf_.get())) return TestFail; return TestPass; } int testConfigured() { /* Test operations which should fail. */ if (camera_->acquire() != -EBUSY) return TestFail; Request request1(camera_.get()); if (camera_->queueRequest(&request1) != -EACCES) return TestFail; /* Test operations which should pass. */ std::unique_ptr<Request> request2 = camera_->createRequest(); if (!request2) return TestFail; if (camera_->stop()) return TestFail; /* Test valid state transitions, end in Running state. */ if (camera_->release()) return TestFail; if (camera_->acquire()) return TestFail; if (camera_->configure(defconf_.get())) return TestFail; /* Use internally allocated buffers. */ allocator_ = new FrameBufferAllocator(camera_); Stream *stream = *camera_->streams().begin(); if (allocator_->allocate(stream) < 0) return TestFail; if (camera_->start()) return TestFail; return TestPass; } int testRuning() { /* Test operations which should fail. */ if (camera_->acquire() != -EBUSY) return TestFail; if (camera_->release() != -EBUSY) return TestFail; if (camera_->configure(defconf_.get()) != -EACCES) return TestFail; if (camera_->start() != -EACCES) return TestFail; /* Test operations which should pass. */ std::unique_ptr<Request> request = camera_->createRequest(); if (!request) return TestFail; Stream *stream = *camera_->streams().begin(); if (request->addBuffer(stream, allocator_->buffers(stream)[0].get())) return TestFail; if (camera_->queueRequest(request.get())) return TestFail; /* Test valid state transitions, end in Available state. */ if (camera_->stop()) return TestFail; delete allocator_; if (camera_->release()) return TestFail; return TestPass; } int init() override { if (status_ != TestPass) return status_; defconf_ = camera_->generateConfiguration({ StreamRole::VideoRecording }); if (!defconf_) { cout << "Failed to generate default configuration" << endl; return TestFail; } return TestPass; } int run() override { if (testAvailable() != TestPass) { cout << "State machine in Available state failed" << endl; return TestFail; } if (testAcquired() != TestPass) { cout << "State machine in Acquired state failed" << endl; return TestFail; } if (testConfigured() != TestPass) { cout << "State machine in Configured state failed" << endl; return TestFail; } if (testRuning() != TestPass) { cout << "State machine in Running state failed" << endl; return TestFail; } return TestPass; } std::unique_ptr<CameraConfiguration> defconf_; FrameBufferAllocator *allocator_; }; } /* namespace */ TEST_REGISTER(Statemachine)