From: <st...@us...> - 2003-06-16 23:01:31
|
Update of /cvsroot/iaxclient/iaxclient/simpleclient/testcall In directory sc8-pr-cvs1:/tmp/cvs-serv20862/simpleclient/testcall Modified Files: testcall.c Log Message: A pretty big commit. 1) Change the overall "event" callback mechanism, to use a structure/union, with just one callback for all events. clients can accept or decline each event, in which case the library might take a "default" action for the event. (currently, the library will ignore all events except for text, which it will print to stderr/stdout). 2) Totally rework call handling, and allow the library to manage multiple calls. Call state is more or less followed through the lifetime of the call, but may not be right in all cases. 3) Implement call appearances based on all of this in wx. 4) Make testcall work with this (only one call). 5) Try to keep Faizan's "WinIAX" client up to date with the API changes, haven't tested the changes there, but they should work for one call. 6) #define out the WIN AUDIO stuff, it's pretty far behind now, and would need some work to get going. portaudio seems to handle the gory details for us very nicely. Need to do more testing with all of this, but this now allows you to make IAXClient -> IAXClient calls. Of course, allowing people to reject calls would be nice too, but I suppose you can always hang up :) Index: testcall.c =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/simpleclient/testcall/testcall.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- testcall.c 9 Jun 2003 21:01:13 -0000 1.8 +++ testcall.c 16 Jun 2003 23:01:29 -0000 1.9 @@ -23,6 +23,7 @@ #include "iaxclient.h" static int answered_call; +int do_levels = 0; /* routine called at exit to shutdown audio I/O and close nicely. NOTE: If all this isnt done, the system doesnt not handle this @@ -40,9 +41,24 @@ } int levels_callback(float input, float output) { - fprintf(stderr, "IN: %f OUT: %f\n", input, output); + if(do_levels) fprintf(stderr, "IN: %f OUT: %f\n", input, output); } +int iaxc_callback(iaxc_event e) +{ + switch(e.type) { + case IAXC_EVENT_LEVELS: + return levels_callback(e.ev.levels.input, e.ev.levels.output); + case IAXC_EVENT_TEXT: + return 0; // don't handle + case IAXC_EVENT_STATE: + return 0; + default: + return 0; // not handled + } +} + + void usage() { fprintf(stderr, "Usage is XXX\n"); @@ -55,7 +71,6 @@ char c; int i; char *dest = "guest@10.23.1.31/9999"; - int do_levels = 0; double silence_threshold = -99; @@ -90,12 +105,12 @@ /* activate the exit handler */ atexit(killem); - iaxc_initialize(AUDIO_INTERNAL_PA); + iaxc_initialize(AUDIO_INTERNAL_PA,1); iaxc_set_encode_format(IAXC_FORMAT_GSM); iaxc_set_silence_threshold(silence_threshold); if(do_levels) - iaxc_set_levels_callback(levels_callback); + iaxc_set_event_callback(iaxc_callback); fprintf(f, "\n\ |