]> git.sesse.net Git - vlc/blob - plugins/mpeg/input_ts.h
* Added a wrapper for readv() on platforms which don't support it. The
[vlc] / plugins / mpeg / input_ts.h
1 /*****************************************************************************
2  * input_ts.h: structures of the input not exported to other modules
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: input_ts.h,v 1.5 2001/05/28 04:23:52 sam Exp $
6  *
7  * Authors: Henri Fallon <henri@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24
25 #define NB_DATA 16384 
26 #define NB_PES  8192
27
28 /* Will be used whne NetworkOpen is ready */
29 typedef struct thread_ts_data_s { 
30     
31     // FILE *                  stream;
32     fd_set s_fdset;
33     
34 } thread_ts_data_t;
35
36 #ifdef WIN32
37 static __inline__ int readv( int i_fd, struct iovec *p_iovec, int i_count )
38 {
39     int i_index, i_len, i_total = 0;
40     char *p_base;
41
42     for( i_index = i_count; i_index; i_index-- )
43     {
44         i_len  = p_iovec->iov_len;
45         p_base = p_iovec->iov_base;
46
47         while( i_len > 0 )
48         {
49             register signed int i_bytes;
50             i_bytes = read( i_fd, p_base, i_len );
51
52             if( i_total == 0 )
53             {
54                 if( i_bytes < 0 )
55                 {
56                     intf_ErrMsg( "input error: read failed on socket" );
57                     return -1;
58                 }
59             }
60
61             if( i_bytes <= 0 )
62             {
63                 return i_total;
64             }
65
66             i_len   -= i_bytes;
67             i_total += i_bytes;
68             p_base  += i_bytes;
69         }
70
71         p_iovec++;
72     }
73
74     return i_total;
75 }
76 #endif
77