* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ts.c,v 1.19 2001/05/08 12:53:30 bozo Exp $
+ * $Id: input_ts.c,v 1.20 2001/05/28 04:23:52 sam Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
#include <sys/select.h>
#endif
-#ifndef WIN32
-#include <sys/uio.h>
+#ifndef WIN32
+# include <sys/uio.h> /* struct iovec */
+#else
+ struct iovec
+ {
+ void *iov_base; /* Pointer to data. */
+ size_t iov_len; /* Length of data. */
+ };
#endif
#include <sys/stat.h>
*****************************************************************************/
void TSFakeOpen( input_thread_t * p_input )
{
-#if !defined( SYS_BEOS ) && !defined( SYS_NTO ) && !defined( WIN32 )
+#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
char *psz_name = p_input->p_source;
if( ( strlen(psz_name) > 3 ) && !strncasecmp( psz_name, "ts:", 3 ) )
memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
/* Fill if some data is available */
- i_data = select(p_input->i_handle + 1, &(p_method->s_fdset), NULL, NULL,
- &s_wait);
+ i_data = select( p_input->i_handle + 1, &(p_method->s_fdset), NULL, NULL,
+ &s_wait);
if( i_data == -1 )
{
if( i_data )
{
-#ifndef WIN32
i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
-#else
- i_read = -1;
-#endif
if( i_read == -1 )
{
* input_ts.h: structures of the input not exported to other modules
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ts.h,v 1.4 2001/03/21 13:42:34 sam Exp $
+ * $Id: input_ts.h,v 1.5 2001/05/28 04:23:52 sam Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
*
fd_set s_fdset;
} thread_ts_data_t;
+
+#ifdef WIN32
+static __inline__ int readv( int i_fd, struct iovec *p_iovec, int i_count )
+{
+ int i_index, i_len, i_total = 0;
+ char *p_base;
+
+ for( i_index = i_count; i_index; i_index-- )
+ {
+ i_len = p_iovec->iov_len;
+ p_base = p_iovec->iov_base;
+
+ while( i_len > 0 )
+ {
+ register signed int i_bytes;
+ i_bytes = read( i_fd, p_base, i_len );
+
+ if( i_total == 0 )
+ {
+ if( i_bytes < 0 )
+ {
+ intf_ErrMsg( "input error: read failed on socket" );
+ return -1;
+ }
+ }
+
+ if( i_bytes <= 0 )
+ {
+ return i_total;
+ }
+
+ i_len -= i_bytes;
+ i_total += i_bytes;
+ p_base += i_bytes;
+ }
+
+ p_iovec++;
+ }
+
+ return i_total;
+}
+#endif
+
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.110 2001/05/28 03:17:01 xav Exp $
+ * $Id: input.c,v 1.111 2001/05/28 04:23:52 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
int i_opt;
struct sockaddr_in sock;
- /* WinSock Library Init. */
-
- #ifdef WIN32
- WSADATA Data;
- int Result = WSAStartup( MAKEWORD( 1,1 ),&Data );
-
- if( Result != 0 )
- {
- intf_ErrMsg( "Can't initiate WinSocks : error %i", Result) ;
- return ;
- }
- #endif
+#ifdef WIN32
+ /* WinSock Library Init. */
+ WSADATA Data;
+ int i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
+
+ if( i_err )
+ {
+ intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
+ return ;
+ }
+#endif
/* Get the remote server */
if( p_input->p_source != NULL )
if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_REUSEADDR,
&i_opt, sizeof( i_opt ) ) == -1 )
{
- intf_ErrMsg("input error: can't configure socket (SO_REUSEADDR: %s)",
- strerror(errno));
+ intf_ErrMsg( "input error: can't configure socket (SO_REUSEADDR: %s)",
+ strerror(errno));
close( p_input->i_handle );
p_input->b_error = 1;
return;
if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_RCVBUF,
&i_opt, sizeof( i_opt ) ) == -1 )
{
- intf_ErrMsg("input error: can't configure socket (SO_RCVBUF: %s)",
- strerror(errno));
+ intf_ErrMsg( "input error: can't configure socket (SO_RCVBUF: %s)",
+ strerror(errno));
close( p_input->i_handle );
p_input->b_error = 1;
return;
}
/* Build the local socket */
- if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast )
- == -1 )
+ if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) == -1 )
{
+ intf_ErrMsg( "input error: can't build local address" );
close( p_input->i_handle );
p_input->b_error = 1;
return;
/* Build socket for remote connection */
if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
{
+ intf_ErrMsg( "input error: can't build remote address" );
close( p_input->i_handle );
p_input->b_error = 1;
return;
if( connect( p_input->i_handle, (struct sockaddr *) &sock,
sizeof( sock ) ) == (-1) )
{
- intf_ErrMsg( "NetworkOpen: can't connect socket : %s",
+ intf_ErrMsg( "input error: can't connect socket, %s",
strerror(errno) );
close( p_input->i_handle );
p_input->b_error = 1;
* with the server. */
p_input->stream.b_pace_control = 0;
p_input->stream.b_seekable = 0;
+
+ intf_WarnMsg( 3, "input: successfully opened network mode" );
return;
}
{
close( p_input->i_handle );
- #ifdef WIN32
- WSACleanup();
- #endif
+#ifdef WIN32
+ WSACleanup();
+#endif
}
#endif
+
* input_netlist.c: netlist management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_netlist.c,v 1.36 2001/05/06 04:32:02 sam Exp $
+ * $Id: input_netlist.c,v 1.37 2001/05/28 04:23:52 sam Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
* the netlist_t struct */
/* As i_loop is unsigned int, and i_ns_data int, this shouldn't be a
* problem */
- for( i_loop=1; i_loop < i_nb_data; i_loop*=2 )
+ for( i_loop = 1; i_loop < i_nb_data; i_loop *= 2 )
+ {
;
+ }
+
intf_DbgMsg( "Netlist : Required %i byte, got %u",i_nb_data,i_loop );
i_nb_data = i_loop;
/* Same thing for i_nb_pes */
- for( i_loop=1; i_loop < i_nb_data; i_loop*=2 )
+ for( i_loop = 1; i_loop < i_nb_data; i_loop *= 2 )
+ {
;
+ }
+
intf_DbgMsg( "Netlist : Required %i byte, got %u",i_nb_data,i_loop );
i_nb_data = i_loop;