mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
Change bus reset handler so it reports useful information such as whether the device being used connected or disconne...
Original commit message from CVS: Change bus reset handler so it reports useful information such as whether the device being used connected or disconnected
This commit is contained in:
parent
f8d30d4744
commit
ff2c5fd49c
3 changed files with 53 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2006-03-16 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||||
|
|
||||||
|
* ext/raw1394/gstdv1394src.c: (gst_dv1394src_bus_reset),
|
||||||
|
(gst_dv1394src_discover_avc_node), (gst_dv1394src_start):
|
||||||
|
* ext/raw1394/gstdv1394src.h:
|
||||||
|
Change bus reset handler so it reports useful information such as
|
||||||
|
whether the device being used connected or disconnected
|
||||||
|
|
||||||
2006-03-16 Tim-Philipp Müller <tim at centricular dot net>
|
2006-03-16 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/id3demux/id3v2frames.c:
|
* gst/id3demux/id3v2frames.c:
|
||||||
|
|
|
@ -450,6 +450,16 @@ gst_dv1394src_iso_receive (raw1394handle_t handle, int channel, size_t len,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When an ieee1394 bus reset happens, usually a device has been removed
|
||||||
|
* or added. We send a message on the message bus with the node count
|
||||||
|
* and whether the capture device used in this element connected, disconnected
|
||||||
|
* or was unchanged
|
||||||
|
* Message structure:
|
||||||
|
* nodecount - integer with number of nodes on bus
|
||||||
|
* current-device-change - integer (1 if device connected, 0 if no change to
|
||||||
|
* current device status, -1 if device disconnected)
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
gst_dv1394src_bus_reset (raw1394handle_t handle, unsigned int generation)
|
gst_dv1394src_bus_reset (raw1394handle_t handle, unsigned int generation)
|
||||||
{
|
{
|
||||||
|
@ -457,15 +467,43 @@ gst_dv1394src_bus_reset (raw1394handle_t handle, unsigned int generation)
|
||||||
gint nodecount;
|
gint nodecount;
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
gint current_device_change;
|
||||||
|
gint i;
|
||||||
|
|
||||||
src = GST_DV1394SRC (raw1394_get_userdata (handle));
|
src = GST_DV1394SRC (raw1394_get_userdata (handle));
|
||||||
|
|
||||||
GST_INFO_OBJECT (src, "have bus reset");
|
GST_INFO_OBJECT (src, "have bus reset");
|
||||||
|
|
||||||
|
/* update generation - told to do so by docs */
|
||||||
|
raw1394_update_generation (handle, generation);
|
||||||
nodecount = raw1394_get_nodecount (handle);
|
nodecount = raw1394_get_nodecount (handle);
|
||||||
|
/* allocate memory for portinfo */
|
||||||
|
|
||||||
|
/* current_device_change is -1 if camera disconnected, 0 if other device
|
||||||
|
* connected or 1 if camera has now connected */
|
||||||
|
current_device_change = -1;
|
||||||
|
for (i = 0; i < nodecount; i++) {
|
||||||
|
if (src->guid == rom1394_get_guid (handle, i)) {
|
||||||
|
/* Camera is with us */
|
||||||
|
GST_DEBUG ("Camera is with us");
|
||||||
|
if (!src->connected) {
|
||||||
|
current_device_change = 1;
|
||||||
|
src->connected = TRUE;
|
||||||
|
} else
|
||||||
|
current_device_change = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (src->connected && current_device_change == -1) {
|
||||||
|
GST_DEBUG ("Camera has disconnected");
|
||||||
|
src->connected = FALSE;
|
||||||
|
} else if (!src->connected && current_device_change == -1) {
|
||||||
|
GST_DEBUG ("Camera is still not with us");
|
||||||
|
current_device_change = 0;
|
||||||
|
}
|
||||||
|
|
||||||
structure = gst_structure_new ("ieee1394-bus-reset", "nodecount", G_TYPE_INT,
|
structure = gst_structure_new ("ieee1394-bus-reset", "nodecount", G_TYPE_INT,
|
||||||
nodecount, NULL);
|
nodecount, "current-device-change", G_TYPE_INT, current_device_change,
|
||||||
|
NULL);
|
||||||
message = gst_message_new_element (GST_OBJECT (src), structure);
|
message = gst_message_new_element (GST_OBJECT (src), structure);
|
||||||
gst_element_post_message (GST_ELEMENT (src), message);
|
gst_element_post_message (GST_ELEMENT (src), message);
|
||||||
|
|
||||||
|
@ -597,6 +635,7 @@ gst_dv1394src_discover_avc_node (GstDV1394Src * src)
|
||||||
avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
|
avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
|
||||||
node = i;
|
node = i;
|
||||||
src->port = j;
|
src->port = j;
|
||||||
|
src->guid = rom1394_get_guid (handle, i);
|
||||||
g_free (src->uri);
|
g_free (src->uri);
|
||||||
src->uri = g_strdup_printf ("dv://%d", src->port);
|
src->uri = g_strdup_printf ("dv://%d", src->port);
|
||||||
break;
|
break;
|
||||||
|
@ -615,6 +654,8 @@ gst_dv1394src_start (GstBaseSrc * bsrc)
|
||||||
GstDV1394Src *src = GST_DV1394SRC (bsrc);
|
GstDV1394Src *src = GST_DV1394SRC (bsrc);
|
||||||
int control_sock[2];
|
int control_sock[2];
|
||||||
|
|
||||||
|
src->connected = FALSE;
|
||||||
|
|
||||||
if (socketpair (PF_UNIX, SOCK_STREAM, 0, control_sock) < 0)
|
if (socketpair (PF_UNIX, SOCK_STREAM, 0, control_sock) < 0)
|
||||||
goto socket_pair;
|
goto socket_pair;
|
||||||
|
|
||||||
|
@ -647,7 +688,7 @@ gst_dv1394src_start (GstBaseSrc * bsrc)
|
||||||
raw1394_set_bus_reset_handler (src->handle, gst_dv1394src_bus_reset);
|
raw1394_set_bus_reset_handler (src->handle, gst_dv1394src_bus_reset);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "successfully opened up 1394 connection");
|
GST_DEBUG_OBJECT (src, "successfully opened up 1394 connection");
|
||||||
|
src->connected = TRUE;
|
||||||
if (raw1394_start_iso_rcv (src->handle, src->channel) < 0)
|
if (raw1394_start_iso_rcv (src->handle, src->channel) < 0)
|
||||||
goto cannot_start;
|
goto cannot_start;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ struct _GstDV1394Src {
|
||||||
int control_sock[2];
|
int control_sock[2];
|
||||||
|
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
|
gboolean connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstDV1394SrcClass {
|
struct _GstDV1394SrcClass {
|
||||||
|
|
Loading…
Reference in a new issue