From: <sb...@us...> - 2007-09-20 17:35:23
|
Revision: 1149 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1149&view=rev Author: sbalea Date: 2007-09-20 10:35:26 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Remove a ton of unnecessary code from stresstest.c Modified Paths: -------------- branches/team/mihai/stresstest/stresstest/simpleclient/stresstest/stresstest.c Modified: branches/team/mihai/stresstest/stresstest/simpleclient/stresstest/stresstest.c =================================================================== --- branches/team/mihai/stresstest/stresstest/simpleclient/stresstest/stresstest.c 2007-09-19 22:29:14 UTC (rev 1148) +++ branches/team/mihai/stresstest/stresstest/simpleclient/stresstest/stresstest.c 2007-09-20 17:35:26 UTC (rev 1149) @@ -30,10 +30,8 @@ #undef main #endif -#define MAX_CALLS 6 +#define MAX_CALLS 1 -static int video = 0; - //int format = IAXC_FORMAT_THEORA | IAXC_FORMAT_SPEEX; int format = IAXC_FORMAT_H263 | IAXC_FORMAT_H263_PLUS | IAXC_FORMAT_H264 | IAXC_FORMAT_MPEG4 | IAXC_FORMAT_THEORA; int formatp = IAXC_FORMAT_H264; //IAXC_FORMAT_THEORA; @@ -43,8 +41,6 @@ int height = 240; int fragsize = 1400; -int preview = 1; - int call_established = 0; // Forward declaration @@ -84,11 +80,6 @@ exit(1); } -void mysleep(void) -{ - iaxc_millisleep(10); -} - int levels_callback(float input, float output) { //fprintf(stderr,"Input level: %f\nOutput level: %f\n",input,output); return 1; @@ -138,85 +129,6 @@ killem(); } -int state_callback(struct iaxc_ev_call_state s) -{ - printf("------------------------------------------------------------\n"); - printf("Call #%d state report\n",s.callNo); - printf("State\t\t: \t %d\n",s.state); - printf("Format\t\t: \t %d\n",s.format); - printf("Video format\t: \t %d\n",s.vformat); - printf("Remote\t\t: \t %s\n",s.remote); - printf("Remote name\t: \t %s\n",s.remote_name); - printf("Local\t\t: \t %s\n",s.local); - printf("Local context\t: \t %s\n",s.local_context); - printf("------------------------------------------------------------\n"); - - // Finished the phase of handshaking for the call in entry - if (s.state == (IAXC_CALL_STATE_ACTIVE | IAXC_CALL_STATE_COMPLETE)) - { - iaxc_stop_sound(sound_ringIN.id); - call_established = 1; - } - if (!(s.state & (IAXC_CALL_STATE_BUSY|IAXC_CALL_STATE_TRANSFER))) - { - iaxc_stop_sound(sound_ringOUT.id); - } - if (s.state == (IAXC_CALL_STATE_ACTIVE|IAXC_CALL_STATE_RINGING)) - { - //iaxc_play_sound(&sound_ringIN, 1 /* ring device */ ); - //to_answer=s.callNo; - fprintf(stderr,"Auto-Answering to caller %s on line %d...\n",s.remote,s.callNo); - fprintf(stderr, "Mihai: answer call vformat=0x%x\n", s.vformat); - //iaxc_unquelch(s.callNo); - iaxc_millisleep(1000); - iaxc_answer_call(s.callNo); - iaxc_select_call(s.callNo); - call_established = 1; - //iaxc_millisleep(1000); - return 0; - } - if (s.state == IAXC_CALL_STATE_FREE) - { - fprintf(stderr,"Disconnect from other end\n"); - hangup_and_exit(); - } - - return 0; -} - -int iaxc_callback(iaxc_event e) -{ - //printf("Received iaxc event type 0x%x\n", e.type); - switch ( e.type ) - { - case IAXC_EVENT_LEVELS: - return levels_callback(e.ev.levels.input, e.ev.levels.output); - case IAXC_EVENT_NETSTAT: - return netstat_callback(e.ev.netstats); - case IAXC_EVENT_TEXT: - process_text_message(e.ev.text.message); - break; - case IAXC_EVENT_STATE: - return state_callback(e.ev.call); - case IAXC_EVENT_VIDEO: - if ( !video ) - return 0; - fprintf(stderr, "Got %s %s video\n", - e.ev.video.source == IAXC_SOURCE_REMOTE ? "remote" : "local", - e.ev.video.encoded ? "encoded" : "raw"); - break; - case IAXC_EVENT_AUDIO: - fprintf(stderr, "Got %s %s audio\n", - e.ev.audio.source == IAXC_SOURCE_REMOTE ? "remote" : "local", - e.ev.audio.encoded ? "encoded" : "raw"); - break; - default: - break; - } - - return 0; -} - void process_text_message(char *message) { unsigned int prefs; @@ -241,36 +153,19 @@ fprintf(stderr, "Text message received: %s\n", message); } -void list_devices() -{ - struct iaxc_audio_device *devs; - int nDevs, input, output,ring; - int i; - - iaxc_audio_devices_get(&devs,&nDevs, &input, &output, &ring); - for(i=0;i<nDevs;i++) - { - fprintf(stderr, "DEVICE ID=%d NAME=%s CAPS=%lx\n", devs[i].devID, devs[i].name, devs[i].capabilities); - iaxc_audio_devices_set(input,output,ring); - } -} - void usage() { printf( "\n" "Usage is: tescall <options>\n\n" "available options:\n" - "-F [codec,framerate,bitrate,width,height,fragsize]\t \n" - "-V force video mode\n" - "-s set silence threshold\n" - "-v [input_video_filename]\n" - "-f [output_video_filename]\n" - "-i [input_audio_filename]\n" - "-a [output_audio_filename]\n" + "-F <codec,framerate,bitrate,width,height,fragsize> set video parameters\n" + "-o <filename> media file to run\n" + "-v stop sending video\n" + "-a stop sending audio\n" + "-l run file in a loop\n" "\n" ); - exit(1); } @@ -326,75 +221,16 @@ return 0; } -void test_mode_main(char *ogg_file, char *dest, int loop) +int main(int argc, char **argv) { + int i; + char mydest[80], *dest = NULL; + char *ogg_file = NULL; + int loop = 0; int video_frame_index; static struct slice_set_t slice_set; unsigned short source_id; - int i; - // Load ogg file - load_ogg_file(ogg_file); - - // Initialize iaxclient - iaxc_video_format_set(formatp, format, framerate, bitrate, width, height, fragsize); - iaxc_set_test_mode(1); - if (iaxc_initialize(MAX_CALLS)) - fatal_error("cannot initialize iaxclient!"); - - iaxc_set_formats(IAXC_FORMAT_SPEEX, IAXC_FORMAT_SPEEX); - iaxc_video_bypass_jitter(0); - iaxc_set_audio_prefs(0); - iaxc_set_video_prefs(0); - iaxc_set_event_callback(test_mode_callback); - - // Crank the engine - iaxc_start_processing_thread(); - - // Dial out - int callNo = iaxc_call(dest); - if (callNo <= 0) - iaxc_select_call(callNo); - else - fprintf(stderr, "Failed to make call to '%s'", dest); - - // Wait for the call to be established; - while ( !call_established ) - iaxc_millisleep(5); - - while ( 42 ) - { - ogg_packet *op; - - op = get_next_audio_op(); - if ( !loop && audio_is_eos() ) - break; - if ( send_audio && op != NULL && op->bytes > 0 ) - iaxc_push_audio(op->packet, op->bytes, SPEEX_SAMPLING_RATE / 1000 * SPEEX_FRAME_DURATION); - - op = get_next_video_op(); - if ( !loop && video_is_eos() ) - break; - if ( send_video && op != NULL && op->bytes > 0 ) - iaxc_push_video(op->packet, op->bytes, 1); - - iaxc_millisleep(5); - } - hangup_and_exit(); -} - -int main(int argc, char **argv) -{ - FILE *f = stdout; - char c; - int i; //,OutLoop=0; - char mydest[80], *dest = NULL; - double silence_threshold = -99; - char *WF_file = NULL; - int jbypass = 0; - char *ogg_file = NULL; - int loop = 0; - /* install signal handler to catch CRTL-Cs */ signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); @@ -406,10 +242,7 @@ { switch(argv[i][1]) { - case 'V': /* v is taken; p: picturephone. Ok, that's lame.. */ - video = 1; - break; - case 'F': /* set video formats */ + case 'F': /* set video params */ { formatp = 1<<atoi(argv[++i]); framerate = atoi(argv[++i]); @@ -419,22 +252,6 @@ fragsize = atoi(argv[++i]); } break; - case 'P': /* */ - preview = 0; - break; - case 's': - if(i+1 >= argc) usage(); - silence_threshold = atof(argv[++i]); - break; - case 'r': - if(i+3 >= argc) usage(); - iaxc_register(argv[i+1],argv[i+2],argv[i+3]); - i+=3; - break; - case 'h': - if(i+1 >= argc) usage(); - WF_file=argv[++i]; - break; case 'o': if ( i+1 >= argc ) usage(); ogg_file = argv[++i]; @@ -448,58 +265,75 @@ case 'l': loop = 1; break; - default: usage(); } } else - { dest=argv[i]; - //iaxc_register("send", "send", "217.9.64.180"); - } } if ( ogg_file != NULL ) { - // We're in test mode - test_mode_main(ogg_file, dest, loop); - return 0; + // We need a media file to run + fprintf(stderr, "No media file, quitting\n"); + return -1; } - // To receive calls... - iaxc_video_format_set(formatp, format, framerate, bitrate, width, height, fragsize); - - if (iaxc_initialize(MAX_CALLS)) fatal_error("cannot initialize iaxclient!"); + if ( dest == NULL ) + { + // We need a destination to call + fprintf(stderr, "No destination, quitting\n"); + return -1; + } - // ERA DEFAULT: + // Load ogg file + load_ogg_file(ogg_file); + + // Initialize iaxclient + iaxc_video_format_set(formatp, format, framerate, bitrate, width, height, fragsize); + iaxc_set_test_mode(1); + if (iaxc_initialize(MAX_CALLS)) + fatal_error("cannot initialize iaxclient!"); + iaxc_set_formats(IAXC_FORMAT_SPEEX, IAXC_FORMAT_SPEEX); - //iaxc_set_formats(IAXC_FORMAT_ALAW,IAXC_FORMAT_ULAW|IAXC_FORMAT_GSM); - iaxc_set_silence_threshold(1.0); - iaxc_set_audio_output(0); - iaxc_set_filters(/*IAXC_FILTER_AGC|*/IAXC_FILTER_DENOISE|IAXC_FILTER_CN/*|IAXC_FILTER_ECHO*/); - - iaxc_set_event_callback(iaxc_callback); - - // Set what kind of video data we want to receive through callbacks - // See iaxclient.h for possible values + iaxc_video_bypass_jitter(0); + iaxc_set_audio_prefs(0); iaxc_set_video_prefs(0); - - fprintf(stderr, "Starting processing thread...\n"); + iaxc_set_event_callback(test_mode_callback); + + // Crank the engine iaxc_start_processing_thread(); + + // Dial out + int callNo = iaxc_call(dest); + if (callNo <= 0) + iaxc_select_call(callNo); + else + fprintf(stderr, "Failed to make call to '%s'", dest); - if ( dest != NULL ) + // Wait for the call to be established; + while ( !call_established ) + iaxc_millisleep(5); + + while ( 42 ) { - fprintf(stderr, "Calling to %s\n", dest); - int callNo = iaxc_call(dest); - if (callNo <= 0) - iaxc_select_call(callNo); - else - fprintf(stderr, "Failed to make call to '%s'", dest); + ogg_packet *op; + + op = get_next_audio_op(); + if ( !loop && audio_is_eos() ) + break; + if ( send_audio && op != NULL && op->bytes > 0 ) + iaxc_push_audio(op->packet, op->bytes, SPEEX_SAMPLING_RATE / 1000 * SPEEX_FRAME_DURATION); + + op = get_next_video_op(); + if ( !loop && video_is_eos() ) + break; + if ( send_video && op != NULL && op->bytes > 0 ) + iaxc_push_video(op->packet, op->bytes, 1); + + iaxc_millisleep(5); } - - /* infinite loop*/ - while (42 ) - iaxc_millisleep(1000); - + + hangup_and_exit(); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |