From 957282a65d58fdc108c6beaed5b2f738ac43b3ba Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 13 Nov 2002 12:35:55 +0000 Subject: [PATCH] v4l plugins: add open/close signals v4l2 plugins: add open/close signals move source format enumeration from v4l2elem... Original commit message from CVS: v4l plugins: * add open/close signals v4l2 plugins: * add open/close signals * move source format enumeration from v4l2element to v4l2src * adapt to the final v4l2 API in kernel 2.5 (patches for 2.4 on http://bytesex.org/patches) * small tweaks --- sys/v4l/TODO | 8 +++++--- sys/v4l/gstv4lelement.c | 24 +++++++++++++++++++++++- sys/v4l/gstv4lelement.h | 6 ++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/sys/v4l/TODO b/sys/v4l/TODO index 9218794..b62ccf1 100644 --- a/sys/v4l/TODO +++ b/sys/v4l/TODO @@ -1,14 +1,14 @@ TODO list (short term): ======================= * fix clocking issues by using gst clock for v4lsrc and by using it - as a correction for v4lmjpegsrc/v4l2src + as a correction for v4lmjpegsrc/v4l2src (pause brokenness etc.) * v4lsrc/v4lmjpegsrc/v4l2src: fix interlacing (not handled at all...) TODO list (long term): ====================== * v4lmpegsrc (*hint* MPEG card needed *hint*) * v4l2sink -* BSD-videosrc (meteorsrc?) +* BSD-videosrc (bktr) * color correction (brightness, hue, etc.) * gamma correction @@ -17,6 +17,8 @@ Useful Documentation: MJPEG/V4L API : ./videodev_mjpeg.h Linux/V4L API : /usr/include/linux/videodev.h or http://roadrunner.swansea.uk.linux.org/v4l.shtml -Linux/V4L2 API: http://www.thedirks.org/v4l2/ +Linux/V4L2 API: /usr/include/linux/videodev2.h or + http://www.thedirks.org/v4l2/ + (kernel patches: http://bytesex.org/patches/) BSD/Meteor API: /usr/include/machine/ioctl_meteor.h mjpegtools : http://www.sourceforge.net/projects/mjpeg diff --git a/sys/v4l/gstv4lelement.c b/sys/v4l/gstv4lelement.c index ab3c9fe..16c98e2 100644 --- a/sys/v4l/gstv4lelement.c +++ b/sys/v4l/gstv4lelement.c @@ -33,6 +33,8 @@ static GstElementDetails gst_v4lelement_details = { /* V4lElement signals and args */ enum { /* FILL ME */ + SIGNAL_OPEN, + SIGNAL_CLOSE, LAST_SIGNAL }; @@ -82,7 +84,7 @@ static gboolean plugin_init (GModule *mo static GstElementClass *parent_class = NULL; -/*static guint gst_v4lelement_signals[LAST_SIGNAL] = { 0 }; */ +static guint gst_v4lelement_signals[LAST_SIGNAL] = { 0 }; GType @@ -205,6 +207,18 @@ gst_v4lelement_class_init (GstV4lElementClass *klass) g_param_spec_pointer("videowindow","videowindow","videowindow", G_PARAM_WRITABLE)); + /* signals */ + gst_v4lelement_signals[SIGNAL_OPEN] = + g_signal_new("open", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GstV4lElementClass, open), + NULL, NULL, g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + gst_v4lelement_signals[SIGNAL_CLOSE] = + g_signal_new("close", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GstV4lElementClass, close), + NULL, NULL, g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + gobject_class->set_property = gst_v4lelement_set_property; gobject_class->get_property = gst_v4lelement_get_property; @@ -532,6 +546,10 @@ gst_v4lelement_change_state (GstElement *element) if (!gst_v4l_open(v4lelement)) return GST_STATE_FAILURE; + g_signal_emit(G_OBJECT(v4lelement), + gst_v4lelement_signals[SIGNAL_OPEN], 0, + v4lelement->videodev); + /* now, sync options */ if (v4lelement->norm >= VIDEO_MODE_PAL && v4lelement->norm < VIDEO_MODE_AUTO && @@ -581,6 +599,10 @@ gst_v4lelement_change_state (GstElement *element) case GST_STATE_READY_TO_NULL: if (!gst_v4l_close(v4lelement)) return GST_STATE_FAILURE; + + g_signal_emit(G_OBJECT(v4lelement), + gst_v4lelement_signals[SIGNAL_CLOSE], 0, + v4lelement->videodev); break; } diff --git a/sys/v4l/gstv4lelement.h b/sys/v4l/gstv4lelement.h index 1519e85..97cccc0 100644 --- a/sys/v4l/gstv4lelement.h +++ b/sys/v4l/gstv4lelement.h @@ -81,6 +81,12 @@ struct _GstV4lElement { struct _GstV4lElementClass { GstElementClass parent_class; + + /* signals */ + void (*open) (GstElement *element, + const gchar *device); + void (*close) (GstElement *element, + const gchar *device); }; GType gst_v4lelement_get_type(void); -- 2.7.4