diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-02-23 13:49:28 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-02-23 13:49:28 +0000 |
commit | bc4d45bb16bb152fcf261ac48e574e184b551bd5 (patch) | |
tree | 905516933c9e4e6220b8fa35a3fac1421b50f14b /pjsip/src/pjsua | |
parent | 6d68baecdefbc8b90749dc7cff8def2a5a88af30 (diff) |
Added support for NULL frame in rtp stream, fixed bugs here and there in INVITE (e.g. dont send SDP on 180), and set version to 0.5.1.2
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@223 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua')
-rw-r--r-- | pjsip/src/pjsua/pjsua.h | 6 | ||||
-rw-r--r-- | pjsip/src/pjsua/pjsua_inv.c | 63 | ||||
-rw-r--r-- | pjsip/src/pjsua/pjsua_opt.c | 59 |
3 files changed, 84 insertions, 44 deletions
diff --git a/pjsip/src/pjsua/pjsua.h b/pjsip/src/pjsua/pjsua.h index 81927821..2e430ce9 100644 --- a/pjsip/src/pjsua/pjsua.h +++ b/pjsip/src/pjsua/pjsua.h @@ -121,6 +121,10 @@ struct pjsua char *wav_file; /**< WAV file name to play. */ unsigned wav_slot; /**< WAV player slot in bridge */ + /* User Agent behaviour: */ + + int auto_answer; /**< Automatically answer in calls. */ + /* Since we support simultaneous calls, we need to have multiple * RTP sockets. @@ -178,7 +182,7 @@ struct pjsua int stun_port2; - /* Misc: */ + /* Logging: */ int log_level; /**< Logging verbosity. */ int app_log_level; /**< stdout log verbosity. */ diff --git a/pjsip/src/pjsua/pjsua_inv.c b/pjsip/src/pjsua/pjsua_inv.c index 83b2bfff..f8b211d3 100644 --- a/pjsip/src/pjsua/pjsua_inv.c +++ b/pjsip/src/pjsua/pjsua_inv.c @@ -278,9 +278,13 @@ pj_bool_t pjsua_inv_on_incoming(pjsip_rx_data *rdata) pj_list_push_back(&pjsua.inv_list, inv_data); - /* Answer with 100 (using the dialog, not invite): */ - - status = pjsip_dlg_create_response(dlg, rdata, 100, NULL, &response); + /* Must answer with some response to initial INVITE. + * If auto-answer flag is set, send 200 straight away, otherwise send 100. + */ + + status = pjsip_inv_initial_answer(inv, rdata, + (pjsua.auto_answer ? 200 : 100), + NULL, NULL, &response); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create 100 response", status); @@ -293,21 +297,32 @@ pj_bool_t pjsua_inv_on_incoming(pjsip_rx_data *rdata) // TODO: Need to delete dialog } else { - status = pjsip_dlg_send_response(dlg, pjsip_rdata_get_tsx(rdata), - response); + status = pjsip_inv_send_msg(inv, response, NULL); if (status != PJ_SUCCESS) pjsua_perror(THIS_FILE, "Unable to send 100 response", status); } - PJ_LOG(3,(THIS_FILE, - "\nIncoming call!!\n" - "From: %.*s\n" - "To: %.*s\n" - "(press 'a' to answer, 'h' to decline)", - (int)dlg->remote.info_str.slen, - dlg->remote.info_str.ptr, - (int)dlg->local.info_str.slen, - dlg->local.info_str.ptr)); + if (pjsua.auto_answer < 200) { + PJ_LOG(3,(THIS_FILE, + "\nIncoming call!!\n" + "From: %.*s\n" + "To: %.*s\n" + "(press 'a' to answer, 'h' to decline)", + (int)dlg->remote.info_str.slen, + dlg->remote.info_str.ptr, + (int)dlg->local.info_str.slen, + dlg->local.info_str.ptr)); + } else { + PJ_LOG(3,(THIS_FILE, + "Call From:%.*s To:%.*s was answered with %d (%s)", + (int)dlg->remote.info_str.slen, + dlg->remote.info_str.ptr, + (int)dlg->local.info_str.slen, + dlg->local.info_str.ptr, + pjsua.auto_answer, + pjsip_get_status_text(pjsua.auto_answer)->ptr )); + } + /* This INVITE request has been handled. */ return PJ_TRUE; } @@ -766,11 +781,23 @@ void pjsua_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status) return; } - /* Connect new call to the sound device port (port zero) in the - * main conference bridge. + /* If auto-play is configured, connect the call to the file player + * port */ - pjmedia_conf_connect_port( pjsua.mconf, 0, inv_data->conf_slot); - pjmedia_conf_connect_port( pjsua.mconf, inv_data->conf_slot, 0); + if (pjsua.wav_file && inv->role == PJSIP_ROLE_UAS) { + + pjmedia_conf_connect_port( pjsua.mconf, pjsua.wav_slot, + inv_data->conf_slot); + + } else { + + /* Connect new call to the sound device port (port zero) in the + * main conference bridge. + */ + pjmedia_conf_connect_port( pjsua.mconf, 0, inv_data->conf_slot); + pjmedia_conf_connect_port( pjsua.mconf, inv_data->conf_slot, 0); + } + /* Done. */ { diff --git a/pjsip/src/pjsua/pjsua_opt.c b/pjsip/src/pjsua/pjsua_opt.c index d40f1de1..52819265 100644 --- a/pjsip/src/pjsua/pjsua_opt.c +++ b/pjsip/src/pjsua/pjsua_opt.c @@ -41,49 +41,50 @@ const char *pjsua_inv_state_names[] = static void usage(void) { puts("Usage:"); - puts(" pjsua [options] [sip-url]"); + puts(" pjsua [options]"); puts(""); puts(" [sip-url] Default URL to invite."); puts(""); puts("General options:"); + puts(" --help Display this help screen"); + puts(" --version Display version info"); + puts(""); + puts("Logging options:"); puts(" --config-file=file Read the config/arguments from file."); puts(" --log-file=fname Log to filename (default stderr)"); puts(" --log-level=N Set log max level to N (0(none) to 6(trace))"); puts(" --app-log-level=N Set log max level for stdout display to N"); - puts(" --help Display this help screen"); - puts(" --version Display version info"); - puts(""); - puts("Media options:"); - puts(" --null-audio Use NULL audio device"); - puts(" --wav-file=file Play WAV file in conference bridge"); puts(""); - //puts(""); - //puts("User Agent options:"); - //puts(" --auto-answer=sec Auto-answer all incoming calls after sec seconds."); - //puts(" --auto-hangup=sec Auto-hangup all calls after sec seconds."); + puts("Authentication options:"); + puts(" --realm=string Set realm"); + puts(" --username=string Set authentication username"); + puts(" --password=string Set authentication password"); puts(""); puts("SIP options:"); - puts(" --local-port=port Set TCP/UDP port"); puts(" --id=url Set the URL of local ID (used in From header)"); puts(" --contact=url Override the Contact information"); puts(" --proxy=url Set the URL of proxy server"); - puts(" --outbound=url Set the URL of outbound proxy server"); + //puts(" --outbound=url Set the URL of outbound proxy server"); + puts(""); + puts("Registration Options:"); puts(" --registrar=url Set the URL of registrar server"); puts(" --reg-timeout=secs Set registration interval to secs (default 3600)"); puts(""); - puts("Authentication options:"); - puts(" --realm=string Set realm"); - puts(" --username=string Set authentication username"); - puts(" --password=string Set authentication password"); - puts(""); - puts("STUN options (all must be specified):"); + puts("Transport Options:"); + puts(" --local-port=port Set TCP/UDP port"); puts(" --use-stun1=host[:port]"); puts(" --use-stun2=host[:port] Use STUN and set host name and port of STUN servers"); puts(""); - puts("SIMPLE options (may be specified more than once):"); + puts("Media Options:"); + puts(" --null-audio Use NULL audio device"); + //puts(" --wav-file=file Play WAV file in conference bridge"); + puts(""); + puts("Buddy List (can be more than one):"); puts(" --add-buddy url Add the specified URL to the buddy list."); - //puts(" --offer-x-ms-msg Offer \"x-ms-message\" in outgoing INVITE"); - //puts(" --no-presence Do not subscribe presence of buddies"); + puts(""); + puts("User Agent options:"); + puts(" --auto-answer=code Automatically answer incoming calls with code (e.g. 200)"); + puts(" --auto-play=file Automatically play WAVE file to incoming calls"); puts(""); fflush(stdout); } @@ -198,7 +199,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) OPT_REALM, OPT_USERNAME, OPT_PASSWORD, OPT_USE_STUN1, OPT_USE_STUN2, OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, - OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_WAV_FILE}; + OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY}; struct option long_options[] = { { "config-file",1, 0, OPT_CONFIG_FILE}, { "log-file", 1, 0, OPT_LOG_FILE}, @@ -224,7 +225,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) { "no-presence", 0, 0, OPT_NO_PRESENCE}, { "auto-answer",1, 0, OPT_AUTO_ANSWER}, { "auto-hangup",1, 0, OPT_AUTO_HANGUP}, - { "wav-file", 1, 0, OPT_WAV_FILE}, + { "auto-play", 1, 0, OPT_AUTO_PLAY}, { NULL, 0, 0, 0} }; pj_status_t status; @@ -409,9 +410,17 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(optarg); break; - case OPT_WAV_FILE: + case OPT_AUTO_PLAY: pjsua.wav_file = optarg; break; + + case OPT_AUTO_ANSWER: + pjsua.auto_answer = atoi(optarg); + if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) { + puts("Error: invalid code in --auto-answer (expecting 100-699"); + return -1; + } + break; } } |