From 74931b8db091d94e0caa4cb2d33ceb918f38c933 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Fri, 20 Dec 2002 20:12:28 +0000 Subject: [PATCH] Fix to allow parameters to be set by gst-launch Original commit message from CVS: Fix to allow parameters to be set by gst-launch --- sys/v4l/gstv4lelement.c | 18 +++++++++++++----- sys/v4l/v4l_calls.c | 42 ++++++++++++++++++++++++++++++++++++------ sys/v4l/v4l_calls.h | 1 + 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/sys/v4l/gstv4lelement.c b/sys/v4l/gstv4lelement.c index bc7bd6d..b29a60b 100644 --- a/sys/v4l/gstv4lelement.c +++ b/sys/v4l/gstv4lelement.c @@ -65,6 +65,7 @@ enum { ARG_DISPLAY, ARG_VIDEOWINDOW, ARG_DO_OVERLAY, + ARG_SIGNAL, }; @@ -142,6 +143,9 @@ gst_v4lelement_class_init (GstV4lElementClass *klass) g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FREQUENCY, g_param_spec_ulong("frequency","frequency","frequency", 0,G_MAXULONG,0,G_PARAM_READWRITE)); + g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SIGNAL, + g_param_spec_uint("signal","signal","signal", + 0,65535,0,G_PARAM_READABLE)); g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HAS_AUDIO, g_param_spec_boolean("has_audio","has_audio","has_audio", @@ -289,11 +293,9 @@ gst_v4lelement_set_property (GObject *object, break; case ARG_FREQUENCY: v4lelement->frequency = g_value_get_ulong(value); - if (GST_V4L_IS_OPEN(v4lelement) && !GST_V4L_IS_ACTIVE(v4lelement)) - { - if (gst_v4l_has_tuner(v4lelement)) - if (!gst_v4l_set_frequency(v4lelement, v4lelement->frequency)) - return; + if (gst_v4l_has_tuner(v4lelement)) + if (!gst_v4l_set_frequency(v4lelement, v4lelement->frequency)) + return; } break; case ARG_MUTE: @@ -432,6 +434,12 @@ gst_v4lelement_get_property (GObject *object, gst_v4l_get_frequency(v4lelement, &temp_ul); g_value_set_ulong(value, temp_ul); break; + case ARG_SIGNAL: + if (GST_V4L_IS_OPEN(v4lelement)) + if (gst_v4l_has_tuner(v4lelement)) + gst_v4l_get_signal(v4lelement, &temp_i); + g_value_set_uint(value, temp_i); + break; case ARG_HAS_AUDIO: g_value_set_boolean(value, FALSE); if (GST_V4L_IS_OPEN(v4lelement)) diff --git a/sys/v4l/v4l_calls.c b/sys/v4l/v4l_calls.c index 2cee265..26cbc54 100644 --- a/sys/v4l/v4l_calls.c +++ b/sys/v4l/v4l_calls.c @@ -243,8 +243,40 @@ gst_v4l_has_tuner (GstV4lElement *v4lelement) DEBUG("checking whether device has a tuner"); GST_V4L_CHECK_OPEN(v4lelement); - return (v4lelement->vcap.type & VID_TYPE_TUNER && - v4lelement->vchan.flags & VIDEO_VC_TUNER); + return v4lelement->vcap.type & VID_TYPE_TUNER; +} + + +/****************************************************** + * gst_v4l_get_signal(): + * get the current signal + * return value: TRUE on success, FALSE on error + ******************************************************/ + +gboolean +gst_v4l_get_signal (GstV4lElement *v4lelement, + guint *signal) +{ + struct video_tuner tuner; + + DEBUG("getting tuner signal"); + GST_V4L_CHECK_OPEN(v4lelement); + + if (!gst_v4l_has_tuner(v4lelement)) + return FALSE; + + tuner.tuner = 0; + if (ioctl(v4lelement->video_fd, VIDIOCGTUNER, &tuner) < 0) + { + gst_element_error(GST_ELEMENT(v4lelement), + "Error getting tuner signal: %s", + sys_errlist[errno]); + return FALSE; + } + + *signal = tuner.signal; + + return TRUE; } @@ -288,8 +320,7 @@ gst_v4l_set_frequency (GstV4lElement *v4lelement, { DEBUG("setting tuner frequency to %lu", frequency); GST_V4L_CHECK_OPEN(v4lelement); - GST_V4L_CHECK_NOT_ACTIVE(v4lelement); - + if (!gst_v4l_has_tuner(v4lelement)) return FALSE; @@ -424,8 +455,7 @@ gst_v4l_has_audio (GstV4lElement *v4lelement) DEBUG("checking whether device has audio"); GST_V4L_CHECK_OPEN(v4lelement); - return (v4lelement->vcap.audios > 0 && - v4lelement->vchan.flags & VIDEO_VC_AUDIO); + return v4lelement->vcap.audios > 0; } diff --git a/sys/v4l/v4l_calls.h b/sys/v4l/v4l_calls.h index c6cc9f6..18e2e0b 100644 --- a/sys/v4l/v4l_calls.h +++ b/sys/v4l/v4l_calls.h @@ -116,6 +116,7 @@ GList *gst_v4l_get_chan_names (GstV4lElement *v4lelement); /* frequency control */ gboolean gst_v4l_has_tuner (GstV4lElement *v4lelement); +gboolean gst_v4l_get_signal (GstV4lElement *v4lelement, guint *signal); gboolean gst_v4l_get_frequency (GstV4lElement *v4lelement, gulong *frequency); gboolean gst_v4l_set_frequency (GstV4lElement *v4lelement, gulong frequency); -- 2.7.4