mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
Some cleanups and comments.
Original commit message from CVS: Some cleanups and comments.
This commit is contained in:
parent
2b1e939991
commit
0b0c7f16f8
8 changed files with 143 additions and 223 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2006-09-27 Edgard Lima <edgard.lima@indt.org.br>
|
||||||
|
|
||||||
|
* sys/v4l2/gstv4l2colorbalance.c:
|
||||||
|
* sys/v4l2/gstv4l2object.c:
|
||||||
|
* sys/v4l2/gstv4l2src.c:
|
||||||
|
* sys/v4l2/gstv4l2src.h:
|
||||||
|
* sys/v4l2/gstv4l2tuner.c:
|
||||||
|
* sys/v4l2/v4l2_calls.c:
|
||||||
|
* sys/v4l2/v4l2src_calls.c:
|
||||||
|
* tests/icles/v4l2src-test.c:
|
||||||
|
Some cleanups and comments.
|
||||||
|
|
||||||
2006-09-26 Wim Taymans <wim@fluendo.com>
|
2006-09-26 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* docs/plugins/Makefile.am:
|
* docs/plugins/Makefile.am:
|
||||||
|
|
|
@ -398,11 +398,9 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
|
||||||
flags |= v4l2object->vcap.capabilities &
|
flags |= v4l2object->vcap.capabilities &
|
||||||
(V4L2_CAP_VIDEO_CAPTURE |
|
(V4L2_CAP_VIDEO_CAPTURE |
|
||||||
V4L2_CAP_VIDEO_OUTPUT |
|
V4L2_CAP_VIDEO_OUTPUT |
|
||||||
V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_TUNER | V4L2_CAP_AUDIO);
|
V4L2_CAP_VIDEO_OVERLAY |
|
||||||
/* FIXME. if there is something with AUDIO we add something with
|
V4L2_CAP_VBI_CAPTURE |
|
||||||
* video? this needs some explanation.. */
|
V4L2_CAP_VBI_OUTPUT | V4L2_CAP_TUNER | V4L2_CAP_AUDIO);
|
||||||
if (v4l2object->vcap.capabilities & V4L2_CAP_AUDIO)
|
|
||||||
flags |= V4L2_FBUF_CAP_CHROMAKEY;
|
|
||||||
}
|
}
|
||||||
g_value_set_flags (value, flags);
|
g_value_set_flags (value, flags);
|
||||||
break;
|
break;
|
||||||
|
@ -438,7 +436,9 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
|
||||||
norm =
|
norm =
|
||||||
GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2object->element)));
|
GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2object->element)));
|
||||||
if (norm) {
|
if (norm) {
|
||||||
/* FIXME, free old? */
|
if (v4l2object->std) {
|
||||||
|
g_free (v4l2object->std);
|
||||||
|
}
|
||||||
v4l2object->std = g_strdup (norm->label);
|
v4l2object->std = g_strdup (norm->label);
|
||||||
gst_tuner_norm_changed (tuner, norm);
|
gst_tuner_norm_changed (tuner, norm);
|
||||||
g_object_notify (G_OBJECT (v4l2object->element), "std");
|
g_object_notify (G_OBJECT (v4l2object->element), "std");
|
||||||
|
@ -453,7 +453,9 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
|
||||||
channel =
|
channel =
|
||||||
GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2object->
|
GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2object->
|
||||||
element)));
|
element)));
|
||||||
/* FIXME, free old? */
|
if (v4l2object->input) {
|
||||||
|
g_free (v4l2object->input);
|
||||||
|
}
|
||||||
v4l2object->input = g_strdup (channel->label);
|
v4l2object->input = g_strdup (channel->label);
|
||||||
gst_tuner_channel_changed (tuner, channel);
|
gst_tuner_channel_changed (tuner, channel);
|
||||||
g_object_notify (G_OBJECT (v4l2object->element), "input");
|
g_object_notify (G_OBJECT (v4l2object->element), "input");
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
* </para>
|
* </para>
|
||||||
* <para>
|
* <para>
|
||||||
* <programlisting>
|
* <programlisting>
|
||||||
* gst-launch v4l2src use-fixed-fps=true ! xvimagesink
|
* gst-launch v4l2src use-undef-fps=true ! xvimagesink
|
||||||
* </programlisting>
|
* </programlisting>
|
||||||
* This example should be used to capture from web-cams
|
* This example should be used to capture from web-cams
|
||||||
* </para>
|
* </para>
|
||||||
|
@ -67,13 +67,13 @@ GST_ELEMENT_DETAILS ("Video (video4linux2/raw) Source",
|
||||||
GST_DEBUG_CATEGORY (v4l2src_debug);
|
GST_DEBUG_CATEGORY (v4l2src_debug);
|
||||||
#define GST_CAT_DEFAULT v4l2src_debug
|
#define GST_CAT_DEFAULT v4l2src_debug
|
||||||
|
|
||||||
#define DEFAULT_PROP_USE_FIXED_FPS TRUE
|
#define DEFAULT_PROP_USE_UNDEF_FPS FALSE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
V4L2_STD_OBJECT_PROPS,
|
V4L2_STD_OBJECT_PROPS,
|
||||||
PROP_USE_FIXED_FPS
|
PROP_USE_UNDEF_FPS
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint32 gst_v4l2_formats[] = {
|
static const guint32 gst_v4l2_formats[] = {
|
||||||
|
@ -284,11 +284,12 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass)
|
||||||
gst_v4l2_object_install_properties_helper (gobject_class);
|
gst_v4l2_object_install_properties_helper (gobject_class);
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(gobject_class, PROP_USE_FIXED_FPS,
|
(gobject_class, PROP_USE_UNDEF_FPS,
|
||||||
g_param_spec_boolean ("use-fixed-fps", "Use Fixed FPS",
|
g_param_spec_boolean ("use-undef-fps", "Use undefined FPS",
|
||||||
"Drop/Insert frames to reach a certain FPS (TRUE) "
|
"For some devices that can't properly report its fps "
|
||||||
"or adapt FPS to suit the number of frabbed frames",
|
"set this property to TRUE. The 'caps' will have its "
|
||||||
DEFAULT_PROP_USE_FIXED_FPS, G_PARAM_READWRITE));
|
"'framerate' set to '0/1'.",
|
||||||
|
DEFAULT_PROP_USE_UNDEF_FPS, G_PARAM_READWRITE));
|
||||||
|
|
||||||
basesrc_class->get_caps = gst_v4l2src_get_caps;
|
basesrc_class->get_caps = gst_v4l2src_get_caps;
|
||||||
basesrc_class->set_caps = gst_v4l2src_set_caps;
|
basesrc_class->set_caps = gst_v4l2src_set_caps;
|
||||||
|
@ -311,7 +312,7 @@ gst_v4l2src_init (GstV4l2Src * v4l2src, GstV4l2SrcClass * klass)
|
||||||
/* fps */
|
/* fps */
|
||||||
v4l2src->fps_n = 0;
|
v4l2src->fps_n = 0;
|
||||||
v4l2src->fps_d = 1;
|
v4l2src->fps_d = 1;
|
||||||
v4l2src->use_fixed_fps = DEFAULT_PROP_USE_FIXED_FPS;
|
v4l2src->use_undef_fps = DEFAULT_PROP_USE_UNDEF_FPS;
|
||||||
|
|
||||||
v4l2src->is_capturing = FALSE;
|
v4l2src->is_capturing = FALSE;
|
||||||
|
|
||||||
|
@ -348,9 +349,9 @@ gst_v4l2src_set_property (GObject * object,
|
||||||
if (!gst_v4l2_object_set_property_helper (v4l2src->v4l2object,
|
if (!gst_v4l2_object_set_property_helper (v4l2src->v4l2object,
|
||||||
prop_id, value, pspec)) {
|
prop_id, value, pspec)) {
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_USE_FIXED_FPS:
|
case PROP_USE_UNDEF_FPS:
|
||||||
if (!GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
|
if (!GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
|
||||||
v4l2src->use_fixed_fps = g_value_get_boolean (value);
|
v4l2src->use_undef_fps = g_value_get_boolean (value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -373,8 +374,8 @@ gst_v4l2src_get_property (GObject * object,
|
||||||
if (!gst_v4l2_object_get_property_helper (v4l2src->v4l2object,
|
if (!gst_v4l2_object_get_property_helper (v4l2src->v4l2object,
|
||||||
prop_id, value, pspec)) {
|
prop_id, value, pspec)) {
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_USE_FIXED_FPS:
|
case PROP_USE_UNDEF_FPS:
|
||||||
g_value_set_boolean (value, v4l2src->use_fixed_fps);
|
g_value_set_boolean (value, v4l2src->use_undef_fps);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -402,8 +403,12 @@ gst_v4l2src_fixate (GstPad * pad, GstCaps * caps)
|
||||||
|
|
||||||
/* FIXME such sizes? we usually fixate to something in the 320x200
|
/* FIXME such sizes? we usually fixate to something in the 320x200
|
||||||
* range... */
|
* range... */
|
||||||
gst_structure_fixate_field_nearest_int (structure, "width", 4096);
|
/* We are fixating to greater possble size (limited to GST_V4L2_MAX_SIZE)
|
||||||
gst_structure_fixate_field_nearest_int (structure, "height", 4096);
|
and framarate closer to 15/2 that is common in web-cams */
|
||||||
|
gst_structure_fixate_field_nearest_int (structure, "width",
|
||||||
|
GST_V4L2_MAX_SIZE);
|
||||||
|
gst_structure_fixate_field_nearest_int (structure, "height",
|
||||||
|
GST_V4L2_MAX_SIZE);
|
||||||
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2);
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2);
|
||||||
|
|
||||||
v = gst_structure_get_value (structure, "format");
|
v = gst_structure_get_value (structure, "format");
|
||||||
|
@ -697,8 +702,8 @@ gst_v4l2src_get_all_caps (void)
|
||||||
structure = gst_v4l2src_v4l2fourcc_to_caps (gst_v4l2_formats[i]);
|
structure = gst_v4l2src_v4l2fourcc_to_caps (gst_v4l2_formats[i]);
|
||||||
if (structure) {
|
if (structure) {
|
||||||
gst_structure_set (structure,
|
gst_structure_set (structure,
|
||||||
"width", GST_TYPE_INT_RANGE, 1, 4096,
|
"width", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
|
||||||
"height", GST_TYPE_INT_RANGE, 1, 4096,
|
"height", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
|
||||||
"framerate", GST_TYPE_FRACTION_RANGE, 1, 1, 100, 1, NULL);
|
"framerate", GST_TYPE_FRACTION_RANGE, 1, 1, 100, 1, NULL);
|
||||||
gst_caps_append_structure (caps, structure);
|
gst_caps_append_structure (caps, structure);
|
||||||
}
|
}
|
||||||
|
@ -745,11 +750,12 @@ gst_v4l2src_get_caps (GstBaseSrc * src)
|
||||||
&min_w, &max_w, &min_h, &max_h)) {
|
&min_w, &max_w, &min_h, &max_h)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* template, FIXME, why limit if the device reported correct results. */
|
/* template, FIXME, why limit if the device reported correct results? */
|
||||||
min_w = CLAMP (min_w, 1, 4096);
|
/* we are doing it right now to avoid unexpected results */
|
||||||
min_h = CLAMP (min_h, 1, 4096);
|
min_w = CLAMP (min_w, 1, GST_V4L2_MAX_SIZE);
|
||||||
max_w = CLAMP (max_w, min_w, 4096);
|
min_h = CLAMP (min_h, 1, GST_V4L2_MAX_SIZE);
|
||||||
max_h = CLAMP (max_h, min_h, 4096);
|
max_w = CLAMP (max_w, min_w, GST_V4L2_MAX_SIZE);
|
||||||
|
max_h = CLAMP (max_h, min_h, GST_V4L2_MAX_SIZE);
|
||||||
|
|
||||||
/* add to list */
|
/* add to list */
|
||||||
structure = gst_v4l2src_v4l2fourcc_to_caps (format->pixelformat);
|
structure = gst_v4l2src_v4l2fourcc_to_caps (format->pixelformat);
|
||||||
|
@ -760,6 +766,13 @@ gst_v4l2src_get_caps (GstBaseSrc * src)
|
||||||
"height", GST_TYPE_INT_RANGE, min_h, max_h, NULL);
|
"height", GST_TYPE_INT_RANGE, min_h, max_h, NULL);
|
||||||
|
|
||||||
/* FIXME, why random range? */
|
/* FIXME, why random range? */
|
||||||
|
/* AFAIK: in v4l2 standard we still don't have a good way to enum
|
||||||
|
for a range. Currently it is on discussion on v4l2 forum.
|
||||||
|
Currently, something more smart could be done for tvcard devices.
|
||||||
|
The maximum value could be determined by 'v4l2_standard.frameperiod'
|
||||||
|
and minimum also to the same if V4L2_CAP_TIMEPERFRAME is not set. */
|
||||||
|
/* another approach for web-cams would be to try to set a very
|
||||||
|
high(100/1) and low(1/1) FPSs and get the values returned */
|
||||||
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION_RANGE,
|
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION_RANGE,
|
||||||
1, 1, 100, 1, NULL);
|
1, 1, 100, 1, NULL);
|
||||||
|
|
||||||
|
@ -794,7 +807,7 @@ gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's fixed, one struct */
|
/* it's undef, one struct */
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
/* we want our own v4l2 type of fourcc codes */
|
/* we want our own v4l2 type of fourcc codes */
|
||||||
|
@ -991,7 +1004,7 @@ gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
if (v4l2src->use_fixed_fps && v4l2src->fps_n == 0)
|
if ((!v4l2src->use_undef_fps) && v4l2src->fps_n == 0)
|
||||||
goto no_framerate;
|
goto no_framerate;
|
||||||
|
|
||||||
if (v4l2src->breq.memory == V4L2_MEMORY_MMAP) {
|
if (v4l2src->breq.memory == V4L2_MEMORY_MMAP) {
|
||||||
|
@ -1005,8 +1018,8 @@ gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
no_framerate:
|
no_framerate:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
|
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
|
||||||
(_("could not get frame rate for %s, try to set use-fixed-fps "
|
(_("could not get frame rate for %s, try to set use-undef-fps "
|
||||||
"property to false"), v4l2src->v4l2object->videodev), (NULL));
|
"property to true"), v4l2src->v4l2object->videodev), (NULL));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ GST_DEBUG_CATEGORY_EXTERN (v4l2src_debug);
|
||||||
|
|
||||||
#define GST_V4L2_MAX_BUFFERS 16
|
#define GST_V4L2_MAX_BUFFERS 16
|
||||||
#define GST_V4L2_MIN_BUFFERS 2
|
#define GST_V4L2_MIN_BUFFERS 2
|
||||||
|
#define GST_V4L2_MAX_SIZE (1<<15) /* 2^15 == 32768 */
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ struct _GstV4l2Src
|
||||||
|
|
||||||
/* how are we going to push buffers? */
|
/* how are we going to push buffers? */
|
||||||
guint fps_n, fps_d;
|
guint fps_n, fps_d;
|
||||||
gboolean use_fixed_fps;
|
gboolean use_undef_fps;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstV4l2SrcClass
|
struct _GstV4l2SrcClass
|
||||||
|
|
|
@ -122,16 +122,6 @@ gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm)
|
||||||
norm->index = 0;
|
norm->index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* output not handled by now */
|
|
||||||
static gboolean
|
|
||||||
gst_v4l2_tuner_is_sink (GstV4l2Object * v4l2object)
|
|
||||||
{
|
|
||||||
GstPadDirection dir = GST_PAD_UNKNOWN;
|
|
||||||
|
|
||||||
return (dir == GST_PAD_SINK);
|
|
||||||
}
|
|
||||||
#endif /* #if 0 - output not handled by now */
|
|
||||||
|
|
||||||
static G_GNUC_UNUSED gboolean
|
static G_GNUC_UNUSED gboolean
|
||||||
gst_v4l2_tuner_contains_channel (GstV4l2Object * v4l2object,
|
gst_v4l2_tuner_contains_channel (GstV4l2Object * v4l2object,
|
||||||
GstV4l2TunerChannel * v4l2channel)
|
GstV4l2TunerChannel * v4l2channel)
|
||||||
|
|
|
@ -83,113 +83,64 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
||||||
{
|
{
|
||||||
gint n;
|
gint n;
|
||||||
|
|
||||||
#if 0 /* output not handled by now */
|
|
||||||
GstPadDirection dir = GST_PAD_UNKNOWN;
|
|
||||||
#endif /* #if 0 - output not handled by now */
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "getting enumerations");
|
GST_DEBUG_OBJECT (v4l2object->element, "getting enumerations");
|
||||||
GST_V4L2_CHECK_OPEN (v4l2object);
|
GST_V4L2_CHECK_OPEN (v4l2object);
|
||||||
|
|
||||||
#if 0 /* output not handled by now */
|
GST_DEBUG_OBJECT (v4l2object->element, " inputs");
|
||||||
if (dir != GST_PAD_SINK) {
|
/* and now, the inputs */
|
||||||
#endif /* #if 0 - output not handled by now */
|
for (n = 0;; n++) {
|
||||||
|
struct v4l2_input input;
|
||||||
|
GstV4l2TunerChannel *v4l2channel;
|
||||||
|
GstTunerChannel *channel;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, " inputs");
|
input.index = n;
|
||||||
/* and now, the inputs */
|
if (ioctl (v4l2object->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
|
||||||
for (n = 0;; n++) {
|
if (errno == EINVAL)
|
||||||
struct v4l2_input input;
|
break; /* end of enumeration */
|
||||||
GstV4l2TunerChannel *v4l2channel;
|
else {
|
||||||
GstTunerChannel *channel;
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
||||||
|
("Failed to get %d in input enumeration for %s",
|
||||||
input.index = n;
|
n, v4l2object->videodev), GST_ERROR_SYSTEM);
|
||||||
if (ioctl (v4l2object->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
|
return FALSE;
|
||||||
if (errno == EINVAL)
|
|
||||||
break; /* end of enumeration */
|
|
||||||
else {
|
|
||||||
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
|
||||||
("Failed to get %d in input enumeration for %s",
|
|
||||||
n, v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
if (input.type == V4L2_INPUT_TYPE_TUNER) {
|
|
||||||
struct v4l2_tuner vtun;
|
|
||||||
|
|
||||||
v4l2channel->tuner = input.tuner;
|
|
||||||
channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
|
|
||||||
|
|
||||||
vtun.index = input.tuner;
|
|
||||||
if (ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
|
|
||||||
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
|
||||||
("Failed to get tuner %d settings on %s",
|
|
||||||
input.tuner, v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
||||||
g_object_unref (G_OBJECT (channel));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
v4l2object->inputs =
|
|
||||||
g_list_append (v4l2object->inputs, (gpointer) channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* output not handled by now */
|
v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
|
||||||
} else {
|
channel = GST_TUNER_CHANNEL (v4l2channel);
|
||||||
/* outputs */
|
channel->label = g_strdup ((const gchar *) input.name);
|
||||||
for (n = 0;; n++) {
|
channel->flags = GST_TUNER_CHANNEL_INPUT;
|
||||||
struct v4l2_output output;
|
v4l2channel->index = n;
|
||||||
GstV4l2TunerChannel *v4l2channel;
|
if (input.type == V4L2_INPUT_TYPE_TUNER) {
|
||||||
GstTunerChannel *channel;
|
struct v4l2_tuner vtun;
|
||||||
|
|
||||||
output.index = n;
|
v4l2channel->tuner = input.tuner;
|
||||||
if (ioctl (v4l2object->video_fd, VIDIOC_ENUMOUTPUT, &output) < 0) {
|
channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
|
||||||
if (errno == EINVAL)
|
|
||||||
break; /* end of enumeration */
|
vtun.index = input.tuner;
|
||||||
else {
|
if (ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
|
||||||
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
|
||||||
("Failed to get %d in output enumeration for %s",
|
("Failed to get tuner %d settings on %s",
|
||||||
n, v4l2object->videodev)
|
input.tuner, v4l2object->videodev), GST_ERROR_SYSTEM);
|
||||||
, GST_ERROR_SYSTEM);
|
g_object_unref (G_OBJECT (channel));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
channel->freq_multiplicator =
|
||||||
v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
|
62.5 * ((vtun.capability & V4L2_TUNER_CAP_LOW) ? 1 : 1000);
|
||||||
channel = GST_TUNER_CHANNEL (v4l2channel);
|
channel->min_frequency = vtun.rangelow * channel->freq_multiplicator;
|
||||||
channel->label = g_strdup ((const gchar *) output.name);
|
channel->max_frequency = vtun.rangehigh * channel->freq_multiplicator;
|
||||||
channel->flags = GST_TUNER_CHANNEL_OUTPUT;
|
channel->min_signal = 0;
|
||||||
v4l2channel->index = n;
|
channel->max_signal = 0xffff;
|
||||||
if (output.audioset) {
|
|
||||||
/* we take the first. We don't care for
|
|
||||||
* the others for now */
|
|
||||||
while (!(output.audioset & (1 << v4l2channel->audio)))
|
|
||||||
v4l2channel->audio++;
|
|
||||||
channel->flags |= GST_TUNER_CHANNEL_AUDIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
v4l2object->inputs =
|
|
||||||
g_list_append (v4l2object->inputs, (gpointer) channel);
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
v4l2object->inputs = g_list_append (v4l2object->inputs, (gpointer) channel);
|
||||||
}
|
}
|
||||||
#endif /* #if 0 - output not handled by now */
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, " norms");
|
GST_DEBUG_OBJECT (v4l2object->element, " norms");
|
||||||
/* norms... */
|
/* norms... */
|
||||||
|
@ -231,6 +182,9 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
||||||
if (n == V4L2_CID_LASTP1) {
|
if (n == V4L2_CID_LASTP1) {
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "checking private CIDs");
|
GST_DEBUG_OBJECT (v4l2object->element, "checking private CIDs");
|
||||||
n = V4L2_CID_PRIVATE_BASE;
|
n = V4L2_CID_PRIVATE_BASE;
|
||||||
|
/* FIXME: We are still not handling private controls. We need a new GstInterface
|
||||||
|
to export those controls */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
control.id = n;
|
control.id = n;
|
||||||
|
@ -267,6 +221,21 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
||||||
case V4L2_CID_GAIN:
|
case V4L2_CID_GAIN:
|
||||||
/* we only handle these for now (why?) */
|
/* we only handle these for now (why?) */
|
||||||
break;
|
break;
|
||||||
|
case V4L2_CID_HFLIP:
|
||||||
|
case V4L2_CID_VFLIP:
|
||||||
|
case V4L2_CID_HCENTER:
|
||||||
|
case V4L2_CID_VCENTER:
|
||||||
|
/* 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:
|
||||||
|
/* FIXME: We should implement GstMixer interface */
|
||||||
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
GST_DEBUG_OBJECT (v4l2object->element,
|
GST_DEBUG_OBJECT (v4l2object->element,
|
||||||
"ControlID %s (%x) unhandled, FIXME", control.name, n);
|
"ControlID %s (%x) unhandled, FIXME", control.name, n);
|
||||||
|
@ -283,7 +252,8 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
||||||
channel->label = g_strdup ((const gchar *) control.name);
|
channel->label = g_strdup ((const gchar *) control.name);
|
||||||
v4l2channel->id = n;
|
v4l2channel->id = n;
|
||||||
|
|
||||||
#if 0 /* FIXME: will be be need just when handling private controls */
|
#if 0 /* FIXME: it will be need just when handling private controls
|
||||||
|
(currently none of base controls are of this type) */
|
||||||
if (control.type == V4L2_CTRL_TYPE_MENU) {
|
if (control.type == V4L2_CTRL_TYPE_MENU) {
|
||||||
struct v4l2_querymenu menu, *mptr;
|
struct v4l2_querymenu menu, *mptr;
|
||||||
int i;
|
int i;
|
||||||
|
@ -319,9 +289,11 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
|
||||||
channel->max_value = TRUE;
|
channel->max_value = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* FIX ME we should find out how to handle V4L2_CTRL_TYPE_BUTTON */
|
/* 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 */
|
||||||
GST_DEBUG_OBJECT (v4l2object->element,
|
GST_DEBUG_OBJECT (v4l2object->element,
|
||||||
"No range for ControlID %s (%x), type=%d",
|
"Control with non supported type %s (%x), type=%d",
|
||||||
control.name, n, control.type);
|
control.name, n, control.type);
|
||||||
channel->min_value = channel->max_value = 0;
|
channel->min_value = channel->max_value = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -497,9 +469,8 @@ gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id * norm)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
std_failed:
|
std_failed:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
GST_DEBUG ("Failed to get the current norm for device %s",
|
||||||
(_("Failed to get the current norm for device %s"),
|
v4l2object->videodev);
|
||||||
v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -765,48 +736,3 @@ input_failed:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* output not handled by now, Indeed it will be another element */
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_v4l2_get_output (GstV4l2Object * v4l2object, gint * output)
|
|
||||||
{
|
|
||||||
gint n;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "trying to get output");
|
|
||||||
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (ioctl (v4l2object->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
|
|
||||||
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
|
||||||
(_("Failed to get current output on device %s"),
|
|
||||||
v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*output = n;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_v4l2_set_output (GstV4l2Object * v4l2object, gint output)
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "trying to set output to %d", output);
|
|
||||||
if (!GST_V4L2_IS_OPEN (v4l2object))
|
|
||||||
return FALSE;
|
|
||||||
if (!GST_V4L2_IS_ACTIVE (v4l2object))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (ioctl (v4l2object->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
|
|
||||||
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
|
|
||||||
(_("Failed to set current output on device %s to %d"),
|
|
||||||
v4l2object->videodev, output), GST_ERROR_SYSTEM);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* #if 0 - output not handled by now , Indeed it will be another element */
|
|
||||||
|
|
|
@ -604,30 +604,6 @@ gst_v4l2src_buffer_pool_free (GstV4l2BufferPool * pool, gboolean do_close)
|
||||||
g_free (pool);
|
g_free (pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_v4l2src_free_buffer (GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstV4l2Buffer *buf = (GstV4l2Buffer *) GST_BUFFER_PRIVATE (buffer);
|
|
||||||
|
|
||||||
GST_LOG ("freeing buffer %p (nr. %d)", buffer, buf->buffer.index);
|
|
||||||
|
|
||||||
if (!g_atomic_int_dec_and_test (&buf->refcount)) {
|
|
||||||
/* we're still in use, add to queue again
|
|
||||||
note: this might fail because the device is already stopped (race) */
|
|
||||||
if (ioctl (buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
|
|
||||||
GST_INFO ("readding to queue failed, assuming video device is stopped");
|
|
||||||
}
|
|
||||||
if (g_atomic_int_dec_and_test (&buf->pool->refcount)) {
|
|
||||||
/* we're last thing that used all this */
|
|
||||||
gst_v4l2src_buffer_pool_free (buf->pool, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
* gst_v4l2src_capture_deinit():
|
* gst_v4l2src_capture_deinit():
|
||||||
* deinitialize the capture system
|
* deinitialize the capture system
|
||||||
|
@ -717,8 +693,8 @@ gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
|
||||||
GST_LOG_OBJECT (v4l2src,
|
GST_LOG_OBJECT (v4l2src,
|
||||||
"got min size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
|
"got min size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||||
|
|
||||||
fmt.fmt.pix.width = 4096;
|
fmt.fmt.pix.width = GST_V4L2_MAX_SIZE;
|
||||||
fmt.fmt.pix.height = 4096;
|
fmt.fmt.pix.height = GST_V4L2_MAX_SIZE;
|
||||||
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
|
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
|
||||||
GST_DEBUG_OBJECT (v4l2src, "failed to get max size: %s",
|
GST_DEBUG_OBJECT (v4l2src, "failed to get max size: %s",
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
|
|
|
@ -335,7 +335,7 @@ main (int argc, char *argv[])
|
||||||
gchar device[128] = { '\0' };
|
gchar device[128] = { '\0' };
|
||||||
gchar input[128] = { '\0' };
|
gchar input[128] = { '\0' };
|
||||||
gulong frequency = 0;
|
gulong frequency = 0;
|
||||||
gboolean nofixedfps = TRUE;
|
gboolean undeffps = FALSE;
|
||||||
|
|
||||||
|
|
||||||
/* see for input option */
|
/* see for input option */
|
||||||
|
@ -348,7 +348,7 @@ main (int argc, char *argv[])
|
||||||
{"Device location. Common in /dev/video0"},
|
{"Device location. Common in /dev/video0"},
|
||||||
{"input/output (channel) to switch to"},
|
{"input/output (channel) to switch to"},
|
||||||
{"frequency to tune to (in Hz)"},
|
{"frequency to tune to (in Hz)"},
|
||||||
{"set use-fixed-fps to FALSE"},
|
{"set use-undef-fps to TRUE"},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
@ -356,7 +356,7 @@ main (int argc, char *argv[])
|
||||||
{"device", 1, 0, 'd'},
|
{"device", 1, 0, 'd'},
|
||||||
{"input", 1, 0, 'i'},
|
{"input", 1, 0, 'i'},
|
||||||
{"frequency", 1, 0, 'f'},
|
{"frequency", 1, 0, 'f'},
|
||||||
{"nofixedfps", 0, 0, 's'},
|
{"undeffps", 0, 0, 's'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
/* getopt_long stores the option index here. */
|
/* getopt_long stores the option index here. */
|
||||||
|
@ -398,7 +398,7 @@ main (int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
nofixedfps = FALSE;
|
undeffps = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -464,8 +464,8 @@ main (int argc, char *argv[])
|
||||||
if (frequency) {
|
if (frequency) {
|
||||||
g_object_set (source, "frequency", frequency, NULL);
|
g_object_set (source, "frequency", frequency, NULL);
|
||||||
}
|
}
|
||||||
if (!nofixedfps) {
|
if (undeffps) {
|
||||||
g_object_set (source, "use-fixed-fps", nofixedfps, NULL);
|
g_object_set (source, "use-undef-fps", undeffps, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* you would normally check that the elements were created properly */
|
/* you would normally check that the elements were created properly */
|
||||||
|
|
Loading…
Reference in a new issue