* udp.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.21 2004/03/01 12:50:39 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
set_callbacks( Open, Close );
vlc_module_end();
-typedef struct sout_access_thread_s
+typedef struct sout_access_thread_t
{
VLC_COMMON_MEMBERS
int i_handle;
int64_t i_caching;
+ int64_t i_late;
+ int i_group;
} sout_access_thread_t;
if( !( p_sys = p_access->p_sys =
malloc( sizeof( sout_access_out_sys_t ) ) ) )
{
- msg_Err( p_access, "Not enough memory" );
+ msg_Err( p_access, "not enough memory" );
return VLC_EGENERIC;
}
if( p_access->psz_access != NULL &&
!strcmp( p_access->psz_access, "rtp" ) )
{
- msg_Warn( p_access, "be carefull that rtp ouput work only with ts "
- "payload(not an error)" );
+ msg_Warn( p_access, "be careful that rtp output only works with ts "
+ "payload (not an error)" );
p_sys->b_rtpts = 1;
}
else
socket_desc.i_ttl = atoi( psz_val );
}
p_sys->p_thread->p_private = (void*)&socket_desc;
- if( !( p_network = module_Need( p_sys->p_thread, "network", "" ) ) )
+ if( !( p_network = module_Need( p_sys->p_thread, "network", NULL, 0 ) ) )
{
msg_Err( p_access, "failed to open a connection (udp)" );
return VLC_EGENERIC;
p_sys->p_thread->i_caching = atoll( psz_val ) * 1000;
}
+ p_sys->p_thread->i_group = 1;
+ if( ( psz_val = sout_cfg_find_value( p_access->p_cfg, "group" ) ) )
+ {
+ p_sys->p_thread->i_group = atoi( psz_val );
+ }
+
+ p_sys->p_thread->i_late = 0;
+ if( ( psz_val = sout_cfg_find_value( p_access->p_cfg, "late" ) ) )
+ {
+ p_sys->p_thread->i_late = atoll( psz_val ) * 1000;
+ }
+
+
p_sys->i_mtu = socket_desc.i_mtu;
#ifdef WIN32
msg_Info( p_access, "Open: addr:`%s' port:`%d'", psz_dst_addr, i_dst_port);
free( psz_dst_addr );
+
+ /* update p_sout->i_out_pace_nocontrol */
+ p_access->p_sout->i_out_pace_nocontrol++;
+
return VLC_SUCCESS;
}
sout_BufferDelete( p_access->p_sout, p_sys->p_buffer );
}
-#if defined( UNDER_CE )
- CloseHandle( (HANDLE)p_sys->p_thread->i_handle );
-#elif defined( WIN32 )
- closesocket( p_sys->p_thread->i_handle );
-#else
- close( p_sys->p_thread->i_handle );
-#endif
+ net_Close( p_sys->p_thread->i_handle );
+
+ /* update p_sout->i_out_pace_nocontrol */
+ p_access->p_sout->i_out_pace_nocontrol--;
free( p_sys );
msg_Info( p_access, "Close" );
sout_access_thread_t *p_thread = (sout_access_thread_t*)p_this;
sout_instance_t *p_sout = p_thread->p_sout;
mtime_t i_date_last = -1;
+ mtime_t i_to_send = p_thread->i_group;
int i_dropped_packets = 0;
- while( ! p_thread->b_die )
+ while( !p_thread->b_die )
{
sout_buffer_t *p_pk;
mtime_t i_date, i_sent;
}
i_sent = mdate();
- if ( i_sent > i_date + 100000 )
+ if( p_thread->i_late > 0 && i_sent > i_date + p_thread->i_late )
{
if( !i_dropped_packets )
+ {
msg_Dbg( p_thread, "late packet to send (" I64Fd ") -> drop",
i_sent - i_date );
+ }
sout_BufferDelete( p_sout, p_pk );
i_date_last = i_date;
i_dropped_packets++;
continue;
}
- mwait( i_date );
+ i_to_send--;
+ if ( !i_to_send )
+ {
+ mwait( i_date );
+ i_to_send = p_thread->i_group;
+ }
send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_size, 0 );
if( i_dropped_packets )