From ccfe0a1af77c3d13e81a913b25206d6a4a4747e4 Mon Sep 17 00:00:00 2001 From: Rishikesh Donadkar Date: Thu, 15 Sep 2022 17:17:34 +0530 Subject: gstreamer: Provide framerate support for libcamerasrc Control the framerate by passing the controls::FrameDurationLimits during Camera::start(). Framerate in gstreamer is expressed as GST_TYPE_FRACTION so we maximise on maintaining it as a fraction throughout and only do arithematic computations as and when required (to compute frame-duration and vice-versa). To weed out abritrary framerate as input, place the clamping via the controls::FrameDurationLimits provided after camera::configure() phase. This is handled by a helper function gst_libcamera_clamp_and_set_frameduration(). Set the bound checked framerate (done in the above mentioned helper) into the caps and pass the ControlList containing the frame-duration to Camera::start(ctrls). Signed-off-by: Rishikesh Donadkar Signed-off-by: Umang Jain Tested-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- src/gstreamer/gstlibcamera-utils.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gstreamer/gstlibcamera-utils.h') diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h index 164189a2..fd304a8b 100644 --- a/src/gstreamer/gstlibcamera-utils.h +++ b/src/gstreamer/gstlibcamera-utils.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include @@ -18,6 +19,12 @@ GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &fo GstCaps *gst_libcamera_stream_configuration_to_caps(const libcamera::StreamConfiguration &stream_cfg); void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &stream_cfg, GstCaps *caps); +void gst_libcamera_get_framerate_from_caps(GstCaps *caps, GstStructure *element_caps); +void gst_libcamera_clamp_and_set_frameduration(libcamera::ControlList &controls, + const libcamera::ControlInfoMap &camera_controls, + GstStructure *element_caps); +void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_caps); + #if !GST_CHECK_VERSION(1, 17, 1) gboolean gst_task_resume(GstTask *task); #endif -- cgit v1.2.1