]> git.sesse.net Git - vlc/blob - src/input/input.c
517bab4a4c3ad029fffdbfc5310d1979e746bf9e
[vlc] / src / input / input.c
1 /*****************************************************************************
2  * input.c: input thread
3  * Read an MPEG2 stream, demultiplex and parse it before sending it to
4  * decoders.
5  *****************************************************************************
6  * Copyright (C) 1998, 1999, 2000 VideoLAN
7  * $Id: input.c,v 1.112 2001/05/30 05:19:03 stef Exp $
8  *
9  * Authors: Christophe Massiot <massiot@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include "defs.h"
30
31 #include <stdlib.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <fcntl.h>
35 #include <unistd.h>
36 #include <string.h>
37 #ifdef STRNCASECMP_IN_STRINGS_H
38 #   include <strings.h>
39 #endif
40 #include <errno.h>
41
42 /* WinSock Includes */
43
44 #ifdef WIN32
45 #include <winsock2.h>
46 #endif
47
48
49 /* Network functions */
50
51 #if !defined( SYS_BEOS ) && !defined( SYS_NTO ) && !defined( WIN32 )
52 #include <netdb.h>                                            /* hostent ... */
53 #include <sys/socket.h>
54 #include <netinet/in.h>
55 #include <arpa/inet.h>
56 #include <sys/types.h>
57 #include <sys/socket.h>
58 #endif
59
60 #ifdef STATS
61 #   include <sys/times.h>
62 #endif
63
64 #include "config.h"
65 #include "common.h"
66 #include "threads.h"
67 #include "mtime.h"
68 #include "netutils.h"
69 #include "modules.h"
70
71 #include "intf_msg.h"
72 #include "intf_playlist.h"
73
74 #include "stream_control.h"
75 #include "input_ext-intf.h"
76 #include "input_ext-dec.h"
77
78 #include "input.h"
79 #include "interface.h"
80
81 #include "main.h"
82
83
84 /*****************************************************************************
85  * Local prototypes
86  *****************************************************************************/
87 static void RunThread       ( input_thread_t *p_input );
88 static  int InitThread      ( input_thread_t *p_input );
89 static void ErrorThread     ( input_thread_t *p_input );
90 static void DestroyThread   ( input_thread_t *p_input );
91 static void EndThread       ( input_thread_t *p_input );
92
93 /*****************************************************************************
94  * input_CreateThread: creates a new input thread
95  *****************************************************************************
96  * This function creates a new input, and returns a pointer
97  * to its description. On error, it returns NULL.
98  * If pi_status is NULL, then the function will block until the thread is ready.
99  * If not, it will be updated using one of the THREAD_* constants.
100  *****************************************************************************/
101 input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
102 {
103     input_thread_t *    p_input;                        /* thread descriptor */
104     int                 i_status;                           /* thread status */
105
106     /* Allocate descriptor */
107     p_input = (input_thread_t *)malloc( sizeof(input_thread_t) );
108     if( p_input == NULL )
109     {
110         intf_ErrMsg( "input error: can't allocate input thread (%s)",
111                      strerror(errno) );
112         return( NULL );
113     }
114
115     /* Packets read once */
116     p_input->i_read_once = INPUT_READ_ONCE;
117
118     /* Initialize thread properties */
119     p_input->b_die              = 0;
120     p_input->b_error            = 0;
121     p_input->b_eof              = 0;
122
123     /* Set target */
124     p_input->p_source           = p_item->psz_name;
125
126     /* I have never understood that stuff --Meuuh */
127     p_input->pi_status          = (pi_status != NULL) ? pi_status : &i_status;
128     *p_input->pi_status         = THREAD_CREATE;
129
130     /* Initialize stream description */
131     p_input->stream.i_es_number = 0;
132     p_input->stream.i_selected_es_number = 0;
133     p_input->stream.i_pgrm_number = 0;
134     p_input->stream.i_new_status = p_input->stream.i_new_rate = 0;
135     p_input->stream.i_mux_rate = 0;
136
137     /* no stream, no area */
138     p_input->stream.i_area_nb = 0;
139     p_input->stream.pp_areas = NULL;
140     p_input->stream.p_selected_area = NULL;
141     p_input->stream.p_new_area = NULL;
142     /* By default there is one areas in a stream */
143     input_AddArea( p_input );
144     p_input->stream.p_selected_area = p_input->stream.pp_areas[0];
145
146     /* Initialize stream control properties. */
147     p_input->stream.control.i_status = PLAYING_S;
148     p_input->stream.control.i_rate = DEFAULT_RATE;
149     p_input->stream.control.b_mute = 0;
150     p_input->stream.control.b_bw = 0;
151
152     /* Create thread and set locks. */
153     vlc_mutex_init( &p_input->stream.stream_lock );
154     vlc_cond_init( &p_input->stream.stream_wait );
155     vlc_mutex_init( &p_input->stream.control.control_lock );
156     if( vlc_thread_create( &p_input->thread_id, "input", (void *) RunThread,
157                            (void *) p_input ) )
158     {
159         intf_ErrMsg( "input error: can't create input thread (%s)",
160                      strerror(errno) );
161         free( p_input );
162         return( NULL );
163     }
164
165     /* If status is NULL, wait until the thread is created */
166     if( pi_status == NULL )
167     {
168         do
169         {
170             msleep( THREAD_SLEEP );
171         } while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
172                 && (i_status != THREAD_FATAL) );
173         if( i_status != THREAD_READY )
174         {
175             return( NULL );
176         }
177     }
178     return( p_input );
179 }
180
181 /*****************************************************************************
182  * input_DestroyThread: mark an input thread as zombie
183  *****************************************************************************
184  * This function should not return until the thread is effectively cancelled.
185  *****************************************************************************/
186 void input_DestroyThread( input_thread_t *p_input, int *pi_status )
187 {
188     int         i_status;                                   /* thread status */
189
190     /* Set status */
191     p_input->pi_status = (pi_status != NULL) ? pi_status : &i_status;
192     *p_input->pi_status = THREAD_DESTROY;
193
194     /* Request thread destruction */
195     p_input->b_die = 1;
196
197     /* Make the thread exit of an eventual vlc_cond_wait() */
198     vlc_mutex_lock( &p_input->stream.stream_lock );
199     vlc_cond_signal( &p_input->stream.stream_wait );
200     vlc_mutex_unlock( &p_input->stream.stream_lock );
201
202     /* If status is NULL, wait until thread has been destroyed */
203     if( pi_status == NULL )
204     {
205         do
206         {
207             msleep( THREAD_SLEEP );
208         } while ( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
209                   && (i_status != THREAD_FATAL) );
210     }
211 }
212
213 /*****************************************************************************
214  * RunThread: main thread loop
215  *****************************************************************************
216  * Thread in charge of processing the network packets and demultiplexing.
217  *****************************************************************************/
218 static void RunThread( input_thread_t *p_input )
219 {
220     int                     i_error, i;
221
222     if( InitThread( p_input ) )
223     {
224
225         /* If we failed, wait before we are killed, and exit */
226         *p_input->pi_status = THREAD_ERROR;
227         p_input->b_error = 1;
228         ErrorThread( p_input );
229         DestroyThread( p_input );
230         return;
231     }
232
233     /* initialization is completed */
234     vlc_mutex_lock( &p_input->stream.stream_lock );
235     p_input->stream.b_changed = 1;
236     vlc_mutex_unlock( &p_input->stream.stream_lock );
237
238     while( !p_input->b_die && !p_input->b_error && !p_input->b_eof )
239     {
240         data_packet_t *         pp_packets[p_input->i_read_once];
241
242 #ifdef STATS
243         p_input->c_loops++;
244 #endif
245
246         vlc_mutex_lock( &p_input->stream.stream_lock );
247
248         if( p_input->stream.p_new_area )
249         {
250             p_input->pf_set_area( p_input, p_input->stream.p_new_area );
251             p_input->stream.p_new_area = NULL;
252         }
253
254         if( p_input->stream.p_selected_area->i_seek != NO_SEEK )
255         {
256             if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
257             {
258                 p_input->pf_seek( p_input,
259                                   p_input->stream.p_selected_area->i_seek );
260
261                 for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
262                 {
263                     pgrm_descriptor_t * p_pgrm
264                                             = p_input->stream.pp_programs[i];
265                     /* Escape all decoders for the stream discontinuity they
266                      * will encounter. */
267                     input_EscapeDiscontinuity( p_input, p_pgrm );
268
269                     /* Reinitialize synchro. */
270                     p_pgrm->i_synchro_state = SYNCHRO_REINIT;
271                 }
272             }
273             p_input->stream.p_selected_area->i_seek = NO_SEEK;
274         }
275
276         if( p_input->stream.p_removed_es )
277         {
278             input_UnselectES( p_input, p_input->stream.p_removed_es );
279             p_input->stream.p_removed_es = NULL;
280         }
281
282         if( p_input->stream.p_newly_selected_es )
283         {
284             input_SelectES( p_input, p_input->stream.p_newly_selected_es );
285             p_input->stream.p_newly_selected_es = NULL;
286         }
287
288         vlc_mutex_unlock( &p_input->stream.stream_lock );
289
290         i_error = p_input->pf_read( p_input, pp_packets );
291
292         /* Demultiplex read packets. */
293         for( i = 0; i < p_input->i_read_once && pp_packets[i] != NULL; i++ )
294         {
295             p_input->pf_demux( p_input, pp_packets[i] );
296         }
297
298         if( i_error )
299         {
300             if( i_error == 1 )
301             {
302                 /* End of file - we do not set b_die because only the
303                  * interface is allowed to do so. */
304                 intf_WarnMsg( 3, "input: EOF reached" );
305                 p_input->b_eof = 1;
306             }
307             else
308             {
309                 p_input->b_error = 1;
310             }
311         }
312     }
313
314     if( p_input->b_error || p_input->b_eof )
315     {
316         ErrorThread( p_input );
317     }
318
319     EndThread( p_input );
320
321     DestroyThread( p_input );
322
323     intf_DbgMsg("input: Thread end");
324 }
325
326 /*****************************************************************************
327  * InitThread: init the input Thread
328  *****************************************************************************/
329 static int InitThread( input_thread_t * p_input )
330 {
331
332 #ifdef STATS
333     /* Initialize statistics */
334     p_input->c_loops                    = 0;
335     p_input->c_bytes                    = 0;
336     p_input->c_payload_bytes            = 0;
337     p_input->c_packets_read             = 0;
338     p_input->c_packets_trashed          = 0;
339 #endif
340
341     p_input->p_input_module = module_Need( MODULE_CAPABILITY_INPUT,
342                                            (probedata_t *)p_input );
343
344     if( p_input->p_input_module == NULL )
345     {
346         intf_ErrMsg( "input error: no suitable input module for `%s'",
347                      p_input->p_source );
348         return( -1 );
349     }
350
351 #define f p_input->p_input_module->p_functions->input.functions.input
352     p_input->pf_init          = f.pf_init;
353     p_input->pf_open          = f.pf_open;
354     p_input->pf_close         = f.pf_close;
355     p_input->pf_end           = f.pf_end;
356     p_input->pf_read          = f.pf_read;
357     p_input->pf_set_area      = f.pf_set_area;
358     p_input->pf_demux         = f.pf_demux;
359     p_input->pf_new_packet    = f.pf_new_packet;
360     p_input->pf_new_pes       = f.pf_new_pes;
361     p_input->pf_delete_packet = f.pf_delete_packet;
362     p_input->pf_delete_pes    = f.pf_delete_pes;
363     p_input->pf_rewind        = f.pf_rewind;
364     p_input->pf_seek          = f.pf_seek;
365 #undef f
366     p_input->pf_open( p_input );
367
368     if( p_input->b_error )
369     {
370         /* We barfed -- exit nicely */
371         p_input->pf_close( p_input );
372         module_Unneed( p_input->p_input_module );
373         return( -1 );
374     }
375
376     p_input->pf_init( p_input );
377
378     if( p_input->b_error )
379     {
380         /* We barfed -- exit nicely */
381         p_input->pf_close( p_input );
382         module_Unneed( p_input->p_input_module );
383         return( -1 );
384     }
385
386     *p_input->pi_status = THREAD_READY;
387
388     return( 0 );
389 }
390
391 /*****************************************************************************
392  * ErrorThread: RunThread() error loop
393  *****************************************************************************
394  * This function is called when an error occured during thread main's loop.
395  *****************************************************************************/
396 static void ErrorThread( input_thread_t *p_input )
397 {
398     while( !p_input->b_die )
399     {
400         /* Sleep a while */
401         msleep( INPUT_IDLE_SLEEP );
402     }
403 }
404
405 /*****************************************************************************
406  * EndThread: end the input thread
407  *****************************************************************************/
408 static void EndThread( input_thread_t * p_input )
409 {
410     int *       pi_status;                                  /* thread status */
411
412     /* Store status */
413     pi_status = p_input->pi_status;
414     *pi_status = THREAD_END;
415
416 #ifdef STATS
417     {
418         struct tms cpu_usage;
419         times( &cpu_usage );
420
421         intf_Msg("input stats: cpu usage (user: %d, system: %d)",
422                  cpu_usage.tms_utime, cpu_usage.tms_stime);
423     }
424 #endif
425
426     /* Free all ES and destroy all decoder threads */
427     input_EndStream( p_input );
428
429     /* Free demultiplexer's data */
430     p_input->pf_end( p_input );
431
432     /* Close stream */
433     p_input->pf_close( p_input );
434
435     /* Release modules */
436     module_Unneed( p_input->p_input_module );
437
438 }
439
440 /*****************************************************************************
441  * DestroyThread: destroy the input thread
442  *****************************************************************************/
443 static void DestroyThread( input_thread_t * p_input )
444 {
445     int *       pi_status;                                  /* thread status */
446
447     /* Store status */
448     pi_status = p_input->pi_status;
449
450     /* Destroy Mutex locks */
451     vlc_mutex_destroy( &p_input->stream.control.control_lock );
452     vlc_mutex_destroy( &p_input->stream.stream_lock );
453     
454     /* Free input structure */
455     free( p_input );
456
457     /* Update status */
458     *pi_status = THREAD_OVER;
459 }
460
461 /*****************************************************************************
462  * input_FileOpen : open a file descriptor
463  *****************************************************************************/
464 void input_FileOpen( input_thread_t * p_input )
465 {
466     struct stat         stat_info;
467     int                 i_stat;
468
469     char *psz_name = p_input->p_source;
470
471     /* FIXME: this code ought to be in the plugin so that code can
472      * be shared with the *_Probe function */
473     if( ( i_stat = stat( psz_name, &stat_info ) ) == (-1) )
474     {
475         int i_size = strlen( psz_name );
476
477         if( ( i_size > 4 )
478             && !strncasecmp( psz_name, "dvd:", 4 ) )
479         {
480             /* get rid of the 'dvd:' stuff and try again */
481             psz_name += 4;
482             i_stat = stat( psz_name, &stat_info );
483         }
484         else if( ( i_size > 5 )
485                  && !strncasecmp( psz_name, "file:", 5 ) )
486         {
487             /* get rid of the 'file:' stuff and try again */
488             psz_name += 5;
489             i_stat = stat( psz_name, &stat_info );
490         }
491
492         if( i_stat == (-1) )
493         {
494             intf_ErrMsg( "input error: cannot stat() file `%s' (%s)",
495                          psz_name, strerror(errno));
496             p_input->b_error = 1;
497             return;
498         }
499     }
500
501     vlc_mutex_lock( &p_input->stream.stream_lock );
502
503     /* If we are here we can control the pace... */
504     p_input->stream.b_pace_control = 1;
505
506     if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
507          || S_ISBLK(stat_info.st_mode) )
508     {
509         p_input->stream.b_seekable = 1;
510         p_input->stream.p_selected_area->i_size = stat_info.st_size;
511     }
512     else if( S_ISFIFO(stat_info.st_mode)
513 #if !defined( SYS_BEOS ) && !defined( WIN32 )
514              || S_ISSOCK(stat_info.st_mode)
515 #endif
516              )
517     {
518         p_input->stream.b_seekable = 0;
519         p_input->stream.p_selected_area->i_size = 0;
520     }
521     else
522     {
523         vlc_mutex_unlock( &p_input->stream.stream_lock );
524         intf_ErrMsg( "input error: unknown file type for `%s'",
525                      psz_name );
526         p_input->b_error = 1;
527         return;
528     }
529
530     p_input->stream.p_selected_area->i_tell = 0;
531     vlc_mutex_unlock( &p_input->stream.stream_lock );
532
533     intf_WarnMsg( 1, "input: opening file `%s'", p_input->p_source );
534 #ifndef WIN32
535     if( (p_input->i_handle = open( psz_name,
536                                    /*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
537 #else
538     if( (p_input->i_handle = open( psz_name, O_BINARY
539                                    /*O_NONBLOCK | O_LARGEFILE*/ )) == (-1) )
540 #endif
541     {
542         intf_ErrMsg( "input error: cannot open file (%s)", strerror(errno) );
543         p_input->b_error = 1;
544         return;
545     }
546
547 }
548
549 /*****************************************************************************
550  * input_FileClose : close a file descriptor
551  *****************************************************************************/
552 void input_FileClose( input_thread_t * p_input )
553 {
554     intf_WarnMsg( 1, "input: closing file `%s'", p_input->p_source );
555     close( p_input->i_handle );
556
557     return;
558 }
559
560
561 #if !defined( SYS_BEOS ) && !defined( SYS_NTO )
562 /*****************************************************************************
563  * input_NetworkOpen : open a network socket 
564  *****************************************************************************/
565 void input_NetworkOpen( input_thread_t * p_input )
566 {
567     char                *psz_server = NULL;
568     char                *psz_broadcast = NULL;
569     int                 i_port = 0;
570     int                 i_opt;
571     struct sockaddr_in  sock;
572
573 #ifdef WIN32
574     /* WinSock Library Init. */
575     WSADATA Data;
576     int i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
577
578     if( i_err )
579     {
580         intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
581         return ;
582     }
583 #endif
584     
585     /* Get the remote server */
586     if( p_input->p_source != NULL )
587     {
588         psz_server = p_input->p_source;
589
590         /* Skip the protocol name */
591         while( *psz_server && *psz_server != ':' )
592         {
593             psz_server++;
594         }
595
596         /* Skip the "://" part */
597         while( *psz_server && (*psz_server == ':' || *psz_server == '/') )
598         {
599             psz_server++;
600         }
601
602         /* Found a server name */
603         if( *psz_server )
604         {
605             char *psz_port = psz_server;
606
607             /* Skip the hostname part */
608             while( *psz_port && *psz_port != ':' )
609             {
610                 psz_port++;
611             }
612
613             /* Found a port name */
614             if( *psz_port )
615             {
616                 /* Replace ':' with '\0' */
617                 *psz_port = '\0';
618                 psz_port++;
619
620                 psz_broadcast = psz_port;
621                 while( *psz_broadcast && *psz_broadcast != ':' )
622                 {
623                     psz_broadcast++;
624                 }
625
626                 if( *psz_broadcast )
627                 {
628                     *psz_broadcast = '\0';
629                     psz_broadcast++;
630                     while( *psz_broadcast && *psz_broadcast == ':' )
631                     {
632                         psz_broadcast++;
633                     }
634                 }
635                 else
636                 {
637                     psz_broadcast = NULL;
638                 }
639
640                 /* port before broadcast address */
641                 if( *psz_port != ':' )
642                 {
643                     i_port = atoi( psz_port );
644                 }
645             }
646         }
647         else
648         {
649             psz_server = NULL;
650         }
651     }
652
653     /* Check that we got a valid server */
654     if( psz_server == NULL )
655     {
656         psz_server = main_GetPszVariable( INPUT_SERVER_VAR, 
657                                           INPUT_SERVER_DEFAULT );
658     }
659
660     /* Check that we got a valid port */
661     if( i_port == 0 )
662     {
663         i_port = main_GetIntVariable( INPUT_PORT_VAR, INPUT_PORT_DEFAULT );
664     }
665
666     if( psz_broadcast == NULL )
667     {
668         /* Are we broadcasting ? */
669         if( main_GetIntVariable( INPUT_BROADCAST_VAR,
670                                  INPUT_BROADCAST_DEFAULT ) )
671         {
672             psz_broadcast = main_GetPszVariable( INPUT_BCAST_ADDR_VAR,
673                                                  INPUT_BCAST_ADDR_DEFAULT );
674         }
675         else
676         {
677            psz_broadcast = NULL; 
678         }
679     }
680
681     intf_WarnMsg( 2, "input: server: %s port: %d broadcast: %s",
682                      psz_server, i_port, psz_broadcast );
683
684     /* Open a SOCK_DGRAM (UDP) socket, in the AF_INET domain, automatic (0)
685      * protocol */
686     p_input->i_handle = socket( AF_INET, SOCK_DGRAM, 0 );
687     if( p_input->i_handle == -1 )
688     {
689         intf_ErrMsg("input error: can't create socket : %s", strerror(errno));
690         p_input->b_error = 1;
691         return;
692     }
693
694     /* We may want to reuse an already used socket */
695     i_opt = 1;
696     if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_REUSEADDR,
697                     &i_opt, sizeof( i_opt ) ) == -1 )
698     {
699         intf_ErrMsg( "input error: can't configure socket (SO_REUSEADDR: %s)",
700                      strerror(errno));
701         close( p_input->i_handle );
702         p_input->b_error = 1;
703         return;
704     }
705
706     /* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s) to avoid
707      * packet loss caused by scheduling problems */
708     i_opt = 0x80000;
709     if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_RCVBUF,
710                     &i_opt, sizeof( i_opt ) ) == -1 )
711     {
712         intf_ErrMsg( "input error: can't configure socket (SO_RCVBUF: %s)", 
713                      strerror(errno));
714         close( p_input->i_handle );
715         p_input->b_error = 1;
716         return;
717     }
718
719     /* Build the local socket */
720     if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) == -1 )
721     {
722         intf_ErrMsg( "input error: can't build local address" );
723         close( p_input->i_handle );
724         p_input->b_error = 1;
725         return;
726     }
727     
728     /* Bind it */
729     if( bind( p_input->i_handle, (struct sockaddr *)&sock, 
730               sizeof( sock ) ) < 0 )
731     {
732         intf_ErrMsg("input error: can't bind socket (%s)", strerror(errno));
733         close( p_input->i_handle );
734         p_input->b_error = 1;
735         return;
736     }
737
738     /* Build socket for remote connection */
739     if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
740     {
741         intf_ErrMsg( "input error: can't build remote address" );
742         close( p_input->i_handle );
743         p_input->b_error = 1;
744         return;
745     }
746
747     /* And connect it ... should we really connect ? */
748     if( connect( p_input->i_handle, (struct sockaddr *) &sock,
749                  sizeof( sock ) ) == (-1) )
750     {
751         intf_ErrMsg( "input error: can't connect socket, %s", 
752                      strerror(errno) );
753         close( p_input->i_handle );
754         p_input->b_error = 1;
755         return;
756     }
757
758     /* We can't pace control, but FIXME : bug in meuuh's code to sync PCR
759      * with the server. */
760     p_input->stream.b_pace_control = 0;
761     p_input->stream.b_seekable = 0;
762
763     intf_WarnMsg( 3, "input: successfully opened network mode" );
764     
765     return;
766 }
767
768 /*****************************************************************************
769  * input_NetworkClose : close a network socket
770  *****************************************************************************/
771 void input_NetworkClose( input_thread_t * p_input )
772 {
773     close( p_input->i_handle );
774
775 #ifdef WIN32 
776     WSACleanup();
777 #endif
778
779 }
780 #endif
781