* udp.c: raw UDP & RTP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.15 2003/03/03 14:21:08 gbazin Exp $
+ * $Id: udp.c,v 1.19 2003/03/30 18:14:35 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Tristan Leteurtre <tooney@via.ecp.fr>
"value should be set in miliseconds units." )
vlc_module_begin();
- set_description( _("raw UDP access module") );
+ set_description( _("UDP/RTP input") );
add_category_hint( N_("udp"), NULL , VLC_TRUE );
add_integer( "udp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
set_capability( "access", 0 );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 0;
p_input->stream.b_seekable = 0;
- p_input->stream.b_connected = 0;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.i_method = INPUT_METHOD_NETWORK;
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_socket_t * p_access_data = (input_socket_t *)p_input->p_access_data;
struct timeval timeout;
fd_set fds;
+ ssize_t i_recv;
int i_ret;
/* Initialize file descriptor set */
timeout.tv_usec = 500000;
/* Find if some data is available */
- i_ret = select( p_access_data->i_handle + 1, &fds,
- NULL, NULL, &timeout );
+ while( (i_ret = select( p_access_data->i_handle + 1, &fds,
+ NULL, NULL, &timeout )) == 0
+ || (i_ret < 0 && errno == EINTR) )
+ {
+ FD_ZERO( &fds );
+ FD_SET( p_access_data->i_handle, &fds );
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500000;
- if( i_ret == -1 && errno != EINTR )
+ if( p_input->b_die || p_input->b_error )
+ {
+ return 0;
+ }
+ }
+
+ if( i_ret < 0 )
{
msg_Err( p_input, "network select error (%s)", strerror(errno) );
+ return -1;
}
- else if( i_ret > 0 )
- {
- ssize_t i_recv = recv( p_access_data->i_handle, p_buffer, i_len, 0 );
- if( i_recv < 0 )
- {
+ i_recv = recv( p_access_data->i_handle, p_buffer, i_len, 0 );
+
+ if( i_recv < 0 )
+ {
#ifdef WIN32
- /* On win32 recv() will fail if the datagram doesn't fit inside
- * the passed buffer, even though the buffer will be filled with
- * the first part of the datagram. */
- if( WSAGetLastError() == WSAEMSGSIZE )
- {
- msg_Err( p_input, "recv() failed. "
- "Increase the mtu size (--mtu option)" );
- i_recv = i_len;
- }
- else
+ /* On win32 recv() will fail if the datagram doesn't fit inside
+ * the passed buffer, even though the buffer will be filled with
+ * the first part of the datagram. */
+ if( WSAGetLastError() == WSAEMSGSIZE )
+ {
+ msg_Err( p_input, "recv() failed. "
+ "Increase the mtu size (--mtu option)" );
+ i_recv = i_len;
+ }
+ else
#endif
- msg_Err( p_input, "recv failed (%s)", strerror(errno) );
- }
-
- return i_recv;
+ msg_Err( p_input, "recv failed (%s)", strerror(errno) );
}
- return 0;
+ return i_recv;
#endif
}