diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-06-14 20:40:53 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-06-14 20:40:53 +0000 |
commit | 24d371781d0f04f841f7979d136fad198ae12ffd (patch) | |
tree | 911de091635448de8da5a7133dcaab062c1d7d18 /pjsip-apps/src/pjsua | |
parent | 849922592a1ae3c3088f362f48a45a8da3f03cbb (diff) |
Refine the tone feature implementation in pjsua
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2023 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/pjsua')
-rw-r--r-- | pjsip-apps/src/pjsua/pjsua_app.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index 0cb0ad1d..505f076a 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -1746,16 +1746,6 @@ static void ringback_start(pjsua_call_id call_id) if (++app_config.ringback_cnt==1 && app_config.ringback_slot!=PJSUA_INVALID_ID) { - pjmedia_tone_desc tone; - - pj_bzero(&tone, sizeof(tone)); - tone.freq1 = RINGBACK_FREQ1; - tone.freq2 = RINGBACK_FREQ2; - tone.on_msec = RINGBACK_ON; - tone.off_msec = RINGBACK_OFF; - pjmedia_tonegen_play(app_config.ringback_port, 1, &tone, - PJMEDIA_TONEGEN_LOOP); - pjsua_conf_connect(app_config.ringback_slot, 0); } } @@ -1773,7 +1763,7 @@ static void ring_stop(pjsua_call_id call_id) app_config.ringback_slot!=PJSUA_INVALID_ID) { pjsua_conf_disconnect(app_config.ringback_slot, 0); - pjmedia_tonegen_stop(app_config.ringback_port); + pjmedia_tonegen_rewind(app_config.ringback_port); } } @@ -1785,7 +1775,7 @@ static void ring_stop(pjsua_call_id call_id) app_config.ring_slot!=PJSUA_INVALID_ID) { pjsua_conf_disconnect(app_config.ring_slot, 0); - pjmedia_tonegen_stop(app_config.ring_port); + pjmedia_tonegen_rewind(app_config.ring_port); } } } @@ -1803,21 +1793,6 @@ static void ring_start(pjsua_call_id call_id) if (++app_config.ring_cnt==1 && app_config.ring_slot!=PJSUA_INVALID_ID) { - unsigned i; - pjmedia_tone_desc tone[3]; - - pj_bzero(&tone, sizeof(tone)); - for (i=0; i<PJ_ARRAY_SIZE(tone); ++i) { - tone[i].freq1 = RING_FREQ1; - tone[i].freq2 = RING_FREQ2; - tone[i].on_msec = RING_ON; - tone[i].off_msec = RING_OFF; - } - tone[PJ_ARRAY_SIZE(tone)-1].off_msec = RING_INTERVAL; - - pjmedia_tonegen_play(app_config.ring_port, PJ_ARRAY_SIZE(tone), - tone, PJMEDIA_TONEGEN_LOOP); - pjsua_conf_connect(app_config.ring_slot, 0); } } @@ -3835,6 +3810,8 @@ pj_status_t app_init(int argc, char *argv[]) /* Create ringback tones */ if (app_config.no_tones == PJ_FALSE) { + unsigned i; + pjmedia_tone_desc tone[3]; pj_str_t name; /* Ringback tone (call is ringing) */ @@ -3845,6 +3822,16 @@ pj_status_t app_init(int argc, char *argv[]) if (status != PJ_SUCCESS) goto on_error; + pj_bzero(&tone, sizeof(tone)); + tone[0].freq1 = RINGBACK_FREQ1; + tone[0].freq2 = RINGBACK_FREQ2; + tone[0].on_msec = RINGBACK_ON; + tone[0].off_msec = RINGBACK_OFF; + + pjmedia_tonegen_play(app_config.ringback_port, 1, &tone[0], + PJMEDIA_TONEGEN_LOOP); + + status = pjsua_conf_add_port(app_config.pool, app_config.ringback_port, &app_config.ringback_slot); if (status != PJ_SUCCESS) @@ -3858,6 +3845,17 @@ pj_status_t app_init(int argc, char *argv[]) if (status != PJ_SUCCESS) goto on_error; + for (i=0; i<PJ_ARRAY_SIZE(tone); ++i) { + tone[i].freq1 = RING_FREQ1; + tone[i].freq2 = RING_FREQ2; + tone[i].on_msec = RING_ON; + tone[i].off_msec = RING_OFF; + } + tone[PJ_ARRAY_SIZE(tone)-1].off_msec = RING_INTERVAL; + + pjmedia_tonegen_play(app_config.ring_port, PJ_ARRAY_SIZE(tone), + tone, PJMEDIA_TONEGEN_LOOP); + status = pjsua_conf_add_port(app_config.pool, app_config.ring_port, &app_config.ring_slot); if (status != PJ_SUCCESS) |