]> git.sesse.net Git - vlc/commitdiff
* Win32 network support by Boris Dor�s <babal@via.ecp.fr>.
authorSam Hocevar <sam@videolan.org>
Thu, 21 Jun 2001 07:22:03 +0000 (07:22 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 21 Jun 2001 07:22:03 +0000 (07:22 +0000)
AUTHORS
include/input_iovec.h
plugins/directx/.cvsignore [new file with mode: 0644]
plugins/mpeg/input_ts.c
plugins/mpeg/input_ts.h
src/input/input.c

diff --git a/AUTHORS b/AUTHORS
index 5424b88722d70cf9244c436141015fee44197bf8..6dd433d8bf0be6e3b0a9f81748a4f639ae33bf15 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -21,7 +21,8 @@ D: directory browsing code in modules.c
 
 N: Gildas Bazin
 E: gbazin@netcourrier.com
-D: mingw32 port
+D: mingw32 port, various win32 fixes
+D: DirectX audio and video output
 
 N: Stéphane Borel
 E: stef@via.ecp.fr
@@ -58,6 +59,11 @@ E: colin@zoy.org
 C: colin
 D: MacOS X sound support
 
+N: Boris Dorès
+E: babal@via.ecp.fr
+C: babal
+D: Win32 network input
+
 N: Jean-Marc Dressler
 E: polux@via.ecp.fr
 C: polux
@@ -115,7 +121,7 @@ D: Bug fixes
 N: Jon Lech Johansen
 E: jon-vl@nanocrew.net
 D: PS input fixes
-D: Win32 port
+D: Win32 DVD input port
 
 N: Michel Kaempf
 E: maxx@via.ecp.fr
index e88cd4c9c3ddb6567b53ea9cb0326c164e48de0d..7d7a5866ce16496837431da5026819913140b26b 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * input_iovec.h: iovec structure and readv() replacement
+ * input_iovec.h: iovec structure
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
  *
@@ -30,58 +30,3 @@ struct iovec
     size_t iov_len;     /* Length of data.  */
 };
 
-/*****************************************************************************
- * readv: readv() replacement for iovec-impaired C libraries
- *****************************************************************************/
-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-- )
-    {
-        register signed int i_bytes;
-
-        i_len  = p_iovec->iov_len;
-        p_base = p_iovec->iov_base;
-
-        /* Loop is unrolled one time to spare the (i_bytes < 0) test */
-        if( i_len > 0 )
-        {
-            i_bytes = read( i_fd, p_base, i_len );
-
-            if( ( i_total == 0 ) && ( i_bytes < 0 ) )
-            {
-                return -1;
-            }
-
-            if( i_bytes <= 0 )
-            {
-                return i_total;
-            }
-
-            i_len   -= i_bytes;
-            i_total += i_bytes;
-            p_base  += i_bytes;
-
-            while( i_len > 0 )
-            {
-                i_bytes = read( i_fd, p_base, i_len );
-
-                if( i_bytes <= 0 )
-                {
-                    return i_total;
-                }
-
-                i_len   -= i_bytes;
-                i_total += i_bytes;
-                p_base  += i_bytes;
-            }
-        }
-
-        p_iovec++;
-    }
-
-    return i_total;
-}
-
diff --git a/plugins/directx/.cvsignore b/plugins/directx/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
index 6645fc96364bea8b7d654a484b17edc7babe1caa..5717e56607e387e61e0d0d8374eb1c5a633b92a8 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.c: TS demux and netlist management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ts.c,v 1.26 2001/06/03 12:47:21 sam Exp $
+ * $Id: input_ts.c,v 1.27 2001/06/21 07:22:03 sam Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org>
  *
@@ -57,6 +57,7 @@
 
 #if defined( WIN32 )
 #   include <io.h>
+#   include <winsock2.h>
 #   include "input_iovec.h"
 #else
 #   include <sys/uio.h>                                      /* struct iovec */
 #include "input_ext-intf.h"
 #include "input_ext-dec.h"
 
-#include "input.h"
-#include "input_ts.h"
-
 #include "mpeg_system.h"
 #include "input_netlist.h"
 
+#include "input.h"
+#include "input_ts.h"
+
 #include "modules.h"
 #include "modules_export.h"
 
@@ -182,6 +183,11 @@ static void TSInit( input_thread_t * p_input )
         return;
     }
 
+#if defined( WIN32 )
+    p_method->i_length = 0;
+    p_method->i_offset = 0;
+#endif
+
     p_input->p_plugin_data = (void *)p_method;
     p_input->p_method_data = NULL;
 
@@ -268,10 +274,9 @@ static int TSRead( input_thread_t * p_input,
 {
     thread_ts_data_t    * p_method;
     unsigned int    i_read, i_loop;
-    int             i_data;
+    int             i_data = 0;
     struct iovec  * p_iovec;
-    struct timeval  s_wait;
-
+    struct timeval  timeout;
 
     /* Get iovecs */
     p_iovec = input_NetlistGetiovec( p_input->p_method_data );
@@ -289,15 +294,20 @@ static int TSRead( input_thread_t * p_input,
     FD_SET( p_input->i_handle, &(p_method->fds) );
 
     /* We'll wait 0.5 second if nothing happens */
-    s_wait.tv_sec = 0;
-    s_wait.tv_usec = 500000;
+    timeout.tv_sec = 0;
+    timeout.tv_usec = 500000;
 
     /* Reset pointer table */
     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->fds), NULL, NULL,
-                     &s_wait);
+#if defined( WIN32 )
+    if ( ! p_input->stream.b_pace_control ) 
+#endif
+    {
+        i_data = select( p_input->i_handle + 1, &p_method->fds,
+                         NULL, NULL, &timeout );
+    }
 
     if( i_data == -1 )
     {
@@ -307,8 +317,19 @@ static int TSRead( input_thread_t * p_input,
 
     if( i_data )
     {
+#if defined( WIN32 )
+        if( p_input->stream.b_pace_control )
+        {
+            i_read = readv_file( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
+        }
+        else
+        {
+            i_read = readv_network( p_input->i_handle, p_iovec,
+                                    INPUT_READ_ONCE, p_method );
+        }
+#else
         i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
-
+#endif
         if( i_read == -1 )
         {
             intf_ErrMsg( "input error: TS readv error" );
index 97dc361d3278f31665bcc4e77dc94fc414caedde..20f4183d790873e2cce069b3e697de4245bcc2dc 100644 (file)
@@ -2,9 +2,10 @@
  * input_ts.h: structures of the input not exported to other modules
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ts.h,v 1.8 2001/06/20 07:43:48 sam Exp $
+ * $Id: input_ts.h,v 1.9 2001/06/21 07:22:03 sam Exp $
  *
  * Authors: Henri Fallon <henri@via.ecp.fr>
+ *          Boris Dorès <babal@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-
 #define NB_DATA 16384 
 #define NB_PES  8192
 
-/* Will be used whne NetworkOpen is ready */
-typedef struct thread_ts_data_s { 
-    
-    // FILE *                  stream;
+#define BUFFER_SIZE (7 * TS_PACKET_SIZE)
+
+/*****************************************************************************
+ * thread_ts_data_t: private input data
+ *****************************************************************************/
+typedef struct thread_ts_data_s
+{ 
+    /* The file descriptor we select() on */
     fd_set fds;
     
+#if defined( WIN32 )
+    char p_buffer[ BUFFER_SIZE ];      /* temporary buffer for readv_network */
+    int  i_length;                               /* length of the UDP packet */
+    int  i_offset;           /* number of bytes already read from the buffer */
+#endif
+    
 } thread_ts_data_t;
 
+/*****************************************************************************
+ * readv_*: readv() replacements for iovec-impaired C libraries
+ *****************************************************************************/
+
+#if defined( WIN32 )
+static __inline__ int readv_file( int i_fd, struct iovec *p_iovec, int i_count )
+{
+    int i_index, i_len, i_total = 0;
+    u8 *p_base;
+
+    for( i_index = i_count; i_index; i_index-- )
+    {
+        register signed int i_bytes;
+
+        i_len  = p_iovec->iov_len;
+        p_base = p_iovec->iov_base;
+
+        /* Loop is unrolled one time to spare the (i_bytes <= 0) test */
+
+        if( i_len > 0 )
+        {
+            i_bytes = read( i_fd, p_base, i_len );
+
+            if( ( i_total == 0 ) && ( i_bytes < 0 ) )
+            {
+                return -1;
+            }
+
+            if( i_bytes <= 0 )
+            {
+                return i_total;
+            }
+
+            i_len -= i_bytes; i_total += i_bytes; p_base += i_bytes;
+
+            while( i_len > 0 )
+            {
+                i_bytes = read( i_fd, p_base, i_len );
+
+                if( i_bytes <= 0 )
+                {
+                    return i_total;
+                }
+
+                i_len -= i_bytes; i_total += i_bytes; p_base += i_bytes;
+            }
+        }
+
+        p_iovec++;
+    }
+
+    return i_total;
+}
+
+static __inline__ int read_network( int i_fd, char * p_base,
+                                    thread_ts_data_t *p_sys, int i_len )
+{
+    int i_bytes;
+
+    if( p_sys->i_offset >= p_sys->i_length )
+    {
+        p_sys->i_length = recv( i_fd, p_sys->p_buffer, BUFFER_SIZE, 0 );
+        if ( p_sys->i_length == SOCKET_ERROR )
+        {
+            return -1;
+        }
+        p_sys->i_offset = 0;
+    }
+
+    if( i_len <= p_sys->i_length - p_sys->i_offset )
+    {
+         i_bytes = i_len;
+    }
+    else
+    {
+         i_bytes = p_sys->i_length - p_sys->i_offset;
+    }
+
+    memcpy( p_base, p_sys->p_buffer + p_sys->i_offset, i_bytes );
+    p_sys->i_offset += i_bytes;
+
+    return i_bytes;
+}
+
+static __inline__ int readv_network( int i_fd, struct iovec *p_iovec,
+                                     int i_count, thread_ts_data_t *p_sys )
+{
+    int i_index, i_len, i_total = 0;
+    u8 *p_base;
+
+    for( i_index = i_count; i_index; i_index-- )
+    {
+        register signed int i_bytes;
+
+        i_len  = p_iovec->iov_len;
+        p_base = p_iovec->iov_base;
+
+        /* Loop is unrolled one time to spare the (i_bytes <= 0) test */
+        if( i_len > 0 )
+        {
+            i_bytes = read_network( i_fd, p_base, p_sys, i_len );
+
+            if( ( i_total == 0 ) && ( i_bytes < 0 ) )
+            {
+                return -1;
+            }
+
+            if( i_bytes <= 0 )
+            {
+                return i_total;
+            }
+
+            i_len -= i_bytes; i_total += i_bytes; p_base += i_bytes;
+
+            while( i_len > 0 )
+            {
+                i_bytes = read_network( i_fd, p_base, p_sys, i_len );
+
+                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
+
index c811f0a9b6d9de10031d1ce935c33edbf59b707a..f9cfeaa6dc774993c0dd253827ebabca76aa2088 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.123 2001/06/15 05:12:30 sam Exp $
+ * $Id: input.c,v 1.124 2001/06/21 07:22:03 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -623,11 +623,14 @@ static void NetworkOpen( input_thread_t * p_input )
     int                 i_port = 0;
     int                 i_opt;
     struct sockaddr_in  sock;
-
 #ifdef WIN32
-    /* WinSock Library Init. */
     WSADATA Data;
-    int i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
+    int i_err;
+#endif
+    
+#ifdef WIN32
+    /* WinSock Library Init. */
+    i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
 
     if( i_err )
     {
@@ -778,6 +781,13 @@ static void NetworkOpen( input_thread_t * p_input )
         p_input->b_error = 1;
         return;
     }
+
+#if defined( WIN32 )
+    if ( psz_broadcast != NULL )
+    {
+        sock.sin_addr.s_addr = INADDR_ANY;
+    }
+#endif
     
     /* Bind it */
     if( bind( p_input->i_handle, (struct sockaddr *)&sock,