2004-06-15 09:11:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* v4l_calls.c: generic V4L calls
|
|
|
|
*
|
2002-01-31 22:22:42 +00:00
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2001-12-23 15:31:15 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-03-09 15:07:53 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2003-06-29 19:46:12 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
#include <gst/gst.h>
|
2005-07-07 11:29:29 +00:00
|
|
|
#include <gst/interfaces/tuner.h>
|
|
|
|
#include <gst/interfaces/colorbalance.h>
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
#include "v4l_calls.h"
|
2003-10-10 12:47:41 +00:00
|
|
|
#include "gstv4ltuner.h"
|
|
|
|
#include "gstv4lcolorbalance.h"
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-11-09 20:54:24 +00:00
|
|
|
#include "gstv4lsrc.h"
|
2005-07-07 11:29:29 +00:00
|
|
|
/* #include "gstv4lmjpegsrc.h" */
|
|
|
|
/* #include "gstv4lmjpegsink.h" */
|
2003-11-09 20:54:24 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (v4l_debug);
|
2004-06-09 11:32:39 +00:00
|
|
|
#define GST_CAT_DEFAULT v4l_debug
|
2004-04-27 11:33:52 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
static const char *picture_name[] = {
|
2003-03-02 21:58:52 +00:00
|
|
|
"Hue",
|
|
|
|
"Brightness",
|
|
|
|
"Contrast",
|
|
|
|
"Saturation",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-11-12 02:47:50 +00:00
|
|
|
G_GNUC_UNUSED static const char *audio_name[] = {
|
2003-03-02 21:58:52 +00:00
|
|
|
"Volume",
|
|
|
|
"Mute",
|
|
|
|
"Mode",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
static const char *norm_name[] = {
|
2003-03-02 21:58:52 +00:00
|
|
|
"PAL",
|
|
|
|
"NTSC",
|
|
|
|
"SECAM",
|
|
|
|
NULL
|
|
|
|
};
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_capabilities():
|
|
|
|
* get the device's capturing capabilities
|
2004-08-12 15:58:52 +00:00
|
|
|
* sets v4lelement->vcap and v4lelement->vwin
|
2001-12-23 15:31:15 +00:00
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_capabilities (GstV4lElement * v4lelement)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting capabilities");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGCAP, &(v4lelement->vcap)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("error getting capabilities %s of from device %s",
|
|
|
|
g_strerror (errno), v4lelement->videodev));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-03 17:26:43 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGWIN, &(v4lelement->vwin)) < 0) {
|
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("error getting window properties %s of from device %s",
|
|
|
|
g_strerror (errno), v4lelement->videodev));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-09 11:32:39 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_set_window_properties():
|
|
|
|
* set the device's capturing parameters (vwin)
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_v4l_set_window_properties (GstV4lElement * v4lelement)
|
|
|
|
{
|
|
|
|
struct video_window vwin;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lelement, "setting window flags 0x%x to device %s",
|
|
|
|
v4lelement->vwin.flags, v4lelement->videodev);
|
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
|
|
|
|
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCSWIN, &(v4lelement->vwin)) < 0) {
|
|
|
|
GST_DEBUG_OBJECT (v4lelement,
|
|
|
|
"could not ioctl window properties 0x%x to device %s",
|
|
|
|
v4lelement->vwin.flags, v4lelement->videodev);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get it again to make sure we have it correctly */
|
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGWIN, &(vwin)) < 0) {
|
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("error getting window properties %s of from device %s",
|
|
|
|
g_strerror (errno), v4lelement->videodev));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (vwin.flags != v4lelement->vwin.flags) {
|
|
|
|
GST_DEBUG_OBJECT (v4lelement, "set 0x%x but got 0x%x back",
|
|
|
|
v4lelement->vwin.flags, vwin.flags);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_open():
|
|
|
|
* open the video device (v4lelement->videodev)
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_open (GstV4lElement * v4lelement)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2003-03-02 21:58:52 +00:00
|
|
|
int num;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "opening device %s", v4lelement->videodev);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_NOT_OPEN (v4lelement);
|
|
|
|
GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* be sure we have a device */
|
2003-10-10 12:47:41 +00:00
|
|
|
if (!v4lelement->videodev) {
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, NOT_FOUND,
|
2004-03-15 19:32:28 +00:00
|
|
|
(_("No device specified.")), (NULL));
|
2003-10-10 12:47:41 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* open the device */
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement->video_fd = open (v4lelement->videodev, O_RDWR);
|
|
|
|
if (!GST_V4L_IS_OPEN (v4lelement)) {
|
2004-06-15 09:11:06 +00:00
|
|
|
if (errno == ENODEV || errno == ENOENT) {
|
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, NOT_FOUND,
|
|
|
|
(_("Device \"%s\" does not exist."), v4lelement->videodev), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-01-28 16:35:47 +00:00
|
|
|
if (errno == EBUSY) {
|
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, BUSY,
|
|
|
|
(_("Device \"%s\" is already being used."), v4lelement->videodev),
|
|
|
|
(NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, OPEN_READ_WRITE,
|
2004-03-15 19:32:28 +00:00
|
|
|
(_("Could not open device \"%s\" for reading and writing."),
|
|
|
|
v4lelement->videodev), GST_ERROR_SYSTEM);
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get capabilities */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4l_get_capabilities (v4lelement)) {
|
|
|
|
close (v4lelement->video_fd);
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lelement->video_fd = -1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-09 20:54:24 +00:00
|
|
|
/* device type check */
|
2004-03-14 22:34:34 +00:00
|
|
|
if ((GST_IS_V4LSRC (v4lelement) &&
|
2005-07-07 11:29:29 +00:00
|
|
|
!(v4lelement->vcap.type & VID_TYPE_CAPTURE))) {
|
|
|
|
/* (GST_IS_V4LMJPEGSRC (v4lelement) && */
|
|
|
|
/* !(v4lelement->vcap.type & VID_TYPE_MJPEG_ENCODER)) || */
|
|
|
|
/* (GST_IS_V4LMJPEGSINK (v4lelement) && */
|
|
|
|
/* !(v4lelement->vcap.type & VID_TYPE_MJPEG_DECODER))) { */
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Device opened, but wrong type (0x%x)", v4lelement->vcap.type));
|
2004-03-14 22:34:34 +00:00
|
|
|
close (v4lelement->video_fd);
|
2003-11-09 20:54:24 +00:00
|
|
|
v4lelement->video_fd = -1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
GST_INFO_OBJECT (v4lelement, "Opened device \'%s\' (\'%s\') successfully",
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement->vcap.name, v4lelement->videodev);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
/* norms + inputs, for the tuner interface */
|
2004-03-14 22:34:34 +00:00
|
|
|
for (num = 0; norm_name[num] != NULL; num++) {
|
2003-10-10 12:47:41 +00:00
|
|
|
GstV4lTunerNorm *v4lnorm = g_object_new (GST_TYPE_V4L_TUNER_NORM,
|
2004-03-15 19:32:28 +00:00
|
|
|
NULL);
|
2003-10-10 12:47:41 +00:00
|
|
|
GstTunerNorm *norm = GST_TUNER_NORM (v4lnorm);
|
|
|
|
|
|
|
|
norm->label = g_strdup (norm_name[num]);
|
2005-11-22 23:39:12 +00:00
|
|
|
if (num == 1)
|
|
|
|
gst_value_set_fraction (&norm->framerate, 30000, 1001);
|
|
|
|
else
|
|
|
|
gst_value_set_fraction (&norm->framerate, 25, 1);
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
v4lnorm->index = num;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement->norms = g_list_append (v4lelement->norms, (gpointer) norm);
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement->channels = gst_v4l_get_chan_names (v4lelement);
|
2003-03-02 21:58:52 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (num = 0; picture_name[num] != NULL; num++) {
|
2003-10-10 12:47:41 +00:00
|
|
|
GstV4lColorBalanceChannel *v4lchannel =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_object_new (GST_TYPE_V4L_COLOR_BALANCE_CHANNEL, NULL);
|
2003-10-10 12:47:41 +00:00
|
|
|
GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (v4lchannel);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
channel->label = g_strdup (picture_name[num]);
|
|
|
|
channel->min_value = 0;
|
|
|
|
channel->max_value = 65535;
|
|
|
|
v4lchannel->index = num;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement->colors = g_list_append (v4lelement->colors, channel);
|
2003-03-02 21:58:52 +00:00
|
|
|
}
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "Setting default norm/input");
|
2003-10-10 12:47:41 +00:00
|
|
|
gst_v4l_set_chan_norm (v4lelement, 0, 0);
|
2003-03-02 21:58:52 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_close():
|
|
|
|
* close the video device (v4lelement->video_fd)
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_close (GstV4lElement * v4lelement)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "closing device");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
|
|
|
GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
close (v4lelement->video_fd);
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lelement->video_fd = -1;
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
g_list_foreach (v4lelement->channels, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4lelement->channels);
|
|
|
|
v4lelement->channels = NULL;
|
|
|
|
|
|
|
|
g_list_foreach (v4lelement->norms, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4lelement->norms);
|
|
|
|
v4lelement->norms = NULL;
|
|
|
|
|
|
|
|
g_list_foreach (v4lelement->colors, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4lelement->colors);
|
|
|
|
v4lelement->colors = NULL;
|
2003-03-02 21:58:52 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_num_chans()
|
2004-06-15 09:11:06 +00:00
|
|
|
* return value: the number of video input channels
|
2001-12-23 15:31:15 +00:00
|
|
|
******************************************************/
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static gint
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_num_chans (GstV4lElement * v4lelement)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting number of channels");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return v4lelement->vcap.channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-20 07:25:40 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_chan_names()
|
|
|
|
* return value: a GList containing the channel names
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
GList *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_chan_names (GstV4lElement * v4lelement)
|
2002-02-20 07:25:40 +00:00
|
|
|
{
|
|
|
|
struct video_channel vchan;
|
|
|
|
GList *list = NULL;
|
|
|
|
gint i;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting channel names");
|
2002-02-20 07:25:40 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_OPEN (v4lelement))
|
2002-02-20 07:25:40 +00:00
|
|
|
return NULL;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (i = 0; i < gst_v4l_get_num_chans (v4lelement); i++) {
|
2003-10-10 12:47:41 +00:00
|
|
|
GstV4lTunerChannel *v4lchannel = g_object_new (GST_TYPE_V4L_TUNER_CHANNEL,
|
2004-03-15 19:32:28 +00:00
|
|
|
NULL);
|
2003-10-10 12:47:41 +00:00
|
|
|
GstTunerChannel *channel = GST_TUNER_CHANNEL (v4lchannel);
|
|
|
|
|
2002-02-20 07:25:40 +00:00
|
|
|
vchan.channel = i;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGCHAN, &vchan) < 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
return NULL; /* memleak... */
|
2003-10-10 12:47:41 +00:00
|
|
|
channel->label = g_strdup (vchan.name);
|
|
|
|
channel->flags = GST_TUNER_CHANNEL_INPUT;
|
|
|
|
v4lchannel->index = i;
|
|
|
|
if (vchan.flags & VIDEO_VC_TUNER) {
|
|
|
|
struct video_tuner vtun;
|
|
|
|
gint n;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (n = 0;; n++) {
|
2004-10-25 18:42:47 +00:00
|
|
|
if (n >= vchan.tuners) {
|
2004-12-01 22:47:41 +00:00
|
|
|
vtun.tuner = 0; /* default */
|
2004-10-25 18:42:47 +00:00
|
|
|
} else {
|
|
|
|
vtun.tuner = n;
|
2004-12-01 22:47:41 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
|
2004-10-25 18:42:47 +00:00
|
|
|
continue; /* no more tuners */
|
|
|
|
if (strcmp (vtun.name, vchan.name) != 0) {
|
2004-12-01 22:47:41 +00:00
|
|
|
continue; /* not this one */
|
2004-10-25 18:42:47 +00:00
|
|
|
}
|
2004-03-15 19:32:28 +00:00
|
|
|
}
|
2004-10-25 18:42:47 +00:00
|
|
|
v4lchannel->tuner = n;
|
|
|
|
channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
|
|
|
|
channel->freq_multiplicator =
|
|
|
|
62.5 * ((vtun.flags & VIDEO_TUNER_LOW) ? 1 : 1000);
|
2008-06-02 20:09:14 +00:00
|
|
|
channel->min_frequency = vtun.rangelow * channel->freq_multiplicator;
|
|
|
|
channel->max_frequency = vtun.rangehigh * channel->freq_multiplicator;
|
2004-10-25 18:42:47 +00:00
|
|
|
channel->min_signal = 0;
|
|
|
|
channel->max_signal = 0xffff;
|
|
|
|
break;
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
2004-10-25 18:42:47 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
if (vchan.flags & VIDEO_VC_AUDIO) {
|
|
|
|
struct video_audio vaud;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
for (n = 0; n < v4lelement->vcap.audios; n++) {
|
2004-03-15 19:32:28 +00:00
|
|
|
vaud.audio = n;
|
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vaud) < 0)
|
|
|
|
continue;
|
|
|
|
if (!strcmp (vaud.name, vchan.name)) {
|
|
|
|
v4lchannel->audio = n;
|
|
|
|
channel->flags |= GST_TUNER_CHANNEL_AUDIO;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
list = g_list_append (list, (gpointer) channel);
|
2002-02-20 07:25:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_chan_norm():
|
|
|
|
* get the currently active video-channel and it's
|
|
|
|
* norm (VIDEO_MODE_{PAL|NTSC|SECAM|AUTO})
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_chan_norm (GstV4lElement * v4lelement, gint * channel, gint * norm)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting current channel and norm");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
if (channel)
|
2002-01-15 15:52:09 +00:00
|
|
|
*channel = v4lelement->vchan.channel;
|
2001-12-23 15:31:15 +00:00
|
|
|
if (norm)
|
2002-01-15 15:52:09 +00:00
|
|
|
*norm = v4lelement->vchan.norm;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_set_chan_norm():
|
|
|
|
* set a new active channel and it's norm
|
|
|
|
* (VIDEO_MODE_{PAL|NTSC|SECAM|AUTO})
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_set_chan_norm (GstV4lElement * v4lelement, gint channel, gint norm)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "setting channel = %d, norm = %d (%s)",
|
2004-03-14 22:34:34 +00:00
|
|
|
channel, norm, norm_name[norm]);
|
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2005-01-14 22:39:37 +00:00
|
|
|
//GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
v4lelement->vchan.channel = channel;
|
|
|
|
v4lelement->vchan.norm = norm;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCSCHAN, &(v4lelement->vchan)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting the channel/norm settings: %s", g_strerror (errno)));
|
2001-12-28 19:54:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGCHAN, &(v4lelement->vchan)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting the channel/norm settings: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-20 20:12:28 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_signal():
|
|
|
|
* get the current signal
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_signal (GstV4lElement * v4lelement, gint tunernum, guint * signal)
|
2002-12-20 20:12:28 +00:00
|
|
|
{
|
2003-10-10 12:47:41 +00:00
|
|
|
struct video_tuner tuner;
|
2002-12-20 20:12:28 +00:00
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting tuner signal");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2002-12-20 20:12:28 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
tuner.tuner = tunernum;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &tuner) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting tuner signal: %s", g_strerror (errno)));
|
2002-12-20 20:12:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*signal = tuner.signal;
|
|
|
|
|
|
|
|
return TRUE;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_frequency():
|
|
|
|
* get the current frequency
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_frequency (GstV4lElement * v4lelement,
|
|
|
|
gint tunernum, gulong * frequency)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2003-10-10 12:47:41 +00:00
|
|
|
struct video_tuner vtun;
|
2004-05-31 14:16:54 +00:00
|
|
|
GstTunerChannel *channel;
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting tuner frequency");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
channel = gst_tuner_get_channel (GST_TUNER (v4lelement));
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
/* check that this is the current input */
|
|
|
|
vtun.tuner = tunernum;
|
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
|
|
|
|
return FALSE;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (strcmp (vtun.name, v4lelement->vchan.name))
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGFREQ, frequency) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting tuner frequency: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
*frequency = *frequency * channel->freq_multiplicator;
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_set_frequency():
|
|
|
|
* set frequency
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_set_frequency (GstV4lElement * v4lelement,
|
|
|
|
gint tunernum, gulong frequency)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2003-10-10 12:47:41 +00:00
|
|
|
struct video_tuner vtun;
|
2004-05-31 14:16:54 +00:00
|
|
|
GstTunerChannel *channel;
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "setting tuner frequency to %lu", frequency);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
channel = gst_tuner_get_channel (GST_TUNER (v4lelement));
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
/* check that this is the current input */
|
|
|
|
vtun.tuner = tunernum;
|
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
|
|
|
|
return FALSE;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (strcmp (vtun.name, v4lelement->vchan.name))
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
frequency = frequency / channel->freq_multiplicator;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCSFREQ, &frequency) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting tuner frequency: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_picture():
|
|
|
|
* get a picture value
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_picture (GstV4lElement * v4lelement,
|
|
|
|
GstV4lPictureType type, gint * value)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
struct video_picture vpic;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting picture property type %d (%s)", type,
|
|
|
|
picture_name[type]);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting picture parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (type) {
|
2001-12-23 15:31:15 +00:00
|
|
|
case V4L_PICTURE_HUE:
|
|
|
|
*value = vpic.hue;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_BRIGHTNESS:
|
|
|
|
*value = vpic.brightness;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_CONTRAST:
|
|
|
|
*value = vpic.contrast;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_SATURATION:
|
|
|
|
*value = vpic.colour;
|
|
|
|
break;
|
|
|
|
default:
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting picture parameters: unknown type %d", type));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_set_picture():
|
|
|
|
* set a picture value
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_set_picture (GstV4lElement * v4lelement,
|
|
|
|
GstV4lPictureType type, gint value)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
struct video_picture vpic;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "setting picture type %d (%s) to value %d",
|
2004-03-14 22:34:34 +00:00
|
|
|
type, picture_name[type], value);
|
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting picture parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (type) {
|
2001-12-23 15:31:15 +00:00
|
|
|
case V4L_PICTURE_HUE:
|
|
|
|
vpic.hue = value;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_BRIGHTNESS:
|
|
|
|
vpic.brightness = value;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_CONTRAST:
|
|
|
|
vpic.contrast = value;
|
|
|
|
break;
|
|
|
|
case V4L_PICTURE_SATURATION:
|
|
|
|
vpic.colour = value;
|
|
|
|
break;
|
|
|
|
default:
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting picture parameters: unknown type %d", type));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCSPICT, &vpic) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting picture parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_get_audio():
|
|
|
|
* get some audio value
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_get_audio (GstV4lElement * v4lelement,
|
|
|
|
gint audionum, GstV4lAudioType type, gint * value)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
struct video_audio vau;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement, "getting audio parameter type %d (%s)", type,
|
|
|
|
audio_name[type]);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
vau.audio = audionum;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting audio parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (type) {
|
2001-12-23 15:31:15 +00:00
|
|
|
case V4L_AUDIO_MUTE:
|
|
|
|
*value = (vau.flags & VIDEO_AUDIO_MUTE);
|
|
|
|
break;
|
|
|
|
case V4L_AUDIO_VOLUME:
|
|
|
|
*value = vau.volume;
|
|
|
|
break;
|
|
|
|
case V4L_AUDIO_MODE:
|
|
|
|
*value = vau.mode;
|
|
|
|
break;
|
|
|
|
default:
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting audio parameters: unknown type %d", type));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l_set_audio():
|
|
|
|
* set some audio value
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4l_set_audio (GstV4lElement * v4lelement,
|
|
|
|
gint audionum, GstV4lAudioType type, gint value)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
struct video_audio vau;
|
|
|
|
|
2004-06-08 16:45:19 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lelement,
|
|
|
|
"setting audio parameter type %d (%s) to value %d", type,
|
|
|
|
audio_name[type], value);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (v4lelement);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
vau.audio = audionum;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting audio parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (type) {
|
2001-12-23 15:31:15 +00:00
|
|
|
case V4L_AUDIO_MUTE:
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!(vau.flags & VIDEO_AUDIO_MUTABLE)) {
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
|
|
|
|
("Error setting audio mute: (un)setting mute is not supported"));
|
|
|
|
return FALSE;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
if (value)
|
2004-03-15 19:32:28 +00:00
|
|
|
vau.flags |= VIDEO_AUDIO_MUTE;
|
2001-12-23 15:31:15 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
vau.flags &= ~VIDEO_AUDIO_MUTE;
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
case V4L_AUDIO_VOLUME:
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!(vau.flags & VIDEO_AUDIO_VOLUME)) {
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
|
|
|
|
("Error setting audio volume: setting volume is not supported"));
|
|
|
|
return FALSE;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
vau.volume = value;
|
|
|
|
break;
|
|
|
|
case V4L_AUDIO_MODE:
|
|
|
|
vau.mode = value;
|
|
|
|
break;
|
|
|
|
default:
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting audio parameters: unknown type %d", type));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (v4lelement->video_fd, VIDIOCSAUDIO, &vau) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error setting audio parameters: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|