v4l2: Cleanup M2M properties

M2M devices were sharing the same properties as src and sink. Most of
these made no sense. This patch reduces the number of propeties and
makes io-mode clearer by having capture-io-mode and output-io-mode. This
also accidently fixed a bug in gstv4l2transform io-mode code, where the
capture io-mode could not be set.

https://bugzilla.gnome.org/show_bug.cgi?id=729591
This commit is contained in:
Nicolas Dufresne 2014-05-15 18:08:53 -04:00 committed by Nicolas Dufresne
parent 0d852cf235
commit 077fcbcf15
4 changed files with 65 additions and 60 deletions

View file

@ -372,6 +372,41 @@ gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class,
}
void
gst_v4l2_object_install_m2m_properties_helper (GObjectClass * gobject_class)
{
g_object_class_install_property (gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device", "Device location",
NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device name",
"Name of the device", DEFAULT_PROP_DEVICE_NAME,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DEVICE_FD,
g_param_spec_int ("device-fd", "File descriptor",
"File descriptor of the device", -1, G_MAXINT, DEFAULT_PROP_DEVICE_FD,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_OUTPUT_IO_MODE,
g_param_spec_enum ("output-io-mode", "Output IO mode",
"Output side I/O mode (matches sink pad)",
GST_TYPE_V4L2_IO_MODE, DEFAULT_PROP_IO_MODE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CAPTURE_IO_MODE,
g_param_spec_enum ("capture-io-mode", "Capture IO mode",
"Capture I/O mode (matches src pad)",
GST_TYPE_V4L2_IO_MODE, DEFAULT_PROP_IO_MODE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_EXTRA_CONTROLS,
g_param_spec_boxed ("extra-controls", "Extra Controls",
"Extra v4l2 controls (CIDs) for the device",
GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
GstV4l2Object *
gst_v4l2_object_new (GstElement * element,
enum v4l2_buf_type type,
@ -541,9 +576,18 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
}
break;
#endif
case PROP_IO_MODE:
v4l2object->req_mode = g_value_get_enum (value);
break;
case PROP_CAPTURE_IO_MODE:
g_return_val_if_fail (!V4L2_TYPE_IS_OUTPUT (v4l2object->type), FALSE);
v4l2object->req_mode = g_value_get_enum (value);
break;
case PROP_OUTPUT_IO_MODE:
g_return_val_if_fail (V4L2_TYPE_IS_OUTPUT (v4l2object->type), FALSE);
v4l2object->req_mode = g_value_get_enum (value);
break;
case PROP_EXTRA_CONTROLS:{
const GstStructure *s = gst_value_get_structure (value);
@ -652,6 +696,14 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
case PROP_IO_MODE:
g_value_set_enum (value, v4l2object->req_mode);
break;
case PROP_CAPTURE_IO_MODE:
g_return_val_if_fail (!V4L2_TYPE_IS_OUTPUT (v4l2object->type), FALSE);
g_value_set_enum (value, v4l2object->req_mode);
break;
case PROP_OUTPUT_IO_MODE:
g_return_val_if_fail (V4L2_TYPE_IS_OUTPUT (v4l2object->type), FALSE);
g_value_set_enum (value, v4l2object->req_mode);
break;
case PROP_EXTRA_CONTROLS:
gst_value_set_structure (value, v4l2object->extra_controls);
break;

View file

@ -190,6 +190,8 @@ GType gst_v4l2_object_get_type (void);
PROP_HUE, \
PROP_TV_NORM, \
PROP_IO_MODE, \
PROP_OUTPUT_IO_MODE, \
PROP_CAPTURE_IO_MODE, \
PROP_EXTRA_CONTROLS, \
PROP_PIXEL_ASPECT_RATIO, \
PROP_FORCE_ASPECT_RATIO
@ -209,6 +211,8 @@ void gst_v4l2_object_destroy (GstV4l2Object * v4l2object);
void gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class,
const char * default_device);
void gst_v4l2_object_install_m2m_properties_helper (GObjectClass * gobject_class);
gboolean gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
guint prop_id,
const GValue * value,

View file

@ -47,8 +47,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_v4l2_transform_debug);
enum
{
PROP_0,
V4L2_STD_OBJECT_PROPS,
PROP_CAPTURE_IO_MODE,
V4L2_STD_OBJECT_PROPS
};
typedef struct
@ -69,9 +68,7 @@ gst_v4l2_transform_set_property (GObject * object,
GstV4l2Transform *self = GST_V4L2_TRANSFORM (object);
switch (prop_id) {
/* Split IO mode so output is configure through 'io-mode' and capture
* through 'capture-io-mode' */
case PROP_IO_MODE:
case PROP_OUTPUT_IO_MODE:
gst_v4l2_object_set_property_helper (self->v4l2output, prop_id, value,
pspec);
break;
@ -80,13 +77,6 @@ gst_v4l2_transform_set_property (GObject * object,
value, pspec);
break;
case PROP_DEVICE:
gst_v4l2_object_set_property_helper (self->v4l2output, prop_id, value,
pspec);
gst_v4l2_object_set_property_helper (self->v4l2capture, prop_id, value,
pspec);
break;
/* By default, only set on output */
default:
if (!gst_v4l2_object_set_property_helper (self->v4l2output,
@ -104,13 +94,13 @@ gst_v4l2_transform_get_property (GObject * object,
GstV4l2Transform *self = GST_V4L2_TRANSFORM (object);
switch (prop_id) {
case PROP_IO_MODE:
case PROP_OUTPUT_IO_MODE:
gst_v4l2_object_get_property_helper (self->v4l2output, prop_id, value,
pspec);
break;
case PROP_CAPTURE_IO_MODE:
gst_v4l2_object_get_property_helper (self->v4l2output, PROP_IO_MODE,
value, pspec);
gst_v4l2_object_get_property_helper (self->v4l2capture, prop_id, value,
pspec);
break;
/* By default read from output */
@ -659,8 +649,6 @@ gst_v4l2_transform_subinstance_init (GTypeInstance * instance, gpointer g_class)
gst_v4l2_get_input, gst_v4l2_set_input, NULL);
self->v4l2capture->no_initial_format = TRUE;
self->v4l2output->keep_aspect = FALSE;
g_object_set (self, "device", klass->default_device, NULL);
}
static void
@ -711,23 +699,10 @@ gst_v4l2_transform_class_init (GstV4l2TransformClass * klass)
base_transform_class->passthrough_on_same_caps = TRUE;
/* FIXME need this ? */
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_v4l2_transform_change_state);
gst_v4l2_object_install_properties_helper (gobject_class,
DEFAULT_PROP_DEVICE);
/**
* GstV4l2Transform:capture-io-mode
*
* Capture IO Mode
*/
g_object_class_install_property (gobject_class, PROP_CAPTURE_IO_MODE,
g_param_spec_enum ("capture-io-mode", "Capture IO mode",
"Capture I/O mode",
GST_TYPE_V4L2_IO_MODE, GST_V4L2_IO_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_v4l2_object_install_m2m_properties_helper (gobject_class);
}
static void

View file

@ -35,8 +35,6 @@
#include <string.h>
#include <gst/gst-i18n-plugin.h>
#define DEFAULT_PROP_DEVICE "/dev/video0"
GST_DEBUG_CATEGORY_STATIC (gst_v4l2_video_dec_debug);
#define GST_CAT_DEFAULT gst_v4l2_video_dec_debug
@ -52,8 +50,7 @@ typedef struct
enum
{
PROP_0,
V4L2_STD_OBJECT_PROPS,
PROP_CAPTURE_IO_MODE,
V4L2_STD_OBJECT_PROPS
};
#define gst_v4l2_video_dec_parent_class parent_class
@ -67,20 +64,11 @@ gst_v4l2_video_dec_set_property (GObject * object,
GstV4l2VideoDec *self = GST_V4L2_VIDEO_DEC (object);
switch (prop_id) {
/* Split IO mode so output is configure through 'io-mode' and capture
* through 'capture-io-mode' */
case PROP_IO_MODE:
case PROP_OUTPUT_IO_MODE:
gst_v4l2_object_set_property_helper (self->v4l2output, prop_id, value,
pspec);
break;
case PROP_CAPTURE_IO_MODE:
gst_v4l2_object_set_property_helper (self->v4l2capture, PROP_IO_MODE,
value, pspec);
break;
case PROP_DEVICE:
gst_v4l2_object_set_property_helper (self->v4l2output, prop_id, value,
pspec);
gst_v4l2_object_set_property_helper (self->v4l2capture, prop_id, value,
pspec);
break;
@ -771,8 +759,6 @@ gst_v4l2_video_dec_subinstance_init (GTypeInstance * instance, gpointer g_class)
gst_v4l2_get_input, gst_v4l2_set_input, NULL);
self->v4l2capture->no_initial_format = TRUE;
self->v4l2output->keep_aspect = FALSE;
g_object_set (self, "device", klass->default_device, NULL);
}
static void
@ -829,19 +815,7 @@ gst_v4l2_video_dec_class_init (GstV4l2VideoDecClass * klass)
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_v4l2_video_dec_change_state);
gst_v4l2_object_install_properties_helper (gobject_class,
DEFAULT_PROP_DEVICE);
/**
* GstV4l2VideoDec:capture-io-mode
*
* Capture IO Mode
*/
g_object_class_install_property (gobject_class, PROP_CAPTURE_IO_MODE,
g_param_spec_enum ("capture-io-mode", "Capture IO mode",
"Capture I/O mode",
GST_TYPE_V4L2_IO_MODE, GST_V4L2_IO_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_v4l2_object_install_m2m_properties_helper (gobject_class);
}
static void