Index | Thread | Search

From:
Alexandre Ratchov <alex@caoua.org>
Subject:
gstreamer/plugins-good: Reenable the v4l2 plugin
To:
ports@openbsd.org
Date:
Mon, 14 Jul 2025 12:18:34 +0200

Download raw body.

Thread
The v4l2 plugin (used for webcam capture) is currently disabled
because of a compilation error (according to a comment in the
Makefile).

The error is a missing "#ifndef __linux__", probably forgotten and
unnoticed as it doesn't affect Linux. This diff fixes it and reenables
v4l2, using the libv4l.

Example of a one-liner to test the plugin with a webcam:

gst-launch-1.0 v4l2src ! videoconvert ! ximagesink

OK?

Off topic, unfortunately this diff is not enough to fix net/dino: now
it finds a valid video device but the screen is black on the other
end.

Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/gstreamer1/plugins-good/Makefile,v
diff -u -p -r1.89 Makefile
--- Makefile	1 May 2025 06:55:57 -0000	1.89
+++ Makefile	14 Jul 2025 09:47:45 -0000
@@ -1,6 +1,7 @@
 COMMENT=		good elements for GStreamer
 
 DISTNAME=		gst-plugins-good-${V}
+REVISION=		0
 
 SITES=			${SITE_GST:=gst-plugins-good/}
 
@@ -9,11 +10,12 @@ COMPILER_LANGS=		c c++
 
 WANTLIB += ${COMPILER_LIBCXX} FLAC X11 Xdamage Xext Xfixes Xtst
 WANTLIB += bz2 cairo cairo-gobject gdk-3 gdk_pixbuf-2.0 gio-2.0
-WANTLIB += glib-2.0 gobject-2.0 gstaudio-1.0 gstbase-1.0 gstfft-1.0
-WANTLIB += gstgl-1.0 gstnet-1.0 gstpbutils-1.0 gstreamer-1.0 gstriff-1.0
-WANTLIB += gstrtp-1.0 gstrtsp-1.0 gstsdp-1.0 gsttag-1.0 gstvideo-1.0
+WANTLIB += glib-2.0 gobject-2.0 gstallocators-1.0 gstaudio-1.0 
+WANTLIB += gstbase-1.0 gstfft-1.0 gstgl-1.0 gstnet-1.0
+WANTLIB += gstpbutils-1.0 gstreamer-1.0 gstriff-1.0 gstrtp-1.0
+WANTLIB += gstrtsp-1.0 gstsdp-1.0 gsttag-1.0 gstvideo-1.0
 WANTLIB += gtk-3 intl jpeg m mp3lame nettle opencore-amrnb opencore-amrwb
-WANTLIB += orc-0.4 png shout speex tag twolame vpx wavpack xml2
+WANTLIB += orc-0.4 png shout speex tag twolame v4l2 vpx wavpack xml2
 WANTLIB += z
 
 LIB_DEPENDS=		multimedia/gstreamer1/plugins-base=${V} \
@@ -25,6 +27,7 @@ LIB_DEPENDS=		multimedia/gstreamer1/plug
 			audio/taglib \
 			audio/twolame \
 			audio/wavpack \
+			multimedia/libv4l \
 			multimedia/libvpx \
 			net/libshout \
 			x11/gtk+3
@@ -52,10 +55,6 @@ CONFIGURE_ARGS=		-Daalib=disabled \
 			-Dwaveform=disabled \
 			-Dv4l2-gudev=disabled \
 			-Drpicamsrc=disabled
-
-# XXX
-# ../gst-plugins-good-1.26.1/sys/v4l2/gstv4l2object.c:601:25: error: use of undeclared identifier 'v4l2_ioctl_wrapper'
-CONFIGURE_ARGS +=	-Dv4l2=disabled
 
 .if ${MACHINE_ARCH} == "amd64"
 BUILD_DEPENDS +=	devel/nasm
Index: patches/patch-sys_v4l2_gstv4l2object_c
===================================================================
RCS file: /cvs/ports/multimedia/gstreamer1/plugins-good/patches/patch-sys_v4l2_gstv4l2object_c,v
diff -u -p -r1.14 patch-sys_v4l2_gstv4l2object_c
--- patches/patch-sys_v4l2_gstv4l2object_c	27 Jun 2025 10:12:15 -0000	1.14
+++ patches/patch-sys_v4l2_gstv4l2object_c	14 Jul 2025 09:47:45 -0000
@@ -1,6 +1,15 @@
 Index: sys/v4l2/gstv4l2object.c
 --- sys/v4l2/gstv4l2object.c.orig
 +++ sys/v4l2/gstv4l2object.c
+@@ -595,7 +595,7 @@ gst_v4l2_object_new (GstElement * element,
+     v4l2object->fd_open = v4l2_fd_open;
+     v4l2object->close = v4l2_close;
+     v4l2object->dup = v4l2_dup;
+-#ifdef __GLIBC__
++#if !defined(__linux__) || defined( __GLIBC__)
+     v4l2object->ioctl = v4l2_ioctl;
+ #else
+     v4l2object->ioctl = v4l2_ioctl_wrapper;
 @@ -5332,7 +5332,9 @@ gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object
      if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_CROPCAP, &cropcap) < 0) {
  
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/multimedia/gstreamer1/plugins-good/pkg/PLIST,v
diff -u -p -r1.6 PLIST
--- pkg/PLIST	1 May 2025 06:55:57 -0000	1.6
+++ pkg/PLIST	14 Jul 2025 09:47:45 -0000
@@ -58,6 +58,7 @@
 @so lib/gstreamer-${API}/libgsttaglib.so
 @so lib/gstreamer-${API}/libgsttwolame.so
 @so lib/gstreamer-${API}/libgstudp.so
+@so lib/gstreamer-${API}/libgstvideo4linux2.so
 @so lib/gstreamer-${API}/libgstvideobox.so
 @so lib/gstreamer-${API}/libgstvideocrop.so
 @so lib/gstreamer-${API}/libgstvideofilter.so