This is the reference implementation for PJSIP and PJMEDIA. PJSUA is a console based application, designed to be simple enough to be readble, but powerful enough to demonstrate all features available in PJSIP and PJMEDIA.
21#define THIS_FILE "pjsua_app.c"
28#define RINGBACK_FREQ1 440
29#define RINGBACK_FREQ2 480
30#define RINGBACK_ON 2000
31#define RINGBACK_OFF 4000
33#define RINGBACK_INTERVAL 4000
40#define RING_INTERVAL 3000
42#define current_acc pjsua_acc_get_default()
45static void stereo_demo();
58static pjsua_app_cfg_t app_cfg;
71 if (app_config.no_tones)
74 if (app_config.call_data[call_id].ringback_on)
77 app_config.call_data[call_id].ringback_on =
PJ_TRUE;
79 if (++app_config.ringback_cnt==1 &&
80 app_config.ringback_slot!=PJSUA_INVALID_ID)
88 if (app_config.no_tones)
91 if (app_config.call_data[call_id].ringback_on) {
92 app_config.call_data[call_id].ringback_on =
PJ_FALSE;
95 if (--app_config.ringback_cnt == 0 &&
96 app_config.ringback_slot!=PJSUA_INVALID_ID)
103 if (app_config.call_data[call_id].ring_on) {
104 app_config.call_data[call_id].ring_on =
PJ_FALSE;
107 if (--app_config.ring_cnt == 0 &&
108 app_config.ring_slot!=PJSUA_INVALID_ID)
118 if (app_config.no_tones)
121 if (app_config.call_data[call_id].ring_on)
124 app_config.call_data[call_id].ring_on =
PJ_TRUE;
126 if (++app_config.ring_cnt==1 &&
127 app_config.ring_slot!=PJSUA_INVALID_ID)
147 if (call_id == PJSUA_INVALID_ID) {
148 PJ_LOG(1,(THIS_FILE,
"Invalid call ID in timer callback"));
158 PJ_LOG(3,(THIS_FILE,
"Duration (%d seconds) has been exceeded "
159 "for call %d, disconnecting the call",
160 app_config.duration, call_id));
161 entry->
id = PJSUA_INVALID_ID;
182 if (app_config.call_data[call_id].timer.id != PJSUA_INVALID_ID) {
183 app_call_data *cd = &app_config.call_data[call_id];
186 cd->timer.id = PJSUA_INVALID_ID;
193 if (app_config.auto_play_hangup)
197 PJ_LOG(3,(THIS_FILE,
"Call %d is DISCONNECTED [reason=%d (%.*s)]",
203 if (call_id == current_call) {
212 "Call %d disconnected, dumping media stats..",
214 log_call_dump(call_id);
219 if (app_config.duration != PJSUA_APP_NO_LIMIT_DURATION &&
223 app_call_data *cd = &app_config.call_data[call_id];
227 cd->timer.id = call_id;
228 delay.
sec = app_config.duration;
255 ringback_start(call_id);
258 PJ_LOG(3,(THIS_FILE,
"Call %d state changed to %.*s (%d %.*s)",
261 (
int)reason.
slen, reason.
ptr));
263 PJ_LOG(3,(THIS_FILE,
"Call %d state changed to %.*s",
269 if (current_call==PJSUA_INVALID_ID)
270 current_call = call_id;
279 pjmedia_stream *strm,
287 "Call %d stream %d destroyed, dumping media stats..",
288 call_id, stream_idx));
289 log_call_dump(call_id);
306 if (current_call==PJSUA_INVALID_ID)
307 current_call = call_id;
310 showNotification(call_id);
317 if (app_config.auto_answer > 0) {
321 opt.
aud_cnt = app_config.aud_cnt;
322 opt.
vid_cnt = app_config.vid.vid_cnt;
328 if (app_config.auto_answer < 200) {
329 char notif_st[80] = {0};
333 snprintf(notif_st,
sizeof(notif_st),
334 "To %s the video, type \"vid %s\" first, "
335 "before answering the call!\n",
336 (app_config.vid.vid_cnt?
"reject":
"accept"),
337 (app_config.vid.vid_cnt?
"disable":
"enable"));
342 "Incoming call for account %d!\n"
343 "Media count: %d audio & %d video\n"
347 "Press %s to answer or %s to reject call",
356 (app_config.use_cli?
"ca a":
"a"),
357 (app_config.use_cli?
"g":
"h")));
362static void on_call_generic_media_state(
pjsua_call_info *ci,
unsigned mi,
365 const char *status_name[] = {
378 PJ_LOG(4,(THIS_FILE,
"Call %d media %d [type=%s], status is %s",
405 if (call_conf_slot == PJSUA_INVALID_ID)
409 if (app_config.auto_loop) {
415 if (app_config.auto_rec && app_config.rec_port != PJSUA_INVALID_ID) {
420 if ((app_config.auto_play || app_config.auto_play_hangup) &&
421 app_config.wav_port != PJSUA_INVALID_ID)
428 if (app_config.avi_auto_play &&
429 app_config.avi_def_idx != PJSUA_INVALID_ID &&
430 app_config.avi[app_config.avi_def_idx].slot != PJSUA_INVALID_ID)
438 if (app_config.auto_conf) {
448 for (i=0; i<call_cnt; ++i) {
449 if (call_ids[i] == ci->
id)
461 if (app_config.auto_rec && app_config.rec_port !=
465 app_config.rec_port);
481 if (app_config.auto_rec && app_config.rec_port != PJSUA_INVALID_ID)
515 for (mi=0; mi<call_info.
media_cnt; ++mi) {
516 on_call_generic_media_state(&call_info, mi, &has_error);
520 on_call_audio_state(&call_info, mi, &has_error);
523 on_call_video_state(&call_info, mi, &has_error);
546 "Just rejected incoming video offer on call %d, "
547 "use \"vid call enable %d\" or \"vid call add\" to "
548 "enable video!", call_id, vid_idx));
574 pj_ansi_snprintf(method,
sizeof(method),
"RFC2833");
577 pj_ansi_snprintf(method,
sizeof(method),
"SIP INFO");
578 pj_ansi_snprintf(duration,
sizeof(duration),
":duration(%d)",
582 PJ_LOG(3,(THIS_FILE,
"Incoming DTMF on call %d: %c%s, using %s method",
583 call_id, info->
digit, duration, method));
602 pj_ansi_strcpy(uristr,
"--URI too long--");
605 PJ_LOG(3,(THIS_FILE,
"Call %d is being redirected to %.*s. "
606 "Press 'Ra' to accept+replace To header, 'RA' to accept, "
607 "'Rr' to reject, or 'Rd' to disconnect.",
608 call_id, len, uristr));
611 return app_config.redir_op;
656 PJ_LOG(3,(THIS_FILE,
"%.*s status is %.*s, subscription state is %s "
657 "(last termination reason code=%d %.*s)",
680 event_info[0] =
'\0';
686 snprintf(event_info,
sizeof(event_info),
692 "Buddy %d: subscription state: %s (event: %s%s)",
713 PJ_LOG(3,(THIS_FILE,
"MESSAGE from %.*s: %.*s (%.*s)",
716 (
int)mime_type->
slen, mime_type->
ptr));
731 PJ_LOG(3,(THIS_FILE,
"IM indication: %.*s %s",
733 (is_typing?
"is typing..":
"has stopped typing")));
746 PJ_LOG(3,(THIS_FILE,
"Call %d: transfer status=%d (%.*s) %s",
747 call_id, status_code,
748 (
int)status_text->
slen, status_text->
ptr,
749 (
final ?
"[final]" :
"")));
751 if (status_code/100 == 2) {
753 "Call %d: call transferred successfully, disconnecting call",
772 PJ_LOG(3,(THIS_FILE,
"Call %d with %.*s is being replaced by "
801 PJ_LOG(3,(THIS_FILE,
"Received MWI for acc %d:", acc_id));
806 PJ_LOG(3,(THIS_FILE,
" Content-Type: %.*s/%.*s",
814 PJ_LOG(3,(THIS_FILE,
" no message body"));
821 PJ_LOG(3,(THIS_FILE,
" Body:\n%.*s", (
int)body.
slen, body.
ptr));
839 PJ_LOG(3,(THIS_FILE,
"SIP %s transport is connected to %s",
849 len = pj_ansi_snprintf(buf,
sizeof(buf),
"SIP %s transport is "
850 "disconnected from %s", tp->
type_name, host_port);
860#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
870 const char *verif_msgs[32];
871 unsigned verif_msg_cnt;
874 PJ_LOG(4,(THIS_FILE,
"TLS cipher used: 0x%06X/%s",
875 ssl_sock_info->cipher,
881 PJ_LOG(4,(THIS_FILE,
"TLS cert info of %s:\n%s", host_port, buf));
886 verif_msgs, &verif_msg_cnt);
887 PJ_LOG(3,(THIS_FILE,
"TLS cert verification result of %s : %s",
889 (verif_msg_cnt == 1? verif_msgs[0]:
"")));
890 if (verif_msg_cnt > 1) {
892 for (i = 0; i < verif_msg_cnt; ++i)
893 PJ_LOG(3,(THIS_FILE,
"- %s", verif_msgs[i]));
896 if (ssl_sock_info->verify_status &&
897 !app_config.udp_cfg.tls_setting.verify_server)
899 PJ_LOG(3,(THIS_FILE,
"PJSUA is configured to ignore TLS cert "
900 "verification errors"));
917 "ICE keep alive failure for transport %d", index));
923static pj_status_t on_snd_dev_operation(
int operation)
925 int cap_dev, play_dev;
928 PJ_LOG(3,(THIS_FILE,
"Turning sound device %d %d %s", cap_dev, play_dev,
929 (operation?
"ON":
"OFF")));
942 return "unknown dir";
953 PJ_LOG(5,(THIS_FILE,
"Event %s",
959 err_data = &
event->data.med_tp_err;
961 "Media transport error event (%s %s %s)",
963 (err_data->
is_rtp)?
"RTP":
"RTCP",
964 get_media_dir(err_data->
dir)));
983 size =
event->data.fmt_changed.new_fmt.det.vid.size;
984 if (size.
w != win_info.
size.
w || size.
h != win_info.
size.
h) {
988 arrange_window(PJSUA_INVALID_ID);
998#ifdef TRANSPORT_ADAPTER_SAMPLE
1016 PJ_PERROR(1,(THIS_FILE, status,
"Error creating adapter"));
1020 PJ_LOG(3,(THIS_FILE,
"Media transport is created for call %d media %d",
1021 call_id, media_idx));
1028void on_playfile_done(
pjmedia_port *port,
void *usr_data)
1041 if (app_config.auto_hangup_timer.id == 1)
1044 app_config.auto_hangup_timer.id = 1;
1048 &app_config.auto_hangup_timer,
1065 pj_ansi_snprintf(info_str,
sizeof(info_str),
1066 "restart transport %.*s",
1072 pj_ansi_snprintf(info_str,
sizeof(info_str),
1073 "transport shutdown for account %.*s",
1080 pj_ansi_snprintf(info_str,
sizeof(info_str),
1081 "update contact for account %.*s, code[%d]",
1086 pj_ansi_snprintf(info_str,
sizeof(info_str),
1087 "update contact for account %.*s",
1094 pj_ansi_snprintf(info_str,
sizeof(info_str),
1095 "hangup call for account %.*s, call_id[%d]",
1101 pj_ansi_snprintf(info_str,
sizeof(info_str),
1102 "reinvite call for account %.*s, call_id[%d]",
1107 pj_ansi_snprintf(info_str,
sizeof(info_str),
1112 PJ_LOG(3,(THIS_FILE,
"IP change progress report : %s", info_str));
1115 PJ_PERROR(3,(THIS_FILE, status,
"IP change progress fail"));
1126 app_config.auto_hangup_timer.id = 0;
1143 rdata, 200, NULL, &tdata);
1148 PJSIP_H_EXPIRES, NULL);
1152 if (h->
type == PJSIP_H_CONTACT) {
1180 rdata, tdata, NULL, NULL);
1208 simple_registrar(rdata);
1217 status_code = PJSIP_SC_BAD_REQUEST;
1220 status_code = PJSIP_SC_METHOD_NOT_ALLOWED;
1226 pjsua_perror(THIS_FILE,
"Unable to create response", status);
1231 if (status_code == PJSIP_SC_METHOD_NOT_ALLOWED) {
1234 PJSIP_H_ALLOW, NULL);
1237 tdata->
pool, cap_hdr));
1245 const pj_str_t USER_AGENT = {
"User-Agent", 10};
1248 pj_ansi_snprintf(tmp,
sizeof(tmp),
"PJSUA v%s/%s",
1269 {
"mod-default-handler", 19 },
1276 &default_mod_on_rx_request,
1290 if (app_cfg.on_started) {
1293 cli_get_info(info,
sizeof(info));
1294 if (app_cfg.on_started) {
1295 (*app_cfg.on_started)(status, info);
1298 if (app_cfg.on_started) {
1299 (*app_cfg.on_started)(status, NULL);
1306void cli_on_stopped(
pj_bool_t restart,
int argc,
char* argv[])
1309 if (app_cfg.on_stopped)
1310 (*app_cfg.on_stopped)(restart, argc, argv);
1315void legacy_on_stopped(
pj_bool_t restart)
1318 if (app_cfg.on_stopped)
1319 (*app_cfg.on_stopped)(restart, 1, NULL);
1326int stdout_refresh_proc(
void *arg)
1328 extern char *stdout_refresh_text;
1338 while (!stdout_refresh_quit) {
1340 puts(stdout_refresh_text);
1370 app_config.cli_cfg.telnet_cfg.on_started = cli_on_started;
1374 status = load_config(app_cfg.argc, app_cfg.argv, &uri_arg);
1381 app_config.cfg.cb.on_call_state = &on_call_state;
1382 app_config.cfg.cb.on_stream_destroyed = &on_stream_destroyed;
1383 app_config.cfg.cb.on_call_media_state = &on_call_media_state;
1384 app_config.cfg.cb.on_incoming_call = &on_incoming_call;
1385 app_config.cfg.cb.on_dtmf_digit2 = &call_on_dtmf_callback2;
1386 app_config.cfg.cb.on_call_redirected = &call_on_redirected;
1387 app_config.cfg.cb.on_reg_state = &on_reg_state;
1388 app_config.cfg.cb.on_incoming_subscribe = &on_incoming_subscribe;
1389 app_config.cfg.cb.on_buddy_state = &on_buddy_state;
1390 app_config.cfg.cb.on_buddy_evsub_state = &on_buddy_evsub_state;
1391 app_config.cfg.cb.on_pager = &on_pager;
1392 app_config.cfg.cb.on_typing = &on_typing;
1393 app_config.cfg.cb.on_call_transfer_status = &on_call_transfer_status;
1394 app_config.cfg.cb.on_call_replaced = &on_call_replaced;
1395 app_config.cfg.cb.on_nat_detect = &on_nat_detect;
1396 app_config.cfg.cb.on_mwi_info = &on_mwi_info;
1397 app_config.cfg.cb.on_transport_state = &on_transport_state;
1398 app_config.cfg.cb.on_ice_transport_error = &on_ice_transport_error;
1399 app_config.cfg.cb.on_snd_dev_operation = &on_snd_dev_operation;
1400 app_config.cfg.cb.on_call_media_event = &on_call_media_event;
1401 app_config.cfg.cb.on_ip_change_progress = &on_ip_change_progress;
1402#ifdef TRANSPORT_ADAPTER_SAMPLE
1403 app_config.cfg.cb.on_create_media_transport = &on_create_media_transport;
1407 if (app_config.capture_lat > 0)
1408 app_config.media_cfg.snd_rec_latency = app_config.capture_lat;
1409 if (app_config.playback_lat)
1410 app_config.media_cfg.snd_play_latency = app_config.playback_lat;
1412 if (app_cfg.on_config_init)
1413 (*app_cfg.on_config_init)(&app_config);
1416 status =
pjsua_init(&app_config.cfg, &app_config.log_cfg,
1417 &app_config.media_cfg);
1425 &mod_default_handler);
1435 app_config.call_data[i].timer.id = PJSUA_INVALID_ID;
1436 app_config.call_data[i].timer.cb = &call_timeout_callback;
1440 for (i=0; i<app_config.wav_count; ++i) {
1442 unsigned play_options = 0;
1444 if (app_config.auto_play_hangup)
1452 if (app_config.wav_id == PJSUA_INVALID_ID) {
1453 app_config.wav_id = wav_id;
1455 if (app_config.auto_play_hangup) {
1465 &hangup_timeout_callback);
1471 for (i=0; i<app_config.tone_count; ++i) {
1477 pj_ansi_snprintf(name,
sizeof(name),
"tone-%d,%d",
1478 app_config.tones[i].freq1,
1479 app_config.tones[i].freq2);
1485 pjsua_perror(THIS_FILE,
"Unable to create tone generator", status);
1490 &app_config.tone_slots[i]);
1498 if (app_config.rec_file.slen) {
1500 &app_config.rec_id);
1507 pj_memcpy(&tcp_cfg, &app_config.udp_cfg,
sizeof(tcp_cfg));
1510 if (app_config.no_tones ==
PJ_FALSE) {
1511 unsigned samples_per_frame;
1515 samples_per_frame = app_config.media_cfg.audio_frame_ptime *
1516 app_config.media_cfg.clock_rate *
1517 app_config.media_cfg.channel_count / 1000;
1520 name =
pj_str(
"ringback");
1522 app_config.media_cfg.clock_rate,
1523 app_config.media_cfg.channel_count,
1526 &app_config.ringback_port);
1531 for (i=0; i<RINGBACK_CNT; ++i) {
1532 tone[i].
freq1 = RINGBACK_FREQ1;
1533 tone[i].
freq2 = RINGBACK_FREQ2;
1534 tone[i].
on_msec = RINGBACK_ON;
1537 tone[RINGBACK_CNT-1].
off_msec = RINGBACK_INTERVAL;
1544 &app_config.ringback_slot);
1551 app_config.media_cfg.clock_rate,
1552 app_config.media_cfg.channel_count,
1555 &app_config.ring_port);
1559 for (i=0; i<RING_CNT; ++i) {
1560 tone[i].
freq1 = RING_FREQ1;
1561 tone[i].
freq2 = RING_FREQ2;
1565 tone[RING_CNT-1].
off_msec = RING_INTERVAL;
1571 &app_config.ring_slot);
1578 if (app_config.avi_cnt) {
1579#if PJMEDIA_HAS_VIDEO && PJMEDIA_VIDEO_DEV_HAS_AVI
1586 PJ_PERROR(1,(THIS_FILE, status,
"Error creating AVI factory"));
1590 for (i=0; i<app_config.avi_cnt; ++i) {
1593 unsigned strm_idx, strm_cnt;
1596 app_config.avi[i].slot = PJSUA_INVALID_ID;
1599 avdp.
path = app_config.avi[i].path;
1604 "Error creating AVI player for %.*s",
1609 PJ_LOG(4,(THIS_FILE,
"AVI player %.*s created, dev_id=%d",
1612 app_config.avi[i].dev_id = avid;
1613 if (app_config.avi_def_idx == PJSUA_INVALID_ID)
1614 app_config.avi_def_idx = i;
1617 for (strm_idx=0; strm_idx<strm_cnt; ++strm_idx) {
1634 "AVI %.*s: audio added to slot %d",
1637 app_config.avi[i].slot = slot;
1641 "AVI %.*s: audio ignored, format=%s",
1649 "Warning: --play-avi is ignored because AVI is disabled"));
1654 if (!app_config.no_udp) {
1659 &app_config.udp_cfg,
1672 app_config_init_video(&acc_cfg);
1673 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1680 if (app_config.udp_cfg.port == 0) {
1692 if (!app_config.no_udp && app_config.ipv6) {
1697 udp_cfg = app_config.udp_cfg;
1698 if (udp_cfg.
port == 0)
1699 udp_cfg.
port = 5060;
1716 app_config_init_video(&acc_cfg);
1717 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1725 if (app_config.udp_cfg.port == 0) {
1734 if (!app_config.no_tcp) {
1751 app_config_init_video(&acc_cfg);
1752 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1761 if (!app_config.no_tcp && app_config.ipv6) {
1781 app_config_init_video(&acc_cfg);
1782 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1792#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
1794 if (app_config.use_tls) {
1820 app_config_init_video(&acc_cfg);
1821 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1829 if (app_config.use_tls && app_config.ipv6) {
1849 app_config_init_video(&acc_cfg);
1850 acc_cfg.
rtp_cfg = app_config.rtp_cfg;
1861 if (transport_id == -1) {
1862 PJ_LOG(1,(THIS_FILE,
"Error: no transport is configured"));
1869 for (i=0; i<app_config.acc_cnt; ++i) {
1870 app_config.acc_cfg[i].rtp_cfg = app_config.rtp_cfg;
1871 app_config.acc_cfg[i].reg_retry_interval = 300;
1872 app_config.acc_cfg[i].reg_first_retry_interval = 60;
1874 app_config_init_video(&app_config.acc_cfg[i]);
1883 for (i=0; i<app_config.buddy_cnt; ++i) {
1886 PJ_PERROR(1,(THIS_FILE, status,
"Error adding buddy"));
1892 for (i=0; i<app_config.codec_dis_cnt; ++i) {
1902 for (i=0; i<app_config.codec_cnt; ++i) {
1913 if (app_config.null_audio) {
1920 if (app_config.capture_dev != PJSUA_INVALID_ID ||
1921 app_config.playback_dev != PJSUA_INVALID_ID)
1924 app_config.playback_dev);
1931 call_opt.aud_cnt = app_config.aud_cnt;
1932 call_opt.vid_cnt = app_config.vid.vid_cnt;
1934#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
1944#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
1954pj_status_t pjsua_app_init(
const pjsua_app_cfg_t *cfg)
1957 pj_memcpy(&app_cfg, cfg,
sizeof(app_cfg));
1959 status = app_init();
1964 if (app_config.use_cli) {
1965 status = cli_init();
1976 if (stdout_refresh > 0) {
1978 NULL, 0, 0, &stdout_refresh_thread);
1985 if (app_config.use_cli && (app_config.cli_cfg.cli_fe & CLI_FE_TELNET)) {
1987 cli_get_info(info,
sizeof(info));
1988 if (app_cfg.on_started) {
1989 (*app_cfg.on_started)(status, info);
1992 if (app_cfg.on_started) {
1993 (*app_cfg.on_started)(status,
"Ready");
2000 call_opt.aud_cnt = app_config.aud_cnt;
2001 call_opt.vid_cnt = app_config.vid.vid_cnt;
2009 if (app_config.use_cli)
2010 cli_main(wait_telnet_cli);
2017 if (stdout_refresh_thread) {
2018 stdout_refresh_quit =
PJ_TRUE;
2035 if (app_config.snd) {
2037 app_config.snd = NULL;
2039 if (app_config.sc_ch1) {
2041 app_config.sc_ch1_slot = PJSUA_INVALID_ID;
2043 app_config.sc_ch1 = NULL;
2045 if (app_config.sc) {
2047 app_config.sc = NULL;
2052 for (i=0; i<app_config.avi_cnt; ++i) {
2053 if (app_config.avi[i].slot != PJSUA_INVALID_ID) {
2055 app_config.avi[i].slot = PJSUA_INVALID_ID;
2057#if PJMEDIA_HAS_VIDEO && PJMEDIA_VIDEO_DEV_HAS_AVI
2066 if (app_config.ringback_port &&
2067 app_config.ringback_slot != PJSUA_INVALID_ID)
2070 app_config.ringback_slot = PJSUA_INVALID_ID;
2072 app_config.ringback_port = NULL;
2076 if (app_config.ring_port && app_config.ring_slot != PJSUA_INVALID_ID) {
2078 app_config.ring_slot = PJSUA_INVALID_ID;
2080 app_config.ring_port = NULL;
2084 if (app_config.wav_id != PJSUA_INVALID_ID) {
2086 app_config.wav_id = PJSUA_INVALID_ID;
2087 app_config.wav_port = PJSUA_INVALID_ID;
2091 if (app_config.rec_id != PJSUA_INVALID_ID) {
2093 app_config.rec_id = PJSUA_INVALID_ID;
2094 app_config.rec_port = PJSUA_INVALID_ID;
2098 for (i=0; i<app_config.tone_count; ++i) {
2099 if (app_config.tone_slots[i] != PJSUA_INVALID_ID) {
2101 app_config.tone_slots[i] = PJSUA_INVALID_ID;
2105#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
2114 if (app_config.use_cli) {
2115 use_cli = app_config.use_cli;
2116 cli_fe = app_config.cli_cfg.cli_fe;
2117 cli_telnet_port = app_config.cli_cfg.telnet_cfg.port;
2121 pj_bzero(&app_config,
sizeof(app_config));
2122 app_config.wav_id = PJSUA_INVALID_ID;
2123 app_config.rec_id = PJSUA_INVALID_ID;
2126 app_config.use_cli = use_cli;
2127 app_config.cli_cfg.cli_fe = cli_fe;
2128 app_config.cli_cfg.telnet_cfg.port = cli_telnet_port;
2138 status = app_destroy();
2140 if (app_config.use_cli) {
2166static void stereo_demo()
2195 &app_config.sc_ch1);
2202 &app_config.sc_ch1_slot);
2211 0, &app_config.snd);
void pj_cli_console_cfg_default(pj_cli_console_cfg *param)
void pj_cli_telnet_cfg_default(pj_cli_telnet_cfg *param)
const char * pj_get_version(void)
void pj_cli_cfg_default(pj_cli_cfg *param)
pj_status_t pjmedia_snd_port_connect(pjmedia_snd_port *snd_port, pjmedia_port *port)
pj_status_t pjmedia_snd_port_create(pj_pool_t *pool, int rec_id, int play_id, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_snd_port **p_port)
pj_status_t pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port)
#define PJSIP_MAX_URL_SIZE
Definition: sip_config.h:354
pj_status_t pjsip_endpt_send_response2(pjsip_endpoint *endpt, pjsip_rx_data *rdata, pjsip_tx_data *tdata, void *token, pjsip_send_callback cb)
pj_status_t pjsip_endpt_create_response(pjsip_endpoint *endpt, const pjsip_rx_data *rdata, int st_code, const pj_str_t *st_text, pjsip_tx_data **p_tdata)
pjsip_redirect_op
Definition: sip_util.h:80
@ PJSIP_REDIRECT_PENDING
Definition: sip_util.h:104
pj_status_t pjsip_endpt_register_module(pjsip_endpoint *endpt, pjsip_module *module)
pj_status_t pjsip_endpt_schedule_timer(pjsip_endpoint *endpt, pj_timer_entry *entry, const pj_time_val *delay)
void pjsip_endpt_cancel_timer(pjsip_endpoint *endpt, pj_timer_entry *entry)
const pjsip_hdr * pjsip_endpt_get_capability(pjsip_endpoint *endpt, int htype, const pj_str_t *hname)
const char * pjsip_evsub_get_state_name(const pjsip_evsub *sub)
const pjsip_method pjsip_notify_method
Definition: evsub.h:219
struct pjsip_evsub pjsip_evsub
Definition: evsub.h:50
const char * pjsip_event_str(pjsip_event_id_e e)
@ PJSIP_EVENT_RX_MSG
Definition: sip_event.h:54
@ PJSIP_EVENT_TSX_STATE
Definition: sip_event.h:60
@ PJSIP_INV_STATE_EARLY
Definition: sip_inv.h:92
@ PJSIP_INV_STATE_DISCONNECTED
Definition: sip_inv.h:95
@ PJSIP_INV_STATE_CONFIRMED
Definition: sip_inv.h:94
@ PJSIP_MOD_PRIORITY_APPLICATION
Definition: sip_module.h:210
void pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *h, pj_str_t *hname, pj_str_t *hvalue)
pjsip_generic_string_hdr * pjsip_generic_string_hdr_create(pj_pool_t *pool, const pj_str_t *hname, const pj_str_t *hvalue)
void * pjsip_hdr_clone(pj_pool_t *pool, const void *hdr)
#define PJSIP_EXPIRES_NOT_SPECIFIED
Definition: sip_msg.h:1427
pjsip_status_code
Definition: sip_msg.h:456
int pjsip_method_cmp(const pjsip_method *m1, const pjsip_method *m2)
const pjsip_method pjsip_ack_method
Definition: sip_msg.h:94
const pjsip_method pjsip_register_method
Definition: sip_msg.h:100
void pjsip_msg_add_hdr(pjsip_msg *msg, pjsip_hdr *hdr)
Definition: sip_msg.h:980
void * pjsip_msg_find_hdr(const pjsip_msg *msg, pjsip_hdr_e type, const void *start)
void pjsip_tls_setting_wipe_keys(pjsip_tls_setting *opt)
pjsip_transport_state
Definition: sip_transport.h:1441
char * pjsip_rx_data_get_info(pjsip_rx_data *rdata)
pj_status_t pjsip_tx_data_dec_ref(pjsip_tx_data *tdata)
@ PJSIP_TP_STATE_CONNECTED
Definition: sip_transport.h:1442
@ PJSIP_TP_STATE_DISCONNECTED
Definition: sip_transport.h:1445
pjsip_transport_type_e
Definition: sip_types.h:62
struct pjsip_endpoint pjsip_endpoint
Definition: sip_types.h:111
@ PJSIP_ROLE_UAC
Definition: sip_types.h:190
@ PJSIP_TRANSPORT_TCP
Definition: sip_types.h:70
@ PJSIP_TRANSPORT_TLS
Definition: sip_types.h:73
@ PJSIP_TRANSPORT_TLS6
Definition: sip_types.h:100
@ PJSIP_TRANSPORT_UDP
Definition: sip_types.h:67
@ PJSIP_TRANSPORT_UDP6
Definition: sip_types.h:94
@ PJSIP_TRANSPORT_TCP6
Definition: sip_types.h:97
int pjsip_uri_print(pjsip_uri_context_e context, const void *uri, char *buf, pj_size_t size)
Definition: sip_uri.h:300
@ PJSIP_URI_IN_FROMTO_HDR
Definition: sip_uri.h:156
pj_status_t pjsua_acc_set_online_status(pjsua_acc_id acc_id, pj_bool_t is_online)
pj_status_t pjsua_acc_add_local(pjsua_transport_id tid, pj_bool_t is_default, pjsua_acc_id *p_acc_id)
pj_status_t pjsua_acc_modify(pjsua_acc_id acc_id, const pjsua_acc_config *acc_cfg)
pj_status_t pjsua_acc_add(const pjsua_acc_config *acc_cfg, pj_bool_t is_default, pjsua_acc_id *p_acc_id)
pj_status_t pjsua_acc_get_config(pjsua_acc_id acc_id, pj_pool_t *pool, pjsua_acc_config *acc_cfg)
pj_status_t pjsua_acc_get_info(pjsua_acc_id acc_id, pjsua_acc_info *info)
@ PJSUA_IPV6_ENABLED
Definition: pjsua-lib/pjsua.h:3681
int pjsua_acc_id
Definition: pjsua-lib/pjsua.h:265
int pjsua_player_id
Definition: pjsua-lib/pjsua.h:271
pjmedia_endpt * pjsua_get_pjmedia_endpt(void)
pj_status_t pjsua_create(void)
pj_pool_t * pjsua_pool_create(const char *name, pj_size_t init_size, pj_size_t increment)
void pjsua_perror(const char *sender, const char *title, pj_status_t status)
pjsua_ip_change_op
Definition: pjsua-lib/pjsua.h:834
pj_status_t pjsua_init(const pjsua_config *ua_cfg, const pjsua_logging_config *log_cfg, const pjsua_media_config *media_cfg)
pj_status_t pjsua_start(void)
int pjsua_buddy_id
Definition: pjsua-lib/pjsua.h:268
pj_pool_factory * pjsua_get_pool_factory(void)
pj_status_t pjsua_destroy(void)
pjsip_endpoint * pjsua_get_pjsip_endpt(void)
void pjsua_msg_data_init(pjsua_msg_data *msg_data)
int pjsua_call_id
Definition: pjsua-lib/pjsua.h:262
int pjsua_conf_port_id
Definition: pjsua-lib/pjsua.h:277
@ PJSUA_IP_CHANGE_OP_ACC_REINVITE_CALLS
Definition: pjsua-lib/pjsua.h:863
@ PJSUA_IP_CHANGE_OP_ACC_UPDATE_CONTACT
Definition: pjsua-lib/pjsua.h:853
@ PJSUA_IP_CHANGE_OP_ACC_HANGUP_CALLS
Definition: pjsua-lib/pjsua.h:858
@ PJSUA_IP_CHANGE_OP_RESTART_LIS
Definition: pjsua-lib/pjsua.h:843
@ PJSUA_IP_CHANGE_OP_ACC_SHUTDOWN_TP
Definition: pjsua-lib/pjsua.h:848
@ PJSUA_IP_CHANGE_OP_COMPLETED
Definition: pjsua-lib/pjsua.h:868
@ PJSUA_DTMF_METHOD_RFC2833
Definition: pjsua-lib/pjsua.h:925
@ PJSUA_DTMF_METHOD_SIP_INFO
Definition: pjsua-lib/pjsua.h:936
@ PJSUA_MED_TP_CLOSE_MEMBER
Definition: pjsua-lib/pjsua.h:747
pj_status_t pjsua_buddy_get_info(pjsua_buddy_id buddy_id, pjsua_buddy_info *info)
pj_status_t pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg, pjsua_buddy_id *p_buddy_id)
pj_status_t pjsua_call_get_info(pjsua_call_id call_id, pjsua_call_info *info)
#define PJSUA_MAX_CALLS
Definition: pjsua-lib/pjsua.h:4947
void pjsua_call_setting_default(pjsua_call_setting *opt)
int pjsua_vid_win_id
Definition: pjsua-lib/pjsua.h:4978
int pjsua_call_get_vid_stream_idx(pjsua_call_id call_id)
pj_status_t pjsua_call_make_call(pjsua_acc_id acc_id, const pj_str_t *dst_uri, const pjsua_call_setting *opt, void *user_data, const pjsua_msg_data *msg_data, pjsua_call_id *p_call_id)
pjsua_conf_port_id pjsua_call_get_conf_port(pjsua_call_id call_id)
unsigned pjsua_call_get_count(void)
pj_bool_t pjsua_call_has_media(pjsua_call_id call_id)
void pjsua_call_hangup_all(void)
pj_status_t pjsua_call_hangup(pjsua_call_id call_id, unsigned code, const pj_str_t *reason, const pjsua_msg_data *msg_data)
pj_status_t pjsua_call_answer2(pjsua_call_id call_id, const pjsua_call_setting *opt, unsigned code, const pj_str_t *reason, const pjsua_msg_data *msg_data)
pj_status_t pjsua_enum_calls(pjsua_call_id ids[], unsigned *count)
@ PJSUA_CALL_MEDIA_ERROR
Definition: pjsua-lib/pjsua.h:5010
@ PJSUA_CALL_MEDIA_REMOTE_HOLD
Definition: pjsua-lib/pjsua.h:5005
@ PJSUA_CALL_MEDIA_ACTIVE
Definition: pjsua-lib/pjsua.h:4995
@ PJSUA_CALL_MEDIA_NONE
Definition: pjsua-lib/pjsua.h:4990
pj_status_t pjsua_transport_create(pjsip_transport_type_e type, const pjsua_transport_config *cfg, pjsua_transport_id *p_id)
int pjsua_transport_id
Definition: pjsua-lib/pjsua.h:3011
pj_status_t pjsua_transport_get_info(pjsua_transport_id id, pjsua_transport_info *info)
pj_status_t pjsua_vid_win_set_size(pjsua_vid_win_id wid, const pjmedia_rect_size *size)
pj_status_t pjsua_vid_win_get_info(pjsua_vid_win_id wid, pjsua_vid_win_info *wi)
pj_status_t pjsua_vid_codec_set_priority(const pj_str_t *codec_id, pj_uint8_t priority)
unsigned short pj_uint16_t
struct pj_thread_t pj_thread_t
struct pj_timer_heap_t pj_timer_heap_t
void pj_list_push_back(pj_list_type *list, pj_list_type *node)
#define PJ_LOG(level, arg)
void pj_pool_safe_release(pj_pool_t **ppool)
void pj_pool_release(pj_pool_t *pool)
void * pj_memcpy(void *dst, const void *src, pj_size_t size)
pj_str_t pj_str(char *str)
#define PJ_CHECK_TRUNC_STR(ret, str, len)
pj_str_t * pj_strdup2_with_null(pj_pool_t *pool, pj_str_t *dst, const char *src)
void pj_bzero(void *dst, pj_size_t size)
pj_uint16_t pj_sockaddr_get_port(const pj_sockaddr_t *addr)
pj_uint16_t pj_ntohs(pj_uint16_t netshort)
char * pj_addr_str_print(const pj_str_t *host_str, int port, char *buf, int size, unsigned flag)
const char * pj_ssl_cipher_name(pj_ssl_cipher cipher)
pj_ssize_t pj_ssl_cert_info_dump(const pj_ssl_cert_info *ci, const char *indent, char *buf, pj_size_t buf_size)
pj_status_t pj_ssl_cert_get_verify_status_strings(pj_uint32_t verify_status, const char *error_strings[], unsigned *count)
int pj_thread_get_prio_min(pj_thread_t *thread)
pj_status_t pj_thread_destroy(pj_thread_t *thread)
pj_status_t pj_thread_join(pj_thread_t *thread)
pj_thread_t * pj_thread_this(void)
pj_status_t pj_thread_set_prio(pj_thread_t *thread, int prio)
pj_status_t pj_thread_create(pj_pool_t *pool, const char *thread_name, pj_thread_proc *proc, void *arg, pj_size_t stack_size, unsigned flags, pj_thread_t **thread)
pj_status_t pj_thread_sleep(unsigned msec)
pj_timer_entry * pj_timer_entry_init(pj_timer_entry *entry, int id, void *user_data, pj_timer_heap_callback *cb)
pj_status_t pjmedia_avi_dev_free(pjmedia_vid_dev_index id)
pj_status_t pjmedia_avi_dev_alloc(pjmedia_vid_dev_factory *f, pjmedia_avi_dev_param *param, pjmedia_vid_dev_index *p_id)
void pjmedia_avi_dev_param_default(pjmedia_avi_dev_param *p)
pj_status_t pjmedia_avi_dev_create_factory(pj_pool_factory *pf, unsigned max_dev, pjmedia_vid_dev_factory **p_ret)
#define PJ_UNUSED_ARG(arg)
#define PJ_PERROR(level, arg)
pj_int32_t pjmedia_vid_dev_index
const char * nat_type_name
Definition: sip_msg.h:1482
pjsip_media_type media
Definition: sip_msg.h:1484
Definition: sip_event.h:81
pjsip_rx_data * rdata
Definition: sip_event.h:107
pjsip_tx_data * tdata
Definition: sip_event.h:108
pjsip_event_id_e type
Definition: sip_event.h:87
struct pjsip_event::@11::@13 tsx_state
union pjsip_event::@11 body
Definition: sip_msg.h:1142
pj_uint32_t ivalue
Definition: sip_msg.h:1146
Definition: sip_msg.h:1070
pj_str_t name
Definition: sip_msg.h:1072
pj_str_t hvalue
Definition: sip_msg.h:1074
Definition: sip_msg.h:324
pjsip_hdr_e type
Definition: sip_msg.h:325
int port
Definition: sip_types.h:226
pj_str_t host
Definition: sip_types.h:225
Definition: sip_module.h:54
void * data
Definition: sip_msg.h:709
unsigned len
Definition: sip_msg.h:719
Definition: sip_msg.h:857
struct pjsip_request_line req
Definition: sip_msg.h:868
pjsip_msg_body * body
Definition: sip_msg.h:880
union pjsip_msg::@19 line
struct pjsip_status_line status
Definition: sip_msg.h:871
pjsip_hdr hdr
Definition: sip_msg.h:875
pjsip_method method
Definition: sip_msg.h:434
Definition: sip_transport.h:295
struct pjsip_rx_data::@26 msg_info
pjsip_msg * msg
Definition: sip_transport.h:364
pjsip_ctype_hdr * ctype
Definition: sip_transport.h:396
int code
Definition: sip_msg.h:444
pj_str_t reason
Definition: sip_msg.h:445
pj_qos_type qos_type
Definition: sip_transport_tls.h:335
pj_qos_params qos_params
Definition: sip_transport_tls.h:344
Definition: sip_transport_tls.h:400
pj_ssl_sock_info * ssl_sock_info
Definition: sip_transport_tls.h:404
Definition: sip_transport.h:1465
pj_status_t status
Definition: sip_transport.h:1469
void * ext_info
Definition: sip_transport.h:1474
Definition: sip_transport.h:806
char * type_name
Definition: sip_transport.h:821
pjsip_host_port remote_name
Definition: sip_transport.h:828
Definition: sip_transport.h:522
pj_pool_t * pool
Definition: sip_transport.h:527
pjsip_msg * msg
Definition: sip_transport.h:555
Definition: sip_uri.h:223
Definition: pjsua-lib/pjsua.h:3709
pjsua_transport_config rtp_cfg
Definition: pjsua-lib/pjsua.h:4155
pjsua_ipv6_use ipv6_media_use
Definition: pjsua-lib/pjsua.h:4167
Definition: pjsua-lib/pjsua.h:4501
pj_str_t acc_uri
Definition: pjsua-lib/pjsua.h:4515
Definition: pjsua-lib/pjsua.h:6294
unsigned sub_term_code
Definition: pjsua-lib/pjsua.h:6349
const char * sub_state_name
Definition: pjsua-lib/pjsua.h:6340
pj_str_t status_text
Definition: pjsua-lib/pjsua.h:6319
pj_str_t sub_term_reason
Definition: pjsua-lib/pjsua.h:6355
pj_str_t uri
Definition: pjsua-lib/pjsua.h:6303
Definition: pjsua-lib/pjsua.h:5097
unsigned rem_vid_cnt
Definition: pjsua-lib/pjsua.h:5187
pjsip_inv_state state
Definition: pjsua-lib/pjsua.h:5126
pjsua_call_media_info media[PJMEDIA_MAX_SDP_MEDIA]
Definition: pjsua-lib/pjsua.h:5161
pjsip_status_code last_status
Definition: pjsua-lib/pjsua.h:5132
pjsua_call_id id
Definition: pjsua-lib/pjsua.h:5099
pj_str_t last_status_text
Definition: pjsua-lib/pjsua.h:5135
unsigned rem_aud_cnt
Definition: pjsua-lib/pjsua.h:5184
pjsua_call_media_status media_status
Definition: pjsua-lib/pjsua.h:5145
pjsip_role_e role
Definition: pjsua-lib/pjsua.h:5102
pj_str_t state_text
Definition: pjsua-lib/pjsua.h:5129
unsigned media_cnt
Definition: pjsua-lib/pjsua.h:5158
pj_bool_t rem_offerer
Definition: pjsua-lib/pjsua.h:5181
pj_str_t local_info
Definition: pjsua-lib/pjsua.h:5108
pj_str_t remote_info
Definition: pjsua-lib/pjsua.h:5114
Definition: pjsua-lib/pjsua.h:1024
unsigned vid_cnt
Definition: pjsua-lib/pjsua.h:1055
unsigned aud_cnt
Definition: pjsua-lib/pjsua.h:1047
Definition: pjsua-lib/pjsua.h:951
unsigned duration
Definition: pjsua-lib/pjsua.h:966
pjsua_dtmf_method method
Definition: pjsua-lib/pjsua.h:955
unsigned digit
Definition: pjsua-lib/pjsua.h:960
Definition: pjsua-lib/pjsua.h:2396
pjsip_hdr hdr_list
Definition: pjsua-lib/pjsua.h:2411
Definition: pjsua-lib/pjsua.h:545
pjsip_rx_data * rdata
Definition: pjsua-lib/pjsua.h:548
Definition: pjsua_internal.h:251
Definition: pjsua-lib/pjsua.h:3021
pj_qos_type qos_type
Definition: pjsua-lib/pjsua.h:3092
pj_qos_params qos_params
Definition: pjsua-lib/pjsua.h:3101
unsigned port
Definition: pjsua-lib/pjsua.h:3028
pjsip_tls_setting tls_setting
Definition: pjsua-lib/pjsua.h:3083
Definition: pjsua-lib/pjsua.h:3139
pj_sockaddr local_addr
Definition: pjsua-lib/pjsua.h:3173
pj_str_t info
Definition: pjsua-lib/pjsua.h:3158
Definition: pjsua-lib/pjsua.h:8366
pjmedia_rect_size size
Definition: pjsua-lib/pjsua.h:8403
Definition: pjsua-lib/pjsua.h:876
int code
Definition: pjsua-lib/pjsua.h:897
struct pjsua_ip_change_op_info::@36 acc_reinvite_calls
struct pjsua_ip_change_op_info::@34 acc_update_contact
struct pjsua_ip_change_op_info::@35 acc_hangup_calls
struct pjsua_ip_change_op_info::@32 lis_restart
struct pjsua_ip_change_op_info::@33 acc_shutdown_tp