2006-09-02 14:28:55 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
2002-09-09 07:14:35 +00:00
|
|
|
* Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2017-02-26 00:47:03 +00:00
|
|
|
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
2006-09-02 14:28:55 +00:00
|
|
|
*
|
|
|
|
* v4l2_calls.c - generic V4L2 calls handling
|
2002-09-09 07:14:35 +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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2002-09-09 07:14:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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-07-03 15:55:12 +00:00
|
|
|
#include <unistd.h>
|
2008-01-21 19:35:58 +00:00
|
|
|
#ifdef __sun
|
|
|
|
/* Needed on older Solaris Nevada builds (72 at least) */
|
|
|
|
#include <stropts.h>
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#endif
|
2017-07-13 00:49:47 +00:00
|
|
|
#include "gstv4l2object.h"
|
2003-10-10 12:47:42 +00:00
|
|
|
#include "gstv4l2tuner.h"
|
|
|
|
#include "gstv4l2colorbalance.h"
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2003-11-10 10:25:59 +00:00
|
|
|
#include "gstv4l2src.h"
|
2009-08-04 07:14:20 +00:00
|
|
|
#include "gstv4l2sink.h"
|
2013-11-28 22:14:18 +00:00
|
|
|
#include "gstv4l2videodec.h"
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2022-03-25 13:59:23 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2003-11-10 10:25:59 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
|
|
|
|
#define GST_CAT_DEFAULT v4l2_debug
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_get_capabilities():
|
|
|
|
* get the device's capturing capabilities
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
2017-07-13 00:53:51 +00:00
|
|
|
static gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_get_capabilities (GstV4l2Object * v4l2object)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GstElement *e;
|
|
|
|
|
|
|
|
e = v4l2object->element;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (e, "getting capabilities");
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_QUERYCAP,
|
|
|
|
&v4l2object->vcap) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto cap_failed;
|
|
|
|
|
2016-07-02 08:56:07 +00:00
|
|
|
if (v4l2object->vcap.capabilities & V4L2_CAP_DEVICE_CAPS)
|
|
|
|
v4l2object->device_caps = v4l2object->vcap.device_caps;
|
|
|
|
else
|
|
|
|
v4l2object->device_caps = v4l2object->vcap.capabilities;
|
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_LOG_OBJECT (e, "driver: '%s'", v4l2object->vcap.driver);
|
|
|
|
GST_LOG_OBJECT (e, "card: '%s'", v4l2object->vcap.card);
|
|
|
|
GST_LOG_OBJECT (e, "bus_info: '%s'", v4l2object->vcap.bus_info);
|
|
|
|
GST_LOG_OBJECT (e, "version: %08x", v4l2object->vcap.version);
|
2019-09-02 12:27:35 +00:00
|
|
|
GST_LOG_OBJECT (e, "capabilities: %08x", v4l2object->device_caps);
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
cap_failed:
|
|
|
|
{
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
Small cleanups.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_set_property_helper),
(gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2xoverlay.c: (gst_v4l2_xoverlay_open):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_set_norm),
(gst_v4l2_get_frequency), (gst_v4l2_set_frequency),
(gst_v4l2_signal_strength), (gst_v4l2_get_attribute),
(gst_v4l2_set_attribute), (gst_v4l2_get_input),
(gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_get_capture),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_buffer_new):
* tests/icles/v4l2src-test.c: (my_bus_callback), (main):
Small cleanups.
Fix error messages.
Use locks when getting timestamps.
Fix leaks in test.
Add licensing header to tests.
2006-09-27 16:14:18 +00:00
|
|
|
(_("Error getting capabilities for device '%s': "
|
|
|
|
"It isn't a v4l2 driver. Check if it is a v4l1 driver."),
|
2006-09-15 19:11:00 +00:00
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2014-03-04 01:15:49 +00:00
|
|
|
/******************************************************
|
|
|
|
* The video4linux command line tool v4l2-ctrl
|
|
|
|
* normalises the names of the controls received from
|
|
|
|
* the kernel like:
|
|
|
|
*
|
|
|
|
* "Exposure (absolute)" -> "exposure_absolute"
|
|
|
|
*
|
|
|
|
* We follow their lead here. @name is modified
|
|
|
|
* in-place.
|
|
|
|
******************************************************/
|
|
|
|
static void
|
|
|
|
gst_v4l2_normalise_control_name (gchar * name)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
for (i = 0, j = 0; name[j]; ++j) {
|
|
|
|
if (g_ascii_isalnum (name[j])) {
|
|
|
|
if (i > 0 && !g_ascii_isalnum (name[j - 1]))
|
|
|
|
name[i++] = '_';
|
|
|
|
name[i++] = g_ascii_tolower (name[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
name[i++] = '\0';
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_empty_lists() and gst_v4l2_fill_lists():
|
|
|
|
* fill/empty the lists of enumerations
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
static gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2013-06-03 07:17:43 +00:00
|
|
|
gint n, next;
|
|
|
|
struct v4l2_queryctrl control = { 0, };
|
2008-06-09 08:42:49 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GstElement *e;
|
|
|
|
|
|
|
|
e = v4l2object->element;
|
2006-05-05 20:12:59 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, "getting enumerations");
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_V4L2_CHECK_OPEN (v4l2object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, " channels");
|
sys/v4l2/: Renamed some properties to match the tuner interface naming.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2tuner.c: (gst_v4l2_tuner_contains_channel),
(gst_v4l2_tuner_list_channels),
(gst_v4l2_tuner_set_channel_and_notify),
(gst_v4l2_tuner_get_channel), (gst_v4l2_tuner_contains_norm),
(gst_v4l2_tuner_list_norms), (gst_v4l2_tuner_set_norm_and_notify),
(gst_v4l2_tuner_get_norm):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_empty_lists):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_get_fps):
Renamed some properties to match the tuner interface naming.
2006-09-27 17:04:22 +00:00
|
|
|
/* and now, the channels */
|
2006-09-27 15:14:07 +00:00
|
|
|
for (n = 0;; n++) {
|
2009-05-15 06:44:39 +00:00
|
|
|
struct v4l2_input input;
|
2006-09-27 15:14:07 +00:00
|
|
|
GstV4l2TunerChannel *v4l2channel;
|
|
|
|
GstTunerChannel *channel;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2009-05-15 06:44:39 +00:00
|
|
|
memset (&input, 0, sizeof (input));
|
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
input.index = n;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
|
2012-08-21 11:47:45 +00:00
|
|
|
if (errno == EINVAL || errno == ENOTTY)
|
2006-09-27 15:14:07 +00:00
|
|
|
break; /* end of enumeration */
|
|
|
|
else {
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to query attributes of input %d in device %s"),
|
|
|
|
n, v4l2object->videodev),
|
|
|
|
("Failed to get %d in input enumeration for %s. (%d - %s)",
|
|
|
|
n, v4l2object->videodev, errno, strerror (errno)));
|
2006-09-27 15:14:07 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-05 20:12:59 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_LOG_OBJECT (e, " index: %d", input.index);
|
|
|
|
GST_LOG_OBJECT (e, " name: '%s'", input.name);
|
|
|
|
GST_LOG_OBJECT (e, " type: %08x", input.type);
|
|
|
|
GST_LOG_OBJECT (e, " audioset: %08x", input.audioset);
|
2013-04-02 22:36:22 +00:00
|
|
|
GST_LOG_OBJECT (e, " std: %016" G_GINT64_MODIFIER "x",
|
|
|
|
(guint64) input.std);
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_LOG_OBJECT (e, " status: %08x", input.status);
|
2006-09-28 17:08:47 +00:00
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
|
|
|
|
channel = GST_TUNER_CHANNEL (v4l2channel);
|
|
|
|
channel->label = g_strdup ((const gchar *) input.name);
|
|
|
|
channel->flags = GST_TUNER_CHANNEL_INPUT;
|
|
|
|
v4l2channel->index = n;
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
if (input.type == V4L2_INPUT_TYPE_TUNER) {
|
|
|
|
struct v4l2_tuner vtun;
|
2024-02-19 13:49:21 +00:00
|
|
|
memset (&vtun, 0, sizeof (vtun));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
v4l2channel->tuner = input.tuner;
|
|
|
|
channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
vtun.index = input.tuner;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
|
2007-03-10 12:30:48 +00:00
|
|
|
(_("Failed to get setting of tuner %d on device '%s'."),
|
2006-09-27 15:14:07 +00:00
|
|
|
input.tuner, v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
|
|
g_object_unref (G_OBJECT (channel));
|
|
|
|
return FALSE;
|
|
|
|
}
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
|
2006-09-27 15:14:07 +00:00
|
|
|
channel->freq_multiplicator =
|
|
|
|
62.5 * ((vtun.capability & V4L2_TUNER_CAP_LOW) ? 1 : 1000);
|
|
|
|
channel->min_frequency = vtun.rangelow * channel->freq_multiplicator;
|
|
|
|
channel->max_frequency = vtun.rangehigh * channel->freq_multiplicator;
|
|
|
|
channel->min_signal = 0;
|
|
|
|
channel->max_signal = 0xffff;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2006-09-27 15:14:07 +00:00
|
|
|
if (input.audioset) {
|
|
|
|
/* we take the first. We don't care for
|
|
|
|
* the others for now */
|
|
|
|
while (!(input.audioset & (1 << v4l2channel->audio)))
|
|
|
|
v4l2channel->audio++;
|
|
|
|
channel->flags |= GST_TUNER_CHANNEL_AUDIO;
|
|
|
|
}
|
|
|
|
|
sys/v4l2/: Renamed some properties to match the tuner interface naming.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2tuner.c: (gst_v4l2_tuner_contains_channel),
(gst_v4l2_tuner_list_channels),
(gst_v4l2_tuner_set_channel_and_notify),
(gst_v4l2_tuner_get_channel), (gst_v4l2_tuner_contains_norm),
(gst_v4l2_tuner_list_norms), (gst_v4l2_tuner_set_norm_and_notify),
(gst_v4l2_tuner_get_norm):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_empty_lists):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_get_fps):
Renamed some properties to match the tuner interface naming.
2006-09-27 17:04:22 +00:00
|
|
|
v4l2object->channels =
|
2009-03-13 15:43:52 +00:00
|
|
|
g_list_prepend (v4l2object->channels, (gpointer) channel);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2009-03-13 15:43:52 +00:00
|
|
|
v4l2object->channels = g_list_reverse (v4l2object->channels);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, " norms");
|
2004-03-14 22:34:33 +00:00
|
|
|
/* norms... */
|
|
|
|
for (n = 0;; n++) {
|
2007-12-11 11:50:54 +00:00
|
|
|
struct v4l2_standard standard = { 0, };
|
2004-03-14 22:34:33 +00:00
|
|
|
GstV4l2TunerNorm *v4l2norm;
|
2008-06-09 08:42:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GstTunerNorm *norm;
|
|
|
|
|
2006-09-28 17:08:47 +00:00
|
|
|
/* fill in defaults */
|
2015-02-18 19:18:00 +00:00
|
|
|
standard.frameperiod.numerator = 1;
|
|
|
|
standard.frameperiod.denominator = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
standard.index = n;
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
|
2014-01-25 07:06:00 +00:00
|
|
|
if (errno == EINVAL || errno == ENOTTY)
|
2004-03-15 19:32:27 +00:00
|
|
|
break; /* end of enumeration */
|
2014-01-25 07:06:00 +00:00
|
|
|
#ifdef ENODATA
|
|
|
|
else if (errno == ENODATA)
|
|
|
|
break; /* end of enumeration, as of Linux 3.7-rc1 */
|
|
|
|
#endif
|
2004-03-14 22:34:33 +00:00
|
|
|
else {
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to query norm on device '%s'."),
|
|
|
|
v4l2object->videodev),
|
2019-09-02 12:27:35 +00:00
|
|
|
("Failed to get attributes for norm %d on divide '%s'. (%d - %s)",
|
2006-11-01 19:48:26 +00:00
|
|
|
n, v4l2object->videodev, errno, strerror (errno)));
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, " '%s', fps: %d / %d",
|
2015-02-18 19:18:00 +00:00
|
|
|
standard.name, standard.frameperiod.denominator,
|
|
|
|
standard.frameperiod.numerator);
|
2006-09-28 17:08:47 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
v4l2norm = g_object_new (GST_TYPE_V4L2_TUNER_NORM, NULL);
|
|
|
|
norm = GST_TUNER_NORM (v4l2norm);
|
2006-03-11 22:50:03 +00:00
|
|
|
norm->label = g_strdup ((const gchar *) standard.name);
|
|
|
|
gst_value_set_fraction (&norm->framerate,
|
2015-02-18 19:18:00 +00:00
|
|
|
standard.frameperiod.denominator, standard.frameperiod.numerator);
|
2004-03-14 22:34:33 +00:00
|
|
|
v4l2norm->index = standard.id;
|
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "index=%08x, label=%s",
|
2010-04-04 11:43:41 +00:00
|
|
|
(unsigned int) v4l2norm->index, norm->label);
|
|
|
|
|
2009-03-13 15:43:52 +00:00
|
|
|
v4l2object->norms = g_list_prepend (v4l2object->norms, (gpointer) norm);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2009-03-13 15:43:52 +00:00
|
|
|
v4l2object->norms = g_list_reverse (v4l2object->norms);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, " controls+menus");
|
2009-09-07 16:28:51 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
/* and lastly, controls+menus (if appropriate) */
|
2013-06-03 07:17:43 +00:00
|
|
|
next = V4L2_CTRL_FLAG_NEXT_CTRL;
|
|
|
|
n = 0;
|
|
|
|
control.id = next;
|
2014-03-15 10:13:05 +00:00
|
|
|
|
2013-06-03 07:17:43 +00:00
|
|
|
while (TRUE) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GstV4l2ColorBalanceChannel *v4l2channel;
|
|
|
|
GstColorBalanceChannel *channel;
|
|
|
|
|
2013-06-03 07:17:43 +00:00
|
|
|
if (!next)
|
|
|
|
n++;
|
|
|
|
|
2014-02-22 20:31:21 +00:00
|
|
|
retry:
|
2006-08-28 14:59:05 +00:00
|
|
|
/* when we reached the last official CID, continue with private CIDs */
|
|
|
|
if (n == V4L2_CID_LASTP1) {
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, "checking private CIDs");
|
2004-03-14 22:34:33 +00:00
|
|
|
n = V4L2_CID_PRIVATE_BASE;
|
2006-08-28 14:59:05 +00:00
|
|
|
}
|
2009-09-07 16:28:51 +00:00
|
|
|
GST_DEBUG_OBJECT (e, "checking control %08x", n);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2013-06-03 07:17:43 +00:00
|
|
|
control.id = n | next;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_QUERYCTRL,
|
|
|
|
&control) < 0) {
|
2013-06-03 07:17:43 +00:00
|
|
|
if (next) {
|
|
|
|
if (n > 0) {
|
|
|
|
GST_DEBUG_OBJECT (e, "controls finished");
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (e, "V4L2_CTRL_FLAG_NEXT_CTRL not supported.");
|
|
|
|
next = 0;
|
|
|
|
n = V4L2_CID_BASE;
|
2014-02-22 20:31:21 +00:00
|
|
|
goto retry;
|
2013-06-03 07:17:43 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-04 09:03:32 +00:00
|
|
|
if (errno == EINVAL || errno == ENOTTY || errno == EIO || errno == ENOENT) {
|
2009-09-07 16:28:51 +00:00
|
|
|
if (n < V4L2_CID_PRIVATE_BASE) {
|
|
|
|
GST_DEBUG_OBJECT (e, "skipping control %08x", n);
|
2006-08-28 14:59:05 +00:00
|
|
|
/* continue so that we also check private controls */
|
2014-01-14 14:48:42 +00:00
|
|
|
n = V4L2_CID_PRIVATE_BASE - 1;
|
2004-03-15 19:32:27 +00:00
|
|
|
continue;
|
2009-09-07 16:28:51 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (e, "controls finished");
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2009-09-07 16:28:51 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2012-02-16 09:14:20 +00:00
|
|
|
GST_WARNING_OBJECT (e, "Failed querying control %d on device '%s'. "
|
|
|
|
"(%d - %s)", n, v4l2object->videodev, errno, strerror (errno));
|
2023-05-30 08:52:34 +00:00
|
|
|
if (n > (V4L2_CID_PRIVATE_BASE + V4L2_CID_MAX_CTRLS)) {
|
|
|
|
GST_DEBUG_OBJECT (e, "Finish control by reaching V4L2_CID_MAX_CTRLS");
|
|
|
|
break;
|
|
|
|
}
|
2012-02-16 09:14:20 +00:00
|
|
|
continue;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-22 20:31:21 +00:00
|
|
|
/* bogus driver might mess with id in unexpected ways (e.g. set to 0), so
|
|
|
|
* make sure to simply try all if V4L2_CTRL_FLAG_NEXT_CTRL not supported */
|
|
|
|
if (next)
|
|
|
|
n = control.id;
|
2009-09-07 16:28:51 +00:00
|
|
|
if (control.flags & V4L2_CTRL_FLAG_DISABLED) {
|
|
|
|
GST_DEBUG_OBJECT (e, "skipping disabled control");
|
2004-03-14 22:34:33 +00:00
|
|
|
continue;
|
2009-09-07 16:28:51 +00:00
|
|
|
}
|
2014-03-15 10:13:05 +00:00
|
|
|
|
2013-06-03 07:17:43 +00:00
|
|
|
if (control.type == V4L2_CTRL_TYPE_CTRL_CLASS) {
|
|
|
|
GST_DEBUG_OBJECT (e, "starting control class '%s'", control.name);
|
|
|
|
continue;
|
|
|
|
}
|
2014-03-15 10:13:05 +00:00
|
|
|
|
2013-05-20 14:45:37 +00:00
|
|
|
switch (control.type) {
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER:
|
|
|
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
|
|
|
case V4L2_CTRL_TYPE_MENU:
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER_MENU:
|
|
|
|
case V4L2_CTRL_TYPE_BITMASK:
|
2020-07-22 01:46:47 +00:00
|
|
|
case V4L2_CTRL_TYPE_BUTTON:
|
|
|
|
case V4L2_CTRL_TYPE_STRING:{
|
2013-05-20 14:45:37 +00:00
|
|
|
control.name[31] = '\0';
|
2014-03-04 01:15:49 +00:00
|
|
|
gst_v4l2_normalise_control_name ((gchar *) control.name);
|
2013-05-20 14:45:37 +00:00
|
|
|
g_datalist_id_set_data (&v4l2object->controls,
|
|
|
|
g_quark_from_string ((const gchar *) control.name),
|
|
|
|
GINT_TO_POINTER (n));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
GST_DEBUG_OBJECT (e,
|
2019-02-22 15:22:44 +00:00
|
|
|
"Control type for '%s' not supported for extra controls.",
|
2013-05-20 14:45:37 +00:00
|
|
|
control.name);
|
|
|
|
break;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case V4L2_CID_BRIGHTNESS:
|
|
|
|
case V4L2_CID_CONTRAST:
|
|
|
|
case V4L2_CID_SATURATION:
|
|
|
|
case V4L2_CID_HUE:
|
|
|
|
case V4L2_CID_BLACK_LEVEL:
|
|
|
|
case V4L2_CID_AUTO_WHITE_BALANCE:
|
|
|
|
case V4L2_CID_DO_WHITE_BALANCE:
|
|
|
|
case V4L2_CID_RED_BALANCE:
|
|
|
|
case V4L2_CID_BLUE_BALANCE:
|
|
|
|
case V4L2_CID_GAMMA:
|
|
|
|
case V4L2_CID_EXPOSURE:
|
|
|
|
case V4L2_CID_AUTOGAIN:
|
|
|
|
case V4L2_CID_GAIN:
|
2009-09-07 16:28:51 +00:00
|
|
|
case V4L2_CID_SHARPNESS:
|
2006-08-28 14:59:05 +00:00
|
|
|
/* we only handle these for now (why?) */
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2006-09-27 15:14:07 +00:00
|
|
|
case V4L2_CID_HFLIP:
|
|
|
|
case V4L2_CID_VFLIP:
|
2008-06-09 08:42:49 +00:00
|
|
|
case V4L2_CID_PAN_RESET:
|
|
|
|
case V4L2_CID_TILT_RESET:
|
2006-09-27 15:14:07 +00:00
|
|
|
/* not handled here, handled by VideoOrientation interface */
|
|
|
|
control.id++;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_AUDIO_VOLUME:
|
|
|
|
case V4L2_CID_AUDIO_BALANCE:
|
|
|
|
case V4L2_CID_AUDIO_BASS:
|
|
|
|
case V4L2_CID_AUDIO_TREBLE:
|
|
|
|
case V4L2_CID_AUDIO_MUTE:
|
|
|
|
case V4L2_CID_AUDIO_LOUDNESS:
|
2014-02-23 11:34:48 +00:00
|
|
|
/* FIXME: We should implement GstMixer interface instead */
|
|
|
|
/* but let's not be pedantic and make element more useful for now */
|
|
|
|
break;
|
2014-03-19 21:00:56 +00:00
|
|
|
case V4L2_CID_ALPHA_COMPONENT:
|
|
|
|
v4l2object->has_alpha_component = TRUE;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
default:
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e,
|
2006-08-28 14:59:05 +00:00
|
|
|
"ControlID %s (%x) unhandled, FIXME", control.name, n);
|
2004-03-15 19:32:27 +00:00
|
|
|
control.id++;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
if (n != control.id)
|
|
|
|
continue;
|
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, "Adding ControlID %s (%x)", control.name, n);
|
2004-03-14 22:34:33 +00:00
|
|
|
v4l2channel = g_object_new (GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL, NULL);
|
|
|
|
channel = GST_COLOR_BALANCE_CHANNEL (v4l2channel);
|
2006-03-11 22:50:03 +00:00
|
|
|
channel->label = g_strdup ((const gchar *) control.name);
|
2006-03-25 05:31:28 +00:00
|
|
|
v4l2channel->id = n;
|
2003-10-10 12:47:42 +00:00
|
|
|
|
2008-08-26 12:27:11 +00:00
|
|
|
#if 0
|
|
|
|
/* FIXME: it will be need just when handling private controls
|
|
|
|
*(currently none of base controls are of this type) */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (control.type == V4L2_CTRL_TYPE_MENU) {
|
|
|
|
struct v4l2_querymenu menu, *mptr;
|
2008-06-09 08:42:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
menu.id = n;
|
|
|
|
for (i = 0;; i++) {
|
2004-03-15 19:32:27 +00:00
|
|
|
menu.index = i;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_QUERYMENU,
|
|
|
|
&menu) < 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
if (errno == EINVAL)
|
|
|
|
break; /* end of enumeration */
|
|
|
|
else {
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
|
2007-03-10 12:30:48 +00:00
|
|
|
(_("Failed getting controls attributes on device '%s'."),
|
2006-11-01 19:48:26 +00:00
|
|
|
v4l2object->videodev),
|
|
|
|
("Failed to get %d in menu enumeration for %s. (%d - %s)",
|
|
|
|
n, v4l2object->videodev, errno, strerror (errno)));
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mptr = g_malloc (sizeof (menu));
|
|
|
|
memcpy (mptr, &menu, sizeof (menu));
|
|
|
|
menus = g_list_append (menus, mptr);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-11 17:59:59 +00:00
|
|
|
v4l2object->menus = g_list_append (v4l2object->menus, menus);
|
2003-10-10 12:47:42 +00:00
|
|
|
#endif
|
2003-03-02 21:58:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (control.type) {
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER:
|
2004-03-15 19:32:27 +00:00
|
|
|
channel->min_value = control.minimum;
|
|
|
|
channel->max_value = control.maximum;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
2004-03-15 19:32:27 +00:00
|
|
|
channel->min_value = FALSE;
|
|
|
|
channel->max_value = TRUE;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
default:
|
2006-09-27 15:14:07 +00:00
|
|
|
/* FIXME we should find out how to handle V4L2_CTRL_TYPE_BUTTON.
|
|
|
|
BUTTON controls like V4L2_CID_DO_WHITE_BALANCE can just be set (1) or
|
|
|
|
unset (0), but can't be queried */
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e,
|
2006-09-27 15:14:07 +00:00
|
|
|
"Control with non supported type %s (%x), type=%d",
|
2006-08-28 14:59:05 +00:00
|
|
|
control.name, n, control.type);
|
2004-03-15 19:32:27 +00:00
|
|
|
channel->min_value = channel->max_value = 0;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2009-03-13 15:43:52 +00:00
|
|
|
v4l2object->colors =
|
|
|
|
g_list_prepend (v4l2object->colors, (gpointer) channel);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2009-03-13 15:43:52 +00:00
|
|
|
v4l2object->colors = g_list_reverse (v4l2object->colors);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GST_DEBUG_OBJECT (e, "done");
|
2004-03-14 22:34:33 +00:00
|
|
|
return TRUE;
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_empty_lists (GstV4l2Object * v4l2object)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "deleting enumerations");
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/: Renamed some properties to match the tuner interface naming.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2tuner.c: (gst_v4l2_tuner_contains_channel),
(gst_v4l2_tuner_list_channels),
(gst_v4l2_tuner_set_channel_and_notify),
(gst_v4l2_tuner_get_channel), (gst_v4l2_tuner_contains_norm),
(gst_v4l2_tuner_list_norms), (gst_v4l2_tuner_set_norm_and_notify),
(gst_v4l2_tuner_get_norm):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_empty_lists):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_get_fps):
Renamed some properties to match the tuner interface naming.
2006-09-27 17:04:22 +00:00
|
|
|
g_list_foreach (v4l2object->channels, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4l2object->channels);
|
|
|
|
v4l2object->channels = NULL;
|
2003-10-10 12:47:42 +00:00
|
|
|
|
sys/v4l2/: Renamed some properties to match the tuner interface naming.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2tuner.c: (gst_v4l2_tuner_contains_channel),
(gst_v4l2_tuner_list_channels),
(gst_v4l2_tuner_set_channel_and_notify),
(gst_v4l2_tuner_get_channel), (gst_v4l2_tuner_contains_norm),
(gst_v4l2_tuner_list_norms), (gst_v4l2_tuner_set_norm_and_notify),
(gst_v4l2_tuner_get_norm):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_empty_lists):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_get_fps):
Renamed some properties to match the tuner interface naming.
2006-09-27 17:04:22 +00:00
|
|
|
g_list_foreach (v4l2object->norms, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4l2object->norms);
|
|
|
|
v4l2object->norms = NULL;
|
2003-10-10 12:47:42 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
g_list_foreach (v4l2object->colors, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (v4l2object->colors);
|
|
|
|
v4l2object->colors = NULL;
|
2013-05-20 14:45:37 +00:00
|
|
|
|
|
|
|
g_datalist_clear (&v4l2object->controls);
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 22:07:05 +00:00
|
|
|
static void
|
|
|
|
gst_v4l2_adjust_buf_type (GstV4l2Object * v4l2object)
|
|
|
|
{
|
|
|
|
/* when calling gst_v4l2_object_new the user decides the initial type
|
|
|
|
* so adjust it if multi-planar is supported
|
|
|
|
* the driver should make it exclusive. So the driver should
|
|
|
|
* not support both MPLANE and non-PLANE.
|
|
|
|
* Because even when using MPLANE it still possibles to use it
|
|
|
|
* in a contiguous manner. In this case the first v4l2 plane
|
|
|
|
* contains all the gst planes.
|
|
|
|
*/
|
|
|
|
switch (v4l2object->type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
2016-07-08 17:28:19 +00:00
|
|
|
if (v4l2object->device_caps &
|
|
|
|
(V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) {
|
2013-11-28 22:07:05 +00:00
|
|
|
GST_DEBUG ("adjust type to multi-planar output");
|
|
|
|
v4l2object->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
2016-07-08 17:28:19 +00:00
|
|
|
if (v4l2object->device_caps &
|
|
|
|
(V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)) {
|
2013-11-28 22:07:05 +00:00
|
|
|
GST_DEBUG ("adjust type to multi-planar capture");
|
|
|
|
v4l2object->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-09 07:14:35 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_open():
|
2006-05-11 17:59:59 +00:00
|
|
|
* open the video device (v4l2object->videodev)
|
2002-09-09 07:14:35 +00:00
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2020-08-06 11:15:10 +00:00
|
|
|
gst_v4l2_open (GstV4l2Object * v4l2object, GstV4l2Error * error)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2006-03-25 05:31:28 +00:00
|
|
|
struct stat st;
|
2017-07-24 18:19:02 +00:00
|
|
|
int libv4l2_fd = -1;
|
2006-03-25 05:31:28 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Trying to open device %s",
|
2006-05-11 17:59:59 +00:00
|
|
|
v4l2object->videodev);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_V4L2_CHECK_NOT_OPEN (v4l2object);
|
|
|
|
GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
/* be sure we have a device */
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!v4l2object->videodev)
|
|
|
|
v4l2object->videodev = g_strdup ("/dev/video");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-03-25 05:31:28 +00:00
|
|
|
/* check if it is a device */
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
if (stat (v4l2object->videodev, &st) == -1)
|
|
|
|
goto stat_failed;
|
|
|
|
|
|
|
|
if (!S_ISCHR (st.st_mode))
|
|
|
|
goto no_device;
|
|
|
|
|
|
|
|
/* open the device */
|
|
|
|
v4l2object->video_fd =
|
|
|
|
open (v4l2object->videodev, O_RDWR /* | O_NONBLOCK */ );
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
goto not_open;
|
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
#ifdef HAVE_LIBV4L2
|
|
|
|
if (v4l2object->fd_open)
|
|
|
|
libv4l2_fd = v4l2object->fd_open (v4l2object->video_fd,
|
|
|
|
V4L2_ENABLE_ENUM_FMT_EMULATION);
|
|
|
|
#endif
|
|
|
|
|
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
Original commit message from CVS:
Patch by: Bastien Nocera <hadess at hadess dot net>,
Hans de Goede <jwrdegoede at fedoraproject dot org>
* configure.ac:
* sys/v4l2/Makefile.am:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_close),
(gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2_calls.h:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_get_nearest_size):
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
2008-11-04 12:32:48 +00:00
|
|
|
/* Note the v4l2_xxx functions are designed so that if they get passed an
|
|
|
|
unknown fd, the will behave exactly as their regular xxx counterparts, so
|
|
|
|
if v4l2_fd_open fails, we continue as normal (missing the libv4l2 custom
|
|
|
|
cam format to normal formats conversion). Chances are big we will still
|
|
|
|
fail then though, as normally v4l2_fd_open only fails if the device is not
|
|
|
|
a v4l2 device. */
|
|
|
|
if (libv4l2_fd != -1)
|
|
|
|
v4l2object->video_fd = libv4l2_fd;
|
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
/* get capabilities, error will be posted */
|
|
|
|
if (!gst_v4l2_get_capabilities (v4l2object))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* do we need to be a capture device? */
|
2009-08-04 07:14:20 +00:00
|
|
|
if (GST_IS_V4L2SRC (v4l2object->element) &&
|
2016-07-02 08:56:07 +00:00
|
|
|
!(v4l2object->device_caps & (V4L2_CAP_VIDEO_CAPTURE |
|
2013-11-13 12:05:40 +00:00
|
|
|
V4L2_CAP_VIDEO_CAPTURE_MPLANE)))
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto not_capture;
|
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
if (GST_IS_V4L2SINK (v4l2object->element) &&
|
2016-07-02 08:56:07 +00:00
|
|
|
!(v4l2object->device_caps & (V4L2_CAP_VIDEO_OUTPUT |
|
2013-11-13 12:05:40 +00:00
|
|
|
V4L2_CAP_VIDEO_OUTPUT_MPLANE)))
|
2009-08-04 07:14:20 +00:00
|
|
|
goto not_output;
|
|
|
|
|
2013-11-28 22:14:18 +00:00
|
|
|
if (GST_IS_V4L2_VIDEO_DEC (v4l2object->element) &&
|
2018-07-13 19:58:36 +00:00
|
|
|
!GST_V4L2_IS_M2M (v4l2object->device_caps))
|
2013-11-28 22:14:18 +00:00
|
|
|
goto not_m2m;
|
2013-11-13 12:05:40 +00:00
|
|
|
|
2013-11-28 22:07:05 +00:00
|
|
|
gst_v4l2_adjust_buf_type (v4l2object);
|
2013-11-13 12:05:40 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
/* create enumerations, posts errors. */
|
|
|
|
if (!gst_v4l2_fill_lists (v4l2object))
|
|
|
|
goto error;
|
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_INFO_OBJECT (v4l2object->dbg_obj,
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
"Opened device '%s' (%s) successfully",
|
|
|
|
v4l2object->vcap.card, v4l2object->videodev);
|
|
|
|
|
2013-05-20 14:45:37 +00:00
|
|
|
if (v4l2object->extra_controls)
|
|
|
|
gst_v4l2_set_controls (v4l2object, v4l2object->extra_controls);
|
|
|
|
|
2013-06-05 03:42:24 +00:00
|
|
|
/* UVC devices are never interlaced, and doing VIDIOC_TRY_FMT on them
|
|
|
|
* causes expensive and slow USB IO, so don't probe them for interlaced
|
|
|
|
*/
|
2017-07-18 00:47:26 +00:00
|
|
|
if (!strcmp ((char *) v4l2object->vcap.driver, "uvcusb") ||
|
|
|
|
!strcmp ((char *) v4l2object->vcap.driver, "uvcvideo")) {
|
2013-06-05 03:42:24 +00:00
|
|
|
v4l2object->never_interlaced = TRUE;
|
|
|
|
}
|
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
stat_failed:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, NOT_FOUND,
|
Small cleanups.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_set_property_helper),
(gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2xoverlay.c: (gst_v4l2_xoverlay_open):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_set_norm),
(gst_v4l2_get_frequency), (gst_v4l2_set_frequency),
(gst_v4l2_signal_strength), (gst_v4l2_get_attribute),
(gst_v4l2_set_attribute), (gst_v4l2_get_input),
(gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_get_capture),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_buffer_new):
* tests/icles/v4l2src-test.c: (my_bus_callback), (main):
Small cleanups.
Fix error messages.
Use locks when getting timestamps.
Fix leaks in test.
Add licensing header to tests.
2006-09-27 16:14:18 +00:00
|
|
|
(_("Cannot identify device '%s'."), v4l2object->videodev),
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ERROR_SYSTEM);
|
2006-03-25 05:31:28 +00:00
|
|
|
goto error;
|
|
|
|
}
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
no_device:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, NOT_FOUND,
|
Small cleanups.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_set_property_helper),
(gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read),
(gst_v4l2src_create):
* sys/v4l2/gstv4l2xoverlay.c: (gst_v4l2_xoverlay_open):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_set_norm),
(gst_v4l2_get_frequency), (gst_v4l2_set_frequency),
(gst_v4l2_signal_strength), (gst_v4l2_get_attribute),
(gst_v4l2_set_attribute), (gst_v4l2_get_input),
(gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_get_capture),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_buffer_new):
* tests/icles/v4l2src-test.c: (my_bus_callback), (main):
Small cleanups.
Fix error messages.
Use locks when getting timestamps.
Fix leaks in test.
Add licensing header to tests.
2006-09-27 16:14:18 +00:00
|
|
|
(_("This isn't a device '%s'."), v4l2object->videodev),
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ERROR_SYSTEM);
|
2006-03-25 05:31:28 +00:00
|
|
|
goto error;
|
|
|
|
}
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
not_open:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, OPEN_READ_WRITE,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Could not open device '%s' for reading and writing."),
|
2006-05-11 17:59:59 +00:00
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
goto error;
|
|
|
|
}
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
not_capture:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, NOT_FOUND,
|
|
|
|
(_("Device '%s' is not a capture device."), v4l2object->videodev),
|
2016-07-02 08:56:07 +00:00
|
|
|
("Capabilities: 0x%x", v4l2object->device_caps));
|
2004-03-14 22:34:33 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2009-08-04 07:14:20 +00:00
|
|
|
not_output:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, NOT_FOUND,
|
|
|
|
(_("Device '%s' is not a output device."), v4l2object->videodev),
|
2016-07-02 08:56:07 +00:00
|
|
|
("Capabilities: 0x%x", v4l2object->device_caps));
|
2009-08-04 07:14:20 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2013-11-28 22:14:18 +00:00
|
|
|
not_m2m:
|
|
|
|
{
|
2020-08-06 11:15:10 +00:00
|
|
|
GST_V4L2_ERROR (error, RESOURCE, NOT_FOUND,
|
|
|
|
(_("Device '%s' is not a M2M device."), v4l2object->videodev),
|
2016-07-02 08:56:07 +00:00
|
|
|
("Capabilities: 0x%x", v4l2object->device_caps));
|
2013-11-28 22:14:18 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
error:
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
{
|
|
|
|
if (GST_V4L2_IS_OPEN (v4l2object)) {
|
|
|
|
/* close device */
|
2017-07-24 18:19:02 +00:00
|
|
|
v4l2object->close (v4l2object->video_fd);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
v4l2object->video_fd = -1;
|
|
|
|
}
|
|
|
|
/* empty lists */
|
|
|
|
gst_v4l2_empty_lists (v4l2object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 22:07:05 +00:00
|
|
|
gboolean
|
|
|
|
gst_v4l2_dup (GstV4l2Object * v4l2object, GstV4l2Object * other)
|
|
|
|
{
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Trying to dup device %s",
|
2013-11-28 22:07:05 +00:00
|
|
|
other->videodev);
|
|
|
|
|
|
|
|
GST_V4L2_CHECK_OPEN (other);
|
|
|
|
GST_V4L2_CHECK_NOT_OPEN (v4l2object);
|
|
|
|
GST_V4L2_CHECK_NOT_ACTIVE (other);
|
|
|
|
GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
|
|
|
|
|
|
|
|
v4l2object->vcap = other->vcap;
|
2016-07-11 01:35:06 +00:00
|
|
|
v4l2object->device_caps = other->device_caps;
|
2013-11-28 22:07:05 +00:00
|
|
|
gst_v4l2_adjust_buf_type (v4l2object);
|
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
v4l2object->video_fd = v4l2object->dup (other->video_fd);
|
2013-11-28 22:07:05 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
goto not_open;
|
|
|
|
|
|
|
|
g_free (v4l2object->videodev);
|
|
|
|
v4l2object->videodev = g_strdup (other->videodev);
|
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_INFO_OBJECT (v4l2object->dbg_obj,
|
2013-11-28 22:07:05 +00:00
|
|
|
"Cloned device '%s' (%s) successfully",
|
|
|
|
v4l2object->vcap.card, v4l2object->videodev);
|
|
|
|
|
|
|
|
v4l2object->never_interlaced = other->never_interlaced;
|
2018-04-13 11:29:06 +00:00
|
|
|
v4l2object->no_initial_format = other->no_initial_format;
|
2013-11-28 22:07:05 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
not_open:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, OPEN_READ_WRITE,
|
|
|
|
(_("Could not dup device '%s' for reading and writing."),
|
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_close():
|
2006-05-11 17:59:59 +00:00
|
|
|
* close the video device (v4l2object->video_fd)
|
2002-09-09 07:14:35 +00:00
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_close (GstV4l2Object * v4l2object)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Trying to close %s",
|
2006-05-11 17:59:59 +00:00
|
|
|
v4l2object->videodev);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_V4L2_CHECK_OPEN (v4l2object);
|
|
|
|
GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
/* close device */
|
2017-07-24 18:19:02 +00:00
|
|
|
v4l2object->close (v4l2object->video_fd);
|
2006-05-11 17:59:59 +00:00
|
|
|
v4l2object->video_fd = -1;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
/* empty lists */
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_empty_lists (v4l2object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
return TRUE;
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_get_norm()
|
|
|
|
* Get the norm of the current device
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id * norm)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "getting norm");
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_STD, norm) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto std_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
std_failed:
|
|
|
|
{
|
2006-09-27 15:14:07 +00:00
|
|
|
GST_DEBUG ("Failed to get the current norm for device %s",
|
|
|
|
v4l2object->videodev);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_set_norm()
|
|
|
|
* Set the norm of the current device
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_set_norm (GstV4l2Object * v4l2object, v4l2_std_id norm)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to set norm to "
|
2010-02-15 12:12:36 +00:00
|
|
|
"%" G_GINT64_MODIFIER "x", (guint64) norm);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_STD, &norm) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto std_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
std_failed:
|
|
|
|
{
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to set norm for device '%s'."),
|
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************
|
2003-03-02 21:58:52 +00:00
|
|
|
* gst_v4l2_get_frequency():
|
2002-09-09 07:14:35 +00:00
|
|
|
* get the current frequency
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_get_frequency (GstV4l2Object * v4l2object,
|
2004-03-14 22:34:33 +00:00
|
|
|
gint tunernum, gulong * frequency)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2009-06-25 16:39:37 +00:00
|
|
|
struct v4l2_frequency freq = { 0, };
|
2008-06-09 08:42:49 +00:00
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
GstTunerChannel *channel;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "getting current tuner frequency");
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
channel = gst_tuner_get_channel (GST_TUNER (v4l2object->element));
|
2004-05-31 14:16:54 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
freq.tuner = tunernum;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto freq_failed;
|
|
|
|
|
|
|
|
*frequency = freq.frequency * channel->freq_multiplicator;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
freq_failed:
|
|
|
|
{
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to get current tuner frequency for device '%s'."),
|
2006-09-15 19:11:00 +00:00
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
2003-03-02 21:58:52 +00:00
|
|
|
* gst_v4l2_set_frequency():
|
2002-09-09 07:14:35 +00:00
|
|
|
* set frequency
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_set_frequency (GstV4l2Object * v4l2object,
|
2004-03-14 22:34:33 +00:00
|
|
|
gint tunernum, gulong frequency)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2009-06-25 16:39:37 +00:00
|
|
|
struct v4l2_frequency freq = { 0, };
|
2008-06-09 08:42:49 +00:00
|
|
|
|
2004-05-31 14:16:54 +00:00
|
|
|
GstTunerChannel *channel;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj,
|
2006-05-11 17:59:59 +00:00
|
|
|
"setting current tuner frequency to %lu", frequency);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
channel = gst_tuner_get_channel (GST_TUNER (v4l2object->element));
|
2004-05-31 14:16:54 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
freq.tuner = tunernum;
|
|
|
|
/* fill in type - ignore error */
|
2017-07-24 18:19:02 +00:00
|
|
|
(void) v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_FREQUENCY, &freq);
|
2004-05-31 14:16:54 +00:00
|
|
|
freq.frequency = frequency / channel->freq_multiplicator;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto freq_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
freq_failed:
|
|
|
|
{
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to set current tuner frequency for device '%s' to %lu Hz."),
|
2006-09-15 19:11:00 +00:00
|
|
|
v4l2object->videodev, frequency), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************
|
2003-03-02 21:58:52 +00:00
|
|
|
* gst_v4l2_signal_strength():
|
2002-09-09 07:14:35 +00:00
|
|
|
* get the strength of the signal on the current input
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_signal_strength (GstV4l2Object * v4l2object,
|
2004-03-14 22:34:33 +00:00
|
|
|
gint tunernum, gulong * signal_strength)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2009-06-25 16:39:37 +00:00
|
|
|
struct v4l2_tuner tuner = { 0, };
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to get signal strength");
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
tuner.index = tunernum;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &tuner) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto tuner_failed;
|
|
|
|
|
|
|
|
*signal_strength = tuner.signal;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
tuner_failed:
|
|
|
|
{
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Failed to get signal strength for device '%s'."),
|
2006-09-15 19:11:00 +00:00
|
|
|
v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************
|
2003-03-02 21:58:52 +00:00
|
|
|
* gst_v4l2_get_attribute():
|
2002-09-09 07:14:35 +00:00
|
|
|
* try to get the value of one specific attribute
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_get_attribute (GstV4l2Object * v4l2object,
|
2004-03-14 22:34:33 +00:00
|
|
|
int attribute_num, int *value)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2009-06-25 16:39:37 +00:00
|
|
|
struct v4l2_control control = { 0, };
|
2003-03-02 21:58:52 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "getting value of attribute %d",
|
2006-05-01 21:37:51 +00:00
|
|
|
attribute_num);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
control.id = attribute_num;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_CTRL, &control) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto ctrl_failed;
|
|
|
|
|
|
|
|
*value = control.value;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
ctrl_failed:
|
|
|
|
{
|
2021-04-21 17:41:08 +00:00
|
|
|
GST_WARNING_OBJECT (v4l2object->dbg_obj,
|
2015-11-26 12:15:06 +00:00
|
|
|
_("Failed to get value for control %d on device '%s'."),
|
|
|
|
attribute_num, v4l2object->videodev);
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
2003-03-02 21:58:52 +00:00
|
|
|
* gst_v4l2_set_attribute():
|
2002-09-09 07:14:35 +00:00
|
|
|
* try to set the value of one specific attribute
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
2006-05-11 17:59:59 +00:00
|
|
|
gst_v4l2_set_attribute (GstV4l2Object * v4l2object,
|
2004-03-14 22:34:33 +00:00
|
|
|
int attribute_num, const int value)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2009-06-25 16:39:37 +00:00
|
|
|
struct v4l2_control control = { 0, };
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "setting value of attribute %d to %d",
|
2006-05-01 21:37:51 +00:00
|
|
|
attribute_num, value);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
control.id = attribute_num;
|
|
|
|
control.value = value;
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_CTRL, &control) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto ctrl_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
/* ERRORS */
|
|
|
|
ctrl_failed:
|
|
|
|
{
|
2015-11-26 12:15:06 +00:00
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
|
|
|
_("Failed to set value %d for control %d on device '%s'."),
|
|
|
|
value, attribute_num, v4l2object->videodev);
|
2006-05-11 17:59:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:46:47 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4l2_set_string_attribute():
|
|
|
|
* try to set the string value of one specific attribute
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
gboolean
|
|
|
|
gst_v4l2_set_string_attribute (GstV4l2Object * v4l2object,
|
|
|
|
int attribute_num, const char *value)
|
|
|
|
{
|
|
|
|
struct v4l2_ext_controls ctrls = { {0}, 1 };
|
|
|
|
struct v4l2_ext_control ctrl;
|
|
|
|
struct v4l2_queryctrl control = { 0, };
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
control.id = attribute_num;
|
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
|
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
|
|
|
"Failed to find control %d on device '%s'.",
|
|
|
|
attribute_num, v4l2object->videodev);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (control.type != V4L2_CTRL_TYPE_STRING) {
|
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
|
|
|
"control %d is not string type on device '%s'.",
|
|
|
|
attribute_num, v4l2object->videodev);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl.id = attribute_num;
|
|
|
|
ctrl.size = strlen (value) + 1;
|
|
|
|
ctrl.string = g_malloc (ctrl.size);
|
|
|
|
strcpy (ctrl.string, value);
|
|
|
|
|
|
|
|
ctrls.which = V4L2_CTRL_ID2WHICH (attribute_num);
|
|
|
|
ctrls.count = 1;
|
|
|
|
ctrls.controls = &ctrl;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "setting value of attribute %d to %s",
|
|
|
|
attribute_num, value);
|
|
|
|
|
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
|
|
|
|
goto ctrl_failed;
|
|
|
|
|
|
|
|
g_free (ctrl.string);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
ctrl_failed:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
|
|
|
_("Failed to set value %s for control %d on device '%s'."),
|
|
|
|
value, attribute_num, v4l2object->videodev);
|
|
|
|
g_free (ctrl.string);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 14:45:37 +00:00
|
|
|
static gboolean
|
2014-03-09 00:29:58 +00:00
|
|
|
set_control (GQuark field_id, const GValue * value, gpointer user_data)
|
2013-05-20 14:45:37 +00:00
|
|
|
{
|
|
|
|
GstV4l2Object *v4l2object = user_data;
|
2014-03-04 01:15:49 +00:00
|
|
|
GQuark normalised_field_id;
|
|
|
|
gpointer *d;
|
|
|
|
|
|
|
|
/* 32 bytes is the maximum size for a control name according to v4l2 */
|
|
|
|
gchar name[32];
|
|
|
|
|
|
|
|
/* Backwards compatibility: in the past GStreamer would normalise strings in
|
|
|
|
a subtly different way to v4l2-ctl. e.g. the kernel's "Focus (absolute)"
|
|
|
|
would become "focus__absolute_" whereas now it becomes "focus_absolute".
|
|
|
|
Please remove the following in GStreamer 1.5 for 1.6 */
|
|
|
|
strncpy (name, g_quark_to_string (field_id), sizeof (name));
|
|
|
|
name[31] = '\0';
|
|
|
|
gst_v4l2_normalise_control_name (name);
|
|
|
|
normalised_field_id = g_quark_from_string (name);
|
|
|
|
if (normalised_field_id != field_id)
|
|
|
|
g_warning ("In GStreamer 1.4 the way V4L2 control names were normalised "
|
|
|
|
"changed. Instead of setting \"%s\" please use \"%s\". The former is "
|
|
|
|
"deprecated and will be removed in a future version of GStreamer",
|
|
|
|
g_quark_to_string (field_id), name);
|
|
|
|
field_id = normalised_field_id;
|
|
|
|
|
|
|
|
d = g_datalist_id_get_data (&v4l2object->controls, field_id);
|
2013-05-20 14:45:37 +00:00
|
|
|
if (!d) {
|
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
|
|
|
"Control '%s' does not exist or has an unsupported type.",
|
|
|
|
g_quark_to_string (field_id));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2020-07-22 01:46:47 +00:00
|
|
|
if (G_VALUE_HOLDS (value, G_TYPE_INT)) {
|
|
|
|
gst_v4l2_set_attribute (v4l2object, GPOINTER_TO_INT (d),
|
|
|
|
g_value_get_int (value));
|
2021-11-04 14:04:30 +00:00
|
|
|
} else if (G_VALUE_HOLDS (value, G_TYPE_BOOLEAN)) {
|
|
|
|
gst_v4l2_set_attribute (v4l2object, GPOINTER_TO_INT (d),
|
|
|
|
g_value_get_boolean (value));
|
2020-07-22 01:46:47 +00:00
|
|
|
} else if (G_VALUE_HOLDS (value, G_TYPE_STRING)) {
|
|
|
|
gst_v4l2_set_string_attribute (v4l2object, GPOINTER_TO_INT (d),
|
|
|
|
g_value_get_string (value));
|
|
|
|
} else {
|
2013-05-20 14:45:37 +00:00
|
|
|
GST_WARNING_OBJECT (v4l2object,
|
2020-07-22 01:46:47 +00:00
|
|
|
"no compatible value expected for control '%s'.",
|
|
|
|
g_quark_to_string (field_id));
|
2013-05-20 14:45:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_v4l2_set_controls (GstV4l2Object * v4l2object, GstStructure * controls)
|
|
|
|
{
|
2014-03-09 00:29:58 +00:00
|
|
|
return gst_structure_foreach (controls, set_control, v4l2object);
|
2013-05-20 14:45:37 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean
|
2021-02-08 22:22:37 +00:00
|
|
|
gst_v4l2_get_input (GstV4l2Object * v4l2object, guint32 * input)
|
2006-05-11 17:59:59 +00:00
|
|
|
{
|
2021-02-08 22:22:37 +00:00
|
|
|
guint32 n;
|
2006-05-11 17:59:59 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to get input");
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_INPUT, &n) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto input_failed;
|
|
|
|
|
|
|
|
*input = n;
|
|
|
|
|
2021-02-08 22:22:37 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "input: %u", n);
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
input_failed:
|
2016-07-02 08:56:07 +00:00
|
|
|
if (v4l2object->device_caps & V4L2_CAP_TUNER) {
|
2010-07-13 15:03:51 +00:00
|
|
|
/* only give a warning message if driver actually claims to have tuner
|
|
|
|
* support
|
|
|
|
*/
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2007-02-22 17:53:26 +00:00
|
|
|
(_("Failed to get current input on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
|
2006-05-11 17:59:59 +00:00
|
|
|
}
|
2010-07-13 15:03:51 +00:00
|
|
|
return FALSE;
|
2006-05-11 17:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2021-02-08 22:22:37 +00:00
|
|
|
gst_v4l2_set_input (GstV4l2Object * v4l2object, guint32 input)
|
2006-05-11 17:59:59 +00:00
|
|
|
{
|
2021-02-08 22:22:37 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to set input to %u", input);
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_INPUT, &input) < 0)
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
goto input_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
input_failed:
|
2016-07-02 08:56:07 +00:00
|
|
|
if (v4l2object->device_caps & V4L2_CAP_TUNER) {
|
2010-07-13 15:03:51 +00:00
|
|
|
/* only give a warning message if driver actually claims to have tuner
|
|
|
|
* support
|
|
|
|
*/
|
2006-09-15 19:11:00 +00:00
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2021-02-08 22:22:37 +00:00
|
|
|
(_("Failed to set input %u on device %s."),
|
2006-09-15 19:11:00 +00:00
|
|
|
input, v4l2object->videodev), GST_ERROR_SYSTEM);
|
2010-07-13 15:03:51 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-08 22:24:00 +00:00
|
|
|
gboolean
|
|
|
|
gst_v4l2_query_input (GstV4l2Object * obj, struct v4l2_input *input)
|
|
|
|
{
|
|
|
|
gint ret;
|
|
|
|
|
|
|
|
ret = obj->ioctl (obj->video_fd, VIDIOC_ENUMINPUT, input);
|
|
|
|
if (ret < 0) {
|
|
|
|
GST_WARNING_OBJECT (obj->dbg_obj, "Failed to read input state: %s (%i)",
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-07-13 15:03:51 +00:00
|
|
|
gboolean
|
2021-02-08 22:22:37 +00:00
|
|
|
gst_v4l2_get_output (GstV4l2Object * v4l2object, guint32 * output)
|
2010-07-13 15:03:51 +00:00
|
|
|
{
|
2021-02-08 22:22:37 +00:00
|
|
|
guint32 n;
|
2010-07-13 15:03:51 +00:00
|
|
|
|
2017-12-13 19:39:47 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to get output");
|
2010-07-13 15:03:51 +00:00
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_G_OUTPUT, &n) < 0)
|
2010-07-13 15:03:51 +00:00
|
|
|
goto output_failed;
|
|
|
|
|
|
|
|
*output = n;
|
|
|
|
|
2021-02-08 22:22:37 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "output: %u", n);
|
2010-07-13 15:03:51 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
output_failed:
|
2016-07-02 08:56:07 +00:00
|
|
|
if (v4l2object->device_caps & V4L2_CAP_TUNER) {
|
2010-07-13 15:03:51 +00:00
|
|
|
/* only give a warning message if driver actually claims to have tuner
|
|
|
|
* support
|
|
|
|
*/
|
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
|
|
|
(_("Failed to get current output on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2021-02-08 22:22:37 +00:00
|
|
|
gst_v4l2_set_output (GstV4l2Object * v4l2object, guint32 output)
|
2010-07-13 15:03:51 +00:00
|
|
|
{
|
2021-02-08 22:22:37 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "trying to set output to %u", output);
|
2010-07-13 15:03:51 +00:00
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
2004-03-14 22:34:33 +00:00
|
|
|
return FALSE;
|
2010-07-13 15:03:51 +00:00
|
|
|
|
2017-07-24 18:19:02 +00:00
|
|
|
if (v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_OUTPUT, &output) < 0)
|
2010-07-13 15:03:51 +00:00
|
|
|
goto output_failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
output_failed:
|
2016-07-02 08:56:07 +00:00
|
|
|
if (v4l2object->device_caps & V4L2_CAP_TUNER) {
|
2010-07-13 15:03:51 +00:00
|
|
|
/* only give a warning message if driver actually claims to have tuner
|
|
|
|
* support
|
|
|
|
*/
|
|
|
|
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
2021-02-08 22:22:37 +00:00
|
|
|
(_("Failed to set output %u on device %s."),
|
2010-07-13 15:03:51 +00:00
|
|
|
output, v4l2object->videodev), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2010-07-13 15:03:51 +00:00
|
|
|
return FALSE;
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
2021-02-04 16:01:38 +00:00
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
gst_v4l2_event_to_string (guint32 event)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case V4L2_EVENT_ALL:
|
|
|
|
return "ALL";
|
|
|
|
case V4L2_EVENT_VSYNC:
|
|
|
|
return "VSYNC";
|
|
|
|
case V4L2_EVENT_EOS:
|
|
|
|
return "EOS";
|
|
|
|
case V4L2_EVENT_CTRL:
|
|
|
|
return "CTRL";
|
|
|
|
case V4L2_EVENT_FRAME_SYNC:
|
|
|
|
return "FRAME_SYNC";
|
|
|
|
case V4L2_EVENT_SOURCE_CHANGE:
|
|
|
|
return "SOURCE_CHANGE";
|
|
|
|
case V4L2_EVENT_MOTION_DET:
|
|
|
|
return "MOTION_DET";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2021-02-09 19:44:02 +00:00
|
|
|
gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event, guint32 id)
|
2021-02-04 16:01:38 +00:00
|
|
|
{
|
2021-02-09 19:44:02 +00:00
|
|
|
struct v4l2_event_subscription sub = {.type = event,.id = id, };
|
2021-02-04 16:01:38 +00:00
|
|
|
gint ret;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Subscribing to '%s' event",
|
|
|
|
gst_v4l2_event_to_string (event));
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
|
|
|
|
if (ret < 0)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
failed:
|
|
|
|
{
|
2021-04-19 10:14:00 +00:00
|
|
|
if (errno == ENOTTY || errno == EINVAL) {
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"Cannot subscribe to '%s' event: %s",
|
|
|
|
gst_v4l2_event_to_string (event), "not supported");
|
|
|
|
} else {
|
2021-02-04 16:01:38 +00:00
|
|
|
GST_ERROR_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"Cannot subscribe to '%s' event: %s",
|
|
|
|
gst_v4l2_event_to_string (event), g_strerror (errno));
|
2021-04-19 10:14:00 +00:00
|
|
|
}
|
2021-02-04 16:01:38 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_v4l2_dequeue_event (GstV4l2Object * v4l2object, struct v4l2_event *event)
|
|
|
|
{
|
|
|
|
gint ret;
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_DQEVENT, event);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
GST_ERROR_OBJECT (v4l2object->dbg_obj, "DQEVENT failed: %s",
|
|
|
|
g_strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Dequeued a '%s' event.",
|
|
|
|
gst_v4l2_event_to_string (event->type));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2021-02-10 20:52:55 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_v4l2_set_dv_timings (GstV4l2Object * v4l2object,
|
|
|
|
struct v4l2_dv_timings *timings)
|
|
|
|
{
|
|
|
|
gint ret;
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_DV_TIMINGS, timings);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
GST_ERROR_OBJECT (v4l2object->dbg_obj, "S_DV_TIMINGS failed: %s (%i)",
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_v4l2_query_dv_timings (GstV4l2Object * v4l2object,
|
|
|
|
struct v4l2_dv_timings *timings)
|
|
|
|
{
|
|
|
|
gint ret;
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_QUERY_DV_TIMINGS,
|
|
|
|
timings);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
switch (errno) {
|
|
|
|
case ENODATA:
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"QUERY_DV_TIMINGS not supported for this input/output");
|
|
|
|
break;
|
|
|
|
case ENOLINK:
|
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"No timings could be detected because no signal was found.");
|
|
|
|
break;
|
|
|
|
case ENOLCK:
|
|
|
|
GST_INFO_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"The signal was unstable and the hardware could not lock on to it.");
|
|
|
|
break;
|
|
|
|
case ERANGE:
|
|
|
|
GST_INFO_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"Timings were found, but they are out of range of the hardware capabilities.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_ERROR_OBJECT (v4l2object->dbg_obj,
|
|
|
|
"QUERY_DV_TIMINGS failed: %s (%i)", g_strerror (errno), errno);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timings->type != V4L2_DV_BT_656_1120) {
|
|
|
|
GST_FIXME_OBJECT (v4l2object->dbg_obj, "Unsupported DV Timings type (%i)",
|
|
|
|
timings->type);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-10 21:37:01 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Detected DV Timings (%i x %i)",
|
2021-02-10 20:52:55 +00:00
|
|
|
timings->bt.width, timings->bt.height);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|