From: <jpg...@us...> - 2007-10-16 23:34:44
|
Revision: 1201 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1201&view=rev Author: jpgrayson Date: 2007-10-16 16:34:48 -0700 (Tue, 16 Oct 2007) Log Message: ----------- Remove trailing whitespace. Modified Paths: -------------- trunk/simpleclient/stresstest/file.c trunk/simpleclient/stresstest/stresstest.c Modified: trunk/simpleclient/stresstest/file.c =================================================================== --- trunk/simpleclient/stresstest/file.c 2007-10-16 23:32:32 UTC (rev 1200) +++ trunk/simpleclient/stresstest/file.c 2007-10-16 23:34:48 UTC (rev 1201) @@ -17,7 +17,7 @@ memcpy(node->op, op, sizeof(*op)); node->op->packet = malloc(op->bytes); memcpy(node->op->packet, op->packet, op->bytes); - + return node; } @@ -46,13 +46,13 @@ } } -/* +/* * We're forced to use a dirty hack here, due to Theora's idiotic API * Theora needs three separate pieces of data, called headers to initialize * its internal decoder structure. After all three pieces have been received, - * we can call theora_decode_init. - * We use a counter and a flag to make sure we have decoded our three headers and then - * we call theora_decode_init so we can initialize a theora_state structure. + * we can call theora_decode_init. + * We use a counter and a flag to make sure we have decoded our three headers and then + * we call theora_decode_init so we can initialize a theora_state structure. * We use the ts structure to convert a granule position into an actual timestamp. * There are many ways in which this can fail, but we rely on having all three headers * at the beginning of the ogg video bitstream. @@ -64,27 +64,27 @@ struct op_node *node; struct theora_headers *th; long timestamp = 0; - + //fprintf(stderr, "Got theora packet, serialno=%d, size=%d, packetno=%lld, granulepos=%lld\n", serialno, op->bytes, op->packetno, op->granulepos); - + th = (struct theora_headers *)video_stream->data; - + if ( theora_packet_isheader(op) ) { theora_decode_header(&(th->ti), &(th->tc), op); th->header_count++; } - + if ( th->header_count >= 3 && !th->have_headers ) { theora_decode_init(&(th->ts), &(th->ti)); th->have_headers = 1; } - + if ( th->have_headers ) { double d; - + d = theora_granule_time(&(th->ts), op->granulepos); timestamp = (long)(d * 1000); } @@ -98,13 +98,13 @@ video_stream->page_ts = timestamp; video_stream->page_count = 0; } - + if ( !theora_packet_isheader(op) ) { node = create_node(op, serialno, timestamp); append_node(video_stream, node); } - + return 0; } @@ -113,42 +113,42 @@ struct op_node *node; long timestamp; static int cnt = 0; - + timestamp = audio_stream->page_ts + audio_stream->page_count * SPEEX_FRAME_DURATION; audio_stream->page_count++; - + cnt++; //fprintf(stderr, "Got speex packet, serialno=%ld, size=%ld, packetno=%lld, granulepos=%lld, timestamp=%ld\n", serialno, op->bytes, op->packetno, op->granulepos, timestamp); - + // Ignore the first two packets, they are headers if ( cnt > 2 ) { node = create_node(op, serialno, timestamp); append_node(audio_stream, node); } - + return 0; } int read_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) { struct theora_headers *th; - + const char theoraId[] = "\x80theora"; const char speexId[] = "Speex "; - + if ( memcmp(op->packet, theoraId, strlen(theoraId)) == 0 ) { //fprintf(stderr, "Detected a Theora stream with serialno=%d\n", serialno); oggz_set_read_callback(oggz, serialno, read_theora_cb, NULL); video_stream->serialno = serialno; - + // Initialize theora specific data fields th = (struct theora_headers *)calloc(1, sizeof(struct theora_headers)); theora_info_init(&(th->ti)); theora_comment_init(&(th->tc)); video_stream->data = th; - + read_theora_cb(oggz, op, serialno, data); } else if ( memcmp(op->packet, speexId, strlen(speexId)) == 0 ) { @@ -179,7 +179,7 @@ void dump_stream(struct ogg_stream *os) { struct op_node *node; - + node = os->first; while ( node != NULL ) { @@ -198,21 +198,21 @@ fprintf(stderr, "Error opening ogg file\n"); } fprintf(stderr, "Successfully opened ogg file %s\n", filename); - + // Initialize internal streams audio_stream = calloc(1, sizeof(struct ogg_stream)); video_stream = calloc(1, sizeof(struct ogg_stream)); - + oggz_set_read_callback(oggz, -1, read_cb, NULL); oggz_set_read_page(oggz, -1, read_page_cb, NULL); - + oggz_run(oggz); - + //fprintf(stderr, "Audio stream, serialno=%d\n", audio_stream->serialno); //dump_stream(audio_stream); //fprintf(stderr, "Video stream, serialno=%d\n", video_stream->serialno); //dump_stream(video_stream); - + oggz_close(oggz); } @@ -221,27 +221,27 @@ ogg_packet *op; struct timeval tv; long time_now; - + if ( os == NULL ) return NULL; - + gettimeofday(&tv, NULL); time_now = tv.tv_sec * 1000 + tv.tv_usec / 1000; - + if ( os->current == NULL ) { // point to the beginning of the stream and reset the time base os->base_ts = time_now; os->current = os->first; } - - op = NULL; + + op = NULL; if ( os->current->timestamp < time_now - os->base_ts ) { op = os->current->op; os->current = os->current->next; } - + return op; } Modified: trunk/simpleclient/stresstest/stresstest.c =================================================================== --- trunk/simpleclient/stresstest/stresstest.c 2007-10-16 23:32:32 UTC (rev 1200) +++ trunk/simpleclient/stresstest/stresstest.c 2007-10-16 23:34:48 UTC (rev 1201) @@ -83,13 +83,13 @@ void signal_handler(int signum) { - if ( signum == SIGTERM || signum == SIGINT ) + if ( signum == SIGTERM || signum == SIGINT ) { running = 0; } } -void fatal_error(char *err) +void fatal_error(char *err) { fprintf(stderr, "FATAL ERROR: %s\n", err); exit(TEST_UNKNOWN_ERROR); @@ -102,10 +102,10 @@ int netstat_callback(struct iaxc_ev_netstats n) { static int i; - + if ( !print_netstats ) return 0; - + if(i++%25 == 0) fprintf(stderr, "RTT\t" "Rjit\tRlos%%\tRlosC\tRpkts\tRdel\tRdrop\tRooo\t" @@ -140,7 +140,7 @@ void process_text_message(char *message) { unsigned int prefs; - + if ( strncmp(message, "CONTROL:", strlen("CONTROL:")) == 0 ) { message += strlen("CONTROL:"); @@ -162,7 +162,7 @@ } void usage() -{ +{ printf( "\n" "Usage is: tescall <options>\n\n" @@ -188,7 +188,7 @@ fprintf(stderr, "Call answered\n"); call_established = 1; } - if (s.state == IAXC_CALL_STATE_FREE) + if (s.state == IAXC_CALL_STATE_FREE) { fprintf(stderr,"Call terminated\n"); running = 0; @@ -199,7 +199,7 @@ int test_mode_callback(iaxc_event e) { - switch ( e.type ) + switch ( e.type ) { case IAXC_EVENT_LEVELS: return levels_callback(e.ev.levels.input, e.ev.levels.output); @@ -230,7 +230,7 @@ int main(int argc, char **argv) { - int i; + int i; char mydest[80], *dest = NULL; char *ogg_file = NULL; int loop = 0; @@ -238,15 +238,15 @@ static struct slice_set_t slice_set; unsigned short source_id; struct timeval now; - + /* install signal handler to catch CRTL-Cs */ signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); - + /* Parse command line */ for(i=1;i<argc;i++) { - if(argv[i][0] == '-') + if(argv[i][0] == '-') { switch(argv[i][1]) { @@ -285,44 +285,44 @@ default: usage(); } - } else + } else dest=argv[i]; } - + if ( dest == NULL ) { // We need a destination to call fprintf(stderr, "No destination, quitting\n"); return -1; } - + if ( ogg_file == NULL ) fprintf(stderr, "No media file, running dry\n"); - + if ( ogg_file ) { // Load ogg file load_ogg_file(ogg_file); } - + // Get start time for timeouts gettimeofday(&start_time, NULL); - + // Initialize iaxclient iaxc_video_format_set(formatp, format, framerate, bitrate, width, height, fragsize); iaxc_set_test_mode(1); - if (iaxc_initialize(MAX_CALLS)) + 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(IAXC_AUDIO_PREF_RECV_REMOTE_ENCODED); iaxc_set_video_prefs(IAXC_VIDEO_PREF_RECV_REMOTE_ENCODED); - iaxc_set_event_callback(test_mode_callback); - + iaxc_set_event_callback(test_mode_callback); + // Crank the engine iaxc_start_processing_thread(); - + // Dial out int callNo = iaxc_call(dest); if (callNo <= 0) @@ -338,7 +338,7 @@ hangup_and_exit(TEST_NO_CONNECTION); iaxc_millisleep(5); } - + running = 1; while ( running ) { @@ -346,29 +346,29 @@ if ( ogg_file && ( send_audio || send_video ) ) { 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); } - + // Tight spinloops are bad, mmmkay? iaxc_millisleep(5); - + // Exit after a positive timeout gettimeofday(&now, NULL); if ( timeout > 0 && msecdiff(&start_time, &now) > timeout ) running = 0; } - + fprintf(stderr, "Received %d audio frames and %d video frames\n", audio_frames_count, video_frames_count); if ( audio_frames_count == 0 && video_frames_count == 0 ) hangup_and_exit(TEST_NO_MEDIA); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |