/*****************************************************************************
* udp.c
*****************************************************************************
- * Copyright (C) 2001-2005 VideoLAN
+ * Copyright (C) 2001-2005 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
#define MAX_EMPTY_BLOCKS 200
+#if defined(WIN32) || defined(UNDER_CE)
+# define WINSOCK_STRERROR_SIZE 20
+static const char *winsock_strerror( char *buf )
+{
+ snprintf( buf, WINSOCK_STRERROR_SIZE, "Winsock error %d",
+ WSAGetLastError( ) );
+ buf[WINSOCK_STRERROR_SIZE - 1] = '\0';
+ return buf;
+}
+#endif
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
"Allows you to modify the default caching value for UDP streams. This " \
"value should be set in millisecond units." )
-#define TTL_TEXT N_("Time To Live")
-#define TTL_LONGTEXT N_("Allows you to define the time to live of the " \
- "outgoing stream.")
-
#define GROUP_TEXT N_("Group packets")
#define GROUP_LONGTEXT N_("Packets can be sent one by one at the right time " \
"or by groups. This allows you to give the number " \
set_category( CAT_SOUT );
set_subcategory( SUBCAT_SOUT_ACO );
add_integer( SOUT_CFG_PREFIX "caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
- add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL,TTL_TEXT, TTL_LONGTEXT,
- VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "group", 1, NULL, GROUP_TEXT, GROUP_LONGTEXT,
VLC_TRUE );
add_suppressed_integer( SOUT_CFG_PREFIX "late" );
static const char *ppsz_sout_options[] = {
"caching",
- "ttl",
"group",
"raw",
NULL
if( p_access->psz_access != NULL &&
!strcmp( p_access->psz_access, "rtp" ) )
{
- msg_Warn( p_access, "be careful that rtp output only works with ts "
- "payload (not an error)" );
p_sys->b_rtpts = 1;
}
else
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;
-
- var_Get( p_access, SOUT_CFG_PREFIX "ttl", &val );
- socket_desc.i_ttl = val.i_int;
+ socket_desc.i_handle = -1;
+ socket_desc.v6only = 0;
+ socket_desc.i_ttl = 0;
p_sys->p_thread->p_private = (void*)&socket_desc;
- if( !( p_network = module_Need( p_sys->p_thread, "network", NULL, 0 ) ) )
+ 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 )
{
- msg_Err( p_access, "failed to open a connection (udp)" );
- return VLC_EGENERIC;
+ 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;
+ }
}
- module_Unneed( p_sys->p_thread, p_network );
p_sys->p_thread->i_handle = socket_desc.i_handle;
+ net_StopRecv( socket_desc.i_handle );
var_Get( p_access, SOUT_CFG_PREFIX "caching", &val );
p_sys->p_thread->i_caching = (int64_t)val.i_int * 1000;
p_sys->i_mtu = socket_desc.i_mtu;
-#ifdef WIN32
if( vlc_thread_create( p_sys->p_thread, "sout write thread", ThreadWrite,
VLC_THREAD_PRIORITY_HIGHEST, VLC_FALSE ) )
-#else
- if( vlc_thread_create( p_sys->p_thread, "sout write thread", ThreadWrite,
- VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-#endif
{
msg_Err( p_access->p_sout, "cannot spawn sout access thread" );
vlc_object_destroy( p_sys->p_thread );
p_dummy->i_dts = 0;
p_dummy->i_pts = 0;
p_dummy->i_length = 0;
+ memset( p_dummy->p_buffer, 0, p_dummy->i_buffer );
block_FifoPut( p_sys->p_thread->p_fifo, p_dummy );
}
vlc_thread_join( p_sys->p_thread );
mtime_t i_date_last = -1;
mtime_t i_to_send = p_thread->i_group;
int i_dropped_packets = 0;
+#if defined(WIN32) || defined(UNDER_CE)
+ char strerror_buf[WINSOCK_STRERROR_SIZE];
+# define strerror( x ) winsock_strerror( strerror_buf )
+#endif
while( !p_thread->b_die )
{
}
i_to_send--;
- if ( !i_to_send || (p_pk->i_flags & BLOCK_FLAG_CLOCK) )
+ if( !i_to_send || (p_pk->i_flags & BLOCK_FLAG_CLOCK) )
{
mwait( i_date );
i_to_send = p_thread->i_group;
}
- send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_buffer, 0 );
+ if( send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_buffer, 0 )
+ == -1 )
+ {
+ msg_Warn( p_thread, "send error: %s", strerror(errno) );
+ }
if( i_dropped_packets )
{