[libcamera-devel] gstreamer: Support for pre-1.16 GstEvent
diff mbox series

Message ID 20240109143017.21783-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 0e0043053fb2ced0f7e271df04256091642ea6e6
Headers show
Series
  • [libcamera-devel] gstreamer: Support for pre-1.16 GstEvent
Related show

Commit Message

Laurent Pinchart Jan. 9, 2024, 2:30 p.m. UTC
The gst_clear_event() function used by libcamerasrc has been introduced
in GStreamer 1.16, while libcamera claims to need 1.14 or newer. This
causes a compilation error. Fix it by copying the gst_clear_event()
implementation to gstlibcamera-utils.h when compiling with older
GStreamer version.

The version check makes it clear that the workaround is needed with
older versions only, flagging it for removal when the minimum GStreamer
version requirement will be bumped.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/gstreamer/gstlibcamera-utils.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Nicolas Dufresne Jan. 9, 2024, 2:32 p.m. UTC | #1
Hello,

Le mardi 09 janvier 2024 à 16:30 +0200, Laurent Pinchart a écrit :
> The gst_clear_event() function used by libcamerasrc has been introduced
> in GStreamer 1.16, while libcamera claims to need 1.14 or newer. This
> causes a compilation error. Fix it by copying the gst_clear_event()
> implementation to gstlibcamera-utils.h when compiling with older
> GStreamer version.
> 
> The version check makes it clear that the workaround is needed with
> older versions only, flagging it for removal when the minimum GStreamer
> version requirement will be bumped.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks for the fix, I like this solution.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  src/gstreamer/gstlibcamera-utils.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h
> index fd304a8bae15..6adeab0eb35a 100644
> --- a/src/gstreamer/gstlibcamera-utils.h
> +++ b/src/gstreamer/gstlibcamera-utils.h
> @@ -25,6 +25,13 @@ void gst_libcamera_clamp_and_set_frameduration(libcamera::ControlList &controls,
>  					       GstStructure *element_caps);
>  void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_caps);
>  
> +#if !GST_CHECK_VERSION(1, 16, 0)
> +static inline void gst_clear_event(GstEvent **event_ptr)
> +{
> +	g_clear_pointer(event_ptr, gst_mini_object_unref);
> +}
> +#endif
> +
>  #if !GST_CHECK_VERSION(1, 17, 1)
>  gboolean gst_task_resume(GstTask *task);
>  #endif
Kieran Bingham Jan. 9, 2024, 2:52 p.m. UTC | #2
Quoting Laurent Pinchart via libcamera-devel (2024-01-09 14:30:17)
> The gst_clear_event() function used by libcamerasrc has been introduced
> in GStreamer 1.16, while libcamera claims to need 1.14 or newer. This
> causes a compilation error. Fix it by copying the gst_clear_event()
> implementation to gstlibcamera-utils.h when compiling with older
> GStreamer version.
> 
> The version check makes it clear that the workaround is needed with
> older versions only, flagging it for removal when the minimum GStreamer
> version requirement will be bumped.

Sounds good to me.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/gstreamer/gstlibcamera-utils.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h
> index fd304a8bae15..6adeab0eb35a 100644
> --- a/src/gstreamer/gstlibcamera-utils.h
> +++ b/src/gstreamer/gstlibcamera-utils.h
> @@ -25,6 +25,13 @@ void gst_libcamera_clamp_and_set_frameduration(libcamera::ControlList &controls,
>                                                GstStructure *element_caps);
>  void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_caps);
>  
> +#if !GST_CHECK_VERSION(1, 16, 0)
> +static inline void gst_clear_event(GstEvent **event_ptr)
> +{
> +       g_clear_pointer(event_ptr, gst_mini_object_unref);
> +}
> +#endif
> +
>  #if !GST_CHECK_VERSION(1, 17, 1)
>  gboolean gst_task_resume(GstTask *task);
>  #endif
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h
index fd304a8bae15..6adeab0eb35a 100644
--- a/src/gstreamer/gstlibcamera-utils.h
+++ b/src/gstreamer/gstlibcamera-utils.h
@@ -25,6 +25,13 @@  void gst_libcamera_clamp_and_set_frameduration(libcamera::ControlList &controls,
 					       GstStructure *element_caps);
 void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_caps);
 
+#if !GST_CHECK_VERSION(1, 16, 0)
+static inline void gst_clear_event(GstEvent **event_ptr)
+{
+	g_clear_pointer(event_ptr, gst_mini_object_unref);
+}
+#endif
+
 #if !GST_CHECK_VERSION(1, 17, 1)
 gboolean gst_task_resume(GstTask *task);
 #endif