diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-03-01 19:29:10 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-03-01 19:29:10 +0000 |
commit | 6b8c1eb422e7f06384c7bad0c91f7680c6b73a33 (patch) | |
tree | 333879b32dc295e05c64f1b7fbceb7354b1fca26 /pjsip/src/pjsua-lib | |
parent | afed82d0613050254f3d877292342e7cc92bc02f (diff) |
Moved pjsua to pjsip-apps
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@253 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 11 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_opt.c | 21 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_reg.c | 70 |
3 files changed, 63 insertions, 39 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index c468f85b..775c96ba 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -58,6 +58,10 @@ void pjsua_default(void) pjsua.sip_port = 5060; + /* Default we start RTP at port 4000 */ + pjsua.start_rtp_port = 4000; + + /* Default logging settings: */ pjsua.log_level = 5; pjsua.app_log_level = 4; @@ -138,8 +142,6 @@ static pj_status_t init_sockets(pj_bool_t sip, pjmedia_sock_info *skinfo) { enum { - RTP_START_PORT = 4000, - RTP_RANDOM_START = 2, RTP_RETRY = 100 }; enum { @@ -148,11 +150,14 @@ static pj_status_t init_sockets(pj_bool_t sip, RTCP_SOCK, }; int i; - static pj_uint16_t rtp_port = RTP_START_PORT; + static pj_uint16_t rtp_port; pj_sock_t sock[3]; pj_sockaddr_in mapped_addr[3]; pj_status_t status = PJ_SUCCESS; + if (rtp_port == 0) + rtp_port = (pj_uint16_t)pjsua.start_rtp_port; + for (i=0; i<3; ++i) sock[i] = PJ_INVALID_SOCKET; diff --git a/pjsip/src/pjsua-lib/pjsua_opt.c b/pjsip/src/pjsua-lib/pjsua_opt.c index bdd1a421..c8b0adac 100644 --- a/pjsip/src/pjsua-lib/pjsua_opt.c +++ b/pjsip/src/pjsua-lib/pjsua_opt.c @@ -82,6 +82,7 @@ static void usage(void) puts(" --auto-play Automatically play the file (to incoming calls only)"); puts(" --auto-loop Automatically loop incoming RTP to outgoing RTP"); puts(" --auto-conf Automatically put incoming calls to conference"); + puts(" --rtp-port=N Base port to try for RTP"); puts(""); puts("Buddy List (can be more than one):"); puts(" --add-buddy url Add the specified URL to the buddy list."); @@ -211,7 +212,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP, OPT_AUTO_CONF, - OPT_PLAY_FILE, + OPT_PLAY_FILE, OPT_RTP_PORT, OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, }; struct option long_options[] = { @@ -243,6 +244,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) { "auto-loop", 0, 0, OPT_AUTO_LOOP}, { "auto-conf", 0, 0, OPT_AUTO_CONF}, { "play-file", 1, 0, OPT_PLAY_FILE}, + { "rtp-port", 1, 0, OPT_RTP_PORT}, { "next-account",0,0, OPT_NEXT_ACCOUNT}, { "next-cred", 0, 0, OPT_NEXT_CRED}, { "max-calls", 1, 0, OPT_MAX_CALLS}, @@ -462,10 +464,19 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) pjsua.wav_file = optarg; break; + case OPT_RTP_PORT: + pjsua.start_rtp_port = my_atoi(optarg); + if (pjsua.start_rtp_port < 1 || pjsua.start_rtp_port > 65535) { + PJ_LOG(1,(THIS_FILE, + "Error: rtp-port argument value (expecting 1-65535")); + return -1; + } + case OPT_AUTO_ANSWER: pjsua.auto_answer = my_atoi(optarg); if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) { - puts("Error: invalid code in --auto-answer (expecting 100-699"); + PJ_LOG(1,(THIS_FILE, + "Error: invalid code in --auto-answer (expecting 100-699")); return -1; } break; @@ -473,7 +484,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) case OPT_MAX_CALLS: pjsua.max_calls = my_atoi(optarg); if (pjsua.max_calls < 1 || pjsua.max_calls > 255) { - puts("Too many calls for max-calls (1-255)"); + PJ_LOG(1,(THIS_FILE,"Too many calls for max-calls (1-255)")); return -1; } break; @@ -577,8 +588,8 @@ void pjsua_dump(void) pjsip_endpt_dump(pjsua.endpt, 1); pjmedia_endpt_dump(pjsua.med_endpt); - pjsip_tsx_layer_dump(); - pjsip_ua_dump(); + pjsip_tsx_layer_dump(1); + pjsip_ua_dump(1); /* Dump all invite sessions: */ diff --git a/pjsip/src/pjsua-lib/pjsua_reg.c b/pjsip/src/pjsua-lib/pjsua_reg.c index e18f7cc8..1552acf6 100644 --- a/pjsip/src/pjsua-lib/pjsua_reg.c +++ b/pjsip/src/pjsua-lib/pjsua_reg.c @@ -86,8 +86,8 @@ static void regc_cb(struct pjsip_regc_cbparam *param) */ void pjsua_regc_update(int acc_index, pj_bool_t renew) { - pj_status_t status; - pjsip_tx_data *tdata; + pj_status_t status = 0; + pjsip_tx_data *tdata = 0; if (renew) { if (pjsua.acc[acc_index].regc == NULL) { @@ -98,7 +98,12 @@ void pjsua_regc_update(int acc_index, pj_bool_t renew) return; } } - status = pjsip_regc_register(pjsua.acc[acc_index].regc, 1, &tdata); + if (!pjsua.acc[acc_index].regc) + return; + + status = pjsip_regc_register(pjsua.acc[acc_index].regc, 1, + &tdata); + } else { if (pjsua.acc[acc_index].regc == NULL) { PJ_LOG(3,(THIS_FILE, "Currently not registered")); @@ -126,41 +131,44 @@ pj_status_t pjsua_regc_init(int acc_index) { pj_status_t status; + if (pjsua.acc[acc_index].reg_uri.slen == 0) { + PJ_LOG(3,(THIS_FILE, "Registrar URI is not specified")); + return PJ_SUCCESS; + } + /* initialize SIP registration if registrar is configured */ - if (pjsua.acc[acc_index].reg_uri.slen) { - status = pjsip_regc_create( pjsua.endpt, - &pjsua.acc[acc_index], - ®c_cb, - &pjsua.acc[acc_index].regc); + status = pjsip_regc_create( pjsua.endpt, + &pjsua.acc[acc_index], + ®c_cb, + &pjsua.acc[acc_index].regc); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to create client registration", - status); - return status; - } + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to create client registration", + status); + return status; + } - status = pjsip_regc_init( pjsua.acc[acc_index].regc, - &pjsua.acc[acc_index].reg_uri, - &pjsua.acc[acc_index].local_uri, - &pjsua.acc[acc_index].local_uri, - 1, &pjsua.acc[acc_index].contact_uri, - pjsua.acc[acc_index].reg_timeout); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, - "Client registration initialization error", - status); - return status; - } + status = pjsip_regc_init( pjsua.acc[acc_index].regc, + &pjsua.acc[acc_index].reg_uri, + &pjsua.acc[acc_index].local_uri, + &pjsua.acc[acc_index].local_uri, + 1, &pjsua.acc[acc_index].contact_uri, + pjsua.acc[acc_index].reg_timeout); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, + "Client registration initialization error", + status); + return status; + } - pjsip_regc_set_credentials( pjsua.acc[acc_index].regc, - pjsua.cred_count, - pjsua.cred_info ); + pjsip_regc_set_credentials( pjsua.acc[acc_index].regc, + pjsua.cred_count, + pjsua.cred_info ); - pjsip_regc_set_route_set( pjsua.acc[acc_index].regc, - &pjsua.acc[acc_index].route_set ); - } + pjsip_regc_set_route_set( pjsua.acc[acc_index].regc, + &pjsua.acc[acc_index].route_set ); return PJ_SUCCESS; } |