diff options
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 1 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 61 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_settings.c | 26 |
3 files changed, 73 insertions, 15 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 726f8f0c..18467129 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -195,6 +195,7 @@ struct pjsua pj_bool_t auto_conf; /**< Auto put to conference? */ int complexity; /**< Codec complexity. */ int quality; /**< Codec quality. */ + int ptime; /**< Codec ptime in msec. */ /* Codec arguments: */ diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index b8fff57f..73f5aac1 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -26,7 +26,7 @@ * Call (INVITE) related stuffs. */ -#define THIS_FILE "pjsua_inv.c" +#define THIS_FILE "pjsua_call.c" #define REFRESH_CALL_TIMER 0x63 @@ -153,10 +153,10 @@ static pj_status_t call_destroy_media(int call_index) call->session = NULL; - } + PJ_LOG(3,(THIS_FILE, "Media session for call %d is destroyed", + call_index)); - PJ_LOG(3,(THIS_FILE, "Media session for call %d is destroyed", - call_index)); + } return PJ_SUCCESS; } @@ -523,6 +523,11 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv, case PJSIP_INV_STATE_DISCONNECTED: pj_gettimeofday(&call->dis_time); break; + default: + /* Nothing to do. Just to keep gcc from complaining about + * unused enums. + */ + break; } /* If this is an outgoing INVITE that was created because of @@ -557,6 +562,12 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv, st_code = e->body.tsx_state.tsx->status_code; ev_state = PJSIP_EVSUB_STATE_TERMINATED; break; + + default: + /* Nothing to do. Just to keep gcc from complaining about + * unused enums. + */ + break; } if (st_code != -1) { @@ -915,6 +926,7 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv, } +#if 0 /* Disconnect call */ static void call_disconnect(pjsip_inv_session *inv, int st_code) @@ -930,6 +942,7 @@ static void call_disconnect(pjsip_inv_session *inv, pjsua_perror(THIS_FILE, "Unable to disconnect call", status); } } +#endif /* * Callback to be called when SDP offer/answer negotiation has just completed @@ -940,6 +953,7 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, pj_status_t status) { pjsua_call *call; + pjmedia_session_info sess_info; const pjmedia_sdp_session *local_sdp; const pjmedia_sdp_session *remote_sdp; pjmedia_port *media_port; @@ -990,17 +1004,38 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, return; } - /* Create new media session. - * The media session is active immediately. - */ if (pjsua.null_audio) return; - - status = pjmedia_session_create( pjsua.med_endpt, 1, - &call->skinfo, - local_sdp, remote_sdp, - call, - &call->session ); + + /* Create media session info based on SDP parameters. + * We only support one stream per session at the moment + */ + status = pjmedia_session_info_from_sdp( call->inv->dlg->pool, + pjsua.med_endpt, 1, + &sess_info, &call->skinfo, + local_sdp, remote_sdp); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to create media session", + status); + //call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + /* Override ptime, if this option is specified. */ + if (pjsua.ptime) { + sess_info.stream_info[0].param->setting.frm_per_pkt = (pj_uint8_t) + (pjsua.ptime / sess_info.stream_info[0].param->info.frm_ptime); + if (sess_info.stream_info[0].param->setting.frm_per_pkt==0) + sess_info.stream_info[0].param->setting.frm_per_pkt = 1; + } + + /* Optionally, application may modify other stream settings here + * (such as jitter buffer parameters, codec ptime, etc.) + */ + + /* Create session based on session info. */ + status = pjmedia_session_create( pjsua.med_endpt, &sess_info, + call, &call->session ); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create media session", status); diff --git a/pjsip/src/pjsua-lib/pjsua_settings.c b/pjsip/src/pjsua-lib/pjsua_settings.c index 46d2d945..cb98effe 100644 --- a/pjsip/src/pjsua-lib/pjsua_settings.c +++ b/pjsip/src/pjsua-lib/pjsua_settings.c @@ -94,6 +94,7 @@ static void usage(void) puts (" --rtp-port=N Base port to try for RTP (default=4000)"); puts (" --complexity=N Specify encoding complexity (0-10, default=none(-1))"); puts (" --quality=N Specify encoding quality (0-10, default=4)"); + puts (" --ptime=MSEC Override codec ptime to MSEC (default=specific)"); puts (""); puts ("Buddy List (can be more than one):"); puts (" --add-buddy url Add the specified URL to the buddy list."); @@ -227,7 +228,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP, OPT_AUTO_CONF, OPT_CLOCK_RATE, OPT_PLAY_FILE, OPT_RTP_PORT, OPT_ADD_CODEC, - OPT_COMPLEXITY, OPT_QUALITY, + OPT_COMPLEXITY, OPT_QUALITY, OPT_PTIME, OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, OPT_UAS_REFRESH, OPT_UAS_DURATION, }; @@ -266,6 +267,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) { "add-codec", 1, 0, OPT_ADD_CODEC}, { "complexity", 1, 0, OPT_COMPLEXITY}, { "quality", 1, 0, OPT_QUALITY}, + { "ptime", 1, 0, OPT_PTIME}, { "next-account",0,0, OPT_NEXT_ACCOUNT}, { "next-cred", 0, 0, OPT_NEXT_CRED}, { "max-calls", 1, 0, OPT_MAX_CALLS}, @@ -559,6 +561,15 @@ pj_status_t pjsua_parse_args(int argc, char *argv[]) } break; + case OPT_PTIME: + pjsua.ptime = my_atoi(pj_optarg); + if (pjsua.ptime < 10 || pjsua.ptime > 1000) { + PJ_LOG(1,(THIS_FILE, + "Error: invalid --ptime option")); + return -1; + } + break; + case OPT_AUTO_ANSWER: pjsua.auto_answer = my_atoi(pj_optarg); if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) { @@ -771,13 +782,15 @@ static void dump_media_session(pjmedia_session *session) } PJ_LOG(3,(THIS_FILE, - " TX pt=%d, stat last update: %s\n" + " TX pt=%d, ptime=%dms, stat last update: %s\n" " total %spkt %sB (%sB +IP hdr)%s\n" " pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" " (msec) min avg max last\n" " loss period: %7.3f %7.3f %7.3f %7.3f%s\n" " jitter : %7.3f %7.3f %7.3f %7.3f%s", info.stream_info[i].tx_pt, + info.stream_info[i].param->info.frm_ptime * + info.stream_info[i].param->setting.frm_per_pkt, last_update, good_number(packets, stat.tx.pkt), good_number(bytes, stat.tx.bytes), @@ -969,6 +982,8 @@ int pjsua_dump_settings(char *buf, pj_size_t max) pj_str_t cfg; char line[128]; + PJ_UNUSED_ARG(max); + cfg.ptr = buf; cfg.slen = 0; @@ -1096,6 +1111,13 @@ int pjsua_dump_settings(char *buf, pj_size_t max) pjsua.complexity); pj_strcat2(&cfg, line); + /* ptime */ + if (pjsua.ptime) { + pj_ansi_sprintf(line, "--ptime %d\n", + pjsua.ptime); + pj_strcat2(&cfg, line); + } + /* Start RTP port. */ pj_ansi_sprintf(line, "--rtp-port %d\n", pjsua.start_rtp_port); |