Changeset 2038 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Jun 20, 2008 9:45:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2024 r2038 87 87 pjsua_conf_port_id wav_port; 88 88 pj_bool_t auto_play; 89 pj_bool_t auto_play_hangup; 90 pj_timer_entry auto_hangup_timer; 89 91 pj_bool_t auto_loop; 90 92 pj_bool_t auto_conf; … … 445 447 OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV, 446 448 OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 447 OPT_AUTO_ANSWER, OPT_AUTO_ HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP,449 OPT_AUTO_ANSWER, OPT_AUTO_PLAY, OPT_AUTO_PLAY_HANGUP, OPT_AUTO_LOOP, 448 450 OPT_AUTO_CONF, OPT_CLOCK_RATE, OPT_SND_CLOCK_RATE, OPT_STEREO, 449 451 OPT_USE_ICE, OPT_USE_SRTP, OPT_SRTP_SECURE, … … 502 504 { "no-presence", 0, 0, OPT_NO_PRESENCE}, 503 505 { "auto-answer",1, 0, OPT_AUTO_ANSWER}, 504 { "auto-hangup",1, 0, OPT_AUTO_HANGUP},505 506 { "auto-play", 0, 0, OPT_AUTO_PLAY}, 507 { "auto-play-hangup",0, 0, OPT_AUTO_PLAY_HANGUP}, 506 508 { "auto-rec", 0, 0, OPT_AUTO_REC}, 507 509 { "auto-loop", 0, 0, OPT_AUTO_LOOP}, … … 856 858 break; 857 859 860 case OPT_AUTO_PLAY_HANGUP: 861 cfg->auto_play_hangup = 1; 862 break; 863 858 864 case OPT_AUTO_REC: 859 865 cfg->auto_rec = 1; … … 1913 1919 pjsip_endpt_cancel_timer(endpt, &cd->timer); 1914 1920 } 1921 1922 /* Rewind play file when hangup automatically, 1923 * since file is not looped 1924 */ 1925 if (app_config.auto_play_hangup) 1926 pjsua_player_set_pos(app_config.wav_id, 0); 1927 1915 1928 1916 1929 PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]", … … 2117 2130 2118 2131 /* Stream a file, if desired */ 2119 if (app_config.auto_play && app_config.wav_port != PJSUA_INVALID_ID) { 2132 if ((app_config.auto_play || app_config.auto_play_hangup) && 2133 app_config.wav_port != PJSUA_INVALID_ID) 2134 { 2120 2135 pjsua_conf_connect(app_config.wav_port, call_info.conf_slot); 2121 2136 connect_sound = PJ_FALSE; … … 2388 2403 } 2389 2404 2405 /* Playfile done notification, set timer to hangup calls */ 2406 pj_status_t on_playfile_done(pjmedia_port *port, void *usr_data) 2407 { 2408 pj_time_val delay; 2409 2410 PJ_UNUSED_ARG(port); 2411 PJ_UNUSED_ARG(usr_data); 2412 2413 /* Just rewind WAV when it is played outside of call */ 2414 if (pjsua_call_get_count() == 0) { 2415 pjsua_player_set_pos(app_config.wav_id, 0); 2416 return PJ_SUCCESS; 2417 } 2418 2419 /* Timer is already active */ 2420 if (app_config.auto_hangup_timer.id == 1) 2421 return PJ_SUCCESS; 2422 2423 app_config.auto_hangup_timer.id = 1; 2424 delay.sec = 0; 2425 delay.msec = 200; /* Give 200 ms before hangup */ 2426 pjsip_endpt_schedule_timer(pjsua_get_pjsip_endpt(), 2427 &app_config.auto_hangup_timer, 2428 &delay); 2429 2430 return PJ_SUCCESS; 2431 } 2432 2433 /* Auto hangup timer callback */ 2434 static void hangup_timeout_callback(pj_timer_heap_t *timer_heap, 2435 struct pj_timer_entry *entry) 2436 { 2437 PJ_UNUSED_ARG(timer_heap); 2438 PJ_UNUSED_ARG(entry); 2439 2440 app_config.auto_hangup_timer.id = 0; 2441 pjsua_call_hangup_all(); 2442 } 2390 2443 2391 2444 /* … … 3761 3814 for (i=0; i<app_config.wav_count; ++i) { 3762 3815 pjsua_player_id wav_id; 3763 3764 status = pjsua_player_create(&app_config.wav_files[i], 0, 3816 unsigned play_options = 0; 3817 3818 if (app_config.auto_play_hangup) 3819 play_options |= PJMEDIA_FILE_NO_LOOP; 3820 3821 status = pjsua_player_create(&app_config.wav_files[i], play_options, 3765 3822 &wav_id); 3766 3823 if (status != PJ_SUCCESS) … … 3770 3827 app_config.wav_id = wav_id; 3771 3828 app_config.wav_port = pjsua_player_get_conf_port(app_config.wav_id); 3829 if (app_config.auto_play_hangup) { 3830 pjmedia_port *port; 3831 3832 pjsua_player_get_port(app_config.wav_id, &port); 3833 status = pjmedia_wav_player_set_eof_cb(port, NULL, 3834 &on_playfile_done); 3835 if (status != PJ_SUCCESS) 3836 goto on_error; 3837 3838 pj_timer_entry_init(&app_config.auto_hangup_timer, 0, NULL, 3839 &hangup_timeout_callback); 3840 } 3772 3841 } 3773 3842 }
Note: See TracChangeset
for help on using the changeset viewer.