URIHandler interface and element properties are now properly synchronized for DV1394src and UDPSrc

Original commit message from CVS:
* ext/raw1394/gstdv1394src.c: (gst_dv1394src_class_init),
(gst_dv1394src_init), (gst_dv1394src_dispose),
(gst_dv1394src_set_property), (gst_dv1394src_discover_avc_node),
(gst_dv1394src_uri_set_uri):
* gst/udp/gstudpsrc.c: (gst_udpsrc_class_init),
(gst_udpsrc_update_uri), (gst_udpsrc_set_uri),
(gst_udpsrc_set_property), (gst_udpsrc_uri_get_uri):
URIHandler interface and element properties are now properly
synchronized for DV1394src and UDPSrc
This commit is contained in:
Edward Hervey 2005-11-22 11:49:30 +00:00
parent 8dbe2e2626
commit f8456ac0f3
3 changed files with 60 additions and 6 deletions

View file

@ -1,3 +1,15 @@
2005-11-22 Edward Hervey <edward@fluendo.com>
* ext/raw1394/gstdv1394src.c: (gst_dv1394src_class_init),
(gst_dv1394src_init), (gst_dv1394src_dispose),
(gst_dv1394src_set_property), (gst_dv1394src_discover_avc_node),
(gst_dv1394src_uri_set_uri):
* gst/udp/gstudpsrc.c: (gst_udpsrc_class_init),
(gst_udpsrc_update_uri), (gst_udpsrc_set_uri),
(gst_udpsrc_set_property), (gst_udpsrc_uri_get_uri):
URIHandler interface and element properties are now properly
synchronized for DV1394src and UDPSrc
2005-11-22 Tim-Philipp Müller <tim at centricular dot net>
* ext/flac/Makefile.am:

View file

@ -114,6 +114,7 @@ static void gst_dv1394src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_dv1394src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_dv1394src_dispose (GObject * object);
static gboolean gst_dv1394src_start (GstBaseSrc * bsrc);
static gboolean gst_dv1394src_stop (GstBaseSrc * bsrc);
@ -173,6 +174,7 @@ gst_dv1394src_class_init (GstDV1394SrcClass * klass)
gobject_class->set_property = gst_dv1394src_set_property;
gobject_class->get_property = gst_dv1394src_get_property;
gobject_class->dispose = gst_dv1394src_dispose;
gst_dv1394src_signals[SIGNAL_FRAME_DROPPED] =
g_signal_new ("frame-dropped", G_TYPE_FROM_CLASS (klass),
@ -232,6 +234,7 @@ gst_dv1394src_init (GstDV1394Src * dv1394src, GstDV1394SrcClass * klass)
dv1394src->drop_incomplete = DEFAULT_DROP_INCOMPLETE;
dv1394src->use_avc = DEFAULT_USE_AVC;
dv1394src->guid = DEFAULT_GUID;
dv1394src->uri = g_strdup_printf ("dv://%d", dv1394src->port);
READ_SOCKET (dv1394src) = -1;
WRITE_SOCKET (dv1394src) = -1;
@ -244,6 +247,17 @@ gst_dv1394src_init (GstDV1394Src * dv1394src, GstDV1394SrcClass * klass)
dv1394src->frame_sequence = 0;
}
static void
gst_dv1394src_dispose (GObject * object)
{
GstDV1394Src *src = GST_DV1394SRC (object);
g_free (src->uri);
src->uri = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_dv1394src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@ -253,6 +267,8 @@ gst_dv1394src_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_PORT:
filter->port = g_value_get_int (value);
g_free (filter->uri);
filter->uri = g_strdup_printf ("dv://%d", filter->port);
break;
case PROP_CHANNEL:
filter->channel = g_value_get_int (value);
@ -565,6 +581,8 @@ gst_dv1394src_discover_avc_node (GstDV1394Src * src)
if (src->guid == rom1394_get_guid (handle, i)) {
node = i;
src->port = j;
g_free (src->uri);
src->uri = g_strdup_printf ("dv://%d", src->port);
break;
}
} else {
@ -579,6 +597,8 @@ gst_dv1394src_discover_avc_node (GstDV1394Src * src)
avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
node = i;
src->port = j;
g_free (src->uri);
src->uri = g_strdup_printf ("dv://%d", src->port);
break;
}
}
@ -865,8 +885,13 @@ gst_dv1394src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
g_free (protocol);
location = gst_uri_get_location (uri);
gst_dv1394src->port = strtol (location, NULL, 10);
if (location && (!(location == "")))
gst_dv1394src->port = strtol (location, NULL, 10);
else
gst_dv1394src->port = DEFAULT_PORT;
g_free (location);
g_free (gst_dv1394src->uri);
gst_dv1394src->uri = g_strdup_printf ("dv://%d", gst_dv1394src->port);
return ret;
}

View file

@ -144,7 +144,7 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_URI,
g_param_spec_string ("uri", "URI",
"URI in the form of udp://hostname:port", UDP_DEFAULT_URI,
"URI in the form of udp://multicast_group:port", UDP_DEFAULT_URI,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CAPS,
g_param_spec_boxed ("caps", "Caps",
@ -312,6 +312,15 @@ receive_error:
}
}
/* Call this function when multicastgroup and/or port are updated */
static void
gst_udpsrc_update_uri (GstUDPSrc * src)
{
g_free (src->uri);
src->uri = g_strdup_printf ("udp://%s:%d", src->multi_group, src->port);
}
static gboolean
gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri)
{
@ -325,14 +334,21 @@ gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri)
g_free (protocol);
location = gst_uri_get_location (uri);
if (!location)
return FALSE;
colptr = strstr (location, ":");
if (colptr != NULL) {
g_free (src->multi_group);
src->multi_group = g_strndup (location, colptr - location);
src->port = atoi (colptr + 1);
} else {
g_free (src->multi_group);
src->multi_group = g_strdup (location);
src->port = UDP_DEFAULT_PORT;
}
g_free (location);
g_free (src->uri);
src->uri = g_strdup (uri);
gst_udpsrc_update_uri (src);
return TRUE;
@ -354,6 +370,7 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
switch (prop_id) {
case PROP_PORT:
udpsrc->port = g_value_get_int (value);
gst_udpsrc_update_uri (udpsrc);
break;
case PROP_MULTICAST_GROUP:
g_free (udpsrc->multi_group);
@ -362,7 +379,7 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
udpsrc->multi_group = g_strdup (UDP_DEFAULT_MULTICAST_GROUP);
else
udpsrc->multi_group = g_strdup (g_value_get_string (value));
gst_udpsrc_update_uri (udpsrc);
break;
case PROP_URI:
gst_udpsrc_set_uri (udpsrc, g_value_get_string (value));
@ -594,7 +611,7 @@ gst_udpsrc_uri_get_uri (GstURIHandler * handler)
{
GstUDPSrc *src = GST_UDPSRC (handler);
return g_strdup (src->uri);
return src->uri;
}
static gboolean