summaryrefslogtreecommitdiffstats
path: root/ext/raw1394/gstdv1394src.c
diff options
context:
space:
mode:
authorJulien Puydt <julien.puydt@laposte.net>2007-11-14 19:10:37 +0000
committerTim-Philipp Müller <tim@centricular.net>2007-11-14 19:10:37 +0000
commitf691a70d69d3e816d370e82cf08de0fd7c7df0b6 (patch)
treef2fbb05d30141f4d3fc8524fb6fb556496104d0c /ext/raw1394/gstdv1394src.c
parent012a21be129d95f53470eec329fdba05940074a7 (diff)
ext/raw1394/: Implement GstPropertyProbe interface and add "device-name" property, so applications can use this to pr...
Original commit message from CVS: Patch by: Julien Puydt <julien dot puydt at laposte net> * ext/raw1394/Makefile.am: * ext/raw1394/gst1394probe.c: (gst_1394_get_guid_array), (gst_1394_property_probe_get_properties), (gst_1394_property_probe_probe_property), (gst_1394_property_probe_needs_probe), (gst_1394_property_probe_get_values), (gst_1394_property_probe_interface_init), (gst_1394_type_add_property_probe_interface): * ext/raw1394/gst1394probe.h: (GST_1394_PROBE_H): * ext/raw1394/gstdv1394src.c: (_do_init), (gst_dv1394src_class_init), (gst_dv1394src_init), (gst_dv1394src_dispose), (gst_dv1394src_set_property), (gst_dv1394src_get_property), (gst_dv1394src_discover_avc_node), (gst_dv1394src_query), (gst_dv1394src_update_device_name): * ext/raw1394/gstdv1394src.h: Implement GstPropertyProbe interface and add "device-name" property, so applications can use this to probe for available devices in the same way they can already with v4lsrc and v4l2src (however horrible this property probe interface may be). Fixes #358841.
Diffstat (limited to 'ext/raw1394/gstdv1394src.c')
-rw-r--r--ext/raw1394/gstdv1394src.c80
1 files changed, 79 insertions, 1 deletions
diff --git a/ext/raw1394/gstdv1394src.c b/ext/raw1394/gstdv1394src.c
index 84476464..34a354f3 100644
--- a/ext/raw1394/gstdv1394src.c
+++ b/ext/raw1394/gstdv1394src.c
@@ -41,6 +41,7 @@
#include <gst/gst.h>
#include "gstdv1394src.h"
+#include "gst1394probe.h"
#define CONTROL_STOP 'S' /* stop the select call */
@@ -93,7 +94,8 @@ enum
PROP_SKIP,
PROP_DROP_INCOMPLETE,
PROP_USE_AVC,
- PROP_GUID
+ PROP_GUID,
+ PROP_DEVICE_NAME
};
static const GstElementDetails gst_dv1394src_details =
@@ -132,6 +134,7 @@ static gboolean gst_dv1394src_convert (GstPad * pad,
static const GstQueryType *gst_dv1394src_get_query_types (GstPad * pad);
static gboolean gst_dv1394src_query (GstPad * pad, GstQuery * query);
+static void gst_dv1394src_update_device_name (GstDV1394Src * src);
static void
_do_init (GType type)
@@ -143,6 +146,8 @@ _do_init (GType type)
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
+ gst_1394_type_add_property_probe_interface (type);
+
GST_DEBUG_CATEGORY_INIT (dv1394src_debug, "dv1394src", 0,
"DV firewire source");
}
@@ -210,6 +215,16 @@ gst_dv1394src_class_init (GstDV1394SrcClass * klass)
"select one of multiple DV devices by its GUID. use a hexadecimal "
"like 0xhhhhhhhhhhhhhhhh. (0 = no guid)", 0, G_MAXUINT64,
DEFAULT_GUID, G_PARAM_READWRITE));
+ /**
+ * GstDV1394Src:device-name
+ *
+ * Descriptive name of the currently opened device
+ *
+ * Since: 0.10.7
+ **/
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEVICE_NAME,
+ g_param_spec_string ("device-name", "device name",
+ "user-friendly name of the device", "Default", G_PARAM_READABLE));
gstbasesrc_class->negotiate = NULL;
gstbasesrc_class->start = gst_dv1394src_start;
@@ -239,6 +254,7 @@ gst_dv1394src_init (GstDV1394Src * dv1394src, GstDV1394SrcClass * klass)
dv1394src->use_avc = DEFAULT_USE_AVC;
dv1394src->guid = DEFAULT_GUID;
dv1394src->uri = g_strdup_printf ("dv://%d", dv1394src->port);
+ dv1394src->device_name = g_strdup_printf ("Default");
READ_SOCKET (dv1394src) = -1;
WRITE_SOCKET (dv1394src) = -1;
@@ -259,6 +275,9 @@ gst_dv1394src_dispose (GObject * object)
g_free (src->uri);
src->uri = NULL;
+ g_free (src->device_name);
+ src->device_name = NULL;
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -291,6 +310,7 @@ gst_dv1394src_set_property (GObject * object, guint prop_id,
break;
case PROP_GUID:
filter->guid = g_value_get_uint64 (value);
+ gst_dv1394src_update_device_name (filter);
break;
default:
break;
@@ -325,6 +345,9 @@ gst_dv1394src_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_GUID:
g_value_set_uint64 (value, filter->guid);
break;
+ case PROP_DEVICE_NAME:
+ g_value_set_string (value, filter->device_name);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -721,8 +744,11 @@ gst_dv1394src_discover_avc_node (GstDV1394Src * src)
src->guid = rom1394_get_guid (handle, i);
g_free (src->uri);
src->uri = g_strdup_printf ("dv://%d", src->port);
+ g_free (src->device_name);
+ src->device_name = g_strdup (rom_dir.label);
break;
}
+ rom1394_free_directory (&rom_dir);
}
}
next:
@@ -1044,6 +1070,58 @@ not_supported:
}
}
+static void
+gst_dv1394src_update_device_name (GstDV1394Src * src)
+{
+ raw1394handle_t handle;
+ gint portcount, port, nodecount, node;
+ rom1394_directory directory;
+
+ g_free (src->device_name);
+ src->device_name = NULL;
+
+ GST_LOG_OBJECT (src, "updating device name for current GUID");
+
+ handle = raw1394_new_handle ();
+
+ if (handle == NULL)
+ goto gethandle_failed;
+
+ portcount = raw1394_get_port_info (handle, NULL, 0);
+ for (port = 0; port < portcount; port++) {
+ if (raw1394_set_port (handle, port) >= 0) {
+ nodecount = raw1394_get_nodecount (handle);
+ for (node = 0; node < nodecount; node++) {
+ if (src->guid == rom1394_get_guid (handle, node)) {
+ if (rom1394_get_directory (handle, node, &directory) >= 0) {
+ g_free (src->device_name);
+ src->device_name = g_strdup (directory.label);
+ rom1394_free_directory (&directory);
+ goto done;
+ } else {
+ GST_WARNING ("error reading rom directory for node %d", node);
+ }
+ }
+ }
+ }
+ }
+
+ src->device_name = g_strdup ("Unknown"); /* FIXME: translate? */
+
+done:
+
+ raw1394_destroy_handle (handle);
+ return;
+
+/* ERRORS */
+gethandle_failed:
+ {
+ GST_WARNING ("failed to get raw1394 handle: %s", g_strerror (errno));
+ src->device_name = g_strdup ("Unknown"); /* FIXME: translate? */
+ return;
+ }
+}
+
/*** GSTURIHANDLER INTERFACE *************************************************/
static guint