]> git.sesse.net Git - vlc/blob - src/interface/main.c
. added comments to src/interface/intf_plst.c and include/intf_plst.h
[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 "stream_control.h"
50 #include "input_ext-intf.h"
51
52 #include "intf_msg.h"
53 #include "intf_plst.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
88 #define OPT_AOUT                180
89 #define OPT_VOUT                181
90 #define OPT_MOTION              182
91 #define OPT_IDCT                183
92 #define OPT_YUV                 184
93 #define OPT_INPUT               185
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     {   "input",            1,          0,      OPT_INPUT },
141     {   "vlans",            0,          0,      OPT_VLANS },
142     {   "server",           1,          0,      OPT_SERVER },
143     {   "port",             1,          0,      OPT_PORT },
144     {   "broadcast",        0,          0,      OPT_BROADCAST },
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     intf_MsgImm( COPYRIGHT_MESSAGE );
235
236     /*
237      * Initialize playlist and get commandline files
238      */
239     p_main->p_playlist = intf_PlstCreate( );
240     if( !p_main->p_playlist )
241     {
242         intf_ErrMsg( "playlist error: playlist initialization failed" );
243         intf_MsgDestroy();
244         return( errno );
245     }
246     intf_PlstInit( p_main->p_playlist );
247
248     /*
249      * Read configuration
250      */
251     if( GetConfiguration( i_argc, ppsz_argv, ppsz_env ) )  /* parse cmd line */
252     {
253         intf_MsgDestroy();
254         return( errno );
255     }
256
257     /*
258      * Initialize plugin bank
259      */
260     p_main->p_bank = bank_Create( );
261     if( !p_main->p_bank )
262     {
263         intf_ErrMsg( "plugin error: plugin bank initialization failed" );
264         intf_PlstDestroy( p_main->p_playlist );
265         intf_MsgDestroy();
266         return( errno );
267     }
268     bank_Init( p_main->p_bank );
269
270     /*
271      * Initialize module bank
272      */
273     p_main->p_module_bank = module_CreateBank( );
274     if( !p_main->p_module_bank )
275     {
276         intf_ErrMsg( "module error: module bank initialization failed" );
277         bank_Destroy( p_main->p_bank );
278         intf_PlstDestroy( p_main->p_playlist );
279         intf_MsgDestroy();
280         return( errno );
281     }
282     module_InitBank( p_main->p_module_bank );
283
284     /*
285      * Initialize shared resources and libraries
286      */
287     /* FIXME: no VLANs */
288 #if 0
289     if( p_main->b_vlans && input_VlanCreate() )
290     {
291         /* On error during vlans initialization, switch off vlans */
292         intf_Msg( "Virtual LANs initialization failed : "
293                   "vlans management is deactivated" );
294         p_main->b_vlans = 0;
295     }
296 #endif
297
298     /*
299      * Run interface
300      */
301     p_main->p_intf = intf_Create();
302
303     if( p_main->p_intf != NULL )
304     {
305         /*
306          * Set signal handling policy for all threads
307          */
308         InitSignalHandler();
309
310         /*
311          * Open audio device and start aout thread
312          */
313         if( p_main->b_audio )
314         {
315             p_main->p_aout = aout_CreateThread( NULL );
316             if( p_main->p_aout == NULL )
317             {
318                 /* On error during audio initialization, switch off audio */
319                 intf_ErrMsg( "aout error: audio initialization failed,"
320                              " audio is deactivated" );
321                 p_main->b_audio = 0;
322             }
323         }
324
325         /*
326          * This is the main loop
327          */
328         intf_Run( p_main->p_intf );
329
330         intf_Destroy( p_main->p_intf );
331
332         /*
333          * Close audio device
334          */
335         if( p_main->b_audio )
336         {
337             aout_DestroyThread( p_main->p_aout, NULL );
338         }
339     }
340
341     /*
342      * Free shared resources and libraries
343      */
344     /* FIXME */
345 #if 0
346     if( p_main->b_vlans )
347     {
348         input_VlanDestroy();
349     }
350 #endif
351
352     /*
353      * Free module bank
354      */
355     module_DestroyBank( p_main->p_module_bank );
356
357     /*
358      * Free plugin bank
359      */
360     bank_Destroy( p_main->p_bank );
361
362     /*
363      * Free playlist
364      */
365     intf_PlstDestroy( p_main->p_playlist );
366
367 #ifdef SYS_BEOS
368     /*
369      * System specific cleaning code
370      */
371     beos_Destroy();
372 #endif
373
374     /*
375      * Terminate messages interface and program
376      */
377     intf_Msg( "intf: program terminated." );
378     intf_MsgDestroy();
379
380     return( 0 );
381 }
382
383 /*****************************************************************************
384  * main_GetIntVariable: get the int value of an environment variable
385  *****************************************************************************
386  * This function is used to read some default parameters in modules.
387  *****************************************************************************/
388 int main_GetIntVariable( char *psz_name, int i_default )
389 {
390     char *      psz_env;                                /* environment value */
391     char *      psz_end;                             /* end of parsing index */
392     long int    i_value;                                            /* value */
393
394     psz_env = getenv( psz_name );
395     if( psz_env )
396     {
397         i_value = strtol( psz_env, &psz_end, 0 );
398         if( (*psz_env != '\0') && (*psz_end == '\0') )
399         {
400             return( i_value );
401         }
402     }
403     return( i_default );
404 }
405
406 /*****************************************************************************
407  * main_GetPszVariable: get the string value of an environment variable
408  *****************************************************************************
409  * This function is used to read some default parameters in modules.
410  *****************************************************************************/
411 char * main_GetPszVariable( char *psz_name, char *psz_default )
412 {
413     char *psz_env;
414
415     psz_env = getenv( psz_name );
416     if( psz_env )
417     {
418         return( psz_env );
419     }
420     return( psz_default );
421 }
422
423 /*****************************************************************************
424  * main_PutPszVariable: set the string value of an environment variable
425  *****************************************************************************
426  * This function is used to set some default parameters in modules. The use of
427  * this function will cause some memory leak: since some systems use the pointer
428  * passed to putenv to store the environment string, it can't be freed.
429  *****************************************************************************/
430 void main_PutPszVariable( char *psz_name, char *psz_value )
431 {
432     char *psz_env;
433
434     psz_env = malloc( strlen(psz_name) + strlen(psz_value) + 2 );
435     if( psz_env == NULL )
436     {
437         intf_ErrMsg( "intf error: cannot create psz_env (%s)",
438                      strerror(ENOMEM) );
439     }
440     else
441     {
442         sprintf( psz_env, "%s=%s", psz_name, psz_value );
443         if( putenv( psz_env ) )
444         {
445             intf_ErrMsg( "intf error: cannot putenv (%s)", strerror(errno) );
446         }
447     }
448 }
449
450 /*****************************************************************************
451  * main_PutIntVariable: set the integer value of an environment variable
452  *****************************************************************************
453  * This function is used to set some default parameters in modules. The use of
454  * this function will cause some memory leak: since some systems use the pointer
455  * passed to putenv to store the environment string, it can't be freed.
456  *****************************************************************************/
457 void main_PutIntVariable( char *psz_name, int i_value )
458 {
459     char psz_value[ 256 ];                               /* buffer for value */
460
461     sprintf( psz_value, "%d", i_value );
462     main_PutPszVariable( psz_name, psz_value );
463 }
464
465 /* following functions are local */
466
467 /*****************************************************************************
468  * SetDefaultConfiguration: set default options
469  *****************************************************************************
470  * This function is called by GetConfiguration before command line is parsed.
471  * It sets all the default values required later by the program. At this stage,
472  * most structure are not yet allocated, so initialization must be done using
473  * environment.
474  *****************************************************************************/
475 static void SetDefaultConfiguration( void )
476 {
477     /*
478      * All features are activated by default except vlans
479      */
480     p_main->b_audio  = 1;
481     p_main->b_video  = 1;
482     p_main->b_vlans  = 0;
483 }
484
485 /*****************************************************************************
486  * GetConfiguration: parse command line
487  *****************************************************************************
488  * Parse command line and configuration file for configuration. If the inline
489  * help is requested, the function Usage() is called and the function returns
490  * -1 (causing main() to exit). The messages interface is initialized at this
491  * stage, but most structures are not allocated, so only environment should
492  * be used.
493  *****************************************************************************/
494 static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
495 {
496     int c, i_opt;
497     char * p_pointer;
498
499     /* Set default configuration and copy arguments */
500     p_main->i_argc    = i_argc;
501     p_main->ppsz_argv = ppsz_argv;
502     p_main->ppsz_env  = ppsz_env;
503     SetDefaultConfiguration();
504
505     /* Get the executable name (similar to the basename command) */
506     p_main->psz_arg0 = p_pointer = ppsz_argv[ 0 ];
507     while( *p_pointer )
508     {
509         if( *p_pointer == '/' )
510         {
511             p_main->psz_arg0 = ++p_pointer;
512         }
513         else
514         {
515             ++p_pointer;
516         }
517     }
518
519     /* Parse command line options */
520 #ifdef HAVE_GETOPT_H
521     opterr = 0;
522     while( ( c = getopt_long( i_argc, ppsz_argv, psz_shortopts, longopts, 0 ) ) != EOF )
523     {
524         switch( c )
525         {
526         /* General/common options */
527         case 'h':                                              /* -h, --help */
528             Usage( SHORT_HELP );
529             return( -1 );
530             break;
531         case 'H':                                          /* -H, --longhelp */
532             Usage( LONG_HELP );
533             return( -1 );
534             break;
535         case 'v':                                           /* -v, --version */
536             Version();
537             return( -1 );
538             break;
539
540         /* Audio options */
541         case OPT_NOAUDIO:                                       /* --noaudio */
542             p_main->b_audio = 0;
543             break;
544         case OPT_AOUT:                                             /* --aout */
545             main_PutPszVariable( AOUT_METHOD_VAR, optarg );
546             break;
547         case OPT_STEREO:                                         /* --stereo */
548             main_PutIntVariable( AOUT_STEREO_VAR, 1 );
549             break;
550         case OPT_MONO:                                             /* --mono */
551             main_PutIntVariable( AOUT_STEREO_VAR, 0 );
552             break;
553
554         /* Video options */
555         case OPT_NOVIDEO:                                       /* --novideo */
556             p_main->b_video = 0;
557             break;
558         case OPT_VOUT:                                             /* --vout */
559             main_PutPszVariable( VOUT_METHOD_VAR, optarg );
560             break;
561         case OPT_DISPLAY:                                       /* --display */
562             main_PutPszVariable( VOUT_DISPLAY_VAR, optarg );
563             break;
564         case OPT_WIDTH:                                           /* --width */
565             main_PutPszVariable( VOUT_WIDTH_VAR, optarg );
566             break;
567         case OPT_HEIGHT:                                         /* --height */
568             main_PutPszVariable( VOUT_HEIGHT_VAR, optarg );
569             break;
570         case 'g':                                         /* -g, --grayscale */
571             main_PutIntVariable( VOUT_GRAYSCALE_VAR, 1 );
572             break;
573         case OPT_COLOR:                                           /* --color */
574             main_PutIntVariable( VOUT_GRAYSCALE_VAR, 0 );
575             break;
576         case OPT_FULLSCREEN:                                 /* --fullscreen */
577             main_PutIntVariable( VOUT_FULLSCREEN_VAR, 1 );
578             break;
579         case OPT_OVERLAY:                                       /* --overlay */
580             main_PutIntVariable( VOUT_OVERLAY_VAR, 1 );
581             break;
582         case OPT_MOTION:                                         /* --motion */
583             main_PutPszVariable( MOTION_METHOD_VAR, optarg );
584             break;
585         case OPT_IDCT:                                             /* --idct */
586             main_PutPszVariable( IDCT_METHOD_VAR, optarg );
587             break;
588         case OPT_YUV:                                               /* --yuv */
589             main_PutPszVariable( YUV_METHOD_VAR, optarg );
590             break;
591
592         /* DVD options */
593         case 'a':
594             if ( ! strcmp(optarg, "ac3") )
595                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_AC3 );
596             else if ( ! strcmp(optarg, "lpcm") )
597                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_LPCM );
598             else if ( ! strcmp(optarg, "mpeg") )
599                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_MPEG );
600             else
601                 main_PutIntVariable( INPUT_DVD_AUDIO_VAR, REQUESTED_NOAUDIO );
602             break;
603         case 'c':
604             main_PutIntVariable( INPUT_DVD_CHANNEL_VAR, atoi(optarg) );
605             break;
606         case 's':
607             main_PutIntVariable( INPUT_DVD_SUBTITLE_VAR, atoi(optarg) );
608             break;
609
610         /* Input options */
611         case OPT_INPUT:                                           /* --input */
612             main_PutPszVariable( INPUT_METHOD_VAR, optarg );
613             break;
614         case OPT_VLANS:                                           /* --vlans */
615             p_main->b_vlans = 1;
616             break;
617         case OPT_SERVER:                                         /* --server */
618             main_PutPszVariable( INPUT_SERVER_VAR, optarg );
619             break;
620         case OPT_PORT:                                             /* --port */
621             main_PutPszVariable( INPUT_PORT_VAR, optarg );
622             break;
623         case OPT_BROADCAST:                                   /* --broadcast */
624             main_PutIntVariable( INPUT_BROADCAST_VAR, 1 );
625             break;
626
627         /* Synchro options */
628         case OPT_SYNCHRO:                                      
629             main_PutPszVariable( VPAR_SYNCHRO_VAR, optarg );
630             break;
631
632         /* Interface warning messages level */
633         case OPT_WARNING:                                       /* --warning */
634             main_PutIntVariable( INTF_WARNING_VAR, atoi(optarg) );
635             break;
636             
637         /* Internal error: unknown option */
638         case '?':
639         default:
640             intf_ErrMsg( "intf error: unknown option `%s'", ppsz_argv[optind - 1] );
641             Usage( USAGE );
642             return( EINVAL );
643             break;
644         }
645     }
646 #endif
647
648     /* We assume that the remaining parameters are filenames */
649     for( i_opt = optind; i_opt < i_argc; i_opt++ )
650     {
651         intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, ppsz_argv[ i_opt ] );
652     }
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_MsgImm( "Usage: %s [options] [parameters] [file]...",
666                  p_main->psz_arg0 );
667
668     if( i_fashion == USAGE )
669     {
670         intf_MsgImm( "Try `%s --help' for more information.",
671                      p_main->psz_arg0 );
672         return;
673     }
674
675     /* Options */
676     intf_MsgImm( "\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      --fullscreen               \tfullscreen output"
687           "\n      --overlay                  \taccelerated display"
688           "\n      --color                    \tcolor output"
689           "\n      --motion <module>          \tmotion compensation method"
690           "\n      --idct <module>            \tIDCT method"
691           "\n      --yuv <module>             \tYUV method"
692           "\n      --synchro <type>           \tforce synchro algorithm"
693           "\n"
694           "\n  -a, --dvdaudio <type>          \tchoose DVD audio type"
695           "\n  -c, --dvdchannel <channel>     \tchoose DVD audio channel"
696           "\n  -s, --dvdsubtitle <channel>    \tchoose DVD subtitle channel"
697           "\n"
698           "\n      --input                    \tinput method"
699           "\n      --vlans                    \tenable vlans"
700           "\n      --server <host>            \tvideo server address"
701           "\n      --port <port>              \tvideo server port"
702           "\n      --broadcast                \tlisten to a broadcast"
703           "\n"
704           "\n      --warning <level>          \tdisplay warning messages"
705           "\n"
706           "\n  -h, --help                     \tprint help and exit"
707           "\n  -H, --longhelp                 \tprint long help and exit"
708           "\n  -v, --version                  \toutput version information and exit" );
709
710     if( i_fashion == SHORT_HELP )
711         return;
712
713     /* Interface parameters */
714     intf_MsgImm( "\nInterface parameters:\n"
715         "\n  " INTF_INIT_SCRIPT_VAR "=<filename>               \tinitialization script"
716         "\n  " INTF_CHANNELS_VAR "=<filename>            \tchannels list"
717         "\n  " INTF_WARNING_VAR "=<level>                \twarning level" );
718
719     /* Audio parameters */
720     intf_MsgImm( "\nAudio parameters:"
721         "\n  " AOUT_METHOD_VAR "=<method name>        \taudio method"
722         "\n  " AOUT_DSP_VAR "=<filename>              \tdsp device path"
723         "\n  " AOUT_STEREO_VAR "={1|0}                \tstereo or mono output"
724         "\n  " AOUT_RATE_VAR "=<rate>             \toutput rate" );
725
726     /* Video parameters */
727     intf_MsgImm( "\nVideo parameters:"
728         "\n  " VOUT_METHOD_VAR "=<method name>        \tdisplay method"
729         "\n  " VOUT_DISPLAY_VAR "=<display name>      \tdisplay used"
730         "\n  " VOUT_WIDTH_VAR "=<width>               \tdisplay width"
731         "\n  " VOUT_HEIGHT_VAR "=<height>             \tdislay height"
732         "\n  " VOUT_FB_DEV_VAR "=<filename>           \tframebuffer device path"
733         "\n  " VOUT_GRAYSCALE_VAR "={1|0}             \tgrayscale or color output"
734         "\n  " VOUT_FULLSCREEN_VAR "={1|0}            \tfullscreen"
735         "\n  " VOUT_OVERLAY_VAR "={1|0}               \toverlay"
736         "\n  " MOTION_METHOD_VAR "=<method name>      \tmotion compensation method"
737         "\n  " IDCT_METHOD_VAR "=<method name>        \tIDCT method"
738         "\n  " YUV_METHOD_VAR "=<method name>         \tYUV method"
739         "\n  " VPAR_SYNCHRO_VAR "={I|I+|IP|IP+|IPB}   \tsynchro algorithm" );
740
741     /* DVD parameters */
742     intf_MsgImm( "\nDVD parameters:"
743         "\n  " INPUT_DVD_DEVICE_VAR "=<device>           \tDVD device"
744         "\n  " INPUT_DVD_AUDIO_VAR "={ac3|lpcm|mpeg|off} \taudio type"
745         "\n  " INPUT_DVD_CHANNEL_VAR "=[0-15]            \taudio channel"
746         "\n  " INPUT_DVD_SUBTITLE_VAR "=[0-31]           \tsubtitle channel" );
747
748     /* Input parameters */
749     intf_MsgImm( "\nInput parameters:\n"
750         "\n  " INPUT_SERVER_VAR "=<hostname>          \tvideo server"
751         "\n  " INPUT_PORT_VAR "=<port>            \tvideo server port"
752         "\n  " INPUT_IFACE_VAR "=<interface>          \tnetwork interface"
753         "\n  " INPUT_BROADCAST_VAR "={1|0}            \tbroadcast mode"
754         "\n  " INPUT_VLAN_SERVER_VAR "=<hostname>     \tvlan server"
755         "\n  " INPUT_VLAN_PORT_VAR "=<port>           \tvlan server port" );
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_MsgImm( 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  * InitSignalHandler: system signal handler initialization
775  *****************************************************************************
776  * Set the signal handlers. SIGTERM is not intercepted, because we need at
777  * at least a method to kill the program when all other methods failed, and
778  * when we don't want to use SIGKILL.
779  *****************************************************************************/
780 static void InitSignalHandler( void )
781 {
782     /* Termination signals */
783     signal( SIGHUP,  FatalSignalHandler );
784     signal( SIGINT,  FatalSignalHandler );
785     signal( SIGQUIT, FatalSignalHandler );
786
787     /* Other signals */
788     signal( SIGALRM, SimpleSignalHandler );
789     signal( SIGPIPE, SimpleSignalHandler );
790 }
791
792
793 /*****************************************************************************
794  * SimpleSignalHandler: system signal handler
795  *****************************************************************************
796  * This function is called when a non fatal signal is received by the program.
797  *****************************************************************************/
798 static void SimpleSignalHandler( int i_signal )
799 {
800     /* Acknowledge the signal received */
801     intf_WarnMsg(0, "intf: ignoring signal %d", i_signal );
802 }
803
804
805 /*****************************************************************************
806  * FatalSignalHandler: system signal handler
807  *****************************************************************************
808  * This function is called when a fatal signal is received by the program.
809  * It tries to end the program in a clean way.
810  *****************************************************************************/
811 static void FatalSignalHandler( int i_signal )
812 {
813     /* Once a signal has been trapped, the termination sequence will be armed and
814      * following signals will be ignored to avoid sending messages to an interface
815      * having been destroyed */
816     signal( SIGHUP,  SIG_IGN );
817     signal( SIGINT,  SIG_IGN );
818     signal( SIGQUIT, SIG_IGN );
819
820     /* Acknowledge the signal received */
821     intf_ErrMsgImm("intf error: signal %d received, exiting", i_signal );
822
823     /* Try to terminate everything - this is done by requesting the end of the
824      * interface thread */
825     p_main->p_intf->b_die = 1;
826 }
827