]> git.sesse.net Git - vlc/blob - src/interface/main.c
The motion compensation routines are now modules as well ; choose your
[vlc] / src / interface / main.c
1 /*****************************************************************************
2  * main.c: main vlc source
3  * Includes the main() function for vlc. Parses command line, start interface
4  * and spawn threads.
5  *****************************************************************************
6  * Copyright (C) 1998, 1999, 2000 VideoLAN
7  *
8  * Authors:
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <signal.h>                               /* SIGHUP, SIGINT, SIGKILL */
31 #include <stdio.h>                                              /* sprintf() */
32
33 #ifdef HAVE_GETOPT_H
34 #include <getopt.h>                                              /* getopt() */
35 #endif
36
37 #include <errno.h>                                                 /* ENOMEM */
38 #include <stdlib.h>                                  /* getenv(), strtol(),  */
39 #include <string.h>                                            /* strerror() */
40
41 #include "config.h"
42 #include "common.h"
43 #include "debug.h"
44 #include "threads.h"
45 #include "mtime.h"
46 #include "tests.h"                                              /* TestCPU() */
47 #include "plugins.h"
48 #include "modules.h"
49 #include "playlist.h"
50 #include "stream_control.h"
51 #include "input_ext-intf.h"
52
53 #include "intf_msg.h"
54 #include "interface.h"
55
56 #include "audio_output.h"
57
58 #ifdef SYS_BEOS
59 #include "beos_specific.h"
60 #endif
61
62 #include "main.h"
63
64 /*****************************************************************************
65  * Command line options constants. If something is changed here, be sure that
66  * GetConfiguration and Usage are also changed.
67  *****************************************************************************/
68
69 /* Long options return values - note that values corresponding to short options
70  * chars, and in general any regular char, should be avoided */
71 #define OPT_NOAUDIO             150
72 #define OPT_AOUT                151
73 #define OPT_STEREO              152
74 #define OPT_MONO                153
75
76 #define OPT_NOVIDEO             160
77 #define OPT_VOUT                161
78 #define OPT_DISPLAY             162
79 #define OPT_WIDTH               163
80 #define OPT_HEIGHT              164
81 #define OPT_COLOR               165
82 #define OPT_MOTION              167
83 #define OPT_IDCT                168
84 #define OPT_YUV                 169
85
86 #define OPT_VLANS               170
87 #define OPT_SERVER              171
88 #define OPT_PORT                172
89 #define OPT_BROADCAST           173
90 #define OPT_DVD                 174
91
92 #define OPT_SYNCHRO             180
93
94 #define OPT_WARNING             190
95
96 /* Usage fashion */
97 #define USAGE                     0
98 #define SHORT_HELP                1
99 #define LONG_HELP                 2
100
101 /* Long options */
102 #ifdef HAVE_GETOPT_H
103 static const struct option longopts[] =
104 {
105     /*  name,               has_arg,    flag,   val */
106
107     /* General/common options */
108     {   "help",             0,          0,      'h' },
109     {   "longhelp",         0,          0,      'H' },
110     {   "version",          0,          0,      'v' },
111
112     /* Audio options */
113     {   "noaudio",          0,          0,      OPT_NOAUDIO },
114     {   "aout",             1,          0,      OPT_AOUT },
115     {   "stereo",           0,          0,      OPT_STEREO },
116     {   "mono",             0,          0,      OPT_MONO },
117
118     /* Video options */
119     {   "novideo",          0,          0,      OPT_NOVIDEO },
120     {   "vout",             1,          0,      OPT_VOUT },
121     {   "display",          1,          0,      OPT_DISPLAY },
122     {   "width",            1,          0,      OPT_WIDTH },
123     {   "height",           1,          0,      OPT_HEIGHT },
124     {   "grayscale",        0,          0,      'g' },
125     {   "color",            0,          0,      OPT_COLOR },
126     {   "motion",           1,          0,      OPT_MOTION },
127     {   "idct",             1,          0,      OPT_IDCT },
128     {   "yuv",              1,          0,      OPT_YUV },
129
130     /* DVD options */
131     {   "dvdaudio",         1,          0,      'a' },
132     {   "dvdchannel",       1,          0,      'c' },
133     {   "dvdsubtitle",      1,          0,      's' },
134     
135     /* Input options */
136     {   "vlans",            0,          0,      OPT_VLANS },
137     {   "server",           1,          0,      OPT_SERVER },
138     {   "port",             1,          0,      OPT_PORT },
139     {   "broadcast",        0,          0,      OPT_BROADCAST },
140     {   "dvd",              0,          0,      OPT_DVD },
141
142     /* Synchro options */
143     {   "synchro",          1,          0,      OPT_SYNCHRO },
144
145     /* Interface messages */
146     {   "warning",          1,          0,      OPT_WARNING },
147     {   0,                  0,          0,      0 }
148 };
149
150 /* Short options */
151 static const char *psz_shortopts = "hHvga:s:c:";
152 #endif
153
154
155 /*****************************************************************************
156  * Global variable program_data - this is the one and only, see main.h
157  *****************************************************************************/
158 main_t *p_main;
159
160 /*****************************************************************************
161  * Local prototypes
162  *****************************************************************************/
163 static void SetDefaultConfiguration ( void );
164 static int  GetConfiguration        ( int i_argc, char *ppsz_argv[],
165                                       char *ppsz_env[] );
166 static void Usage                   ( int i_fashion );
167 static void Version                 ( void );
168
169 static void InitSignalHandler       ( void );
170 static void SimpleSignalHandler     ( int i_signal );
171 static void FatalSignalHandler      ( int i_signal );
172
173 /*****************************************************************************
174  * main: parse command line, start interface and spawn threads
175  *****************************************************************************
176  * Steps during program execution are:
177  *      -configuration parsing and messages interface initialization
178  *      -opening of audio output device and some global modules
179  *      -execution of interface, which exit on error or on user request
180  *      -closing of audio output device and some global modules
181  * On error, the spawned threads are canceled, and the open devices closed.
182  *****************************************************************************/
183 int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
184 {
185     main_t  main_data;                      /* root of all data - see main.h */
186
187     p_main = &main_data;                       /* set up the global variable */
188
189     /*
190      * System specific initialization code
191      */
192 #ifdef SYS_BEOS
193     beos_Create();
194 #endif
195
196     p_main->i_cpu_capabilities = CPUCapabilities();
197
198     /*
199      * Test if our code is likely to run on this CPU 
200      */
201 #if defined( __pentium__ ) || defined( __pentiumpro__ )
202     if( ! TestCPU( CPU_CAPABILITY_586 ) )
203     {
204         fprintf( stderr, "Sorry, this program needs a Pentium CPU.\n"
205                          "Please try a version without Pentium support.\n" );
206         return( 1 );
207     }
208 #endif
209
210 #ifdef HAVE_MMX
211     if( ! TestCPU( CPU_CAPABILITY_MMX ) )
212     {
213         fprintf( stderr, "Sorry, this program needs MMX extensions.\n"
214                          "Please try a version without MMX support.\n" );
215         return( 1 );
216     }
217 #endif
218
219     /*
220      * Initialize messages interface
221      */
222     p_main->p_msg = intf_MsgCreate();
223     if( !p_main->p_msg )                         /* start messages interface */
224     {
225         fprintf( stderr, "error: can't initialize messages interface (%s)\n",
226                  strerror(errno) );
227         return( errno );
228     }
229
230     /*
231      * Read configuration
232      */
233     if( GetConfiguration( i_argc, ppsz_argv, ppsz_env ) )  /* parse cmd line */
234     {
235         intf_MsgDestroy();
236         return( errno );
237     }
238
239     /*
240      * Initialize playlist and get commandline files
241      */
242     p_main->p_playlist = playlist_Create( );
243     if( !p_main->p_playlist )
244     {
245         intf_ErrMsg( "playlist error: playlist initialization failed" );
246         intf_MsgDestroy();
247         return( errno );
248     }
249     playlist_Init( p_main->p_playlist, optind );
250
251     /*
252      * Initialize plugin bank
253      */
254     p_main->p_bank = bank_Create( );
255     if( !p_main->p_bank )
256     {
257         intf_ErrMsg( "plugin error: plugin bank initialization failed" );
258         playlist_Destroy( p_main->p_playlist );
259         intf_MsgDestroy();
260         return( errno );
261     }
262     bank_Init( p_main->p_bank );
263
264     /*
265      * Initialize module bank
266      */
267     p_main->p_module_bank = module_CreateBank( );
268     if( !p_main->p_module_bank )
269     {
270         intf_ErrMsg( "module error: module bank initialization failed" );
271         bank_Destroy( p_main->p_bank );
272         playlist_Destroy( p_main->p_playlist );
273         intf_MsgDestroy();
274         return( errno );
275     }
276     module_InitBank( p_main->p_module_bank );
277
278     /*
279      * Initialize shared resources and libraries
280      */
281     /* FIXME: no VLANs */
282 #if 0
283     if( p_main->b_vlans && input_VlanCreate() )
284     {
285         /* On error during vlans initialization, switch off vlans */
286         intf_Msg( "Virtual LANs initialization failed : "
287                   "vlans management is deactivated" );
288         p_main->b_vlans = 0;
289     }
290 #endif
291
292     /*
293      * Run interface
294      */
295     p_main->p_intf = intf_Create();
296
297     if( p_main->p_intf != NULL )
298     {
299         /*
300          * Set signal handling policy for all threads
301          */
302         InitSignalHandler();
303
304         /*
305          * Open audio device and start aout thread
306          */
307         if( p_main->b_audio )
308         {
309             p_main->p_aout = aout_CreateThread( NULL );
310             if( p_main->p_aout == NULL )
311             {
312                 /* On error during audio initialization, switch off audio */
313                 intf_ErrMsg( "aout error: audio initialization failed,"
314                              " audio is deactivated" );
315                 p_main->b_audio = 0;
316             }
317         }
318
319         /*
320          * This is the main loop
321          */
322         intf_Run( p_main->p_intf );
323
324         intf_Destroy( p_main->p_intf );
325
326         /*
327          * Close audio device
328          */
329         if( p_main->b_audio )
330         {
331             aout_DestroyThread( p_main->p_aout, NULL );
332         }
333     }
334
335     /*
336      * Free shared resources and libraries
337      */
338     /* FIXME */
339 #if 0
340     if( p_main->b_vlans )
341     {
342         input_VlanDestroy();
343     }
344 #endif
345
346     /*
347      * Free module bank
348      */
349     module_DestroyBank( p_main->p_module_bank );
350
351     /*
352      * Free plugin bank
353      */
354     bank_Destroy( p_main->p_bank );
355
356     /*
357      * Free playlist
358      */
359     playlist_Destroy( p_main->p_playlist );
360
361 #ifdef SYS_BEOS
362     /*
363      * System specific cleaning code
364      */
365     beos_Destroy();
366 #endif
367
368     /*
369      * Terminate messages interface and program
370      */
371     intf_Msg( "intf: program terminated." );
372     intf_MsgDestroy();
373
374     return( 0 );
375 }
376
377 /*****************************************************************************
378  * main_GetIntVariable: get the int value of an environment variable
379  *****************************************************************************
380  * This function is used to read some default parameters in modules.
381  *****************************************************************************/
382 int main_GetIntVariable( char *psz_name, int i_default )
383 {
384     char *      psz_env;                                /* environment value */
385     char *      psz_end;                             /* end of parsing index */
386     long int    i_value;                                            /* value */
387
388     psz_env = getenv( psz_name );
389     if( psz_env )
390     {
391         i_value = strtol( psz_env, &psz_end, 0 );
392         if( (*psz_env != '\0') && (*psz_end == '\0') )
393         {
394             return( i_value );
395         }
396     }
397     return( i_default );
398 }
399
400 /*****************************************************************************
401  * main_GetPszVariable: get the string value of an environment variable
402  *****************************************************************************
403  * This function is used to read some default parameters in modules.
404  *****************************************************************************/
405 char * main_GetPszVariable( char *psz_name, char *psz_default )
406 {
407     char *psz_env;
408
409     psz_env = getenv( psz_name );
410     if( psz_env )
411     {
412         return( psz_env );
413     }
414     return( psz_default );
415 }
416
417 /*****************************************************************************
418  * main_PutPszVariable: set the string value of an environment variable
419  *****************************************************************************
420  * This function is used to set some default parameters in modules. The use of
421  * this function will cause some memory leak: since some systems use the pointer
422  * passed to putenv to store the environment string, it can't be freed.
423  *****************************************************************************/
424 void main_PutPszVariable( char *psz_name, char *psz_value )
425 {
426     char *psz_env;
427
428     psz_env = malloc( strlen(psz_name) + strlen(psz_value) + 2 );
429     if( psz_env == NULL )
430     {
431         intf_ErrMsg( "intf error: cannot create psz_env (%s)",
432                      strerror(ENOMEM) );
433     }
434     else
435     {
436         sprintf( psz_env, "%s=%s", psz_name, psz_value );
437         if( putenv( psz_env ) )
438         {
439             intf_ErrMsg( "intf error: cannot putenv (%s)", strerror(errno) );
440         }
441     }
442 }
443
444 /*****************************************************************************
445  * main_PutIntVariable: set the integer value of an environment variable
446  *****************************************************************************
447  * This function is used to set some default parameters in modules. The use of
448  * this function will cause some memory leak: since some systems use the pointer
449  * passed to putenv to store the environment string, it can't be freed.
450  *****************************************************************************/
451 void main_PutIntVariable( char *psz_name, int i_value )
452 {
453     char psz_value[ 256 ];                               /* buffer for value */
454
455     sprintf( psz_value, "%d", i_value );
456     main_PutPszVariable( psz_name, psz_value );
457 }
458
459 /* following functions are local */
460
461 /*****************************************************************************
462  * SetDefaultConfiguration: set default options
463  *****************************************************************************
464  * This function is called by GetConfiguration before command line is parsed.
465  * It sets all the default values required later by the program. At this stage,
466  * most structure are not yet allocated, so initialization must be done using
467  * environment.
468  *****************************************************************************/
469 static void SetDefaultConfiguration( void )
470 {
471     /*
472      * All features are activated by default except vlans
473      */
474     p_main->b_audio  = 1;
475     p_main->b_video  = 1;
476     p_main->b_vlans  = 0;
477     p_main->b_dvd    = 0;
478 }
479
480 /*****************************************************************************
481  * GetConfiguration: parse command line
482  *****************************************************************************
483  * Parse command line and configuration file for configuration. If the inline
484  * help is requested, the function Usage() is called and the function returns
485  * -1 (causing main() to exit). The messages interface is initialized at this
486  * stage, but most structures are not allocated, so only environment should
487  * be used.
488  *****************************************************************************/
489 static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
490 {
491     int c, i_opt;
492     char * p_pointer;
493
494     /* Set default configuration and copy arguments */
495     p_main->i_argc    = i_argc;
496     p_main->ppsz_argv = ppsz_argv;
497     p_main->ppsz_env  = ppsz_env;
498     SetDefaultConfiguration();
499
500     intf_MsgImm( COPYRIGHT_MESSAGE );
501
502     /* Get the executable name (similar to the basename command) */
503     p_main->psz_arg0 = p_pointer = ppsz_argv[ 0 ];
504     while( *p_pointer )
505     {
506         if( *p_pointer == '/' )
507         {
508             p_main->psz_arg0 = ++p_pointer;
509         }
510         else
511         {
512             ++p_pointer;
513         }
514     }
515
516     /* Parse command line options */
517 #ifdef HAVE_GETOPT_H
518     opterr = 0;
519     while( ( c = getopt_long( i_argc, ppsz_argv, psz_shortopts, longopts, 0 ) ) != EOF )
520     {
521         switch( c )
522         {
523         /* General/common options */
524         case 'h':                                              /* -h, --help */
525             Usage( SHORT_HELP );
526             return( -1 );
527             break;
528         case 'H':                                          /* -H, --longhelp */
529             Usage( LONG_HELP );
530             return( -1 );
531             break;
532         case 'v':                                           /* -v, --version */
533             Version();
534             return( -1 );
535             break;
536
537         /* Audio options */
538         case OPT_NOAUDIO:                                       /* --noaudio */
539             p_main->b_audio = 0;
540             break;
541         case OPT_AOUT:                                             /* --aout */
542             main_PutPszVariable( AOUT_METHOD_VAR, optarg );
543             break;
544         case OPT_STEREO:                                         /* --stereo */
545             main_PutIntVariable( AOUT_STEREO_VAR, 1 );
546             break;
547         case OPT_MONO:                                             /* --mono */
548             main_PutIntVariable( AOUT_STEREO_VAR, 0 );
549             break;
550
551         /* Video options */
552         case OPT_NOVIDEO:                                       /* --novideo */
553             p_main->b_video = 0;
554             break;
555         case OPT_VOUT:                                             /* --vout */
556             main_PutPszVariable( VOUT_METHOD_VAR, optarg );
557             break;
558         case OPT_DISPLAY:                                       /* --display */
559             main_PutPszVariable( VOUT_DISPLAY_VAR, optarg );
560             break;
561         case OPT_WIDTH:                                           /* --width */
562             main_PutPszVariable( VOUT_WIDTH_VAR, optarg );
563             break;
564         case OPT_HEIGHT:                                         /* --height */
565             main_PutPszVariable( VOUT_HEIGHT_VAR, optarg );
566             break;
567
568         case 'g':                                         /* -g, --grayscale */
569             main_PutIntVariable( VOUT_GRAYSCALE_VAR, 1 );
570             break;
571         case OPT_COLOR:                                           /* --color */
572             main_PutIntVariable( VOUT_GRAYSCALE_VAR, 0 );
573             break;
574         case OPT_MOTION:                                         /* --motion */
575             main_PutPszVariable( MOTION_METHOD_VAR, optarg );
576             break;
577         case OPT_IDCT:                                             /* --idct */
578             main_PutPszVariable( IDCT_METHOD_VAR, optarg );
579             break;
580         case OPT_YUV:                                               /* --yuv */
581             main_PutPszVariable( YUV_METHOD_VAR, optarg );
582             break;
583
584         /* DVD options */
585         case 'a':
586             if ( ! strcmp(optarg, "ac3") )
587                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_AC3 );
588             else if ( ! strcmp(optarg, "lpcm") )
589                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_LPCM );
590             else if ( ! strcmp(optarg, "off") )
591                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_NOAUDIO );
592             else
593                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_MPEG );
594             break;
595         case 'c':
596             main_PutIntVariable( INPUT_DVD_CHANNEL_VAR, atoi(optarg) );
597             break;
598         case 's':
599             main_PutIntVariable( INPUT_DVD_SUBTITLE_VAR, atoi(optarg) );
600             break;
601
602         /* Input options */
603         case OPT_VLANS:                                           /* --vlans */
604             p_main->b_vlans = 1;
605             break;
606         case OPT_SERVER:                                         /* --server */
607             main_PutPszVariable( INPUT_SERVER_VAR, optarg );
608             break;
609         case OPT_PORT:                                             /* --port */
610             main_PutPszVariable( INPUT_PORT_VAR, optarg );
611             break;
612         case OPT_BROADCAST:                                   /* --broadcast */
613             main_PutIntVariable( INPUT_BROADCAST_VAR, 1 );
614             break;
615         case OPT_DVD:                                               /* --dvd */
616             p_main->b_dvd = 1;
617             break;
618
619         /* Synchro options */
620         case OPT_SYNCHRO:                                      
621             main_PutPszVariable( VPAR_SYNCHRO_VAR, optarg );
622             break;
623
624         /* Interface warning messages level */
625         case OPT_WARNING:                                       /* --warning */
626             main_PutIntVariable( INTF_WARNING_VAR, atoi(optarg) );
627             break;
628             
629         /* Internal error: unknown option */
630         case '?':
631         default:
632             intf_ErrMsg( "intf error: unknown option `%s'", ppsz_argv[optind - 1] );
633             Usage( USAGE );
634             return( EINVAL );
635             break;
636         }
637     }
638 #endif
639
640     /* Parse command line parameters - no check is made for these options */
641     for( i_opt = optind; i_opt < i_argc; i_opt++ )
642     {
643         putenv( ppsz_argv[ i_opt ] );
644     }
645     return( 0 );
646 }
647
648 /*****************************************************************************
649  * Usage: print program usage
650  *****************************************************************************
651  * Print a short inline help. Message interface is initialized at this stage.
652  *****************************************************************************/
653 static void Usage( int i_fashion )
654 {
655     /* Usage */
656     intf_Msg( "Usage: %s [options] [parameters] [file]...",
657               p_main->psz_arg0 );
658
659     if( i_fashion == USAGE )
660     {
661         intf_Msg( "Try `%s --help' for more information.",
662                   p_main->psz_arg0 );
663         return;
664     }
665
666     /* Options */
667     intf_Msg( "\nOptions:"
668               "\n      --noaudio                  \tdisable audio"
669               "\n      --aout <module>            \taudio output method"
670               "\n      --stereo, --mono           \tstereo/mono audio"
671               "\n"
672               "\n      --novideo                  \tdisable video"
673               "\n      --vout <module>            \tvideo output method"
674               "\n      --display <display>        \tdisplay string"
675               "\n      --width <w>, --height <h>  \tdisplay dimensions"
676               "\n  -g, --grayscale                \tgrayscale output"
677               "\n      --color                    \tcolor output"
678               "\n      --motion <module>          \tmotion compensation method"
679               "\n      --idct <module>            \tIDCT method"
680               "\n      --yuv <module>             \tYUV method"
681               "\n      --synchro <type>           \tforce synchro algorithm"
682               "\n"
683               "\n      --dvd                      \tDVD mode"
684               "\n  -a, --dvdaudio <type>          \tchoose DVD audio type"
685               "\n  -c, --dvdchannel <channel>     \tchoose DVD audio channel"
686               "\n  -s, --dvdsubtitle <channel>    \tchoose DVD subtitle channel"
687               "\n"
688               "\n      --vlans                    \tenable vlans"
689               "\n      --server <host>            \tvideo server address"
690               "\n      --port <port>              \tvideo server port"
691               "\n      --broadcast                \tlisten to a broadcast"
692               "\n"
693               "\n      --warning <level>          \tdisplay warning messages"
694               "\n"
695               "\n  -h, --help                     \tprint help and exit"
696               "\n  -H, --longhelp                 \tprint long help and exit"
697               "\n  -v, --version                  \toutput version information and exit" );
698
699     if( i_fashion == SHORT_HELP )
700         return;
701
702     /* Interface parameters */
703     intf_Msg( "\nInterface parameters:\n"
704               "\n  " INTF_INIT_SCRIPT_VAR "=<filename>               \tinitialization script"
705               "\n  " INTF_CHANNELS_VAR "=<filename>            \tchannels list"
706               "\n  " INTF_WARNING_VAR "=<level>                \twarning level" );
707
708     /* Audio parameters */
709     intf_Msg( "\nAudio parameters:"
710               "\n  " AOUT_METHOD_VAR "=<method name>        \taudio method"
711               "\n  " AOUT_DSP_VAR "=<filename>              \tdsp device path"
712               "\n  " AOUT_STEREO_VAR "={1|0}                \tstereo or mono output"
713               "\n  " AOUT_RATE_VAR "=<rate>             \toutput rate" );
714
715     /* Video parameters */
716     intf_Msg( "\nVideo parameters:"
717               "\n  " VOUT_METHOD_VAR "=<method name>        \tdisplay method"
718               "\n  " VOUT_DISPLAY_VAR "=<display name>      \tdisplay used"
719               "\n  " VOUT_WIDTH_VAR "=<width>               \tdisplay width"
720               "\n  " VOUT_HEIGHT_VAR "=<height>             \tdislay height"
721               "\n  " VOUT_FB_DEV_VAR "=<filename>           \tframebuffer device path"
722               "\n  " VOUT_GRAYSCALE_VAR "={1|0}             \tgrayscale or color output"
723               "\n  " MOTION_METHOD_VAR "=<method name>      \tmotion compensation method"
724               "\n  " IDCT_METHOD_VAR "=<method name>        \tIDCT method"
725               "\n  " YUV_METHOD_VAR "=<method name>         \tYUV method"
726               "\n  " VPAR_SYNCHRO_VAR "={I|I+|IP|IP+|IPB}   \tsynchro algorithm" );
727
728     /* DVD parameters */
729     intf_Msg( "\nDVD parameters:"
730               "\n  " INPUT_DVD_DEVICE_VAR "=<device>           \tDVD device"
731               "\n  " INPUT_DVD_AUDIO_VAR "={ac3|lpcm|mpeg|off} \taudio type"
732               "\n  " INPUT_DVD_CHANNEL_VAR "=[0-15]            \taudio channel"
733               "\n  " INPUT_DVD_SUBTITLE_VAR "=[0-31]           \tsubtitle channel" );
734
735     /* Input parameters */
736     intf_Msg( "\nInput parameters:\n"
737               "\n  " INPUT_SERVER_VAR "=<hostname>          \tvideo server"
738               "\n  " INPUT_PORT_VAR "=<port>            \tvideo server port"
739               "\n  " INPUT_IFACE_VAR "=<interface>          \tnetwork interface"
740               "\n  " INPUT_BROADCAST_VAR "={1|0}            \tbroadcast mode"
741               "\n  " INPUT_VLAN_SERVER_VAR "=<hostname>     \tvlan server"
742               "\n  " INPUT_VLAN_PORT_VAR "=<port>           \tvlan server port"
743  );
744
745 }
746
747 /*****************************************************************************
748  * Version: print complete program version
749  *****************************************************************************
750  * Print complete program version and build number.
751  *****************************************************************************/
752 static void Version( void )
753 {
754     intf_Msg( VERSION_MESSAGE
755               "This program comes with NO WARRANTY, to the extent permitted by law.\n"
756               "You may redistribute it under the terms of the GNU General Public License;\n"
757               "see the file named COPYING for details.\n"
758               "Written by the VideoLAN team at Ecole Centrale, Paris." );
759
760 }
761
762 /*****************************************************************************
763  * InitSignalHandler: system signal handler initialization
764  *****************************************************************************
765  * Set the signal handlers. SIGTERM is not intercepted, because we need at
766  * at least a method to kill the program when all other methods failed, and
767  * when we don't want to use SIGKILL.
768  *****************************************************************************/
769 static void InitSignalHandler( void )
770 {
771     /* Termination signals */
772     signal( SIGHUP,  FatalSignalHandler );
773     signal( SIGINT,  FatalSignalHandler );
774     signal( SIGQUIT, FatalSignalHandler );
775
776     /* Other signals */
777     signal( SIGALRM, SimpleSignalHandler );
778     signal( SIGPIPE, SimpleSignalHandler );
779 }
780
781
782 /*****************************************************************************
783  * SimpleSignalHandler: system signal handler
784  *****************************************************************************
785  * This function is called when a non fatal signal is received by the program.
786  *****************************************************************************/
787 static void SimpleSignalHandler( int i_signal )
788 {
789     /* Acknowledge the signal received */
790     intf_WarnMsg(0, "intf: ignoring signal %d", i_signal );
791 }
792
793
794 /*****************************************************************************
795  * FatalSignalHandler: system signal handler
796  *****************************************************************************
797  * This function is called when a fatal signal is received by the program.
798  * It tries to end the program in a clean way.
799  *****************************************************************************/
800 static void FatalSignalHandler( int i_signal )
801 {
802     /* Once a signal has been trapped, the termination sequence will be armed and
803      * following signals will be ignored to avoid sending messages to an interface
804      * having been destroyed */
805     signal( SIGHUP,  SIG_IGN );
806     signal( SIGINT,  SIG_IGN );
807     signal( SIGQUIT, SIG_IGN );
808
809     /* Acknowledge the signal received */
810     intf_ErrMsgImm("intf error: signal %d received, exiting", i_signal );
811
812     /* Try to terminate everything - this is done by requesting the end of the
813      * interface thread */
814     p_main->p_intf->b_die = 1;
815 }
816