gst/udp/gstudpsrc.c: Call getsockname() after the call to bind() to get updated values for the port, etc. This fixes ...

Original commit message from CVS:
* gst/udp/gstudpsrc.c: (gst_udpsrc_start):
Call getsockname() after the call to bind() to get updated values
for the port, etc. This fixes the usage of udpsrc on anonymous
binding and it's usage by rtspsrc. Fixes bugs #539372, #539548.
Thanks to Aurelien Grimaud for pointing out the obvious fix.
This commit is contained in:
Sebastian Dröge 2008-06-25 08:12:18 +00:00
parent b2c97f7bc6
commit 8ca7dbfae5
2 changed files with 40 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2008-06-25 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/udp/gstudpsrc.c: (gst_udpsrc_start):
Call getsockname() after the call to bind() to get updated values
for the port, etc. This fixes the usage of udpsrc on anonymous
binding and it's usage by rtspsrc. Fixes bugs #539372, #539548.
Thanks to Aurelien Grimaud for pointing out the obvious fix.
2008-06-25 Sebastian Dröge <sebastian.droege@collabora.co.uk> 2008-06-25 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* tests/check/pipelines/wavpack.c: (bus_handler): * tests/check/pipelines/wavpack.c: (bus_handler):

View file

@ -194,11 +194,17 @@ enum
static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data); static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
static GstCaps *gst_udpsrc_getcaps (GstBaseSrc * src); static GstCaps *gst_udpsrc_getcaps (GstBaseSrc * src);
static GstFlowReturn gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf); static GstFlowReturn gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf);
static gboolean gst_udpsrc_start (GstBaseSrc * bsrc); static gboolean gst_udpsrc_start (GstBaseSrc * bsrc);
static gboolean gst_udpsrc_stop (GstBaseSrc * bsrc); static gboolean gst_udpsrc_stop (GstBaseSrc * bsrc);
static gboolean gst_udpsrc_unlock (GstBaseSrc * bsrc); static gboolean gst_udpsrc_unlock (GstBaseSrc * bsrc);
static gboolean gst_udpsrc_unlock_stop (GstBaseSrc * bsrc); static gboolean gst_udpsrc_unlock_stop (GstBaseSrc * bsrc);
static void gst_udpsrc_finalize (GObject * object); static void gst_udpsrc_finalize (GObject * object);
static void gst_udpsrc_set_property (GObject * object, guint prop_id, static void gst_udpsrc_set_property (GObject * object, guint prop_id,
@ -238,7 +244,9 @@ static void
gst_udpsrc_class_init (GstUDPSrcClass * klass) gst_udpsrc_class_init (GstUDPSrcClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstBaseSrcClass *gstbasesrc_class; GstBaseSrcClass *gstbasesrc_class;
GstPushSrcClass *gstpushsrc_class; GstPushSrcClass *gstpushsrc_class;
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
@ -362,10 +370,15 @@ static GstFlowReturn
gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf) gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
{ {
GstUDPSrc *udpsrc; GstUDPSrc *udpsrc;
GstNetBuffer *outbuf; GstNetBuffer *outbuf;
struct sockaddr_storage tmpaddr; struct sockaddr_storage tmpaddr;
socklen_t len; socklen_t len;
guint8 *pktdata; guint8 *pktdata;
gint pktsize; gint pktsize;
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
@ -374,7 +387,9 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
gulong readsize; gulong readsize;
#endif #endif
GstClockTime timeout; GstClockTime timeout;
gint ret; gint ret;
gboolean try_again; gboolean try_again;
udpsrc = GST_UDPSRC_CAST (psrc); udpsrc = GST_UDPSRC_CAST (psrc);
@ -565,7 +580,9 @@ static gboolean
gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri) gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri)
{ {
gchar *protocol; gchar *protocol;
gchar *location; gchar *location;
gchar *colptr; gchar *colptr;
protocol = gst_uri_get_protocol (uri); protocol = gst_uri_get_protocol (uri);
@ -631,7 +648,9 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
case PROP_CAPS: case PROP_CAPS:
{ {
const GstCaps *new_caps_val = gst_value_get_caps (value); const GstCaps *new_caps_val = gst_value_get_caps (value);
GstCaps *new_caps; GstCaps *new_caps;
GstCaps *old_caps; GstCaps *old_caps;
if (new_caps_val == NULL) { if (new_caps_val == NULL) {
@ -719,11 +738,17 @@ static gboolean
gst_udpsrc_start (GstBaseSrc * bsrc) gst_udpsrc_start (GstBaseSrc * bsrc)
{ {
guint bc_val; guint bc_val;
gint reuse; gint reuse;
int port; int port;
GstUDPSrc *src; GstUDPSrc *src;
gint ret; gint ret;
int rcvsize; int rcvsize;
guint len; guint len;
src = GST_UDPSRC (bsrc); src = GST_UDPSRC (bsrc);
@ -752,6 +777,11 @@ gst_udpsrc_start (GstBaseSrc * bsrc)
if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr, if ((ret = bind (src->sock.fd, (struct sockaddr *) &src->myaddr,
sizeof (src->myaddr))) < 0) sizeof (src->myaddr))) < 0)
goto bind_error; goto bind_error;
len = sizeof (src->myaddr);
if ((ret = getsockname (src->sock.fd, (struct sockaddr *) &src->myaddr,
&len)) < 0)
goto getsockname_error;
} else { } else {
GST_DEBUG_OBJECT (src, "using provided socket %d", src->sockfd); GST_DEBUG_OBJECT (src, "using provided socket %d", src->sockfd);
/* we use the configured socket, try to get some info about it */ /* we use the configured socket, try to get some info about it */
@ -935,6 +965,7 @@ gst_udpsrc_uri_get_type (void)
{ {
return GST_URI_SRC; return GST_URI_SRC;
} }
static gchar ** static gchar **
gst_udpsrc_uri_get_protocols (void) gst_udpsrc_uri_get_protocols (void)
{ {
@ -955,6 +986,7 @@ static gboolean
gst_udpsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri) gst_udpsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{ {
gboolean ret; gboolean ret;
GstUDPSrc *src = GST_UDPSRC (handler); GstUDPSrc *src = GST_UDPSRC (handler);
ret = gst_udpsrc_set_uri (src, uri); ret = gst_udpsrc_set_uri (src, uri);