【正文】
e arpa/ include sys/ include sys/ include include include include include include include /* globals */ static globals global。 fprintf(stderr, Example 1:\n \ To open an UVC webcam \/dev/video1\ and stream it via HTTP:\n \ %s i \ d /dev/video1\ o \\\n, progname)。 fprintf(stderr, Example 3:\n \ To get help for a certain input plugin:\n \ %s i \ help\\n, progname)。 } /****************************************************************************** Description.: pressing CTRL+C sends signals to this process instead of just killing it plugins can tidily shutdown and free allocated ressources. The function prototype is defined by the system, because it is a callback function. Input Value.: sig tells us which signal was received Return Value: ******************************************************************************/ void signal_handler(int sig) { int i。 /* clean up threads */ LOG(force cancelation of threads and cleanup ressources\n)。 i++) { [i].stop([i].)。 for(i=0。 for(j=i+1。 } } if ( skip ) { continue。 pthread_cond_destroy(amp。 LOG(done\n)。 } /****************************************************************************** Description.: Input Value.: Return Value: ******************************************************************************/ int control(int mand, char *details) { switch(mand) { case CONTROL_CMD_RECONFIGURE_INPUT: printf(will reload input plugin: %s\n, details)。 } /****************************************************************************** Description.: Input Value.: Return Value: ******************************************************************************/ int main(int argc, char *argv[]) 《專業(yè)實訓 》 課程 設計論文 25 { char *input = resolution 640x480 fps 5 device /dev/video0。 output[0] = port 8080。 static struct option long_options[] = \ { {h, no_argument, 0, 0}, {help, no_argument, 0, 0}, {i, required_argument, 0, 0}, {input, required_argument, 0, 0}, {o, required_argument, 0, 0}, {output, required_argument, 0, 0}, {v, no_argument, 0, 0}, {version, no_argument, 0, 0}, {b, no_argument, 0, 0}, {background, no_argument, 0, 0}, {0, 0, 0, 0} }。 /* unrecognized option */ if(c==39。 } switch (option_index) { /* h, help */ case 0: case 1: help(argv[0])。 break。 return 0。 default: help(argv[0])。 syslog(LOG_INFO, starting application)。 《專業(yè)實訓 》 課程 設計論文 28 = NULL。, NULL) != 0 ) { LOG(could not initialize mutex variable\n)。, NULL) != 0 ) { LOG(could not initialize condition variable\n)。 /* register signal handler for CTRL+C in order to clean up */ if (signal(SIGINT, signal_handler) == SIG_ERR) { LOG(could not register signal handler\n)。 /* check if at least one output plugin was selected */ if ( == 0 ) { /* no? Then use the default plugin instead */ = 1。 = (tmp 0)?strndup(input, tmp):strdup(input)。 LOG( export LD_LIBRARY_PATH=/path/to/plugin/folder\n)。 } = dlsym(, input_init)。 if ( == NULL ) { LOG(%s\n, dlerror())。 exit(EXIT_FAILURE)。)。) ) { LOG(input_init() return value signals to exit)。 i。 [i].plugin = (tmp 0)?strndup(output[i], tmp):strdup(output[i])。 LOG( export LD_LIBRARY_PATH=/path/to/plugin/folder\n)。 《專業(yè)實訓 》 課程 設計論文 31 } [i].init = dlsym([i].handle, output_init)。 if ( [i].stop == NULL ) { LOG(%s\n, dlerror())。 exit(EXIT_FAILURE)。)。 if ( [i].init(amp。 } } /* start to read the input, push pictures into global buffer */ 《專業(yè)實訓 》 課程 設計論文 32 DBG(starting input plugin\n)。 return 1。 i++) { syslog(LOG_INFO, starting output plugin: %s (ID: %02d), [i].plugin, [i].)。 } 。 } /* wa