From patchwork Wed Jun 4 13:07:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 23462 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 99AF1C31E9 for ; Wed, 4 Jun 2025 13:07:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ACB5C68DC2; Wed, 4 Jun 2025 15:07:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tA52AUVh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C8B2868DA8 for ; Wed, 4 Jun 2025 15:07:52 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C507CD21; Wed, 4 Jun 2025 15:07:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1749042470; bh=oHdMYAWVQJ61xAla214M0VduvDQQTO3f+76Zlwi9opU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tA52AUVhIW/YwJLOyRNhwF0WcijKSpsi4Ao/37UeT8fguNcSJegm1p2uky+y7b6ef D1fr0gbiWp8gs3eM4U7yArW4BOvvNmFIYhiGjI7CRsbAW5djAZC3cJj6HZPGS6060Z OdyubfH1g8HGmJQcu1YkmVLBid92TLUSBJjtqGjU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: Hou Qi , Nicolas Dufresne Subject: [PATCH v2 1/7] gstreamer: Document improvements when updating minimum GStreamer version Date: Wed, 4 Jun 2025 16:07:35 +0300 Message-ID: <20250604130741.9228-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250604130741.9228-1-laurent.pinchart@ideasonboard.com> References: <20250604130741.9228-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Nicolas Dufresne --- src/gstreamer/gstlibcamerasrc.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index b34f089778ec..6ede43b06a8a 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -285,10 +285,19 @@ 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; + * + * 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 +307,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(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(dest_info), + dest, GST_MAP_WRITE)) { GST_ERROR("Could not map dest buffer"); gst_video_frame_unmap(&src_frame); return GST_FLOW_ERROR;