[0.10] gst-plugins-good: v4l2src: Adding a pre-set-format signal
Sebastian Dröge
slomo at kemper.freedesktop.org
Thu Apr 19 00:27:29 PDT 2012
Module: gst-plugins-good
Branch: 0.10
Commit: 099e97c98f47b7dc2150882dece51a06f2b8d330
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=099e97c98f47b7dc2150882dece51a06f2b8d330
Author: Youness Alaoui <youness.alaoui at collabora.co.uk>
Date: Mon Apr 16 22:06:21 2012 +0000
v4l2src: Adding a pre-set-format signal
In order to support UVC H264 encoding cameras, an H264 Probe&Commit
must happen before the normal v4l2 set-format. This new signal is
meant to allow an external application or bin to do it.
It also serves to expose the file descriptor used by v4l2src in case
some custom ioctls need to be called.
---
sys/v4l2/.gitignore | 4 ++--
sys/v4l2/Makefile.am | 17 +++++++++++++++++
sys/v4l2/gstv4l2-marshal.list | 1 +
sys/v4l2/gstv4l2src.c | 32 ++++++++++++++++++++++++++++++++
sys/v4l2/v4l2src_calls.c | 3 +++
5 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/sys/v4l2/.gitignore b/sys/v4l2/.gitignore
index 5377360..1ad32f9 100644
--- a/sys/v4l2/.gitignore
+++ b/sys/v4l2/.gitignore
@@ -1,2 +1,2 @@
-gstv4l2element-marshal.h
-gstv4l2element-marshal.c
+gstv4l2-marshal.c
+gstv4l2-marshal.h
diff --git a/sys/v4l2/Makefile.am b/sys/v4l2/Makefile.am
index a7a99de..ed33189 100644
--- a/sys/v4l2/Makefile.am
+++ b/sys/v4l2/Makefile.am
@@ -8,6 +8,23 @@ xv_source =
xv_libs =
endif
+glib_gen_prefix = __gst_v4l2
+glib_gen_basename = gstv4l2
+
+include $(top_srcdir)/common/gst-glib-gen.mak
+
+built_sources = gstv4l2-marshal.c
+built_headers = gstv4l2-marshal.h
+
+BUILT_SOURCES = $(built_sources) $(built_headers)
+
+CLEANFILES = $(BUILT_SOURCES)
+
+nodist_libgstvideo4linux2_la_SOURCES = \
+ $(built_sources)
+
+EXTRA_DIST = gstcv4l2-marshal.list
+
libgstvideo4linux2_la_SOURCES = gstv4l2.c \
gstv4l2colorbalance.c \
gstv4l2object.c \
diff --git a/sys/v4l2/gstv4l2-marshal.list b/sys/v4l2/gstv4l2-marshal.list
new file mode 100644
index 0000000..266c722
--- /dev/null
+++ b/sys/v4l2/gstv4l2-marshal.list
@@ -0,0 +1 @@
+VOID:INT,UINT,UINT,UINT
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index d5502a4..7e8d858 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -51,6 +51,7 @@
#include "v4l2src_calls.h"
#include <unistd.h>
+#include "gstv4l2-marshal.h"
#include "gstv4l2colorbalance.h"
#include "gstv4l2tuner.h"
#ifdef HAVE_XVIDEO
@@ -78,6 +79,15 @@ enum
PROP_DECIMATE
};
+/* signals and args */
+enum
+{
+ SIGNAL_PRE_SET_FORMAT,
+ LAST_SIGNAL
+};
+
+static guint gst_v4l2_signals[LAST_SIGNAL] = { 0 };
+
GST_IMPLEMENT_V4L2_PROBE_METHODS (GstV4l2SrcClass, gst_v4l2src);
GST_IMPLEMENT_V4L2_COLOR_BALANCE_METHODS (GstV4l2Src, gst_v4l2src);
GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Src, gst_v4l2src);
@@ -285,6 +295,28 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass)
"Only use every nth frame", 1, G_MAXINT,
PROP_DEF_DECIMATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstV4l2Src::pre-set-format:
+ * @v4l2src: the v4l2src instance
+ * @fd: the file descriptor of the current device
+ * @fourcc: the fourcc of the format being set
+ * @width: The width of the video
+ * @height: The height of the video
+ *
+ * This signal gets emitted before calling the v4l2 VIDIOC_S_FMT ioctl
+ * (set format). This allows for any custom configuration of the device to
+ * happen prior to the format being set.
+ * This is mostly useful for UVC H264 encoding cameras which need the H264
+ * Probe & Commit to happen prior to the normal Probe & Commit.
+ */
+ gst_v4l2_signals[SIGNAL_PRE_SET_FORMAT] = g_signal_new ("pre-set-format",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ __gst_v4l2_marshal_VOID__INT_UINT_UINT_UINT,
+ G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+
basesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_get_caps);
basesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_set_caps);
basesrc_class->start = GST_DEBUG_FUNCPTR (gst_v4l2src_start);
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index bfa5589..f50a581 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -218,6 +218,9 @@ gst_v4l2src_set_capture (GstV4l2Src * v4l2src, guint32 pixelformat,
if (pixelformat == GST_MAKE_FOURCC ('M', 'P', 'E', 'G'))
return TRUE;
+ g_signal_emit_by_name (v4l2src, "pre-set-format",
+ v4l2src->v4l2object->video_fd, pixelformat, width, height);
+
if (!gst_v4l2_object_set_format (v4l2src->v4l2object, pixelformat, width,
height, interlaced)) {
/* error already reported */
More information about the gstreamer-commits
mailing list