summaryrefslogtreecommitdiffstats
path: root/sys/v4l2
diff options
context:
space:
mode:
Diffstat (limited to 'sys/v4l2')
-rw-r--r--sys/v4l2/gstv4l2.c22
-rw-r--r--sys/v4l2/gstv4l2colorbalance.c60
-rw-r--r--sys/v4l2/gstv4l2colorbalance.h12
-rw-r--r--sys/v4l2/gstv4l2element.c731
-rw-r--r--sys/v4l2/gstv4l2element.h68
-rw-r--r--sys/v4l2/gstv4l2src.c856
-rw-r--r--sys/v4l2/gstv4l2src.h97
-rw-r--r--sys/v4l2/gstv4l2tuner.c108
-rw-r--r--sys/v4l2/gstv4l2tuner.h28
-rw-r--r--sys/v4l2/gstv4l2xoverlay.c40
-rw-r--r--sys/v4l2/gstv4l2xoverlay.h13
-rw-r--r--sys/v4l2/v4l2-overlay_calls.c144
-rw-r--r--sys/v4l2/v4l2_calls.c942
-rw-r--r--sys/v4l2/v4l2_calls.h60
-rw-r--r--sys/v4l2/v4l2src_calls.c304
-rw-r--r--sys/v4l2/v4l2src_calls.h41
16 files changed, 1710 insertions, 1816 deletions
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index dffb3f07..633ce52e 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -29,7 +29,7 @@
#include "gstv4l2src.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* actually, we can survive without it, but I'll create
* that handling later on. */
@@ -37,9 +37,9 @@ plugin_init (GstPlugin *plugin)
return FALSE;
if (!gst_element_register (plugin, "v4l2element",
- GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
+ GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
!gst_element_register (plugin, "v4l2src",
- GST_RANK_NONE, GST_TYPE_V4L2SRC))
+ GST_RANK_NONE, GST_TYPE_V4L2SRC))
return FALSE;
#ifdef ENABLE_NLS
@@ -50,14 +50,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "video4linux2",
- "elements for Video 4 Linux 2",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "video4linux2",
+ "elements for Video 4 Linux 2",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/sys/v4l2/gstv4l2colorbalance.c b/sys/v4l2/gstv4l2colorbalance.c
index 0fd18677..274043d8 100644
--- a/sys/v4l2/gstv4l2colorbalance.c
+++ b/sys/v4l2/gstv4l2colorbalance.c
@@ -28,19 +28,17 @@
#include "gstv4l2element.h"
static void
-gst_v4l2_color_balance_channel_class_init(GstV4l2ColorBalanceChannelClass *klass);
-static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel);
-
-static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance);
-static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
-static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass);
+static void gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *
+ channel);
+
+static const GList *gst_v4l2_color_balance_list_channels (GstColorBalance *
+ balance);
+static void gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+static gint gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
static GstColorBalanceChannelClass *parent_class = NULL;
@@ -65,30 +63,30 @@ gst_v4l2_color_balance_channel_get_type (void)
gst_v4l2_color_balance_channel_type =
g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
- "GstV4l2ColorBalanceChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_color_balance_channel_type;
}
static void
-gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *klass)
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass)
{
parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
}
static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel)
+gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
{
channel->index = 0;
}
void
-gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
+gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass)
{
GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
-
+
/* default virtual functions */
klass->list_channels = gst_v4l2_color_balance_list_channels;
klass->set_value = gst_v4l2_color_balance_set_value;
@@ -96,8 +94,8 @@ gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
}
static gboolean
-gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2ColorBalanceChannel *v4l2channel)
+gst_v4l2_color_balance_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2ColorBalanceChannel * v4l2channel)
{
const GList *item;
@@ -109,42 +107,40 @@ gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element
}
static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance)
+gst_v4l2_color_balance_list_channels (GstColorBalance * balance)
{
return GST_V4L2ELEMENT (balance)->colors;
}
static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel));
+ v4l2channel));
gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
}
static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
gint value;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel),
- 0);
+ v4l2channel), 0);
if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))
return 0;
diff --git a/sys/v4l2/gstv4l2colorbalance.h b/sys/v4l2/gstv4l2colorbalance.h
index 4003203b..f0de44ce 100644
--- a/sys/v4l2/gstv4l2colorbalance.h
+++ b/sys/v4l2/gstv4l2colorbalance.h
@@ -27,7 +27,6 @@
#include "v4l2_calls.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL \
(gst_v4l2_color_balance_channel_get_type ())
#define GST_V4L2_COLOR_BALANCE_CHANNEL(obj) \
@@ -40,19 +39,20 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
#define GST_IS_V4L2_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
-
-typedef struct _GstV4l2ColorBalanceChannel {
+ typedef struct _GstV4l2ColorBalanceChannel
+{
GstColorBalanceChannel parent;
guint32 index;
} GstV4l2ColorBalanceChannel;
-typedef struct _GstV4l2ColorBalanceChannelClass {
+typedef struct _GstV4l2ColorBalanceChannelClass
+{
GstColorBalanceChannelClass parent;
} GstV4l2ColorBalanceChannelClass;
-GType gst_v4l2_color_balance_channel_get_type (void);
+GType gst_v4l2_color_balance_channel_get_type (void);
-void gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass);
+void gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass);
#endif /* __GST_V4L2_COLOR_BALANCE_H__ */
diff --git a/sys/v4l2/gstv4l2element.c b/sys/v4l2/gstv4l2element.c
index eb12501d..246d4949 100644
--- a/sys/v4l2/gstv4l2element.c
+++ b/sys/v4l2/gstv4l2element.c
@@ -35,21 +35,23 @@
/* elementfactory details */
static GstElementDetails gst_v4l2element_details = {
- "Generic video4linux2 Element",
- "Generic/Video",
- "Generic plugin for handling common video4linux2 calls",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Generic video4linux2 Element",
+ "Generic/Video",
+ "Generic plugin for handling common video4linux2 calls",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Element signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_OPEN,
SIGNAL_CLOSE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DEVICE,
ARG_DEVICE_NAME,
@@ -60,20 +62,16 @@ enum {
};
-static void gst_v4l2element_class_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_base_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_init (GstV4l2Element *v4lelement);
-static void gst_v4l2element_dispose (GObject *object);
-static void gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2element_class_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_base_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_init (GstV4l2Element * v4lelement);
+static void gst_v4l2element_dispose (GObject * object);
+static void gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_v4l2element_change_state (GstElement *element);
+gst_v4l2element_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
@@ -81,260 +79,244 @@ static guint gst_v4l2element_signals[LAST_SIGNAL] = { 0 };
static gboolean
-gst_v4l2_iface_supported (GstImplementsInterface *iface,
- GType iface_type)
+gst_v4l2_iface_supported (GstImplementsInterface * iface, GType iface_type)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
- g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_X_OVERLAY ||
- iface_type == GST_TYPE_COLOR_BALANCE);
+ g_assert (iface_type == GST_TYPE_TUNER ||
+ iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_COLOR_BALANCE);
- if (v4l2element->video_fd == -1)
- return FALSE;
+ if (v4l2element->video_fd == -1)
+ return FALSE;
- if (iface_type == GST_TYPE_X_OVERLAY &&
- !GST_V4L2_IS_OVERLAY(v4l2element))
- return FALSE;
+ if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2element))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
-gst_v4l2_interface_init (GstImplementsInterfaceClass *klass)
+gst_v4l2_interface_init (GstImplementsInterfaceClass * klass)
{
- /* default virtual functions */
- klass->supported = gst_v4l2_iface_supported;
+ /* default virtual functions */
+ klass->supported = gst_v4l2_iface_supported;
}
static const GList *
-gst_v4l2_probe_get_properties (GstPropertyProbe *probe)
+gst_v4l2_probe_get_properties (GstPropertyProbe * probe)
{
- GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
- static GList *list = NULL;
+ GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
+ static GList *list = NULL;
- if (!list) {
- list = g_list_append (NULL,
- g_object_class_find_property (klass, "device"));
- }
+ if (!list) {
+ list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
+ }
- return list;
+ return list;
}
static gboolean
-gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
- gboolean check)
+gst_v4l2_class_probe_devices (GstV4l2ElementClass * klass, gboolean check)
{
- static gboolean init = FALSE;
- static GList *devices = NULL;
-
- if (!init && !check) {
- gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
- gint base, n, fd;
-
- while (devices) {
- GList *item = devices;
- gchar *device = item->data;
-
- devices = g_list_remove (devices, item);
- g_free (device);
- }
-
- /* detect /dev entries */
- for (n = 0; n < 64; n++) {
- for (base = 0; dev_base[base] != NULL; base++) {
- struct stat s;
- gchar *device = g_strdup_printf ("%s%d",
- dev_base[base], n);
-
- /* does the /dev/ entry exist at all? */
- if (stat (device, &s) == 0) {
- /* yes: is a device attached? */
- if ((fd = open (device, O_RDONLY)) > 0 ||
- errno == EBUSY) {
- if (fd > 0)
- close (fd);
-
- devices =
- g_list_append (devices,
- device);
- break;
- }
- }
- g_free (device);
- }
- }
-
- init = TRUE;
+ static gboolean init = FALSE;
+ static GList *devices = NULL;
+
+ if (!init && !check) {
+ gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
+ gint base, n, fd;
+
+ while (devices) {
+ GList *item = devices;
+ gchar *device = item->data;
+
+ devices = g_list_remove (devices, item);
+ g_free (device);
+ }
+
+ /* detect /dev entries */
+ for (n = 0; n < 64; n++) {
+ for (base = 0; dev_base[base] != NULL; base++) {
+ struct stat s;
+ gchar *device = g_strdup_printf ("%s%d",
+ dev_base[base], n);
+
+ /* does the /dev/ entry exist at all? */
+ if (stat (device, &s) == 0) {
+ /* yes: is a device attached? */
+ if ((fd = open (device, O_RDONLY)) > 0 || errno == EBUSY) {
+ if (fd > 0)
+ close (fd);
+
+ devices = g_list_append (devices, device);
+ break;
+ }
}
+ g_free (device);
+ }
+ }
- klass->devices = devices;
+ init = TRUE;
+ }
- return init;
+ klass->devices = devices;
+
+ return init;
}
static void
-gst_v4l2_probe_probe_property (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_probe_property (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
-
- switch (prop_id) {
- case ARG_DEVICE:
- gst_v4l2_class_probe_devices (klass, FALSE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ gst_v4l2_class_probe_devices (klass, FALSE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
}
static gboolean
-gst_v4l2_probe_needs_probe (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_needs_probe (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- gboolean ret = FALSE;
-
- switch (prop_id) {
- case ARG_DEVICE:
- ret = !gst_v4l2_class_probe_devices (klass, TRUE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ gboolean ret = FALSE;
- return ret;
+ switch (prop_id) {
+ case ARG_DEVICE:
+ ret = !gst_v4l2_class_probe_devices (klass, TRUE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
+
+ return ret;
}
static GValueArray *
-gst_v4l2_class_list_devices (GstV4l2ElementClass *klass)
+gst_v4l2_class_list_devices (GstV4l2ElementClass * klass)
{
- GValueArray *array;
- GValue value = { 0 };
- GList *item;
+ GValueArray *array;
+ GValue value = { 0 };
+ GList *item;
- if (!klass->devices)
- return NULL;
+ if (!klass->devices)
+ return NULL;
- array = g_value_array_new (g_list_length (klass->devices));
- item = klass->devices;
- g_value_init (&value, G_TYPE_STRING);
- while (item) {
- gchar *device = item->data;
+ array = g_value_array_new (g_list_length (klass->devices));
+ item = klass->devices;
+ g_value_init (&value, G_TYPE_STRING);
+ while (item) {
+ gchar *device = item->data;
- g_value_set_string (&value, device);
- g_value_array_append (array, &value);
+ g_value_set_string (&value, device);
+ g_value_array_append (array, &value);
- item = item->next;
- }
- g_value_unset (&value);
+ item = item->next;
+ }
+ g_value_unset (&value);
- return array;
+ return array;
}
static GValueArray *
-gst_v4l2_probe_get_values (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_get_values (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- GValueArray *array = NULL;
-
- switch (prop_id) {
- case ARG_DEVICE:
- array = gst_v4l2_class_list_devices (klass);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ GValueArray *array = NULL;
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ array = gst_v4l2_class_list_devices (klass);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
- return array;
+ return array;
}
static void
-gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface *iface)
+gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface * iface)
{
- iface->get_properties = gst_v4l2_probe_get_properties;
- iface->probe_property = gst_v4l2_probe_probe_property;
- iface->needs_probe = gst_v4l2_probe_needs_probe;
- iface->get_values = gst_v4l2_probe_get_values;
+ iface->get_properties = gst_v4l2_probe_get_properties;
+ iface->probe_property = gst_v4l2_probe_probe_property;
+ iface->needs_probe = gst_v4l2_probe_needs_probe;
+ iface->get_values = gst_v4l2_probe_get_values;
}
GType
gst_v4l2element_get_type (void)
{
- static GType v4l2element_type = 0;
-
- if (!v4l2element_type) {
- static const GTypeInfo v4l2element_info = {
- sizeof(GstV4l2ElementClass),
- (GBaseInitFunc) gst_v4l2element_base_init,
- NULL,
- (GClassInitFunc) gst_v4l2element_class_init,
- NULL,
- NULL,
- sizeof(GstV4l2Element),
- 0,
- (GInstanceInitFunc) gst_v4l2element_init,
- NULL
- };
- static const GInterfaceInfo v4l2iface_info = {
- (GInterfaceInitFunc) gst_v4l2_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_tuner_info = {
- (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_xoverlay_info = {
- (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_colorbalance_info = {
- (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_propertyprobe_info = {
- (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
- NULL,
- NULL,
- };
-
- v4l2element_type =
- g_type_register_static(GST_TYPE_ELEMENT,
- "GstV4l2Element", &v4l2element_info, 0);
-
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_IMPLEMENTS_INTERFACE,
- &v4l2iface_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_TUNER,
- &v4l2_tuner_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_X_OVERLAY,
- &v4l2_xoverlay_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_COLOR_BALANCE,
- &v4l2_colorbalance_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_PROPERTY_PROBE,
- &v4l2_propertyprobe_info);
- }
+ static GType v4l2element_type = 0;
+
+ if (!v4l2element_type) {
+ static const GTypeInfo v4l2element_info = {
+ sizeof (GstV4l2ElementClass),
+ (GBaseInitFunc) gst_v4l2element_base_init,
+ NULL,
+ (GClassInitFunc) gst_v4l2element_class_init,
+ NULL,
+ NULL,
+ sizeof (GstV4l2Element),
+ 0,
+ (GInstanceInitFunc) gst_v4l2element_init,
+ NULL
+ };
+ static const GInterfaceInfo v4l2iface_info = {
+ (GInterfaceInitFunc) gst_v4l2_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_tuner_info = {
+ (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_xoverlay_info = {
+ (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_colorbalance_info = {
+ (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_propertyprobe_info = {
+ (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
+ NULL,
+ NULL,
+ };
+
+ v4l2element_type =
+ g_type_register_static (GST_TYPE_ELEMENT,
+ "GstV4l2Element", &v4l2element_info, 0);
+
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_TUNER, &v4l2_tuner_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_PROPERTY_PROBE, &v4l2_propertyprobe_info);
+ }
- return v4l2element_type;
+ return v4l2element_type;
}
@@ -342,80 +324,78 @@ gst_v4l2element_get_type (void)
GType
gst_v4l2_device_get_type (void)
{
- static GType v4l2_device_type = 0;
-
- if (v4l2_device_type == 0) {
- static const GFlagsValue values[] = {
- { V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
- "Device can capture" },
- { V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
- "Device can playback" },
- { V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
- "Device can do overlay" },
- { V4L2_CAP_TUNER, "TUNER",
- "Device has a tuner" },
- { V4L2_CAP_AUDIO, "AUDIO",
- "Device handles audio" },
- { 0, NULL, NULL }
- };
-
- v4l2_device_type =
- g_flags_register_static ("GstV4l2DeviceTypeFlags",
- values);
- }
+ static GType v4l2_device_type = 0;
+
+ if (v4l2_device_type == 0) {
+ static const GFlagsValue values[] = {
+ {V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
+ "Device can capture"},
+ {V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
+ "Device can playback"},
+ {V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
+ "Device can do overlay"},
+ {V4L2_CAP_TUNER, "TUNER",
+ "Device has a tuner"},
+ {V4L2_CAP_AUDIO, "AUDIO",
+ "Device handles audio"},
+ {0, NULL, NULL}
+ };
+
+ v4l2_device_type =
+ g_flags_register_static ("GstV4l2DeviceTypeFlags", values);
+ }
- return v4l2_device_type;
+ return v4l2_device_type;
}
static void
-gst_v4l2element_base_init (GstV4l2ElementClass *klass)
+gst_v4l2element_base_init (GstV4l2ElementClass * klass)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
- klass->devices = NULL;
+ klass->devices = NULL;
- gst_element_class_set_details (gstelement_class,
- &gst_v4l2element_details);
+ gst_element_class_set_details (gstelement_class, &gst_v4l2element_details);
}
static void
-gst_v4l2element_class_init (GstV4l2ElementClass *klass)
+gst_v4l2element_class_init (GstV4l2ElementClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- g_object_class_install_property(gobject_class, ARG_DEVICE,
- g_param_spec_string("device", "Device", "Device location",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_DEVICE_NAME,
- g_param_spec_string("device_name", "Device name",
- "Name of the device", NULL, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_FLAGS,
- g_param_spec_flags("flags", "Flags", "Device type flags",
- GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_NORM,
- g_param_spec_string("norm", "norm",
- "Norm to use", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_CHANNEL,
- g_param_spec_string("channel", "channel",
- "input/output to switch to", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_FREQUENCY,
+ g_object_class_install_property (gobject_class, ARG_DEVICE,
+ g_param_spec_string ("device", "Device", "Device location",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_DEVICE_NAME,
+ g_param_spec_string ("device_name", "Device name",
+ "Name of the device", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_FLAGS,
+ g_param_spec_flags ("flags", "Flags", "Device type flags",
+ GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NORM,
+ g_param_spec_string ("norm", "norm",
+ "Norm to use", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_CHANNEL,
+ g_param_spec_string ("channel", "channel",
+ "input/output to switch to", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_FREQUENCY,
g_param_spec_ulong ("frequency", "frequency",
"frequency to tune to", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
/* signals */
gst_v4l2element_signals[SIGNAL_OPEN] =
- g_signal_new("open", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, open),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("open", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, open),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gst_v4l2element_signals[SIGNAL_CLOSE] =
- g_signal_new("close", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, close),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("close", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, close),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gobject_class->set_property = gst_v4l2element_set_property;
gobject_class->get_property = gst_v4l2element_get_property;
@@ -426,29 +406,29 @@ gst_v4l2element_class_init (GstV4l2ElementClass *klass)
static void
-gst_v4l2element_init (GstV4l2Element *v4l2element)
+gst_v4l2element_init (GstV4l2Element * v4l2element)
{
- /* some default values */
- v4l2element->video_fd = -1;
- v4l2element->buffer = NULL;
- v4l2element->device = g_strdup("/dev/video");
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
+ /* some default values */
+ v4l2element->video_fd = -1;
+ v4l2element->buffer = NULL;
+ v4l2element->device = g_strdup ("/dev/video");
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
- v4l2element->channels = NULL;
- v4l2element->norms = NULL;
- v4l2element->colors = NULL;
+ v4l2element->channels = NULL;
+ v4l2element->norms = NULL;
+ v4l2element->colors = NULL;
- v4l2element->overlay = gst_v4l2_xoverlay_new(v4l2element);
+ v4l2element->overlay = gst_v4l2_xoverlay_new (v4l2element);
}
static void
-gst_v4l2element_dispose (GObject *object)
+gst_v4l2element_dispose (GObject * object)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(object);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (object);
if (v4l2element->overlay) {
- gst_v4l2_xoverlay_free(v4l2element);
+ gst_v4l2_xoverlay_free (v4l2element);
}
if (v4l2element->display) {
@@ -461,37 +441,36 @@ gst_v4l2element_dispose (GObject *object)
v4l2element->norm = NULL;
g_free (v4l2element->channel);
v4l2element->channel = NULL;
-
+
if (((GObjectClass *) parent_class)->dispose)
- ((GObjectClass *) parent_class)->dispose(object);
+ ((GObjectClass *) parent_class)->dispose (object);
}
static void
-gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4l2Element *v4l2element;
GstTuner *tuner;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_V4L2ELEMENT (object));
v4l2element = GST_V4L2ELEMENT (object);
/* stupid GstInterface */
tuner = (GstTuner *) object;
-
+
switch (prop_id) {
case ARG_DEVICE:
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
if (v4l2element->device)
- g_free(v4l2element->device);
- v4l2element->device = g_value_dup_string(value);
+ g_free (v4l2element->device);
+ v4l2element->device = g_value_dup_string (value);
}
break;
case ARG_NORM:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerNorm *norm = gst_tuner_get_norm (tuner);
+
if (norm) {
gst_tuner_set_norm (tuner, norm);
}
@@ -502,8 +481,9 @@ gst_v4l2element_set_property (GObject *object,
}
break;
case ARG_CHANNEL:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel = gst_tuner_get_channel (tuner);
+
if (channel) {
gst_tuner_set_channel (tuner, channel);
}
@@ -514,9 +494,11 @@ gst_v4l2element_set_property (GObject *object,
}
break;
case ARG_FREQUENCY:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel;
- if (!v4l2element->channel) return;
+
+ if (!v4l2element->channel)
+ return;
channel = gst_tuner_get_channel (tuner);
g_assert (channel);
gst_tuner_set_frequency (tuner, channel, g_value_get_ulong (value));
@@ -533,94 +515,91 @@ gst_v4l2element_set_property (GObject *object,
static void
-gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Element *v4l2element;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_V4L2ELEMENT(object));
- v4l2element = GST_V4L2ELEMENT(object);
-
- switch (prop_id) {
- case ARG_DEVICE:
- g_value_set_string(value, v4l2element->device);
- break;
- case ARG_DEVICE_NAME: {
- gchar *new = NULL;
- if (GST_V4L2_IS_OPEN(v4l2element))
- new = v4l2element->vcap.card;
- g_value_set_string(value, new);
- break;
- }
- case ARG_FLAGS: {
- guint flags = 0;
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- flags |= v4l2element->vcap.capabilities &
- 30007;
- }
- g_value_set_flags(value, flags);
- break;
- }
- case ARG_NORM:
- g_value_set_string (value, v4l2element->norm);
- break;
- case ARG_CHANNEL:
- g_value_set_string (value, v4l2element->channel);
- break;
- case ARG_FREQUENCY:
- g_value_set_ulong (value, v4l2element->frequency);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_V4L2ELEMENT (object));
+ v4l2element = GST_V4L2ELEMENT (object);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ g_value_set_string (value, v4l2element->device);
+ break;
+ case ARG_DEVICE_NAME:{
+ gchar *new = NULL;
+
+ if (GST_V4L2_IS_OPEN (v4l2element))
+ new = v4l2element->vcap.card;
+ g_value_set_string (value, new);
+ break;
+ }
+ case ARG_FLAGS:{
+ guint flags = 0;
+
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ flags |= v4l2element->vcap.capabilities & 30007;
+ }
+ g_value_set_flags (value, flags);
+ break;
+ }
+ case ARG_NORM:
+ g_value_set_string (value, v4l2element->norm);
+ break;
+ case ARG_CHANNEL:
+ g_value_set_string (value, v4l2element->channel);
+ break;
+ case ARG_FREQUENCY:
+ g_value_set_ulong (value, v4l2element->frequency);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2element_change_state (GstElement *element)
+gst_v4l2element_change_state (GstElement * element)
{
- GstV4l2Element *v4l2element;
-
- g_return_val_if_fail(GST_IS_V4L2ELEMENT(element), GST_STATE_FAILURE);
-
- v4l2element = GST_V4L2ELEMENT(element);
-
- /* if going down into NULL state, close the device if it's open
- * if going to READY, open the device (and set some options)
- */
- switch (GST_STATE_TRANSITION(element)) {
- case GST_STATE_NULL_TO_READY:
- gst_v4l2_set_display(v4l2element);
-
- if (!gst_v4l2_open(v4l2element))
- return GST_STATE_FAILURE;
-
- gst_v4l2_xoverlay_open(v4l2element);
-
- /* emit a signal! whoopie! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_OPEN], 0,
- v4l2element->device);
- break;
- case GST_STATE_READY_TO_NULL:
- gst_v4l2_xoverlay_close(v4l2element);
-
- if (!gst_v4l2_close(v4l2element))
- return GST_STATE_FAILURE;
-
- /* emit yet another signal! wheehee! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_CLOSE], 0,
- v4l2element->device);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ g_return_val_if_fail (GST_IS_V4L2ELEMENT (element), GST_STATE_FAILURE);
+
+ v4l2element = GST_V4L2ELEMENT (element);
+
+ /* if going down into NULL state, close the device if it's open
+ * if going to READY, open the device (and set some options)
+ */
+ switch (GST_STATE_TRANSITION (element)) {
+ case GST_STATE_NULL_TO_READY:
+ gst_v4l2_set_display (v4l2element);
+
+ if (!gst_v4l2_open (v4l2element))
+ return GST_STATE_FAILURE;
+
+ gst_v4l2_xoverlay_open (v4l2element);
+
+ /* emit a signal! whoopie! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_OPEN], 0, v4l2element->device);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ gst_v4l2_xoverlay_close (v4l2element);
+
+ if (!gst_v4l2_close (v4l2element))
+ return GST_STATE_FAILURE;
+
+ /* emit yet another signal! wheehee! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_CLOSE], 0, v4l2element->device);
+ break;
+ }
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- return GST_STATE_SUCCESS;
+ return GST_STATE_SUCCESS;
}
diff --git a/sys/v4l2/gstv4l2element.h b/sys/v4l2/gstv4l2element.h
index e46b2440..7dcd6846 100644
--- a/sys/v4l2/gstv4l2element.h
+++ b/sys/v4l2/gstv4l2element.h
@@ -55,53 +55,53 @@
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2ELEMENT, GstV4l2ElementClass))
-typedef struct _GstV4l2Element GstV4l2Element;
-typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
+typedef struct _GstV4l2Element GstV4l2Element;
+typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
-struct _GstV4l2Element {
- GstElement element;
+struct _GstV4l2Element
+{
+ GstElement element;
- /* the video device */
- char *device;
+ /* the video device */
+ char *device;
- /* the video-device's file descriptor */
- gint video_fd;
+ /* the video-device's file descriptor */
+ gint video_fd;
- /* the video buffer (mmap()'ed) */
- guint8 **buffer;
+ /* the video buffer (mmap()'ed) */
+ guint8 **buffer;
- /* the video-device's capabilities */
- struct v4l2_capability vcap;
+ /* the video-device's capabilities */
+ struct v4l2_capability vcap;
- /* the toys available to us */
- GList *channels;
- GList *norms;
- GList *colors;
+ /* the toys available to us */
+ GList *channels;
+ GList *norms;
+ GList *colors;
- /* X-overlay */
- GstXWindowListener *overlay;
- XID xwindow_id;
+ /* X-overlay */
+ GstXWindowListener *overlay;
+ XID xwindow_id;
- /* properties */
- gchar *norm;
- gchar *channel;
- gulong frequency;
+ /* properties */
+ gchar *norm;
+ gchar *channel;
+ gulong frequency;
- /* caching values */
- gchar *display;
+ /* caching values */
+ gchar *display;
};
-struct _GstV4l2ElementClass {
- GstElementClass parent_class;
+struct _GstV4l2ElementClass
+{
+ GstElementClass parent_class;
- /* probed devices */
- GList *devices;
+ /* probed devices */
+ GList *devices;
- /* signals */
- void (*open) (GstElement *element,
- const gchar *device);
- void (*close) (GstElement *element,
- const gchar *device);
+ /* signals */
+ void (*open) (GstElement * element, const gchar * device);
+ void (*close) (GstElement * element, const gchar * device);
};
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index 8b0abe1a..5e5cdddc 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -31,115 +31,102 @@ GST_DEBUG_CATEGORY (v4l2src_debug);
/* elementfactory details */
static GstElementDetails gst_v4l2src_details = {
- "Video (video4linux2) Source",
- "Source/Video",
- "Reads frames (compressed or uncompressed) from a video4linux2 device",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Video (video4linux2) Source",
+ "Source/Video",
+ "Reads frames (compressed or uncompressed) from a video4linux2 device",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Src signals and args */
-enum {
- SIGNAL_FRAME_CAPTURE,
- SIGNAL_FRAME_DROP,
- SIGNAL_FRAME_INSERT,
- SIGNAL_FRAME_LOST,
- LAST_SIGNAL
+enum
+{
+ SIGNAL_FRAME_CAPTURE,
+ SIGNAL_FRAME_DROP,
+ SIGNAL_FRAME_INSERT,
+ SIGNAL_FRAME_LOST,
+ LAST_SIGNAL
};
/* arguments */
-enum {
- ARG_0,
- ARG_NUMBUFS,
- ARG_BUFSIZE,
- ARG_USE_FIXED_FPS
+enum
+{
+ ARG_0,
+ ARG_NUMBUFS,
+ ARG_BUFSIZE,
+ ARG_USE_FIXED_FPS
};
guint32 gst_v4l2_formats[] = {
/* from Linux 2.6.0 videodev2.h */
- V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
- V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
- V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
- V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
- V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
- V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
- V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
- V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
- V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
- V4L2_PIX_FMT_GREY, /* 8 Greyscale */
- V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
- V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
- V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
- V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
- V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
- V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
- V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
- V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
- V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
- V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_HI240, /* 8 8-bit color */
- V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
- V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
- V4L2_PIX_FMT_DV, /* 1394 */
- V4L2_PIX_FMT_MPEG, /* MPEG */
- V4L2_PIX_FMT_WNVA /* Winnov hw compres */
+ V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
+ V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
+ V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
+ V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
+ V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
+ V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
+ V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
+ V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
+ V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
+ V4L2_PIX_FMT_GREY, /* 8 Greyscale */
+ V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
+ V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
+ V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
+ V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
+ V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
+ V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
+ V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
+ V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
+ V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
+ V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_HI240, /* 8 8-bit color */
+ V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
+ V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
+ V4L2_PIX_FMT_DV, /* 1394 */
+ V4L2_PIX_FMT_MPEG, /* MPEG */
+ V4L2_PIX_FMT_WNVA /* Winnov hw compres */
};
+
#define GST_V4L2_FORMAT_COUNT (G_N_ELEMENTS (gst_v4l2_formats))
GST_FORMATS_FUNCTION (GstPad *, gst_v4l2src_get_formats,
- GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
+ GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4l2src_get_query_types,
- GST_QUERY_POSITION);
+ GST_QUERY_POSITION);
/* init functions */
-static void gst_v4l2src_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_v4l2src_base_init (gpointer g_class);
-static void gst_v4l2src_init (GTypeInstance * instance,
- gpointer g_class);
+static void gst_v4l2src_class_init (gpointer g_class, gpointer class_data);
+static void gst_v4l2src_base_init (gpointer g_class);
+static void gst_v4l2src_init (GTypeInstance * instance, gpointer g_class);
/* signal functions */
-static void gst_v4l2src_open (GstElement *element,
- const gchar *device);
-static void gst_v4l2src_close (GstElement *element,
- const gchar *device);
+static void gst_v4l2src_open (GstElement * element, const gchar * device);
+static void gst_v4l2src_close (GstElement * element, const gchar * device);
/* pad/buffer functions */
-static const GstCaps * gst_v4l2src_get_all_caps (void);
-static GstPadLinkReturn gst_v4l2src_link (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_v4l2src_getcaps (GstPad *pad);
-static GstCaps * gst_v4l2src_fixate (GstPad * pad,
- const GstCaps * caps);
-static GstData * gst_v4l2src_get (GstPad *pad);
-static gboolean gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static const GstCaps *gst_v4l2src_get_all_caps (void);
+static GstPadLinkReturn gst_v4l2src_link (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_v4l2src_getcaps (GstPad * pad);
+static GstCaps *gst_v4l2src_fixate (GstPad * pad, const GstCaps * caps);
+static GstData *gst_v4l2src_get (GstPad * pad);
+static gboolean gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/* get/set params */
-static void gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* state handling */
-static GstElementStateReturn
- gst_v4l2src_change_state (GstElement *element);
+static GstElementStateReturn gst_v4l2src_change_state (GstElement * element);
/* set_clock function for A/V sync */
-static void gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock);
+static void gst_v4l2src_set_clock (GstElement * element, GstClock * clock);
static GstElementClass *parent_class = NULL;
static guint gst_v4l2src_signals[LAST_SIGNAL] = { 0 };
@@ -163,7 +150,7 @@ gst_v4l2src_get_type (void)
gst_v4l2src_init,
NULL
};
- v4l2src_type = g_type_register_static(GST_TYPE_V4L2ELEMENT,
+ v4l2src_type = g_type_register_static (GST_TYPE_V4L2ELEMENT,
"GstV4l2Src", &v4l2src_info, 0);
GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "v4l2src element");
}
@@ -175,7 +162,7 @@ gst_v4l2src_base_init (gpointer g_class)
{
GstPadTemplate *template;
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_v4l2src_details);
template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
@@ -196,40 +183,36 @@ gst_v4l2src_class_init (gpointer g_class, gpointer class_data)
gobject_class->set_property = gst_v4l2src_set_property;
gobject_class->get_property = gst_v4l2src_get_property;
- g_object_class_install_property(gobject_class, ARG_NUMBUFS,
- g_param_spec_int("num_buffers","num_buffers","num_buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_int("buffer_size","buffer_size","buffer_size",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "num_buffers", "num_buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "buffer_size", "buffer_size",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_USE_FIXED_FPS,
- g_param_spec_boolean("use_fixed_fps", "Use Fixed FPS",
- "Drop/Insert frames to reach a certain FPS (TRUE) "
- "or adapt FPS to suit the number of frabbed frames",
- TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_USE_FIXED_FPS,
+ g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
+ "Drop/Insert frames to reach a certain FPS (TRUE) "
+ "or adapt FPS to suit the number of frabbed frames",
+ TRUE, G_PARAM_READWRITE));
/* signals */
gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE] =
- g_signal_new("frame-capture", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_capture),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_capture), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_DROP] =
- g_signal_new("frame-drop", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_drop),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_drop), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_INSERT] =
- g_signal_new("frame_insert", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_insert),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame_insert", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_insert), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_LOST] =
- g_signal_new("frame-lost", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_lost),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("frame-lost", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_lost), NULL,
+ NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstelement_class->change_state = gst_v4l2src_change_state;
@@ -241,24 +224,26 @@ gst_v4l2src_class_init (gpointer g_class, gpointer class_data)
static void
-gst_v4l2src_init (GTypeInstance *instance, gpointer g_class)
+gst_v4l2src_init (GTypeInstance * instance, gpointer g_class)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (instance);
-
- GST_FLAG_SET(GST_ELEMENT(v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
- v4l2src->srcpad = gst_pad_new_from_template(
- gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
- gst_element_add_pad(GST_ELEMENT(v4l2src), v4l2src->srcpad);
+ GST_FLAG_SET (GST_ELEMENT (v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
+
+ v4l2src->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template
+ (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (v4l2src), v4l2src->srcpad);
- gst_pad_set_get_function(v4l2src->srcpad, gst_v4l2src_get);
- gst_pad_set_link_function(v4l2src->srcpad, gst_v4l2src_link);
+ gst_pad_set_get_function (v4l2src->srcpad, gst_v4l2src_get);
+ gst_pad_set_link_function (v4l2src->srcpad, gst_v4l2src_link);
gst_pad_set_getcaps_function (v4l2src->srcpad, gst_v4l2src_getcaps);
gst_pad_set_fixate_function (v4l2src->srcpad, gst_v4l2src_fixate);
gst_pad_set_convert_function (v4l2src->srcpad, gst_v4l2src_src_convert);
gst_pad_set_formats_function (v4l2src->srcpad, gst_v4l2src_get_formats);
gst_pad_set_query_function (v4l2src->srcpad, gst_v4l2src_src_query);
- gst_pad_set_query_type_function (v4l2src->srcpad, gst_v4l2src_get_query_types);
+ gst_pad_set_query_type_function (v4l2src->srcpad,
+ gst_v4l2src_get_query_types);
v4l2src->breq.count = 0;
@@ -273,121 +258,113 @@ gst_v4l2src_init (GTypeInstance *instance, gpointer g_class)
static void
-gst_v4l2src_open (GstElement *element,
- const gchar *device)
+gst_v4l2src_open (GstElement * element, const gchar * device)
{
gst_v4l2src_fill_format_list (GST_V4L2SRC (element));
}
static void
-gst_v4l2src_close (GstElement *element,
- const gchar *device)
+gst_v4l2src_close (GstElement * element, const gchar * device)
{
gst_v4l2src_clear_format_list (GST_V4L2SRC (element));
}
static gfloat
-gst_v4l2src_get_fps (GstV4l2Src *v4l2src)
+gst_v4l2src_get_fps (GstV4l2Src * v4l2src)
{
- v4l2_std_id norm;
- const GList *item;
-
- if (!v4l2src->use_fixed_fps &&
- v4l2src->clock != NULL &&
- v4l2src->handled > 0) {
- /* try to get time from clock master and calculate fps */
- GstClockTime time = gst_clock_get_time(v4l2src->clock) -
- v4l2src->substract_time;
- return v4l2src->handled * GST_SECOND / time;
- }
+ v4l2_std_id norm;
+ const GList *item;
+
+ if (!v4l2src->use_fixed_fps && v4l2src->clock != NULL && v4l2src->handled > 0) {
+ /* try to get time from clock master and calculate fps */
+ GstClockTime time = gst_clock_get_time (v4l2src->clock) -
+ v4l2src->substract_time;
+ return v4l2src->handled * GST_SECOND / time;
+ }
- /* if that failed ... */
-
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src)))
- return 0.;
-
- if (!gst_v4l2_get_norm(GST_V4L2ELEMENT(v4l2src), &norm))
- return 0.;
- for (item = GST_V4L2ELEMENT(v4l2src)->norms;
- item != NULL; item = item->next) {
- GstV4l2TunerNorm *v4l2norm = item->data;
- if (v4l2norm->index == norm)
- return GST_TUNER_NORM(v4l2norm)->fps;
- }
+ /* if that failed ... */
- return 0.;
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src)))
+ return 0.;
+
+ if (!gst_v4l2_get_norm (GST_V4L2ELEMENT (v4l2src), &norm))
+ return 0.;
+ for (item = GST_V4L2ELEMENT (v4l2src)->norms; item != NULL; item = item->next) {
+ GstV4l2TunerNorm *v4l2norm = item->data;
+
+ if (v4l2norm->index == norm)
+ return GST_TUNER_NORM (v4l2norm)->fps;
+ }
+
+ return 0.;
}
static gboolean
-gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value)
+gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
- GstV4l2Src *v4l2src;
- gdouble fps;
-
- v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
-
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
- return FALSE;
-
- switch (src_format) {
- case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * fps / GST_SECOND;
- break;
- default:
- return FALSE;
- }
- break;
-
- case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / fps;
- break;
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
+ GstV4l2Src *v4l2src;
+ gdouble fps;
+
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- return TRUE;
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
+ return FALSE;
+
+ switch (src_format) {
+ case GST_FORMAT_TIME:
+ switch (*dest_format) {
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * fps / GST_SECOND;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / fps;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
-gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
gboolean res = TRUE;
gdouble fps;
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
return FALSE;
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = v4l2src->handled * GST_SECOND / fps;
- break;
- case GST_FORMAT_DEFAULT:
- *value = v4l2src->handled;
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = v4l2src->handled * GST_SECOND / fps;
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = v4l2src->handled;
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
@@ -404,8 +381,8 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
GstStructure *structure = NULL;
switch (fourcc) {
- case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
- case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
+ case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
+ case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
structure = gst_structure_new ("video/x-jpeg", NULL);
break;
case V4L2_PIX_FMT_RGB332:
@@ -416,21 +393,25 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_RGB32:
- case V4L2_PIX_FMT_BGR32: {
- guint depth=0, bpp=0;
+ case V4L2_PIX_FMT_BGR32:{
+ guint depth = 0, bpp = 0;
gint endianness = 0;
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
switch (fourcc) {
case V4L2_PIX_FMT_RGB332:
bpp = depth = 8;
- endianness = G_BYTE_ORDER; /* 'like, whatever' */
- r_mask = 0xe0; g_mask = 0x1c; b_mask = 0x03;
+ endianness = G_BYTE_ORDER; /* 'like, whatever' */
+ r_mask = 0xe0;
+ g_mask = 0x1c;
+ b_mask = 0x03;
break;
case V4L2_PIX_FMT_RGB555:
case V4L2_PIX_FMT_RGB555X:
- bpp = 16; depth = 15;
- endianness = fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ bpp = 16;
+ depth = 15;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0x7c00;
g_mask = 0x03e0;
b_mask = 0x001f;
@@ -438,7 +419,8 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
bpp = depth = 16;
- endianness = fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0xf800;
g_mask = 0x07e0;
b_mask = 0x001f;
@@ -471,108 +453,107 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc)
b_mask = 0x00ff0000;
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, bpp,
- "depth", G_TYPE_INT, depth,
- "red_mask", G_TYPE_INT, r_mask,
+ "bpp", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, depth,
+ "red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "endianness", G_TYPE_INT, endianness,
- NULL);
+ "blue_mask", G_TYPE_INT, b_mask,
+ "endianness", G_TYPE_INT, endianness, NULL);
break;
}
- case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
- case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
- case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
- case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
- case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
- case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
- case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
+ case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
+ case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
+ case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
+ case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
+ case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
+ case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
+ case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
/* FIXME: get correct fourccs here */
break;
case V4L2_PIX_FMT_YVU410:
case V4L2_PIX_FMT_YUV410:
- case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
+ case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_Y41P: {
+ case V4L2_PIX_FMT_Y41P:{
guint32 fcc = 0;
switch (fourcc) {
case V4L2_PIX_FMT_YVU410:
- fcc = GST_MAKE_FOURCC('Y','V','U','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
break;
case V4L2_PIX_FMT_YUV410:
- fcc = GST_MAKE_FOURCC('Y','U','V','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
break;
case V4L2_PIX_FMT_YUV420:
- fcc = GST_MAKE_FOURCC('I','4','2','0');
+ fcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
break;
case V4L2_PIX_FMT_YUYV:
- fcc = GST_MAKE_FOURCC('Y','U','Y','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
break;
case V4L2_PIX_FMT_YVU420:
- fcc = GST_MAKE_FOURCC('Y','V','1','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
break;
case V4L2_PIX_FMT_UYVY:
- fcc = GST_MAKE_FOURCC('U','Y','V','Y');
+ fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
break;
case V4L2_PIX_FMT_Y41P:
- fcc = GST_MAKE_FOURCC('Y','4','1','B');
+ fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fcc,
- NULL);
+ "format", GST_TYPE_FOURCC, fcc, NULL);
break;
}
case V4L2_PIX_FMT_DV:
- structure = gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
+ structure =
+ gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
break;
- case V4L2_PIX_FMT_MPEG: /* MPEG */
+ case V4L2_PIX_FMT_MPEG: /* MPEG */
/* someone figure out the MPEG format used... */
break;
- case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
+ case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
break;
default:
GST_DEBUG ("Unknown fourcc 0x%08x " GST_FOURCC_FORMAT,
- fourcc, GST_FOURCC_ARGS(fourcc));
+ fourcc, GST_FOURCC_ARGS (fourcc));
break;
}
#if 0
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
#endif
return structure;
}
static struct v4l2_fmtdesc *
-gst_v4l2src_get_format_from_fourcc (GstV4l2Src *v4l2src, guint32 fourcc)
-{
+gst_v4l2src_get_format_from_fourcc (GstV4l2Src * v4l2src, guint32 fourcc)
+{
struct v4l2_fmtdesc *fmt;
GSList *walk;
-
+
if (fourcc == 0)
return NULL;
-
+
walk = v4l2src->formats;
while (walk) {
fmt = (struct v4l2_fmtdesc *) walk->data;
if (fmt->pixelformat == fourcc)
return fmt;
/* special case for jpeg */
- if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG) ||
- (fmt->pixelformat == V4L2_PIX_FMT_JPEG && fourcc == V4L2_PIX_FMT_MJPEG)) {
+ if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG)
+ || (fmt->pixelformat == V4L2_PIX_FMT_JPEG
+ && fourcc == V4L2_PIX_FMT_MJPEG)) {
return fmt;
}
walk = g_slist_next (walk);
@@ -582,36 +563,36 @@ gst_v4l2src_get_format_from_fourcc (GstV4l2Src *v4l2src, guint32 fourcc)
}
static guint32
-gst_v4l2_fourcc_from_structure (GstStructure *structure)
+gst_v4l2_fourcc_from_structure (GstStructure * structure)
{
guint32 fourcc = 0;
const gchar *mimetype = gst_structure_get_name (structure);
- if (!strcmp(mimetype, "video/x-raw-yuv") ||
- !strcmp(mimetype, "video/x-raw-rgb")) {
- if (!strcmp(mimetype, "video/x-raw-rgb"))
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
+ if (!strcmp (mimetype, "video/x-raw-yuv") ||
+ !strcmp (mimetype, "video/x-raw-rgb")) {
+ if (!strcmp (mimetype, "video/x-raw-rgb"))
+ fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
else
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- case GST_MAKE_FOURCC('I','Y','U','V'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
fourcc = V4L2_PIX_FMT_YUV420;
break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
fourcc = V4L2_PIX_FMT_YUYV;
break;
- case GST_MAKE_FOURCC('Y','4','1','P'):
+ case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
fourcc = V4L2_PIX_FMT_Y41P;
break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
fourcc = V4L2_PIX_FMT_UYVY;
break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
fourcc = V4L2_PIX_FMT_YVU420;
break;
- case GST_MAKE_FOURCC('R','G','B',' '): {
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):{
gint depth, endianness, r_mask;
gst_structure_get_int (structure, "depth", &depth);
@@ -624,29 +605,23 @@ gst_v4l2_fourcc_from_structure (GstStructure *structure)
break;
case 15:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB555 :
- V4L2_PIX_FMT_RGB555X;
+ V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
break;
case 16:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB565 :
- V4L2_PIX_FMT_RGB565X;
+ V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
break;
case 24:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR24 :
- V4L2_PIX_FMT_RGB24;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
break;
case 32:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR32 :
- V4L2_PIX_FMT_RGB32;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
break;
}
- default:
- break;
+ default:
+ break;
}
- }
+ }
} else if (strcmp (mimetype, "video/x-dv") == 0) {
fourcc = V4L2_PIX_FMT_DV;
} else if (strcmp (mimetype, "video/x-jpeg") == 0) {
@@ -657,7 +632,7 @@ gst_v4l2_fourcc_from_structure (GstStructure *structure)
}
static struct v4l2_fmtdesc *
-gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, GstStructure *structure)
+gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src * v4l2src, GstStructure * structure)
{
return gst_v4l2src_get_format_from_fourcc (v4l2src,
gst_v4l2_fourcc_from_structure (structure));
@@ -679,8 +654,7 @@ gst_v4l2src_get_all_caps (void)
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, 4096,
"height", GST_TYPE_INT_RANGE, 1, 4096,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
@@ -691,7 +665,7 @@ gst_v4l2src_get_all_caps (void)
}
static GstCaps *
-gst_v4l2src_fixate (GstPad *pad, const GstCaps *const_caps)
+gst_v4l2src_fixate (GstPad * pad, const GstCaps * const_caps)
{
gint i;
GstStructure *structure;
@@ -702,25 +676,31 @@ gst_v4l2src_fixate (GstPad *pad, const GstCaps *const_caps)
caps_str = gst_caps_to_string (caps);
GST_DEBUG_OBJECT (gst_pad_get_parent (pad), "fixating caps %s", caps_str);
g_free (caps_str);
-
+
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "width", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "width",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "height", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "height",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
gst_caps_free (caps);
return NULL;
}
static GstPadLinkReturn
-gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
+gst_v4l2src_link (GstPad * pad, const GstCaps * caps)
{
GstV4l2Src *v4l2src;
GstV4l2Element *v4l2element;
@@ -728,33 +708,33 @@ gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
int w, h;
GstStructure *structure;
- v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
- v4l2element = GST_V4L2ELEMENT(v4l2src);
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
+ v4l2element = GST_V4L2ELEMENT (v4l2src);
structure = gst_caps_get_structure (caps, 0);
/* clean up if we still haven't cleaned up our previous
* capture session */
- if (GST_V4L2_IS_ACTIVE(v4l2element)) {
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_PAD_LINK_REFUSED;
- } else if (!GST_V4L2_IS_OPEN(v4l2element)) {
- return GST_PAD_LINK_DELAYED;
+ if (GST_V4L2_IS_ACTIVE (v4l2element)) {
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_PAD_LINK_REFUSED;
+ } else if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ return GST_PAD_LINK_DELAYED;
}
/* we want our own v4l2 type of fourcc codes */
- if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, structure))) {
- return GST_PAD_LINK_REFUSED;
+ if (!(format = gst_v4l2_caps_to_v4l2fourcc (v4l2src, structure))) {
+ return GST_PAD_LINK_REFUSED;
}
gst_structure_get_int (structure, "width", &w);
gst_structure_get_int (structure, "height", &h);
/* we found the pixelformat! - try it out */
- if (gst_v4l2src_set_capture(v4l2src, format, w, h)) {
- if (gst_v4l2src_capture_init(v4l2src)) {
- return GST_PAD_LINK_OK;
- }
+ if (gst_v4l2src_set_capture (v4l2src, format, w, h)) {
+ if (gst_v4l2src_capture_init (v4l2src)) {
+ return GST_PAD_LINK_OK;
+ }
}
return GST_PAD_LINK_REFUSED;
@@ -762,29 +742,29 @@ gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
static GstCaps *
-gst_v4l2src_getcaps (GstPad *pad)
+gst_v4l2src_getcaps (GstPad * pad)
{
- GstV4l2Src *v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
+ GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
GstCaps *caps;
struct v4l2_fmtdesc *format;
int min_w, max_w, min_h, max_h;
GSList *walk;
GstStructure *structure;
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src))) {
- return gst_caps_new_any ();
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src))) {
+ return gst_caps_new_any ();
}
/* build our own capslist */
- caps = gst_caps_new_empty();
+ caps = gst_caps_new_empty ();
walk = v4l2src->formats;
while (walk) {
format = (struct v4l2_fmtdesc *) walk->data;
walk = g_slist_next (walk);
/* get size delimiters */
- if (!gst_v4l2src_get_size_limits(v4l2src, format,
- &min_w, &max_w, &min_h, &max_h)) {
+ if (!gst_v4l2src_get_size_limits (v4l2src, format,
+ &min_w, &max_w, &min_h, &max_h)) {
continue;
}
@@ -795,8 +775,7 @@ gst_v4l2src_getcaps (GstPad *pad)
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, min_w, max_w,
"height", GST_TYPE_INT_RANGE, min_h, max_h,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
@@ -805,8 +784,8 @@ gst_v4l2src_getcaps (GstPad *pad)
return caps;
}
-static GstData*
-gst_v4l2src_get (GstPad *pad)
+static GstData *
+gst_v4l2src_get (GstPad * pad)
{
GstV4l2Src *v4l2src;
GstBuffer *buf;
@@ -815,9 +794,9 @@ gst_v4l2src_get (GstPad *pad)
v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- if (v4l2src->use_fixed_fps &&
- (fps = gst_v4l2src_get_fps(v4l2src)) == 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL), ("could not get frame rate for element"));
+ if (v4l2src->use_fixed_fps && (fps = gst_v4l2src_get_fps (v4l2src)) == 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("could not get frame rate for element"));
return NULL;
}
@@ -827,13 +806,14 @@ gst_v4l2src_get (GstPad *pad)
v4l2src->need_writes--;
} else {
GstClockTime time;
+
/* grab a frame from the device */
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
/* to check if v4l2 sets the correct time */
- time = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp);
+ time = GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp);
if (v4l2src->clock && v4l2src->use_fixed_fps && time != 0) {
gboolean have_frame = FALSE;
@@ -847,9 +827,12 @@ gst_v4l2src_get (GstPad *pad)
/* first check whether we lost any frames according to the device */
if (v4l2src->last_seq != 0) {
- if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq > 1) {
- v4l2src->need_writes = v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
+ if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq >
+ 1) {
+ v4l2src->need_writes =
+ v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
v4l2src->need_writes - 1);
}
}
@@ -865,23 +848,27 @@ gst_v4l2src_get (GstPad *pad)
* timeframe. This means that if time - begin_time = X sec,
* we want to have written X*fps frames. If we've written
* more - drop, if we've written less - dup... */
- if (v4l2src->handled * (GST_SECOND/fps) - time > 1.5 * (GST_SECOND/fps)) {
+ if (v4l2src->handled * (GST_SECOND / fps) - time >
+ 1.5 * (GST_SECOND / fps)) {
/* yo dude, we've got too many frames here! Drop! DROP! */
- v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
- } else if (v4l2src->handled * (GST_SECOND/fps) - time < -1.5 * (GST_SECOND/fps)) {
+ v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
+ } else if (v4l2src->handled * (GST_SECOND / fps) - time <
+ -1.5 * (GST_SECOND / fps)) {
/* this means we're lagging far behind */
- v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
+ v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
}
if (v4l2src->need_writes > 0) {
have_frame = TRUE;
v4l2src->need_writes--;
} else {
- if (!gst_v4l2src_queue_frame(v4l2src, num))
+ if (!gst_v4l2src_queue_frame (v4l2src, num))
return NULL;
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
}
@@ -889,17 +876,18 @@ gst_v4l2src_get (GstPad *pad)
}
g_assert (num != -1);
- GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num, v4l2src->need_writes + 1);
- i = v4l2src->pool->buffers[num].buffer.bytesused > 0 ?
- v4l2src->pool->buffers[num].buffer.bytesused :
- v4l2src->pool->buffers[num].length;
+ GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num,
+ v4l2src->need_writes + 1);
+ i = v4l2src->pool->buffers[num].buffer.bytesused >
+ 0 ? v4l2src->pool->buffers[num].buffer.bytesused : v4l2src->pool->
+ buffers[num].length;
/* check if this is the last buffer in the queue. If so do a memcpy to put it back asap
to avoid framedrops and deadlocks because of stupid elements */
if (gst_atomic_int_read (&v4l2src->pool->refcount) == v4l2src->breq.count) {
GST_LOG_OBJECT (v4l2src, "using memcpy'd buffer");
buf = gst_buffer_new_and_alloc (i);
memcpy (GST_BUFFER_DATA (buf), v4l2src->pool->buffers[num].start, i);
- if (!gst_v4l2src_queue_frame(v4l2src, num)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, num)) {
gst_data_unref (GST_DATA (buf));
return NULL;
}
@@ -920,7 +908,8 @@ gst_v4l2src_get (GstPad *pad)
GST_BUFFER_DURATION (buf) = GST_SECOND / fps;
} else {
/* calculate time based on our own clock */
- GST_BUFFER_TIMESTAMP(buf) = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp) -
+ GST_BUFFER_TIMESTAMP (buf) =
+ GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp) -
v4l2src->substract_time;
}
if (v4l2src->need_writes > 0) {
@@ -932,135 +921,130 @@ gst_v4l2src_get (GstPad *pad)
}
v4l2src->handled++;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE], 0);
+ g_signal_emit (G_OBJECT (v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE],
+ 0);
return GST_DATA (buf);
}
static void
-gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
-
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
-
- switch (prop_id) {
- case ARG_NUMBUFS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->breq.count = g_value_get_int(value);
- }
- break;
-
- case ARG_USE_FIXED_FPS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->use_fixed_fps = g_value_get_boolean(value);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstV4l2Src *v4l2src;
+
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
+
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->breq.count = g_value_get_int (value);
+ }
+ break;
+
+ case ARG_USE_FIXED_FPS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->use_fixed_fps = g_value_get_boolean (value);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
+ GstV4l2Src *v4l2src;
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
- switch (prop_id) {
- case ARG_NUMBUFS:
- g_value_set_int(value, v4l2src->breq.count);
- break;
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ g_value_set_int (value, v4l2src->breq.count);
+ break;
- case ARG_BUFSIZE:
- g_value_set_int(value, v4l2src->format.fmt.pix.sizeimage);
- break;
+ case ARG_BUFSIZE:
+ g_value_set_int (value, v4l2src->format.fmt.pix.sizeimage);
+ break;
- case ARG_USE_FIXED_FPS:
- g_value_set_boolean(value, v4l2src->use_fixed_fps);
- break;
+ case ARG_USE_FIXED_FPS:
+ g_value_set_boolean (value, v4l2src->use_fixed_fps);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2src_change_state (GstElement *element)
+gst_v4l2src_change_state (GstElement * element)
{
- GstV4l2Src *v4l2src;
- gint transition = GST_STATE_TRANSITION (element);
- GstElementStateReturn parent_return;
- GTimeVal time;
-
- g_return_val_if_fail(GST_IS_V4L2SRC(element), GST_STATE_FAILURE);
- v4l2src = GST_V4L2SRC(element);
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state) {
- parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
- if (parent_return != GST_STATE_SUCCESS)
- return parent_return;
- }
+ GstV4l2Src *v4l2src;
+ gint transition = GST_STATE_TRANSITION (element);
+ GstElementStateReturn parent_return;
+ GTimeVal time;
- switch (transition) {
- case GST_STATE_NULL_TO_READY:
- if (!gst_v4l2src_get_capture(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_PAUSED:
- v4l2src->handled = 0;
- v4l2src->need_writes = 0;
- v4l2src->substract_time = 0;
- /* buffer setup moved to capsnego */
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- /* queue all buffer, start streaming capture */
- if (!gst_v4l2src_capture_start(v4l2src))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- v4l2src->last_seq = 0;
- break;
- case GST_STATE_PLAYING_TO_PAUSED:
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- /* de-queue all queued buffers */
- if (!gst_v4l2src_capture_stop(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_PAUSED_TO_READY:
- /* stop capturing, unmap all buffers */
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- }
+ g_return_val_if_fail (GST_IS_V4L2SRC (element), GST_STATE_FAILURE);
+ v4l2src = GST_V4L2SRC (element);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state) {
+ parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ if (parent_return != GST_STATE_SUCCESS)
+ return parent_return;
+ }
- return GST_STATE_SUCCESS;
+ switch (transition) {
+ case GST_STATE_NULL_TO_READY:
+ if (!gst_v4l2src_get_capture (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_PAUSED:
+ v4l2src->handled = 0;
+ v4l2src->need_writes = 0;
+ v4l2src->substract_time = 0;
+ /* buffer setup moved to capsnego */
+ break;
+ case GST_STATE_PAUSED_TO_PLAYING:
+ /* queue all buffer, start streaming capture */
+ if (!gst_v4l2src_capture_start (v4l2src))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ v4l2src->last_seq = 0;
+ break;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ /* de-queue all queued buffers */
+ if (!gst_v4l2src_capture_stop (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ /* stop capturing, unmap all buffers */
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ }
+
+ return GST_STATE_SUCCESS;
}
static void
-gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock)
+gst_v4l2src_set_clock (GstElement * element, GstClock * clock)
{
- GST_V4L2SRC(element)->clock = clock;
+ GST_V4L2SRC (element)->clock = clock;
}
-
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index ca528d1e..d68f9cf8 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -38,72 +38,75 @@ GST_DEBUG_CATEGORY_EXTERN (v4l2src_debug);
#define GST_IS_V4L2SRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4L2SRC))
-typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
-typedef struct _GstV4l2Buffer GstV4l2Buffer;
-typedef struct _GstV4l2Src GstV4l2Src;
-typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
+typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
+typedef struct _GstV4l2Buffer GstV4l2Buffer;
+typedef struct _GstV4l2Src GstV4l2Src;
+typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
/* global info */
-struct _GstV4l2BufferPool {
- GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
- gint video_fd;
- guint buffer_count;
- GstV4l2Buffer * buffers;
+struct _GstV4l2BufferPool
+{
+ GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
+ gint video_fd;
+ guint buffer_count;
+ GstV4l2Buffer *buffers;
};
-struct _GstV4l2Buffer {
- struct v4l2_buffer buffer;
- guint8 * start;
- guint length;
- GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
- GstV4l2BufferPool * pool;
+struct _GstV4l2Buffer
+{
+ struct v4l2_buffer buffer;
+ guint8 *start;
+ guint length;
+ GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
+ GstV4l2BufferPool *pool;
};
-struct _GstV4l2Src {
- GstV4l2Element v4l2element;
+struct _GstV4l2Src
+{
+ GstV4l2Element v4l2element;
- /* pads */
- GstPad *srcpad;
+ /* pads */
+ GstPad *srcpad;
- /* internal lists */
- GSList *formats; /* list of available capture formats */
+ /* internal lists */
+ GSList *formats; /* list of available capture formats */
- /* buffers */
- GstV4l2BufferPool *pool;
+ /* buffers */
+ GstV4l2BufferPool *pool;
- struct v4l2_requestbuffers breq;
- struct v4l2_format format;
+ struct v4l2_requestbuffers breq;
+ struct v4l2_format format;
- /* True if we want to stop */
- gboolean quit;
+ /* True if we want to stop */
+ gboolean quit;
- /* A/V sync... frame counter and internal cache */
- gulong handled;
- gint need_writes;
- GstBuffer *cached_buffer;
- gulong last_seq;
+ /* A/V sync... frame counter and internal cache */
+ gulong handled;
+ gint need_writes;
+ GstBuffer *cached_buffer;
+ gulong last_seq;
- /* clock */
- GstClock *clock;
-
- /* time to substract from clock time to get back to timestamp */
- GstClockTime substract_time;
+ /* clock */
+ GstClock *clock;
- /* how are we going to push buffers? */
- gboolean use_fixed_fps;
+ /* time to substract from clock time to get back to timestamp */
+ GstClockTime substract_time;
+
+ /* how are we going to push buffers? */
+ gboolean use_fixed_fps;
};
-struct _GstV4l2SrcClass {
- GstV4l2ElementClass parent_class;
+struct _GstV4l2SrcClass
+{
+ GstV4l2ElementClass parent_class;
- void (*frame_capture) (GObject *object);
- void (*frame_drop) (GObject *object);
- void (*frame_insert) (GObject *object);
- void (*frame_lost) (GObject *object,
- gint num_lost);
+ void (*frame_capture) (GObject * object);
+ void (*frame_drop) (GObject * object);
+ void (*frame_insert) (GObject * object);
+ void (*frame_lost) (GObject * object, gint num_lost);
};
-GType gst_v4l2src_get_type(void);
+GType gst_v4l2src_get_type (void);
#endif /* __GST_V4L2SRC_H__ */
diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c
index f4f2cd64..5d5626f2 100644
--- a/sys/v4l2/gstv4l2tuner.c
+++ b/sys/v4l2/gstv4l2tuner.c
@@ -30,33 +30,28 @@
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass);
-static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel);
+static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *
+ klass);
+static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel);
-static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass);
-static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm);
+static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass);
+static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm);
-static const GList *
- gst_v4l2_tuner_list_channels (GstTuner *mixer);
-static void gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel);
-static GstTunerChannel *
- gst_v4l2_tuner_get_channel (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_channels (GstTuner * mixer);
+static void gst_v4l2_tuner_set_channel (GstTuner * mixer,
+ GstTunerChannel * channel);
+static GstTunerChannel *gst_v4l2_tuner_get_channel (GstTuner * mixer);
-static const GList *
- gst_v4l2_tuner_list_norms (GstTuner *mixer);
-static void gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm);
-static GstTunerNorm *
- gst_v4l2_tuner_get_norm (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_norms (GstTuner * mixer);
+static void gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm);
+static GstTunerNorm *gst_v4l2_tuner_get_norm (GstTuner * mixer);
-static void gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency);
-static gulong gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel);
-static gint gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel);
+static void gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency);
+static gulong gst_v4l2_tuner_get_frequency (GstTuner * mixer,
+ GstTunerChannel * channel);
+static gint gst_v4l2_tuner_signal_strength (GstTuner * mixer,
+ GstTunerChannel * channel);
static GstTunerNormClass *norm_parent_class = NULL;
static GstTunerChannelClass *channel_parent_class = NULL;
@@ -82,21 +77,20 @@ gst_v4l2_tuner_channel_get_type (void)
gst_v4l2_tuner_channel_type =
g_type_register_static (GST_TYPE_TUNER_CHANNEL,
- "GstV4l2TunerChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2TunerChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_tuner_channel_type;
}
static void
-gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass)
+gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass * klass)
{
channel_parent_class = g_type_class_ref (GST_TYPE_TUNER_CHANNEL);
}
static void
-gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel)
+gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel)
{
channel->index = 0;
channel->tuner = 0;
@@ -124,27 +118,26 @@ gst_v4l2_tuner_norm_get_type (void)
gst_v4l2_tuner_norm_type =
g_type_register_static (GST_TYPE_TUNER_NORM,
- "GstV4l2TunerNorm",
- &v4l2_tuner_norm_info, 0);
+ "GstV4l2TunerNorm", &v4l2_tuner_norm_info, 0);
}
return gst_v4l2_tuner_norm_type;
}
static void
-gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass)
+gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass)
{
norm_parent_class = g_type_class_ref (GST_TYPE_TUNER_NORM);
}
static void
-gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm)
+gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm)
{
norm->index = 0;
}
void
-gst_v4l2_tuner_interface_init (GstTunerClass *klass)
+gst_v4l2_tuner_interface_init (GstTunerClass * klass)
{
/* default virtual functions */
klass->list_channels = gst_v4l2_tuner_list_channels;
@@ -161,7 +154,7 @@ gst_v4l2_tuner_interface_init (GstTunerClass *klass)
}
static gboolean
-gst_v4l2_tuner_is_sink (GstV4l2Element *v4l2element)
+gst_v4l2_tuner_is_sink (GstV4l2Element * v4l2element)
{
const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
GstPadDirection dir = GST_PAD_UNKNOWN;
@@ -174,8 +167,8 @@ gst_v4l2_tuner_is_sink (GstV4l2Element *v4l2element)
}
static gboolean
-gst_v4l2_tuner_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2TunerChannel *v4l2channel)
+gst_v4l2_tuner_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2TunerChannel * v4l2channel)
{
const GList *item;
@@ -187,15 +180,14 @@ gst_v4l2_tuner_contains_channel (GstV4l2Element *v4l2element,
}
static const GList *
-gst_v4l2_tuner_list_channels (GstTuner *mixer)
+gst_v4l2_tuner_list_channels (GstTuner * mixer)
{
/* ... or output, if we're a sink... */
return GST_V4L2ELEMENT (mixer)->channels;
}
static void
-gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_set_channel (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -205,7 +197,7 @@ gst_v4l2_tuner_set_channel (GstTuner *mixer,
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
/* ... or output, if we're a sink... */
- if (gst_v4l2_tuner_is_sink (v4l2element) ?
+ if (gst_v4l2_tuner_is_sink (v4l2element) ?
gst_v4l2_set_output (v4l2element, v4l2channel->index) :
gst_v4l2_set_input (v4l2element, v4l2channel->index)) {
gst_tuner_channel_changed (mixer, channel);
@@ -214,7 +206,7 @@ gst_v4l2_tuner_set_channel (GstTuner *mixer,
}
static GstTunerChannel *
-gst_v4l2_tuner_get_channel (GstTuner *mixer)
+gst_v4l2_tuner_get_channel (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
@@ -238,8 +230,8 @@ gst_v4l2_tuner_get_channel (GstTuner *mixer)
}
static gboolean
-gst_v4l2_tuner_contains_norm (GstV4l2Element *v4l2element,
- GstV4l2TunerNorm *v4l2norm)
+gst_v4l2_tuner_contains_norm (GstV4l2Element * v4l2element,
+ GstV4l2TunerNorm * v4l2norm)
{
const GList *item;
@@ -251,14 +243,13 @@ gst_v4l2_tuner_contains_norm (GstV4l2Element *v4l2element,
}
static const GList *
-gst_v4l2_tuner_list_norms (GstTuner *mixer)
+gst_v4l2_tuner_list_norms (GstTuner * mixer)
{
return GST_V4L2ELEMENT (mixer)->norms;
}
static void
-gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm)
+gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerNorm *v4l2norm = GST_V4L2_TUNER_NORM (norm);
@@ -269,12 +260,12 @@ gst_v4l2_tuner_set_norm (GstTuner *mixer,
if (gst_v4l2_set_norm (v4l2element, v4l2norm->index)) {
gst_tuner_norm_changed (mixer, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
}
static GstTunerNorm *
-gst_v4l2_tuner_get_norm (GstTuner *mixer)
+gst_v4l2_tuner_get_norm (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
@@ -294,9 +285,8 @@ gst_v4l2_tuner_get_norm (GstTuner *mixer)
}
static void
-gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency)
+gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -305,7 +295,7 @@ gst_v4l2_tuner_set_frequency (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY));
+ GST_TUNER_CHANNEL_FREQUENCY));
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
gst_v4l2_get_input (v4l2element, &chan);
@@ -313,14 +303,13 @@ gst_v4l2_tuner_set_frequency (GstTuner *mixer,
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (gst_v4l2_set_frequency (v4l2element, v4l2channel->tuner, frequency)) {
gst_tuner_frequency_changed (mixer, channel, frequency);
- g_object_notify (G_OBJECT (v4l2element), "frequency");
+ g_object_notify (G_OBJECT (v4l2element), "frequency");
}
}
}
static gulong
-gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_get_frequency (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -330,9 +319,9 @@ gst_v4l2_tuner_get_frequency (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
@@ -344,8 +333,7 @@ gst_v4l2_tuner_get_frequency (GstTuner *mixer,
}
static gint
-gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_signal_strength (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
@@ -355,9 +343,9 @@ gst_v4l2_tuner_signal_strength (GstTuner *mixer,
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
diff --git a/sys/v4l2/gstv4l2tuner.h b/sys/v4l2/gstv4l2tuner.h
index a768ea2f..729fe221 100644
--- a/sys/v4l2/gstv4l2tuner.h
+++ b/sys/v4l2/gstv4l2tuner.h
@@ -28,7 +28,6 @@
#include "gstv4l2element.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_TUNER_CHANNEL \
(gst_v4l2_tuner_channel_get_type ())
#define GST_V4L2_TUNER_CHANNEL(obj) \
@@ -41,16 +40,17 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_CHANNEL))
#define GST_IS_V4L2_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_CHANNEL))
-
-typedef struct _GstV4l2TunerChannel {
+ typedef struct _GstV4l2TunerChannel
+{
GstTunerChannel parent;
- guint32 index;
- guint32 tuner;
- guint32 audio;
+ guint32 index;
+ guint32 tuner;
+ guint32 audio;
} GstV4l2TunerChannel;
-typedef struct _GstV4l2TunerChannelClass {
+typedef struct _GstV4l2TunerChannelClass
+{
GstTunerChannelClass parent;
} GstV4l2TunerChannelClass;
@@ -67,19 +67,21 @@ typedef struct _GstV4l2TunerChannelClass {
#define GST_IS_V4L2_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_NORM))
-typedef struct _GstV4l2TunerNorm {
+typedef struct _GstV4l2TunerNorm
+{
GstTunerNorm parent;
- v4l2_std_id index;
+ v4l2_std_id index;
} GstV4l2TunerNorm;
-typedef struct _GstV4l2TunerNormClass {
+typedef struct _GstV4l2TunerNormClass
+{
GstTunerNormClass parent;
} GstV4l2TunerNormClass;
-GType gst_v4l2_tuner_channel_get_type (void);
-GType gst_v4l2_tuner_norm_get_type (void);
+GType gst_v4l2_tuner_channel_get_type (void);
+GType gst_v4l2_tuner_norm_get_type (void);
-void gst_v4l2_tuner_interface_init (GstTunerClass *klass);
+void gst_v4l2_tuner_interface_init (GstTunerClass * klass);
#endif /* __GST_V4L2_TUNER_H__ */
diff --git a/sys/v4l2/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2xoverlay.c
index 10c5f77b..1af62cc1 100644
--- a/sys/v4l2/gstv4l2xoverlay.c
+++ b/sys/v4l2/gstv4l2xoverlay.c
@@ -31,24 +31,23 @@
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id);
+static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay,
+ XID xwindow_id);
void
-gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass)
+gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass)
{
/* default virtual functions */
klass->set_xwindow_id = gst_v4l2_xoverlay_set_xwindow_id;
}
GstXWindowListener *
-gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element)
{
- GstXWindowListener *xwin =
- gst_x_window_listener_new (NULL,
- (MapWindowFunc) gst_v4l2_enable_overlay,
- (SetWindowFunc) gst_v4l2_set_window,
- (gpointer) v4l2element);
+ GstXWindowListener *xwin = gst_x_window_listener_new (NULL,
+ (MapWindowFunc) gst_v4l2_enable_overlay,
+ (SetWindowFunc) gst_v4l2_set_window,
+ (gpointer) v4l2element);
v4l2element->overlay = xwin;
v4l2element->xwindow_id = 0;
@@ -57,7 +56,7 @@ gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
}
void
-gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element)
{
gst_v4l2_xoverlay_close (v4l2element);
g_object_unref (G_OBJECT (v4l2element->overlay));
@@ -65,7 +64,7 @@ gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
}
void
-gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
@@ -73,22 +72,20 @@ gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
xwin->display_name = g_strdup (v4l2element->display);
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
}
void
-gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
if (xwin != NULL) {
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
@@ -98,8 +95,7 @@ gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
}
static void
-gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id)
+gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
GstXWindowListener *xwin = v4l2element->overlay;
@@ -110,9 +106,7 @@ gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
@@ -120,9 +114,7 @@ gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
diff --git a/sys/v4l2/gstv4l2xoverlay.h b/sys/v4l2/gstv4l2xoverlay.h
index cfcdfd35..d5cb7796 100644
--- a/sys/v4l2/gstv4l2xoverlay.h
+++ b/sys/v4l2/gstv4l2xoverlay.h
@@ -27,16 +27,13 @@
#include "gstv4l2element.h"
-G_BEGIN_DECLS
+G_BEGIN_DECLS void gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass);
-void gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass);
-
-GstXWindowListener *
- gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element);
+GstXWindowListener *gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element);
/* signal handlers */
-void gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element);
+void gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element);
#endif /* __GST_V4L2_X_OVERLAY_H__ */
diff --git a/sys/v4l2/v4l2-overlay_calls.c b/sys/v4l2/v4l2-overlay_calls.c
index 4d948d0b..d4a10ab7 100644
--- a/sys/v4l2/v4l2-overlay_calls.c
+++ b/sys/v4l2/v4l2-overlay_calls.c
@@ -43,39 +43,37 @@
******************************************************/
gboolean
-gst_v4l2_set_display (GstV4l2Element *v4l2element)
+gst_v4l2_set_display (GstV4l2Element * v4l2element)
{
- gchar *buff;
-
- if (v4l2element->display)
- g_free(v4l2element->display);
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
-
- DEBUG("trying to set overlay to '%s'", v4l2element->display);
-
- /* start v4l-conf */
- buff = g_strdup_printf("v4l-conf -q -c %s -d %s",
- v4l2element->device, v4l2element->display);
-
- switch (system(buff)) {
- case -1:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Could not start v4l-conf.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- case 0:
- break;
- default:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Executing v4l-conf failed.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- }
-
- g_free(buff);
- return TRUE;
+ gchar *buff;
+
+ if (v4l2element->display)
+ g_free (v4l2element->display);
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
+
+ DEBUG ("trying to set overlay to '%s'", v4l2element->display);
+
+ /* start v4l-conf */
+ buff = g_strdup_printf ("v4l-conf -q -c %s -d %s",
+ v4l2element->device, v4l2element->display);
+
+ switch (system (buff)) {
+ case -1:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ case 0:
+ break;
+ default:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ }
+
+ g_free (buff);
+ return TRUE;
}
@@ -86,38 +84,33 @@ gst_v4l2_set_display (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_set_window (GstElement *element,
- gint x,
- gint y,
- gint w,
- gint h,
- struct v4l2_clip *clips,
- gint num_clips)
+gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip * clips, gint num_clips)
{
- struct v4l2_format fmt;
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(element);
-
- DEBUG("trying to set video window to %dx%d,%d,%d", x,y,w,h);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- fmt.type = V4L2_CAP_VIDEO_OVERLAY;
- fmt.fmt.win.clipcount = 0;
- fmt.fmt.win.w.left = x;
- fmt.fmt.win.w.top = y;
- fmt.fmt.win.w.width = w;
- fmt.fmt.win.w.height = h;
- fmt.fmt.win.clips = clips;
- fmt.fmt.win.clipcount = num_clips;
- fmt.fmt.win.bitmap = NULL;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to set the video window: %s", g_strerror (errno)));
- return FALSE;
- }
-
- return TRUE;
+ struct v4l2_format fmt;
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (element);
+
+ DEBUG ("trying to set video window to %dx%d,%d,%d", x, y, w, h);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ fmt.type = V4L2_CAP_VIDEO_OVERLAY;
+ fmt.fmt.win.clipcount = 0;
+ fmt.fmt.win.w.left = x;
+ fmt.fmt.win.w.top = y;
+ fmt.fmt.win.w.width = w;
+ fmt.fmt.win.w.height = h;
+ fmt.fmt.win.clips = clips;
+ fmt.fmt.win.clipcount = num_clips;
+ fmt.fmt.win.bitmap = NULL;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to set the video window: %s", g_strerror (errno)));
+ return FALSE;
+ }
+
+ return TRUE;
}
@@ -128,21 +121,20 @@ gst_v4l2_set_window (GstElement *element,
******************************************************/
gboolean
-gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable)
+gst_v4l2_enable_overlay (GstV4l2Element * v4l2element, gboolean enable)
{
- gint doit = enable?1:0;
+ gint doit = enable ? 1 : 0;
- DEBUG("trying to %s overlay display", enable?"enable":"disable");
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
+ DEBUG ("trying to %s overlay display", enable ? "enable" : "disable");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to %s overlay display: %s",
- enable?"enable":"disable", g_strerror (errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to %s overlay display: %s",
+ enable ? "enable" : "disable", g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index f7c3d3a0..f75ea550 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -49,19 +49,19 @@
******************************************************/
static gboolean
-gst_v4l2_get_capabilities (GstV4l2Element *v4l2element)
+gst_v4l2_get_capabilities (GstV4l2Element * v4l2element)
{
- DEBUG("getting capabilities");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Error getting %s capabilities: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting capabilities");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Error getting %s capabilities: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -72,288 +72,269 @@ gst_v4l2_get_capabilities (GstV4l2Element *v4l2element)
******************************************************/
static gboolean
-gst_v4l2_fill_lists (GstV4l2Element *v4l2element)
+gst_v4l2_fill_lists (GstV4l2Element * v4l2element)
{
- gint n;
- const GList *pads =
- gst_element_get_pad_list (GST_ELEMENT (v4l2element));
- GstPadDirection dir = GST_PAD_UNKNOWN;
-
- DEBUG("getting enumerations");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- /* sinks have outputs, all others have inputs */
- if (pads && g_list_length ((GList *) pads) == 1)
- dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
-
- if (dir != GST_PAD_SINK) {
- /* and now, the inputs */
- for (n=0;;n++) {
- struct v4l2_input input;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- input.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMINPUT,
- &input) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in input enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel =
- g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(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(v4l2element->video_fd, VIDIOC_G_TUNER,
- &vtun) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get tuner %d settings on %s: %s",
- input.tuner,
- v4l2element->device,
- g_strerror (errno)));
- g_object_unref(G_OBJECT(channel));
- return FALSE;
- }
- channel->min_frequency = vtun.rangelow;
- channel->max_frequency = vtun.rangehigh;
- 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;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
- } else {
- /* outputs */
- for (n=0;;n++) {
- struct v4l2_output output;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- output.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMOUTPUT,
- &output) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in output enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(output.name);
- channel->flags = GST_TUNER_CHANNEL_OUTPUT;
- v4l2channel->index = n;
- 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;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
+ gint n;
+ const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
+ GstPadDirection dir = GST_PAD_UNKNOWN;
+
+ DEBUG ("getting enumerations");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ /* sinks have outputs, all others have inputs */
+ if (pads && g_list_length ((GList *) pads) == 1)
+ dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
+
+ if (dir != GST_PAD_SINK) {
+ /* and now, the inputs */
+ for (n = 0;; n++) {
+ struct v4l2_input input;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ input.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in input enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
-
- /* norms... */
- for (n=0;;n++) {
- struct v4l2_standard standard;
- GstV4l2TunerNorm *v4l2norm;
- GstTunerNorm *norm;
-
- standard.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in norm enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2norm = g_object_new(GST_TYPE_V4L2_TUNER_NORM, NULL);
- norm = GST_TUNER_NORM (v4l2norm);
- norm->label = g_strdup(standard.name);
- norm->fps = (gfloat) standard.frameperiod.denominator /
- standard.frameperiod.numerator;
- v4l2norm->index = standard.id;
-
- v4l2element->norms = g_list_append(v4l2element->norms,
- (gpointer) norm);
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (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 (v4l2element->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get tuner %d settings on %s: %s",
+ input.tuner, v4l2element->device, g_strerror (errno)));
+ g_object_unref (G_OBJECT (channel));
+ return FALSE;
+ }
+ channel->min_frequency = vtun.rangelow;
+ channel->max_frequency = vtun.rangehigh;
+ 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;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ } else {
+ /* outputs */
+ for (n = 0;; n++) {
+ struct v4l2_output output;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ output.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMOUTPUT, &output) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in output enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (output.name);
+ channel->flags = GST_TUNER_CHANNEL_OUTPUT;
+ v4l2channel->index = n;
+ 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;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ }
- /* and lastly, controls+menus (if appropriate) */
- for (n=V4L2_CID_BASE;;n++) {
- struct v4l2_queryctrl control;
- GstV4l2ColorBalanceChannel *v4l2channel;
- GstColorBalanceChannel *channel;
-
- /* hacky... */
- if (n == V4L2_CID_LASTP1)
- n = V4L2_CID_PRIVATE_BASE;
-
- control.id = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
- if (errno == EINVAL) {
- if (n < V4L2_CID_PRIVATE_BASE)
- continue;
- else
- break;
- } else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in control enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- if (control.flags & V4L2_CTRL_FLAG_DISABLED)
- continue;
-
- 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:
- /* we only handle these for now */
- break;
- default:
- DEBUG("ControlID %s (%d) unhandled, FIXME",
- control.name, n);
- control.id++;
- break;
- }
- if (n != control.id)
- continue;
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL,
- NULL);
- channel = GST_COLOR_BALANCE_CHANNEL(v4l2channel);
- channel->label = g_strdup(control.name);
- v4l2channel->index = n;
+ /* norms... */
+ for (n = 0;; n++) {
+ struct v4l2_standard standard;
+ GstV4l2TunerNorm *v4l2norm;
+ GstTunerNorm *norm;
+
+ standard.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in norm enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+
+ v4l2norm = g_object_new (GST_TYPE_V4L2_TUNER_NORM, NULL);
+ norm = GST_TUNER_NORM (v4l2norm);
+ norm->label = g_strdup (standard.name);
+ norm->fps = (gfloat) standard.frameperiod.denominator /
+ standard.frameperiod.numerator;
+ v4l2norm->index = standard.id;
+
+ v4l2element->norms = g_list_append (v4l2element->norms, (gpointer) norm);
+ }
+
+ /* and lastly, controls+menus (if appropriate) */
+ for (n = V4L2_CID_BASE;; n++) {
+ struct v4l2_queryctrl control;
+ GstV4l2ColorBalanceChannel *v4l2channel;
+ GstColorBalanceChannel *channel;
+
+ /* hacky... */
+ if (n == V4L2_CID_LASTP1)
+ n = V4L2_CID_PRIVATE_BASE;
+
+ control.id = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
+ if (errno == EINVAL) {
+ if (n < V4L2_CID_PRIVATE_BASE)
+ continue;
+ else
+ break;
+ } else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in control enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ if (control.flags & V4L2_CTRL_FLAG_DISABLED)
+ continue;
+
+ 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:
+ /* we only handle these for now */
+ break;
+ default:
+ DEBUG ("ControlID %s (%d) unhandled, FIXME", control.name, n);
+ control.id++;
+ break;
+ }
+ if (n != control.id)
+ continue;
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL, NULL);
+ channel = GST_COLOR_BALANCE_CHANNEL (v4l2channel);
+ channel->label = g_strdup (control.name);
+ v4l2channel->index = n;
#if 0
- if (control.type == V4L2_CTRL_TYPE_MENU) {
- struct v4l2_querymenu menu, *mptr;
- int i;
- menu.id = n;
- for (i=0;;i++) {
- menu.index = i;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in menu enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- mptr = g_malloc(sizeof(menu));
- memcpy(mptr, &menu, sizeof(menu));
- menus = g_list_append(menus, mptr);
- }
- }
- v4l2element->menus = g_list_append(v4l2element->menus, menus);
+ if (control.type == V4L2_CTRL_TYPE_MENU) {
+ struct v4l2_querymenu menu, *mptr;
+ int i;
+
+ menu.id = n;
+ for (i = 0;; i++) {
+ menu.index = i;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in menu enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ mptr = g_malloc (sizeof (menu));
+ memcpy (mptr, &menu, sizeof (menu));
+ menus = g_list_append (menus, mptr);
+ }
+ }
+ v4l2element->menus = g_list_append (v4l2element->menus, menus);
#endif
- switch (control.type) {
- case V4L2_CTRL_TYPE_INTEGER:
- channel->min_value = control.minimum;
- channel->max_value = control.maximum;
- break;
- case V4L2_CTRL_TYPE_BOOLEAN:
- channel->min_value = FALSE;
- channel->max_value = TRUE;
- break;
- default:
- channel->min_value =
- channel->max_value = 0;
- break;
- }
-
- v4l2element->colors = g_list_append(v4l2element->colors,
- (gpointer) channel);
- }
+ switch (control.type) {
+ case V4L2_CTRL_TYPE_INTEGER:
+ channel->min_value = control.minimum;
+ channel->max_value = control.maximum;
+ break;
+ case V4L2_CTRL_TYPE_BOOLEAN:
+ channel->min_value = FALSE;
+ channel->max_value = TRUE;
+ break;
+ default:
+ channel->min_value = channel->max_value = 0;
+ break;
+ }
- return TRUE;
+ v4l2element->colors = g_list_append (v4l2element->colors,
+ (gpointer) channel);
+ }
+
+ return TRUE;
}
static void
-gst_v4l2_empty_lists (GstV4l2Element *v4l2element)
+gst_v4l2_empty_lists (GstV4l2Element * v4l2element)
{
- DEBUG("deleting enumerations");
+ DEBUG ("deleting enumerations");
- g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->channels);
- v4l2element->channels = NULL;
+ g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->channels);
+ v4l2element->channels = NULL;
- g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->norms);
- v4l2element->norms = NULL;
+ g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->norms);
+ v4l2element->norms = NULL;
- g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->colors);
- v4l2element->colors = NULL;
+ g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->colors);
+ v4l2element->colors = NULL;
}
/* FIXME: move this stuff to gstv4l2tuner.c? */
static void
-gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
+gst_v4l2_set_defaults (GstV4l2Element * v4l2element)
{
GstTunerNorm *norm = NULL;
GstTunerChannel *channel = NULL;
GstTuner *tuner = GST_TUNER (v4l2element);
-
+
if (v4l2element->norm)
norm = gst_tuner_find_norm_by_name (tuner, v4l2element->norm);
if (norm) {
@@ -362,18 +343,19 @@ gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
norm = GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2element)));
v4l2element->norm = g_strdup (norm->label);
gst_tuner_norm_changed (tuner, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
-
- if (v4l2element->channel)
+
+ if (v4l2element->channel)
channel = gst_tuner_find_channel_by_name (tuner, v4l2element->channel);
if (channel) {
gst_tuner_set_channel (tuner, channel);
} else {
- channel = GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
+ channel =
+ GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
v4l2element->channel = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
- g_object_notify (G_OBJECT (v4l2element), "channel");
+ g_object_notify (G_OBJECT (v4l2element), "channel");
}
if (v4l2element->frequency != 0) {
gst_tuner_set_frequency (tuner, channel, v4l2element->frequency);
@@ -396,61 +378,61 @@ gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_open (GstV4l2Element *v4l2element)
+gst_v4l2_open (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to open device %s", v4l2element->device);
- GST_V4L2_CHECK_NOT_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- /* be sure we have a device */
- if (!v4l2element->device)
- v4l2element->device = g_strdup("/dev/video");
-
- /* open the device */
- v4l2element->video_fd = open(v4l2element->device, O_RDWR);
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
- (_("Could not open device \"%s\" for reading and writing."), v4l2element->device),
- GST_ERROR_SYSTEM);
- goto error;
- }
+ DEBUG ("Trying to open device %s", v4l2element->device);
+ GST_V4L2_CHECK_NOT_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ /* be sure we have a device */
+ if (!v4l2element->device)
+ v4l2element->device = g_strdup ("/dev/video");
+
+ /* open the device */
+ v4l2element->video_fd = open (v4l2element->device, O_RDWR);
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
+ (_("Could not open device \"%s\" for reading and writing."),
+ v4l2element->device), GST_ERROR_SYSTEM);
+ goto error;
+ }
- /* get capabilities */
- if (!gst_v4l2_get_capabilities(v4l2element)) {
- goto error;
- }
+ /* get capabilities */
+ if (!gst_v4l2_get_capabilities (v4l2element)) {
+ goto error;
+ }
- /* do we need to be a capture device? */
- if (GST_IS_V4L2SRC(v4l2element) &&
- !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
- (_("Device \"%s\" is not a capture device."), v4l2element->device),
- ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
- goto error;
- }
+ /* do we need to be a capture device? */
+ if (GST_IS_V4L2SRC (v4l2element) &&
+ !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
+ (_("Device \"%s\" is not a capture device."), v4l2element->device),
+ ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
+ goto error;
+ }
- /* create enumerations */
- if (!gst_v4l2_fill_lists(v4l2element))
- goto error;
+ /* create enumerations */
+ if (!gst_v4l2_fill_lists (v4l2element))
+ goto error;
- /* set defaults */
- gst_v4l2_set_defaults (v4l2element);
+ /* set defaults */
+ gst_v4l2_set_defaults (v4l2element);
- GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
- v4l2element->vcap.card, v4l2element->device);
+ GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
+ v4l2element->vcap.card, v4l2element->device);
- return TRUE;
+ return TRUE;
error:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
- }
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
+ }
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return FALSE;
+ return FALSE;
}
@@ -461,20 +443,20 @@ error:
******************************************************/
gboolean
-gst_v4l2_close (GstV4l2Element *v4l2element)
+gst_v4l2_close (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to close %s", v4l2element->device);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
+ DEBUG ("Trying to close %s", v4l2element->device);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return TRUE;
+ return TRUE;
}
@@ -485,20 +467,19 @@ gst_v4l2_close (GstV4l2Element *v4l2element)
******************************************************/
gboolean
-gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm)
+gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm)
{
- DEBUG("getting norm");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get the current norm for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting norm");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get the current norm for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -509,21 +490,20 @@ gst_v4l2_get_norm (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm)
+gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm)
{
- DEBUG("trying to set norm to %llx", norm);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set norm 0x%llx for device %s: %s",
- norm, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set norm to %llx", norm);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set norm 0x%llx for device %s: %s",
+ norm, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -534,24 +514,23 @@ gst_v4l2_set_norm (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input)
+gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input)
{
- gint n;
+ gint n;
- DEBUG("trying to get input");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get input");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current input on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current input on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *input = n;
+ *input = n;
- return TRUE;
+ return TRUE;
}
@@ -562,21 +541,20 @@ gst_v4l2_get_input (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input)
+gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input)
{
- DEBUG("trying to set input to %d", input);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set input %d on device %s: %s",
- input, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set input to %d", input);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set input %d on device %s: %s",
+ input, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -587,24 +565,23 @@ gst_v4l2_set_input (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output)
+gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output)
{
- gint n;
+ gint n;
- DEBUG("trying to get output");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get output");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current output on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current output on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *output = n;
+ *output = n;
- return TRUE;
+ return TRUE;
}
@@ -615,21 +592,20 @@ gst_v4l2_get_output (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output)
+gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output)
{
- DEBUG("trying to set output to %d", output);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set output %d on device %s: %s",
- output, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set output to %d", output);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set output %d on device %s: %s",
+ output, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -640,26 +616,25 @@ gst_v4l2_set_output (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency)
+gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency)
{
- struct v4l2_frequency freq;
+ struct v4l2_frequency freq;
- DEBUG("getting current tuner frequency");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("getting current tuner frequency");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- freq.tuner = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current tuner frequency for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ freq.tuner = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current tuner frequency for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *frequency = freq.frequency;
+ *frequency = freq.frequency;
- return TRUE;
+ return TRUE;
}
@@ -670,29 +645,28 @@ gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency)
+gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency)
{
- struct v4l2_frequency freq;
-
- DEBUG("setting current tuner frequency to %lu", frequency);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- freq.tuner = tunernum;
- /* fill in type - ignore error */
- ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
- freq.frequency = frequency;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set tuner frequency to %lu for device %s: %s",
- frequency, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ struct v4l2_frequency freq;
+
+ DEBUG ("setting current tuner frequency to %lu", frequency);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ freq.tuner = tunernum;
+ /* fill in type - ignore error */
+ ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
+ freq.frequency = frequency;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set tuner frequency to %lu for device %s: %s",
+ frequency, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -703,26 +677,25 @@ gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal_strength)
+gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal_strength)
{
- struct v4l2_tuner tuner;
+ struct v4l2_tuner tuner;
- DEBUG("trying to get signal strength");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get signal strength");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- tuner.index = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get signal strength for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ tuner.index = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get signal strength for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *signal_strength = tuner.signal;
+ *signal_strength = tuner.signal;
- return TRUE;
+ return TRUE;
}
@@ -733,28 +706,27 @@ gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- int *value)
+gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, int *value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("getting value of attribute %d", attribute_num);
+ DEBUG ("getting value of attribute %d", attribute_num);
- control.id = attribute_num;
+ control.id = attribute_num;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get value for control %d on device %s: %s",
- attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get value for control %d on device %s: %s",
+ attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *value = control.value;
+ *value = control.value;
- return TRUE;
+ return TRUE;
}
@@ -765,26 +737,24 @@ gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
******************************************************/
gboolean
-gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- const int value)
+gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, const int value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("setting value of attribute %d to %d", attribute_num, value);
+ DEBUG ("setting value of attribute %d to %d", attribute_num, value);
- control.id = attribute_num;
- control.value = value;
+ control.id = attribute_num;
+ control.value = value;
- if (ioctl(v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set value %d for control %d on device %s: %s",
- value, attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set value %d for control %d on device %s: %s",
+ value, attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-
diff --git a/sys/v4l2/v4l2_calls.h b/sys/v4l2/v4l2_calls.h
index 428c57aa..488e7bca 100644
--- a/sys/v4l2/v4l2_calls.h
+++ b/sys/v4l2/v4l2_calls.h
@@ -82,50 +82,36 @@
/* open/close the device */
-gboolean gst_v4l2_open (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_close (GstV4l2Element *v4l2element);
+gboolean gst_v4l2_open (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_close (GstV4l2Element * v4l2element);
/* norm/input/output */
-gboolean gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm);
-gboolean gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm);
-gboolean gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input);
-gboolean gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input);
-gboolean gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output);
-gboolean gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output);
+gboolean gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm);
+gboolean gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm);
+gboolean gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input);
+gboolean gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input);
+gboolean gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output);
+gboolean gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output);
/* frequency control */
-gboolean gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency);
-gboolean gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency);
-gboolean gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal);
+gboolean gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency);
+gboolean gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency);
+gboolean gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal);
/* attribute control */
-gboolean gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute,
- int *value);
-gboolean gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute,
- const int value);
+gboolean gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute, int *value);
+gboolean gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute, const int value);
/* overlay */
-gboolean gst_v4l2_set_display (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_set_window (GstElement *element,
- gint x, gint y,
- gint w, gint h,
- struct v4l2_clip *clips,
- gint num_clips);
-gboolean gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable);
+gboolean gst_v4l2_set_display (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip *clips, gint num_clips);
+gboolean gst_v4l2_enable_overlay (GstV4l2Element * v4l2element,
+ gboolean enable);
#endif /* __V4L2_CALLS_H__ */
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index 8b3276a6..00d710eb 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -56,7 +56,7 @@
******************************************************/
gboolean
-gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src)
{
gint n;
struct v4l2_fmtdesc *format;
@@ -64,22 +64,24 @@ gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
GST_DEBUG_OBJECT (v4l2src, "getting src format enumerations");
/* format enumeration */
- for (n=0;;n++) {
+ for (n = 0;; n++) {
format = g_new (struct v4l2_fmtdesc, 1);
+
format->index = n;
format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_ENUM_FMT, format) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_ENUM_FMT,
+ format) < 0) {
if (errno == EINVAL) {
- break; /* end of enumeration */
+ break; /* end of enumeration */
} else {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
("failed to get number %d in pixelformat enumeration for %s: %s",
- n, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ n, GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
g_free (format);
return FALSE;
}
}
- GST_LOG_OBJECT (v4l2src, "got format"GST_FOURCC_FORMAT,
+ GST_LOG_OBJECT (v4l2src, "got format" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (format->pixelformat));
v4l2src->formats = g_slist_prepend (v4l2src->formats, format);
}
@@ -95,7 +97,7 @@ gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src)
{
g_slist_foreach (v4l2src->formats, (GFunc) g_free, NULL);
g_slist_free (v4l2src->formats);
@@ -111,15 +113,16 @@ gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i)
+gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i)
{
GST_LOG_OBJECT (v4l2src, "queueing frame %u", i);
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QBUF, &v4l2src->pool->buffers[i].buffer) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QBUF,
+ &v4l2src->pool->buffers[i].buffer) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, WRITE,
- (_("Could not write to device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("Error queueing buffer %u on device %s", i, g_strerror(errno)));
+ (_("Could not write to device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("Error queueing buffer %u on device %s", i, g_strerror (errno)));
return FALSE;
}
@@ -134,16 +137,17 @@ gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
******************************************************/
gint
-gst_v4l2src_grab_frame (GstV4l2Src *v4l2src)
+gst_v4l2src_grab_frame (GstV4l2Src * v4l2src)
{
struct v4l2_buffer buffer;
-
+
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- while (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
+ while (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
/* if the sync() got interrupted, we can retry */
if (errno != EINTR) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL), ("could not sync on a buffer on device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL),
+ ("could not sync on a buffer on device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return -1;
}
GST_DEBUG_OBJECT (v4l2src, "grab got interrupted");
@@ -162,21 +166,22 @@ gst_v4l2src_grab_frame (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_get_capture (GstV4l2Src *v4l2src)
+gst_v4l2src_get_capture (GstV4l2Src * v4l2src)
{
- DEBUG("Getting capture format");
+ DEBUG ("Getting capture format");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_G_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to get pixelformat for device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_G_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to get pixelformat for device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
@@ -187,33 +192,33 @@ gst_v4l2src_get_capture (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height)
+gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * fmt, gint width, gint height)
{
- DEBUG("Setting capture format to %dx%d, format %s",
- width, height, fmt->description);
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
-
- memset(&v4l2src->format, 0, sizeof(struct v4l2_format));
- v4l2src->format.fmt.pix.width = width;
- v4l2src->format.fmt.pix.height = height;
- v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
- v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_S_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
- fmt->description, width, height, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
-
- /* update internal info */
- return gst_v4l2src_get_capture(v4l2src);
+ DEBUG ("Setting capture format to %dx%d, format %s",
+ width, height, fmt->description);
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
+
+ memset (&v4l2src->format, 0, sizeof (struct v4l2_format));
+ v4l2src->format.fmt.pix.width = width;
+ v4l2src->format.fmt.pix.height = height;
+ v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
+ v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_S_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
+ fmt->description, width, height, GST_V4L2ELEMENT (v4l2src)->device,
+ g_strerror (errno)));
+ return FALSE;
+ }
+
+ /* update internal info */
+ return gst_v4l2src_get_capture (v4l2src);
}
@@ -224,15 +229,15 @@ gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
******************************************************/
gboolean
-gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_init (GstV4l2Src * v4l2src)
{
gint n;
guint buffers;
GST_DEBUG_OBJECT (v4l2src, "initting the capture system");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* request buffer info */
buffers = v4l2src->breq.count;
@@ -244,25 +249,32 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
}
v4l2src->breq.type = v4l2src->format.type;
v4l2src->breq.memory = V4L2_MEMORY_MMAP;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_REQBUFS, &v4l2src->breq) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_REQBUFS,
+ &v4l2src->breq) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("error requesting %d buffers: %s", v4l2src->breq.count, g_strerror (errno)));
+ (_("Could not get buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("error requesting %d buffers: %s", v4l2src->breq.count,
+ g_strerror (errno)));
return FALSE;
}
if (v4l2src->breq.count < GST_V4L2_MIN_BUFFERS) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get enough buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("we received %d, we want at least %d", v4l2src->breq.count, GST_V4L2_MIN_BUFFERS));
+ (_("Could not get enough buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("we received %d, we want at least %d", v4l2src->breq.count,
+ GST_V4L2_MIN_BUFFERS));
v4l2src->breq.count = buffers;
return FALSE;
}
if (v4l2src->breq.count != buffers)
g_object_notify (G_OBJECT (v4l2src), "num_buffers");
- GST_INFO_OBJECT (v4l2src, "Got %d buffers ("GST_FOURCC_FORMAT") of size %d KB\n",
- v4l2src->breq.count, GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
+ GST_INFO_OBJECT (v4l2src,
+ "Got %d buffers (" GST_FOURCC_FORMAT ") of size %d KB\n",
+ v4l2src->breq.count,
+ GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
v4l2src->format.fmt.pix.sizeimage / 1024);
/* Map the buffers */
@@ -279,29 +291,32 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
buffer->pool = v4l2src->pool;
buffer->buffer.index = n;
buffer->buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QUERYBUF, &buffer->buffer) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not get buffer properties of buffer %d: %s", n, g_strerror (errno)));
- gst_v4l2src_capture_deinit(v4l2src);
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QUERYBUF,
+ &buffer->buffer) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not get buffer properties of buffer %d: %s", n,
+ g_strerror (errno)));
+ gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
- buffer->start = mmap (0, buffer->buffer.length, PROT_READ|PROT_WRITE, MAP_SHARED,
- GST_V4L2ELEMENT(v4l2src)->video_fd, buffer->buffer.m.offset);
+ buffer->start =
+ mmap (0, buffer->buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ GST_V4L2ELEMENT (v4l2src)->video_fd, buffer->buffer.m.offset);
if (buffer->start == MAP_FAILED) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
buffer->start = 0;
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
buffer->length = buffer->buffer.length;
- if (!gst_v4l2src_queue_frame(v4l2src, n)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, n)) {
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
}
- GST_V4L2_SET_ACTIVE(GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_SET_ACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
@@ -313,24 +328,24 @@ gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_capture_start (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_start (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "starting the capturing");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT(v4l2src))) {
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
gst_pad_renegotiate (v4l2src->srcpad);
}
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
v4l2src->quit = FALSE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, OPEN_READ, (NULL),
- ("Error starting streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror(errno)));
+ ("Error starting streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
@@ -345,31 +360,31 @@ gst_v4l2src_capture_start (GstV4l2Src *v4l2src)
******************************************************/
gboolean
-gst_v4l2src_capture_stop (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_stop (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "stopping capturing");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* we actually need to sync on all queued buffers but not
* on the non-queued ones */
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, CLOSE, (NULL),
- ("Error stopping streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ ("Error stopping streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
/* make an optional pending wait stop */
v4l2src->quit = TRUE;
-
+
return TRUE;
}
static void
-gst_v4l2src_buffer_pool_free (GstV4l2BufferPool *pool, gboolean do_close)
+gst_v4l2src_buffer_pool_free (GstV4l2BufferPool * pool, gboolean do_close)
{
guint i;
@@ -385,16 +400,16 @@ gst_v4l2src_buffer_pool_free (GstV4l2BufferPool *pool, gboolean do_close)
}
void
-gst_v4l2src_free_buffer (GstBuffer *buffer)
+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 (!gst_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)
+ if (ioctl (buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
GST_INFO ("readding to queue failed, assuming video device is stopped");
}
if (gst_atomic_int_dec_and_test (&buf->pool->refcount)) {
@@ -410,14 +425,14 @@ gst_v4l2src_free_buffer (GstBuffer *buffer)
******************************************************/
gboolean
-gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src)
{
gint i, dequeue = 0;
-
+
GST_DEBUG_OBJECT (v4l2src, "deinitting capture system");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* free the buffers */
for (i = 0; i < v4l2src->breq.count; i++) {
@@ -426,16 +441,18 @@ gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
}
for (i = 0; i < dequeue; i++) {
struct v4l2_buffer buffer;
- buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
- GST_WARNING_OBJECT (v4l2src, "Could not dequeue buffer on uninitialization");
+
+ buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
+ GST_WARNING_OBJECT (v4l2src,
+ "Could not dequeue buffer on uninitialization");
}
if (gst_atomic_int_dec_and_test (&v4l2src->pool->refcount)) {
/* we're last thing that used all this */
gst_v4l2src_buffer_pool_free (v4l2src->pool, FALSE);
}
v4l2src->pool = NULL;
-
+
GST_V4L2_SET_INACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
@@ -446,46 +463,45 @@ gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
*/
gboolean
-gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *format,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h)
+gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * format,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h)
{
- struct v4l2_format fmt;
-
- GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (format->pixelformat));
-
- /* get size delimiters */
- memset(&fmt, 0, sizeof(fmt));
- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmt.fmt.pix.width = 0;
- fmt.fmt.pix.height = 0;
- fmt.fmt.pix.pixelformat = format->pixelformat;
- fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (min_w)
- *min_w = fmt.fmt.pix.width;
- if (min_h)
- *min_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- fmt.fmt.pix.width = G_MAXINT;
- fmt.fmt.pix.height = 576;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (max_w)
- *max_w = fmt.fmt.pix.width;
- if (max_h)
- *max_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- return TRUE;
+ struct v4l2_format fmt;
+
+ GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (format->pixelformat));
+
+ /* get size delimiters */
+ memset (&fmt, 0, sizeof (fmt));
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = 0;
+ fmt.fmt.pix.height = 0;
+ fmt.fmt.pix.pixelformat = format->pixelformat;
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (min_w)
+ *min_w = fmt.fmt.pix.width;
+ if (min_h)
+ *min_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ fmt.fmt.pix.width = G_MAXINT;
+ fmt.fmt.pix.height = 576;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (max_w)
+ *max_w = fmt.fmt.pix.width;
+ if (max_h)
+ *max_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ return TRUE;
}
diff --git a/sys/v4l2/v4l2src_calls.h b/sys/v4l2/v4l2src_calls.h
index dc5fca0c..043dddf0 100644
--- a/sys/v4l2/v4l2src_calls.h
+++ b/sys/v4l2/v4l2src_calls.h
@@ -24,30 +24,25 @@
#include "v4l2_calls.h"
-gboolean gst_v4l2src_get_capture (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height);
-gboolean gst_v4l2src_capture_init (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_start (GstV4l2Src *v4l2src);
-gint gst_v4l2src_grab_frame (GstV4l2Src *v4l2src);
-guint8 * gst_v4l2src_get_buffer (GstV4l2Src *v4l2src,
- gint num);
-gboolean gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i);
-gboolean gst_v4l2src_capture_stop (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src);
-
-gboolean gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src);
+gboolean gst_v4l2src_get_capture (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt, gint width, gint height);
+gboolean gst_v4l2src_capture_init (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_start (GstV4l2Src * v4l2src);
+gint gst_v4l2src_grab_frame (GstV4l2Src * v4l2src);
+guint8 *gst_v4l2src_get_buffer (GstV4l2Src * v4l2src, gint num);
+gboolean gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i);
+gboolean gst_v4l2src_capture_stop (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src);
+
+gboolean gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src);
/* hacky */
-gboolean gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h);
+gboolean gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h);
+
+void gst_v4l2src_free_buffer (GstBuffer * buffer);
-void gst_v4l2src_free_buffer (GstBuffer *buffer);
-
#endif /* __V4L2SRC_CALLS_H__ */