Commit 434f2999 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

On send error ENOTCONN try to reconnect the stream output instance with the...

On send error ENOTCONN try to reconnect the stream output instance with the network. This worksaround accidental unplugging of a cable while streaming. However it only works with multicast upto the timeout period of the multicast stream. If that expires the switch or os kicks in and all multicast joins expire. Resulting in no stream what so ever. The client then needs to reconnect. O, yes also only works with fixed ipaddresses.
parent feeadc4b
......@@ -141,6 +141,9 @@ typedef struct sout_access_thread_t
block_fifo_t *p_fifo;
int i_handle;
char *psz_dst_addr;
int i_dst_port;
int i_ttl;
int64_t i_caching;
int i_group;
......@@ -254,6 +257,9 @@ static int Open( vlc_object_t *p_this )
}
p_sys->p_thread->i_handle = i_handle;
p_sys->p_thread->psz_dst_addr = strdup(psz_dst_addr);
p_sys->p_thread->i_dst_port = i_dst_port;
p_sys->p_thread->i_ttl = val.i_int;
net_StopRecv( i_handle );
var_Get( p_access, SOUT_CFG_PREFIX "caching", &val );
......@@ -268,6 +274,7 @@ static int Open( vlc_object_t *p_this )
VLC_THREAD_PRIORITY_HIGHEST, VLC_FALSE ) )
{
msg_Err( p_access->p_sout, "cannot spawn sout access thread" );
free( p_sys->p_thread->psz_dst_addr );
vlc_object_destroy( p_sys->p_thread );
return VLC_EGENERIC;
}
......@@ -321,7 +328,7 @@ static void Close( vlc_object_t * p_this )
if( p_sys->p_buffer ) block_Release( p_sys->p_buffer );
net_Close( p_sys->p_thread->i_handle );
free( p_sys->p_thread->psz_dst_addr );
vlc_object_detach( p_sys->p_thread );
vlc_object_destroy( p_sys->p_thread );
/* update p_sout->i_out_pace_nocontrol */
......@@ -565,6 +572,20 @@ static void ThreadWrite( vlc_object_t *p_this )
== -1 )
{
msg_Warn( p_thread, "send error: %s", strerror(errno) );
/* Try reconnecting */
if( errno == ENOTCONN )
{
net_Close( p_thread->i_handle );
p_thread->i_handle = net_ConnectUDP( p_this,
p_thread->psz_dst_addr, p_thread->i_dst_port,
p_thread->i_ttl );
if( p_thread->i_handle == -1 )
{
msg_Err( p_thread, "failed to reopen connection (udp)" );
}
net_StopRecv( p_thread->i_handle );
}
}
if( i_dropped_packets )
......
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