Main Page | Class List | File List | Class Members | File Members

main.c

Go to the documentation of this file.
00001 /*
00002  * Main program control
00003  *
00004  * This program is free software; you can redistribute it and/or modify 
00005  * it under the terms of the GNU General Public License as published by 
00006  * the Free Software Foundation version 2.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License (LICENSE) for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  * 
00017  */
00018 
00019 #include "standard.h"
00020 #include "config.h"
00021 
00022 _session session;
00023 int debug;
00024 int Quit_Mux;
00025 
00026 extern char *mux_version;
00027 extern char *build_date;
00028 extern int  mux_build;
00029 
00030 /*
00031  * basic stuff:
00032  *  
00033  */
00034 static void program_info(void)
00035 {
00036   printf("\n");
00037   printf("H.223 Multiplex Simulator Version %s\n",mux_version);
00038   printf("Copyright (C) 1997 UCLA and Samsung Electronics Company\n");
00039   printf("This simulator comes with ABSOLUTELY NO WARRANTY, for details see\n");
00040   printf("the GNU Public license included with the distribution (LICENSE)\n");
00041   printf("\n");
00042   printf("build %d %s\n", mux_build, build_date);
00043   printf("\n");
00044 }
00045 
00046 
00047 static void main_loop(void)
00048 {
00049   int *jblock;
00050   int j;
00051 
00052   Quit_Mux = 0;
00053   while (!Quit_Mux) { 
00054     printf("%s Main Loop\n", print_time());
00055     interface();
00056 
00057     code_video(session.local.Video);
00058     code_video(session.remote.Video);  
00059       
00060     code_audio(session.local.Audio);
00061     code_audio(session.remote.Audio);  
00062     
00063     multiplex(session.local.Mux, 3);   /* num channels hard coded to 3 */
00064     multiplex(session.remote.Mux, 3);  /* num channels hard coded to 3 */
00065       
00066     demultiplex(session.local.Demux);
00067     demultiplex(session.remote.Demux);
00068       
00069     decode_audio(session.local.Audio);
00070     decode_audio(session.remote.Audio);
00071      
00072     decode_video(session.local.Video);
00073     decode_video(session.remote.Video);
00074      
00075     increment_clock();
00076   }
00077 }
00078 
00079 static void cleanup(void)
00080 {
00081 
00082   /*
00083    * Close received audio files. 
00084    */
00085   close_audio_codec(session.local.Audio);
00086   close_audio_codec(session.remote.Audio);
00087 
00088   /*
00089    * Close video codecs. 
00090    */
00091   close_video_codec(session.local.Video);
00092   close_video_codec(session.remote.Video);
00093 
00094   /*
00095    * Close muxes.
00096    */
00097 
00098   close_mux(session.local.Mux);
00099   close_mux(session.remote.Mux);
00100 
00101   /*
00102    * Close demuxes.
00103    */
00104 
00105   close_demux(session.local.Demux);
00106   close_demux(session.remote.Demux);
00107 
00108   /* 
00109    * Close channels
00110    */
00111 
00112   close_channel(session.local.Channel);
00113   close_channel(session.remote.Channel);
00114 
00115 }
00116 
00117 
00118 void sig_int()
00119 {
00120   fprintf(stderr, "\n\n%s: Caught SIGINT.  Exiting.\n\n", mux_version);
00121   exit(1);
00122 }
00123 
00124 void sig_quit()
00125 {
00126   fprintf(stderr, "\n\n%s: Caught SIGQUIT.  Exiting.\n\n", mux_version);
00127   exit(1);
00128 }
00129 
00130 
00131 int main(int argc, char *argv[])
00132 {
00133   if (signal(SIGINT, SIG_IGN) != SIG_IGN)
00134     signal(SIGINT, sig_int);
00135   if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
00136     signal(SIGQUIT, sig_quit);
00137 
00138   program_info();
00139   
00140   set_config(argc, argv);
00141   
00142   main_loop();
00143   
00144   cleanup();
00145 
00146   exit(0);
00147 }
00148 

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1