int main(int argc, char* argv[]) { // Version number of the NatNet protocol, as reported by the server. unsigned char natNetMajor; unsigned char natNetMinor; // Sockets int sdCommand; int sdData; // Catch ctrl-c and terminate gracefully. signal(SIGINT, terminate); // Set addresses readOpts( argc, argv ); // Use this socket address to send commands to the server. struct sockaddr_in serverCommands = NatNet::createAddress(Globals::serverAddress, NatNet::commandPort); // Create sockets sdCommand = NatNet::createCommandSocket( Globals::localAddress ); sdData = NatNet::createDataSocket( Globals::localAddress ); // Start the CommandListener in a new thread. CommandListener commandListener(sdCommand); commandListener.start(); // Send a ping packet to the server so that it sends us the NatNet version // in its response to commandListener. NatNetPacket ping = NatNetPacket::pingPacket(); ping.send(sdCommand, serverCommands); // Wait here for ping response to give us the NatNet version. commandListener.getNatNetVersion(natNetMajor, natNetMinor); // Start up a FrameListener in a new thread. FrameListener frameListener(sdData, natNetMajor, natNetMinor); frameListener.start(); // This infinite loop simulates a "worker" thread that reads the frame // buffer each time through, and exits when ctrl-c is pressed. printFrames(frameListener); //timeStats(frameListener); // Wait for threads to finish. frameListener.stop(); commandListener.stop(); frameListener.join(); commandListener.join(); // Epilogue close(sdData); close(sdCommand); return 0; }
/*--------------------------------- MAIN -------------------------------------*/ int main(int argc, char *argv[]) { int ret=0; gboolean control_only = FALSE; /* * In order to register the reading end of the pipe with the event loop * we must convert it into a GIOChannel. */ GIOChannel *g_signal_in; long fd_flags; /* used to change the pipe into non-blocking mode */ GError *error = NULL; /* handle errors */ /*print package name and version*/ g_print("%s\n", PACKAGE_STRING); //g_type_init (); //gdk_threads_init(); #ifdef ENABLE_NLS char* lc_all = setlocale (LC_ALL, ""); char* lc_dir = bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); char* txtdom = textdomain (GETTEXT_PACKAGE); const gchar * const * langs = g_get_language_names (); //get ordered list of defined languages #endif /*structure containing all shared data - passed in callbacks*/ struct ALL_DATA all_data; memset(&all_data,0,sizeof(struct ALL_DATA)); /** initGlobals needs codecs registered * so do it here */ #if !LIBAVCODEC_VER_AT_LEAST(53,34) avcodec_init(); #endif // register all the codecs (you can also register only the codec //you wish to have smaller code) avcodec_register_all(); /*allocate global variables*/ global = g_new0(struct GLOBAL, 1); initGlobals(global); /*------------------------ reads command line options --------------------*/ readOpts(argc,argv,global); /*------------------------- reads configuration file ---------------------*/ readConf(global); //sets local control_only flag - prevents several initializations/allocations control_only = (global->control_only || global->add_ctrls) ; if(global->no_display && (global->control_only || !(global->exit_on_close && (global->Capture_time || global->image_timer)))) { if(!(global->exit_on_close && (global->Capture_time || global->image_timer))) g_printerr("no_display must be used with exit_on_close and a timed capture: enabling display"); else g_printerr("incompatible options (control_only and no_display): enabling display"); global->no_display = FALSE; } /*---------------------------------- Allocations -------------------------*/ gwidget = g_new0(struct GWIDGET, 1); gwidget->vid_widget_state = TRUE; /* widgets */ GtkWidget *scroll1; GtkWidget *Tab1; GtkWidget *Tab1Label; GtkWidget *Tab1Icon; GtkWidget *ImgButton_Img; GtkWidget *VidButton_Img; GtkWidget *QButton_Img; GtkWidget *HButtonBox; s = g_new0(struct VidState, 1); if(!control_only) /*control_only exclusion (video and Audio) */ { pdata = g_new0(struct paRecordData, 1); //pdata->maincontext = g_main_context_default(); /*create mutex for sound buffers*/ __INIT_MUTEX(__AMUTEX); /* Allocate the video Format struct */ videoF = g_new0(struct VideoFormatData, 1); /*---------------------------- Start PortAudio API -----------------------*/ if(global->debug) g_print("starting portaudio...\n"); Pa_Initialize(); }