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