Commit 494933e1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use net_ConnectUDP

parent 544ad949
......@@ -180,8 +180,7 @@ static int Open( vlc_object_t *p_this )
char *psz_dst_addr;
int i_dst_port;
module_t *p_network;
network_socket_t socket_desc;
int i_handle;
vlc_value_t val;
......@@ -249,37 +248,16 @@ static int Open( vlc_object_t *p_this )
p_sys->p_thread->i_empty_depth = 0;
vlc_mutex_init( p_access, &p_sys->p_thread->blocks_lock );
/* FIXME: use net_OpenUDP API */
socket_desc.psz_server_addr = psz_dst_addr;
socket_desc.i_server_port = i_dst_port;
socket_desc.psz_bind_addr = "";
socket_desc.i_bind_port = 0;
socket_desc.i_handle = -1;
socket_desc.v6only = 0;
var_Get( p_access, SOUT_CFG_PREFIX "ttl", &val );
socket_desc.i_ttl = val.i_int;
p_sys->p_thread->p_private = (void*)&socket_desc;
p_network = module_Need( p_sys->p_thread, "network", "ipv4", VLC_TRUE );
if( p_network != NULL )
module_Unneed( p_sys->p_thread, p_network );
if( socket_desc.i_handle == -1 )
i_handle = net_ConnectUDP( p_this, psz_dst_addr, i_dst_port, val.i_int );
if( i_handle == -1 )
{
p_network = module_Need( p_sys->p_thread, "network", "ipv6", VLC_TRUE );
if( p_network != NULL )
module_Unneed( p_sys->p_thread, p_network );
if( socket_desc.i_handle == -1 )
{
msg_Err( p_access, "failed to open a connection (udp)" );
return VLC_EGENERIC;
}
msg_Err( p_access, "failed to open a connection (udp)" );
return VLC_EGENERIC;
}
p_sys->p_thread->i_handle = socket_desc.i_handle;
net_StopRecv( socket_desc.i_handle );
p_sys->p_thread->i_handle = i_handle;
net_StopRecv( i_handle );
var_Get( p_access, SOUT_CFG_PREFIX "caching", &val );
p_sys->p_thread->i_caching = (int64_t)val.i_int * 1000;
......@@ -287,7 +265,7 @@ static int Open( vlc_object_t *p_this )
var_Get( p_access, SOUT_CFG_PREFIX "group", &val );
p_sys->p_thread->i_group = val.i_int;
p_sys->i_mtu = socket_desc.i_mtu;
p_sys->i_mtu = var_CreateGetInteger( p_this, "mtu" );
if( vlc_thread_create( p_sys->p_thread, "sout write thread", ThreadWrite,
VLC_THREAD_PRIORITY_HIGHEST, VLC_FALSE ) )
......
......@@ -166,16 +166,9 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
if( i_hlim < 1 )
{
vlc_value_t val;
if( var_Get( p_this, "ttl", &val ) != VLC_SUCCESS )
{
var_Create( p_this, "ttl", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, "ttl", &val );
}
i_hlim = val.i_int;
if( i_hlim < 1 ) i_hlim = 1;
i_hlim = var_CreateGetInteger( p_this, "ttl" );
if( i_hlim < 1 )
i_hlim = 1;
}
memset( &hints, 0, sizeof( hints ) );
......
......@@ -57,7 +57,6 @@ struct sap_address_t
{
char *psz_address;
char psz_machine[NI_MAXNUMERICHOST];
int i_port;
int i_rfd; /* Read socket */
int i_wfd; /* Write socket */
......@@ -370,9 +369,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
return VLC_ENOMEM;
}
p_address->psz_address = strdup( psz_addr );
p_address->i_port = 9875;
p_address->i_wfd = net_OpenUDP( p_sap, "", 0, psz_addr,
p_address->i_port );
p_address->i_wfd = net_ConnectUDP( p_sap, psz_addr, SAP_PORT, 0 );
if( p_address->i_wfd != -1 )
{
char *ptr;
......@@ -389,8 +386,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
if( p_sap->b_control == VLC_TRUE )
{
p_address->i_rfd = net_OpenUDP( p_sap, psz_addr,
p_address->i_port, "", 0 );
p_address->i_rfd = net_OpenUDP( p_sap, psz_addr, SAP_PORT, "", 0 );
if( p_address->i_rfd != -1 )
net_StopSend( p_address->i_rfd );
p_address->i_buff = 0;
......@@ -558,7 +554,7 @@ static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
i_ret = net_Write( p_sap, p_session->p_address->i_wfd, NULL,
p_session->psz_data,
p_session->i_length );
if( i_ret != p_session->i_length )
if( i_ret != (int)p_session->i_length )
{
msg_Warn( p_sap, "SAP send failed on address %s (%i %i)",
p_session->p_address->psz_address,
......@@ -628,7 +624,7 @@ static char *SDPGenerate( sap_handler_t *p_sap,
psz_group ? "a=x-plgroup:" : "",
psz_group ? psz_group : "", psz_group ? "\r\n" : "" ) == -1 )
return NULL;
msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp),
psz_sdp );
return psz_sdp;
......@@ -679,9 +675,7 @@ static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
}
#ifdef EXTRA_DEBUG
msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s",
p_address->psz_address,p_address->i_port,
i_rate,
p_address->i_interval );
p_address->psz_address,SAP_PORT, i_rate, p_address->i_interval );
#endif
p_address->b_ready = VLC_TRUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment