libcamera: v4l2_device: Implement stream{On,Off}
Support starting and stopping a stream on a V4L2 device. Buffers must be queued before the stream is started. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
dffbde33b8
commit
374673f84a
2 changed files with 48 additions and 0 deletions
|
@ -756,4 +756,49 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)
|
|||
* \brief A Signal emitted when a buffer completes
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Start the video stream
|
||||
*
|
||||
* \return 0 on success or a negative error code otherwise
|
||||
*/
|
||||
int V4L2Device::streamOn()
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd_, VIDIOC_STREAMON, &bufferType_);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(V4L2, Error)
|
||||
<< "Failed to start streaming: " << strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Stop the video stream
|
||||
*
|
||||
* \todo Ensure completion notifications are sent for all queued buffers
|
||||
*
|
||||
* \return 0 on success or a negative error code otherwise
|
||||
*/
|
||||
int V4L2Device::streamOff()
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioctl(fd_, VIDIOC_STREAMOFF, &bufferType_);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(V4L2, Error)
|
||||
<< "Failed to stop streaming: " << strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
queuedBuffersCount_ = 0;
|
||||
fdEvent_->setEnabled(false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue