mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-24 06:56:26 +00:00
multiudpsink: get family of external sockets too
Get the family of externally configured sockets so that we can configure it correctly.
This commit is contained in:
parent
3197490c2f
commit
efbdecd0ac
1 changed files with 23 additions and 1 deletions
|
@ -834,7 +834,7 @@ gst_multiudpsink_init_send (GstMultiUDPSink * sink)
|
||||||
GST_DEBUG_OBJECT (sink, "creating sockets");
|
GST_DEBUG_OBJECT (sink, "creating sockets");
|
||||||
/* create sender socket try IP6, fall back to IP4 */
|
/* create sender socket try IP6, fall back to IP4 */
|
||||||
sink->ss_family = AF_INET6;
|
sink->ss_family = AF_INET6;
|
||||||
if ((sink->sock = socket (AF_INET6, SOCK_DGRAM, 0)) == -1){
|
if ((sink->sock = socket (AF_INET6, SOCK_DGRAM, 0)) == -1) {
|
||||||
sink->ss_family = AF_INET;
|
sink->ss_family = AF_INET;
|
||||||
if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
goto no_socket;
|
goto no_socket;
|
||||||
|
@ -843,7 +843,20 @@ gst_multiudpsink_init_send (GstMultiUDPSink * sink)
|
||||||
GST_DEBUG_OBJECT (sink, "have socket");
|
GST_DEBUG_OBJECT (sink, "have socket");
|
||||||
sink->externalfd = FALSE;
|
sink->externalfd = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
struct sockaddr_storage myaddr;
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
gint len;
|
||||||
|
#else
|
||||||
|
guint len;
|
||||||
|
#endif
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "using configured socket");
|
GST_DEBUG_OBJECT (sink, "using configured socket");
|
||||||
|
/* we use the configured socket, try to get some info about it */
|
||||||
|
len = sizeof (myaddr);
|
||||||
|
if (getsockname (sink->sockfd, (struct sockaddr *) &myaddr, &len) < 0)
|
||||||
|
goto getsockname_error;
|
||||||
|
|
||||||
|
sink->ss_family = myaddr.ss_family;
|
||||||
/* we use the configured socket */
|
/* we use the configured socket */
|
||||||
sink->sock = sink->sockfd;
|
sink->sock = sink->sockfd;
|
||||||
sink->externalfd = TRUE;
|
sink->externalfd = TRUE;
|
||||||
|
@ -879,6 +892,15 @@ no_socket:
|
||||||
g_free (errormessage);
|
g_free (errormessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
getsockname_error:
|
||||||
|
{
|
||||||
|
gchar *errormessage = socket_last_error_message ();
|
||||||
|
int errorcode = socket_last_error_code ();
|
||||||
|
GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, (NULL),
|
||||||
|
("Could not getsockname (%d): %s", errorcode, errormessage));
|
||||||
|
g_free (errormessage);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
no_broadcast:
|
no_broadcast:
|
||||||
{
|
{
|
||||||
gchar *errormessage = socket_last_error_message ();
|
gchar *errormessage = socket_last_error_message ();
|
||||||
|
|
Loading…
Reference in a new issue