[PATCH 1/4] gstreamer: Document improvements when updating minimum GStreamer version
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed May 28 17:46:50 CEST 2025
On Thu, May 22, 2025 at 01:25:24PM -0400, Nicolas Dufresne wrote:
> Le jeudi 22 mai 2025 à 14:55 +0200, Laurent Pinchart a écrit :
> > A const_cast<> was recently added to fix a compilation issue with older
> > GStreamer versions. Add a comment to indicate it can be removed when
> > bumping the minimum GStreamer version requirement. While at it, also
> > document a possible future improvement in the same function, and wrap
> > long lines.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> > src/gstreamer/gstlibcamerasrc.cpp | 18 +++++++++++++++---
> > 1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> > index b34f089778ec..70bb0606c72c 100644
> > --- a/src/gstreamer/gstlibcamerasrc.cpp
> > +++ b/src/gstreamer/gstlibcamerasrc.cpp
> > @@ -285,10 +285,17 @@ gst_libcamera_extrapolate_info(GstVideoInfo *info, guint32 stride)
> > }
> >
> > static GstFlowReturn
> > -gst_libcamera_video_frame_copy(GstBuffer *src, GstBuffer *dest, const GstVideoInfo *dest_info, guint32 stride)
> > +gst_libcamera_video_frame_copy(GstBuffer *src, GstBuffer *dest,
> > + const GstVideoInfo *dest_info, guint32 stride)
> > {
> > - GstVideoInfo src_info = *dest_info;
> > + /*
> > + * When dropping support for versions earlier than v1.22.0, use
> > + *
> > + * g_auto (GstVideoFrame) src_frame = GST_VIDEO_FRAME_INIT;
> > + * g_auto (GstVideoFrame) dest_frame = GST_VIDEO_FRAME_INIT;
>
> Do you think your readers will understand that g_auto() allows the removal of all
> the unmap() calls ? Otherwise I'd add this to the comment too.
That's a good idea. I'll expand the comment to
/*
* When dropping support for versions earlier than v1.22.0, use
*
* g_auto (GstVideoFrame) src_frame = GST_VIDEO_FRAME_INIT;
* g_auto (GstVideoFrame) dest_frame = GST_VIDEO_FRAME_INIT;
*
* and drop the gst_video_frame_unmap() calls.
*/
> >
> > + */
> > GstVideoFrame src_frame, dest_frame;
> > + GstVideoInfo src_info = *dest_info;
> >
> > gst_libcamera_extrapolate_info(&src_info, stride);
> > src_info.size = gst_buffer_get_size(src);
> > @@ -298,7 +305,12 @@ gst_libcamera_video_frame_copy(GstBuffer *src, GstBuffer *dest, const GstVideoIn
> > return GST_FLOW_ERROR;
> > }
> >
> > - if (!gst_video_frame_map(&dest_frame, const_cast<GstVideoInfo *>(dest_info), dest, GST_MAP_WRITE)) {
> > + /*
> > + * When dropping support for versions earlier than 1.20.0, drop the
> > + * const_cast<>().
> > + */
> > + if (!gst_video_frame_map(&dest_frame, const_cast<GstVideoInfo *>(dest_info),
> > + dest, GST_MAP_WRITE)) {
> > GST_ERROR("Could not map dest buffer");
> > gst_video_frame_unmap(&src_frame);
> > return GST_FLOW_ERROR;
>
> Nothing major otherwise, feel free to edit and add:
>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list