Message ID | 20250522125521.6465-2-laurent.pinchart@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi, 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@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. > > + */ > 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@collabora.com> Nicolas
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; + */ 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;
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@ideasonboard.com> --- src/gstreamer/gstlibcamerasrc.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)