BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJSIP Reference

PJSUA

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.

This file is pjsip-apps/src/pjsua/pjsua_app.c

Screenshot on WinXP:

pjsua.jpg
pjsua on WinXP
1 /* $Id: pjsua_app.c 5534 2017-01-19 07:41:25Z nanang $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #include "pjsua_app.h"
21 
22 #define THIS_FILE "pjsua_app.c"
23 
24 //#define STEREO_DEMO
25 //#define TRANSPORT_ADAPTER_SAMPLE
26 //#define HAVE_MULTIPART_TEST
27 
28 /* Ringtones US UK */
29 #define RINGBACK_FREQ1 440 /* 400 */
30 #define RINGBACK_FREQ2 480 /* 450 */
31 #define RINGBACK_ON 2000 /* 400 */
32 #define RINGBACK_OFF 4000 /* 200 */
33 #define RINGBACK_CNT 1 /* 2 */
34 #define RINGBACK_INTERVAL 4000 /* 2000 */
35 
36 #define RING_FREQ1 800
37 #define RING_FREQ2 640
38 #define RING_ON 200
39 #define RING_OFF 100
40 #define RING_CNT 3
41 #define RING_INTERVAL 3000
42 
43 #define current_acc pjsua_acc_get_default()
44 
45 #ifdef STEREO_DEMO
46 static void stereo_demo();
47 #endif
48 
49 #ifdef USE_GUI
50 pj_bool_t showNotification(pjsua_call_id call_id);
51 #endif
52 
53 static void ringback_start(pjsua_call_id call_id);
54 static void ring_start(pjsua_call_id call_id);
55 static void ring_stop(pjsua_call_id call_id);
56 static pj_status_t app_init();
57 static pj_status_t app_destroy();
58 
59 static pjsua_app_cfg_t app_cfg;
60 pj_str_t uri_arg;
61 pj_bool_t app_running = PJ_FALSE;
62 
63 /*****************************************************************************
64  * Configuration manipulation
65  */
66 
67 /*****************************************************************************
68  * Callback
69  */
70 static void ringback_start(pjsua_call_id call_id)
71 {
72  if (app_config.no_tones)
73  return;
74 
75  if (app_config.call_data[call_id].ringback_on)
76  return;
77 
78  app_config.call_data[call_id].ringback_on = PJ_TRUE;
79 
80  if (++app_config.ringback_cnt==1 &&
81  app_config.ringback_slot!=PJSUA_INVALID_ID)
82  {
83  pjsua_conf_connect(app_config.ringback_slot, 0);
84  }
85 }
86 
87 static void ring_stop(pjsua_call_id call_id)
88 {
89  if (app_config.no_tones)
90  return;
91 
92  if (app_config.call_data[call_id].ringback_on) {
93  app_config.call_data[call_id].ringback_on = PJ_FALSE;
94 
95  pj_assert(app_config.ringback_cnt>0);
96  if (--app_config.ringback_cnt == 0 &&
97  app_config.ringback_slot!=PJSUA_INVALID_ID)
98  {
99  pjsua_conf_disconnect(app_config.ringback_slot, 0);
100  pjmedia_tonegen_rewind(app_config.ringback_port);
101  }
102  }
103 
104  if (app_config.call_data[call_id].ring_on) {
105  app_config.call_data[call_id].ring_on = PJ_FALSE;
106 
107  pj_assert(app_config.ring_cnt>0);
108  if (--app_config.ring_cnt == 0 &&
109  app_config.ring_slot!=PJSUA_INVALID_ID)
110  {
111  pjsua_conf_disconnect(app_config.ring_slot, 0);
112  pjmedia_tonegen_rewind(app_config.ring_port);
113  }
114  }
115 }
116 
117 static void ring_start(pjsua_call_id call_id)
118 {
119  if (app_config.no_tones)
120  return;
121 
122  if (app_config.call_data[call_id].ring_on)
123  return;
124 
125  app_config.call_data[call_id].ring_on = PJ_TRUE;
126 
127  if (++app_config.ring_cnt==1 &&
128  app_config.ring_slot!=PJSUA_INVALID_ID)
129  {
130  pjsua_conf_connect(app_config.ring_slot, 0);
131  }
132 }
133 
134 /* Callback from timer when the maximum call duration has been
135  * exceeded.
136  */
137 static void call_timeout_callback(pj_timer_heap_t *timer_heap,
138  struct pj_timer_entry *entry)
139 {
140  pjsua_call_id call_id = entry->id;
141  pjsua_msg_data msg_data_;
143  pj_str_t hname = pj_str("Warning");
144  pj_str_t hvalue = pj_str("399 pjsua \"Call duration exceeded\"");
145 
146  PJ_UNUSED_ARG(timer_heap);
147 
148  if (call_id == PJSUA_INVALID_ID) {
149  PJ_LOG(1,(THIS_FILE, "Invalid call ID in timer callback"));
150  return;
151  }
152 
153  /* Add warning header */
154  pjsua_msg_data_init(&msg_data_);
155  pjsip_generic_string_hdr_init2(&warn, &hname, &hvalue);
156  pj_list_push_back(&msg_data_.hdr_list, &warn);
157 
158  /* Call duration has been exceeded; disconnect the call */
159  PJ_LOG(3,(THIS_FILE, "Duration (%d seconds) has been exceeded "
160  "for call %d, disconnecting the call",
161  app_config.duration, call_id));
162  entry->id = PJSUA_INVALID_ID;
163  pjsua_call_hangup(call_id, 200, NULL, &msg_data_);
164 }
165 
166 /*
167  * Handler when invite state has changed.
168  */
169 static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
170 {
171  pjsua_call_info call_info;
172 
173  PJ_UNUSED_ARG(e);
174 
175  pjsua_call_get_info(call_id, &call_info);
176 
177  if (call_info.state == PJSIP_INV_STATE_DISCONNECTED) {
178 
179  /* Stop all ringback for this call */
180  ring_stop(call_id);
181 
182  /* Cancel duration timer, if any */
183  if (app_config.call_data[call_id].timer.id != PJSUA_INVALID_ID) {
184  app_call_data *cd = &app_config.call_data[call_id];
186 
187  cd->timer.id = PJSUA_INVALID_ID;
188  pjsip_endpt_cancel_timer(endpt, &cd->timer);
189  }
190 
191  /* Rewind play file when hangup automatically,
192  * since file is not looped
193  */
194  if (app_config.auto_play_hangup)
195  pjsua_player_set_pos(app_config.wav_id, 0);
196 
197 
198  PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]",
199  call_id,
200  call_info.last_status,
201  call_info.last_status_text.ptr));
202 
203  if (call_id == current_call) {
204  find_next_call();
205  }
206 
207  /* Dump media state upon disconnected */
208  if (1) {
209  PJ_LOG(5,(THIS_FILE,
210  "Call %d disconnected, dumping media stats..",
211  call_id));
212  log_call_dump(call_id);
213  }
214 
215  } else {
216 
217  if (app_config.duration != PJSUA_APP_NO_LIMIT_DURATION &&
218  call_info.state == PJSIP_INV_STATE_CONFIRMED)
219  {
220  /* Schedule timer to hangup call after the specified duration */
221  app_call_data *cd = &app_config.call_data[call_id];
223  pj_time_val delay;
224 
225  cd->timer.id = call_id;
226  delay.sec = app_config.duration;
227  delay.msec = 0;
228  pjsip_endpt_schedule_timer(endpt, &cd->timer, &delay);
229  }
230 
231  if (call_info.state == PJSIP_INV_STATE_EARLY) {
232  int code;
233  pj_str_t reason;
234  pjsip_msg *msg;
235 
236  /* This can only occur because of TX or RX message */
238 
239  if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {
240  msg = e->body.tsx_state.src.rdata->msg_info.msg;
241  } else {
242  msg = e->body.tsx_state.src.tdata->msg;
243  }
244 
245  code = msg->line.status.code;
246  reason = msg->line.status.reason;
247 
248  /* Start ringback for 180 for UAC unless there's SDP in 180 */
249  if (call_info.role==PJSIP_ROLE_UAC && code==180 &&
250  msg->body == NULL &&
252  {
253  ringback_start(call_id);
254  }
255 
256  PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s (%d %.*s)",
257  call_id, call_info.state_text.ptr,
258  code, (int)reason.slen, reason.ptr));
259  } else {
260  PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s",
261  call_id,
262  call_info.state_text.ptr));
263  }
264 
265  if (current_call==PJSUA_INVALID_ID)
266  current_call = call_id;
267 
268  }
269 }
270 
274 static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
275  pjsip_rx_data *rdata)
276 {
277  pjsua_call_info call_info;
278 
279  PJ_UNUSED_ARG(acc_id);
280  PJ_UNUSED_ARG(rdata);
281 
282  pjsua_call_get_info(call_id, &call_info);
283 
284  if (current_call==PJSUA_INVALID_ID)
285  current_call = call_id;
286 
287 #ifdef USE_GUI
288  if (!showNotification(call_id))
289  return;
290 #endif
291 
292  /* Start ringback */
293  ring_start(call_id);
294 
295  if (app_config.auto_answer > 0) {
296  pjsua_call_setting opt;
297 
299  opt.aud_cnt = app_config.aud_cnt;
300  opt.vid_cnt = app_config.vid.vid_cnt;
301 
302  pjsua_call_answer2(call_id, &opt, app_config.auto_answer, NULL,
303  NULL);
304  }
305 
306  if (app_config.auto_answer < 200) {
307  char notif_st[80] = {0};
308 
309 #if PJSUA_HAS_VIDEO
310  if (call_info.rem_offerer && call_info.rem_vid_cnt) {
311  snprintf(notif_st, sizeof(notif_st),
312  "To %s the video, type \"vid %s\" first, "
313  "before answering the call!\n",
314  (app_config.vid.vid_cnt? "reject":"accept"),
315  (app_config.vid.vid_cnt? "disable":"enable"));
316  }
317 #endif
318 
319  PJ_LOG(3,(THIS_FILE,
320  "Incoming call for account %d!\n"
321  "Media count: %d audio & %d video\n"
322  "%s"
323  "From: %s\n"
324  "To: %s\n"
325  "Press %s to answer or %s to reject call",
326  acc_id,
327  call_info.rem_aud_cnt,
328  call_info.rem_vid_cnt,
329  notif_st,
330  call_info.remote_info.ptr,
331  call_info.local_info.ptr,
332  (app_config.use_cli?"ca a":"a"),
333  (app_config.use_cli?"g":"h")));
334  }
335 }
336 
337 /*
338  * Handler when a transaction within a call has changed state.
339  */
340 static void on_call_tsx_state(pjsua_call_id call_id,
341  pjsip_transaction *tsx,
342  pjsip_event *e)
343 {
344  const pjsip_method info_method =
345  {
347  { "INFO", 4 }
348  };
349 
350  if (pjsip_method_cmp(&tsx->method, &info_method)==0) {
351  /*
352  * Handle INFO method.
353  */
354  const pj_str_t STR_APPLICATION = { "application", 11};
355  const pj_str_t STR_DTMF_RELAY = { "dtmf-relay", 10 };
356  pjsip_msg_body *body = NULL;
357  pj_bool_t dtmf_info = PJ_FALSE;
358 
359  if (tsx->role == PJSIP_ROLE_UAC) {
360  if (e->body.tsx_state.type == PJSIP_EVENT_TX_MSG)
361  body = e->body.tsx_state.src.tdata->msg->body;
362  else
363  body = e->body.tsx_state.tsx->last_tx->msg->body;
364  } else {
365  if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
366  body = e->body.tsx_state.src.rdata->msg_info.msg->body;
367  }
368 
369  /* Check DTMF content in the INFO message */
370  if (body && body->len &&
371  pj_stricmp(&body->content_type.type, &STR_APPLICATION)==0 &&
372  pj_stricmp(&body->content_type.subtype, &STR_DTMF_RELAY)==0)
373  {
374  dtmf_info = PJ_TRUE;
375  }
376 
377  if (dtmf_info && tsx->role == PJSIP_ROLE_UAC &&
378  (tsx->state == PJSIP_TSX_STATE_COMPLETED ||
380  e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED)))
381  {
382  /* Status of outgoing INFO request */
383  if (tsx->status_code >= 200 && tsx->status_code < 300) {
384  PJ_LOG(4,(THIS_FILE,
385  "Call %d: DTMF sent successfully with INFO",
386  call_id));
387  } else if (tsx->status_code >= 300) {
388  PJ_LOG(4,(THIS_FILE,
389  "Call %d: Failed to send DTMF with INFO: %d/%.*s",
390  call_id,
391  tsx->status_code,
392  (int)tsx->status_text.slen,
393  tsx->status_text.ptr));
394  }
395  } else if (dtmf_info && tsx->role == PJSIP_ROLE_UAS &&
397  {
398  /* Answer incoming INFO with 200/OK */
399  pjsip_rx_data *rdata;
400  pjsip_tx_data *tdata;
401  pj_status_t status;
402 
403  rdata = e->body.tsx_state.src.rdata;
404 
405  if (rdata->msg_info.msg->body) {
406  status = pjsip_endpt_create_response(tsx->endpt, rdata,
407  200, NULL, &tdata);
408  if (status == PJ_SUCCESS)
409  status = pjsip_tsx_send_msg(tsx, tdata);
410 
411  PJ_LOG(3,(THIS_FILE, "Call %d: incoming INFO:\n%.*s",
412  call_id,
413  (int)rdata->msg_info.msg->body->len,
414  rdata->msg_info.msg->body->data));
415  } else {
416  status = pjsip_endpt_create_response(tsx->endpt, rdata,
417  400, NULL, &tdata);
418  if (status == PJ_SUCCESS)
419  status = pjsip_tsx_send_msg(tsx, tdata);
420  }
421  }
422  }
423 }
424 
425 /* General processing for media state. "mi" is the media index */
426 static void on_call_generic_media_state(pjsua_call_info *ci, unsigned mi,
427  pj_bool_t *has_error)
428 {
429  const char *status_name[] = {
430  "None",
431  "Active",
432  "Local hold",
433  "Remote hold",
434  "Error"
435  };
436 
437  PJ_UNUSED_ARG(has_error);
438 
439  pj_assert(ci->media[mi].status <= PJ_ARRAY_SIZE(status_name));
441 
442  PJ_LOG(4,(THIS_FILE, "Call %d media %d [type=%s], status is %s",
443  ci->id, mi, pjmedia_type_name(ci->media[mi].type),
444  status_name[ci->media[mi].status]));
445 }
446 
447 /* Process audio media state. "mi" is the media index. */
448 static void on_call_audio_state(pjsua_call_info *ci, unsigned mi,
449  pj_bool_t *has_error)
450 {
451  PJ_UNUSED_ARG(has_error);
452 
453  /* Stop ringback */
454  ring_stop(ci->id);
455 
456  /* Connect ports appropriately when media status is ACTIVE or REMOTE HOLD,
457  * otherwise we should NOT connect the ports.
458  */
459  if (ci->media[mi].status == PJSUA_CALL_MEDIA_ACTIVE ||
461  {
462  pj_bool_t connect_sound = PJ_TRUE;
463  pj_bool_t disconnect_mic = PJ_FALSE;
464  pjsua_conf_port_id call_conf_slot;
465 
466  call_conf_slot = ci->media[mi].stream.aud.conf_slot;
467 
468  /* Loopback sound, if desired */
469  if (app_config.auto_loop) {
470  pjsua_conf_connect(call_conf_slot, call_conf_slot);
471  connect_sound = PJ_FALSE;
472  }
473 
474  /* Automatically record conversation, if desired */
475  if (app_config.auto_rec && app_config.rec_port != PJSUA_INVALID_ID) {
476  pjsua_conf_connect(call_conf_slot, app_config.rec_port);
477  }
478 
479  /* Stream a file, if desired */
480  if ((app_config.auto_play || app_config.auto_play_hangup) &&
481  app_config.wav_port != PJSUA_INVALID_ID)
482  {
483  pjsua_conf_connect(app_config.wav_port, call_conf_slot);
484  connect_sound = PJ_FALSE;
485  }
486 
487  /* Stream AVI, if desired */
488  if (app_config.avi_auto_play &&
489  app_config.avi_def_idx != PJSUA_INVALID_ID &&
490  app_config.avi[app_config.avi_def_idx].slot != PJSUA_INVALID_ID)
491  {
492  pjsua_conf_connect(app_config.avi[app_config.avi_def_idx].slot,
493  call_conf_slot);
494  disconnect_mic = PJ_TRUE;
495  }
496 
497  /* Put call in conference with other calls, if desired */
498  if (app_config.auto_conf) {
499  pjsua_call_id call_ids[PJSUA_MAX_CALLS];
500  unsigned call_cnt=PJ_ARRAY_SIZE(call_ids);
501  unsigned i;
502 
503  /* Get all calls, and establish media connection between
504  * this call and other calls.
505  */
506  pjsua_enum_calls(call_ids, &call_cnt);
507 
508  for (i=0; i<call_cnt; ++i) {
509  if (call_ids[i] == ci->id)
510  continue;
511 
512  if (!pjsua_call_has_media(call_ids[i]))
513  continue;
514 
515  pjsua_conf_connect(call_conf_slot,
516  pjsua_call_get_conf_port(call_ids[i]));
518  call_conf_slot);
519 
520  /* Automatically record conversation, if desired */
521  if (app_config.auto_rec && app_config.rec_port !=
522  PJSUA_INVALID_ID)
523  {
525  app_config.rec_port);
526  }
527 
528  }
529 
530  /* Also connect call to local sound device */
531  connect_sound = PJ_TRUE;
532  }
533 
534  /* Otherwise connect to sound device */
535  if (connect_sound) {
536  pjsua_conf_connect(call_conf_slot, 0);
537  if (!disconnect_mic)
538  pjsua_conf_connect(0, call_conf_slot);
539 
540  /* Automatically record conversation, if desired */
541  if (app_config.auto_rec && app_config.rec_port != PJSUA_INVALID_ID)
542  {
543  pjsua_conf_connect(call_conf_slot, app_config.rec_port);
544  pjsua_conf_connect(0, app_config.rec_port);
545  }
546  }
547  }
548 }
549 
550 /* Process video media state. "mi" is the media index. */
551 static void on_call_video_state(pjsua_call_info *ci, unsigned mi,
552  pj_bool_t *has_error)
553 {
555  return;
556 
557  arrange_window(ci->media[mi].stream.vid.win_in);
558 
559  PJ_UNUSED_ARG(has_error);
560 }
561 
562 /*
563  * Callback on media state changed event.
564  * The action may connect the call to sound device, to file, or
565  * to loop the call.
566  */
567 static void on_call_media_state(pjsua_call_id call_id)
568 {
569  pjsua_call_info call_info;
570  unsigned mi;
571  pj_bool_t has_error = PJ_FALSE;
572 
573  pjsua_call_get_info(call_id, &call_info);
574 
575  for (mi=0; mi<call_info.media_cnt; ++mi) {
576  on_call_generic_media_state(&call_info, mi, &has_error);
577 
578  switch (call_info.media[mi].type) {
579  case PJMEDIA_TYPE_AUDIO:
580  on_call_audio_state(&call_info, mi, &has_error);
581  break;
582  case PJMEDIA_TYPE_VIDEO:
583  on_call_video_state(&call_info, mi, &has_error);
584  break;
585  default:
586  /* Make gcc happy about enum not handled by switch/case */
587  break;
588  }
589  }
590 
591  if (has_error) {
592  pj_str_t reason = pj_str("Media failed");
593  pjsua_call_hangup(call_id, 500, &reason, NULL);
594  }
595 
596 #if PJSUA_HAS_VIDEO
597  /* Check if remote has just tried to enable video */
598  if (call_info.rem_offerer && call_info.rem_vid_cnt)
599  {
600  int vid_idx;
601 
602  /* Check if there is active video */
603  vid_idx = pjsua_call_get_vid_stream_idx(call_id);
604  if (vid_idx == -1 || call_info.media[vid_idx].dir == PJMEDIA_DIR_NONE) {
605  PJ_LOG(3,(THIS_FILE,
606  "Just rejected incoming video offer on call %d, "
607  "use \"vid call enable %d\" or \"vid call add\" to "
608  "enable video!", call_id, vid_idx));
609  }
610  }
611 #endif
612 }
613 
614 /*
615  * DTMF callback.
616  */
617 static void call_on_dtmf_callback(pjsua_call_id call_id, int dtmf)
618 {
619  PJ_LOG(3,(THIS_FILE, "Incoming DTMF on call %d: %c", call_id, dtmf));
620 }
621 
622 /*
623  * Redirection handler.
624  */
625 static pjsip_redirect_op call_on_redirected(pjsua_call_id call_id,
626  const pjsip_uri *target,
627  const pjsip_event *e)
628 {
629  PJ_UNUSED_ARG(e);
630 
631  if (app_config.redir_op == PJSIP_REDIRECT_PENDING) {
632  char uristr[PJSIP_MAX_URL_SIZE];
633  int len;
634 
635  len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, target, uristr,
636  sizeof(uristr));
637  if (len < 1) {
638  pj_ansi_strcpy(uristr, "--URI too long--");
639  }
640 
641  PJ_LOG(3,(THIS_FILE, "Call %d is being redirected to %.*s. "
642  "Press 'Ra' to accept+replace To header, 'RA' to accept, "
643  "'Rr' to reject, or 'Rd' to disconnect.",
644  call_id, len, uristr));
645  }
646 
647  return app_config.redir_op;
648 }
649 
650 /*
651  * Handler registration status has changed.
652  */
653 static void on_reg_state(pjsua_acc_id acc_id)
654 {
655  PJ_UNUSED_ARG(acc_id);
656 
657  // Log already written.
658 }
659 
660 /*
661  * Handler for incoming presence subscription request
662  */
663 static void on_incoming_subscribe(pjsua_acc_id acc_id,
664  pjsua_srv_pres *srv_pres,
665  pjsua_buddy_id buddy_id,
666  const pj_str_t *from,
667  pjsip_rx_data *rdata,
668  pjsip_status_code *code,
669  pj_str_t *reason,
670  pjsua_msg_data *msg_data_)
671 {
672  /* Just accept the request (the default behavior) */
673  PJ_UNUSED_ARG(acc_id);
674  PJ_UNUSED_ARG(srv_pres);
675  PJ_UNUSED_ARG(buddy_id);
676  PJ_UNUSED_ARG(from);
677  PJ_UNUSED_ARG(rdata);
678  PJ_UNUSED_ARG(code);
679  PJ_UNUSED_ARG(reason);
680  PJ_UNUSED_ARG(msg_data_);
681 }
682 
683 
684 /*
685  * Handler on buddy state changed.
686  */
687 static void on_buddy_state(pjsua_buddy_id buddy_id)
688 {
690  pjsua_buddy_get_info(buddy_id, &info);
691 
692  PJ_LOG(3,(THIS_FILE, "%.*s status is %.*s, subscription state is %s "
693  "(last termination reason code=%d %.*s)",
694  (int)info.uri.slen,
695  info.uri.ptr,
696  (int)info.status_text.slen,
697  info.status_text.ptr,
698  info.sub_state_name,
699  info.sub_term_code,
700  (int)info.sub_term_reason.slen,
701  info.sub_term_reason.ptr));
702 }
703 
704 
705 /*
706  * Subscription state has changed.
707  */
708 static void on_buddy_evsub_state(pjsua_buddy_id buddy_id,
709  pjsip_evsub *sub,
710  pjsip_event *event)
711 {
712  char event_info[80];
713 
714  PJ_UNUSED_ARG(sub);
715 
716  event_info[0] = '\0';
717 
718  if (event->type == PJSIP_EVENT_TSX_STATE &&
719  event->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
720  {
721  pjsip_rx_data *rdata = event->body.tsx_state.src.rdata;
722  snprintf(event_info, sizeof(event_info),
723  " (RX %s)",
724  pjsip_rx_data_get_info(rdata));
725  }
726 
727  PJ_LOG(4,(THIS_FILE,
728  "Buddy %d: subscription state: %s (event: %s%s)",
729  buddy_id, pjsip_evsub_get_state_name(sub),
730  pjsip_event_str(event->type),
731  event_info));
732 
733 }
734 
735 
739 static void on_pager(pjsua_call_id call_id, const pj_str_t *from,
740  const pj_str_t *to, const pj_str_t *contact,
741  const pj_str_t *mime_type, const pj_str_t *text)
742 {
743  /* Note: call index may be -1 */
744  PJ_UNUSED_ARG(call_id);
745  PJ_UNUSED_ARG(to);
746  PJ_UNUSED_ARG(contact);
747  PJ_UNUSED_ARG(mime_type);
748 
749  PJ_LOG(3,(THIS_FILE,"MESSAGE from %.*s: %.*s (%.*s)",
750  (int)from->slen, from->ptr,
751  (int)text->slen, text->ptr,
752  (int)mime_type->slen, mime_type->ptr));
753 }
754 
755 
759 static void on_typing(pjsua_call_id call_id, const pj_str_t *from,
760  const pj_str_t *to, const pj_str_t *contact,
761  pj_bool_t is_typing)
762 {
763  PJ_UNUSED_ARG(call_id);
764  PJ_UNUSED_ARG(to);
765  PJ_UNUSED_ARG(contact);
766 
767  PJ_LOG(3,(THIS_FILE, "IM indication: %.*s %s",
768  (int)from->slen, from->ptr,
769  (is_typing?"is typing..":"has stopped typing")));
770 }
771 
772 
776 static void on_call_transfer_status(pjsua_call_id call_id,
777  int status_code,
778  const pj_str_t *status_text,
779  pj_bool_t final,
780  pj_bool_t *p_cont)
781 {
782  PJ_LOG(3,(THIS_FILE, "Call %d: transfer status=%d (%.*s) %s",
783  call_id, status_code,
784  (int)status_text->slen, status_text->ptr,
785  (final ? "[final]" : "")));
786 
787  if (status_code/100 == 2) {
788  PJ_LOG(3,(THIS_FILE,
789  "Call %d: call transferred successfully, disconnecting call",
790  call_id));
791  pjsua_call_hangup(call_id, PJSIP_SC_GONE, NULL, NULL);
792  *p_cont = PJ_FALSE;
793  }
794 }
795 
796 
797 /*
798  * Notification that call is being replaced.
799  */
800 static void on_call_replaced(pjsua_call_id old_call_id,
801  pjsua_call_id new_call_id)
802 {
803  pjsua_call_info old_ci, new_ci;
804 
805  pjsua_call_get_info(old_call_id, &old_ci);
806  pjsua_call_get_info(new_call_id, &new_ci);
807 
808  PJ_LOG(3,(THIS_FILE, "Call %d with %.*s is being replaced by "
809  "call %d with %.*s",
810  old_call_id,
811  (int)old_ci.remote_info.slen, old_ci.remote_info.ptr,
812  new_call_id,
813  (int)new_ci.remote_info.slen, new_ci.remote_info.ptr));
814 }
815 
816 
817 /*
818  * NAT type detection callback.
819  */
820 static void on_nat_detect(const pj_stun_nat_detect_result *res)
821 {
822  if (res->status != PJ_SUCCESS) {
823  pjsua_perror(THIS_FILE, "NAT detection failed", res->status);
824  } else {
825  PJ_LOG(3, (THIS_FILE, "NAT detected as %s", res->nat_type_name));
826  }
827 }
828 
829 
830 /*
831  * MWI indication
832  */
833 static void on_mwi_info(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info)
834 {
835  pj_str_t body;
836 
837  PJ_LOG(3,(THIS_FILE, "Received MWI for acc %d:", acc_id));
838 
839  if (mwi_info->rdata->msg_info.ctype) {
840  const pjsip_ctype_hdr *ctype = mwi_info->rdata->msg_info.ctype;
841 
842  PJ_LOG(3,(THIS_FILE, " Content-Type: %.*s/%.*s",
843  (int)ctype->media.type.slen,
844  ctype->media.type.ptr,
845  (int)ctype->media.subtype.slen,
846  ctype->media.subtype.ptr));
847  }
848 
849  if (!mwi_info->rdata->msg_info.msg->body) {
850  PJ_LOG(3,(THIS_FILE, " no message body"));
851  return;
852  }
853 
854  body.ptr = (char *)mwi_info->rdata->msg_info.msg->body->data;
855  body.slen = mwi_info->rdata->msg_info.msg->body->len;
856 
857  PJ_LOG(3,(THIS_FILE, " Body:\n%.*s", (int)body.slen, body.ptr));
858 }
859 
860 
861 /*
862  * Transport status notification
863  */
864 static void on_transport_state(pjsip_transport *tp,
865  pjsip_transport_state state,
866  const pjsip_transport_state_info *info)
867 {
868  char host_port[128];
869 
870  pj_ansi_snprintf(host_port, sizeof(host_port), "[%.*s:%d]",
871  (int)tp->remote_name.host.slen,
872  tp->remote_name.host.ptr,
873  tp->remote_name.port);
874 
875  switch (state) {
877  {
878  PJ_LOG(3,(THIS_FILE, "SIP %s transport is connected to %s",
879  tp->type_name, host_port));
880  }
881  break;
882 
884  {
885  char buf[100];
886 
887  snprintf(buf, sizeof(buf), "SIP %s transport is disconnected "
888  "from %s", tp->type_name, host_port);
889  pjsua_perror(THIS_FILE, buf, info->status);
890  }
891  break;
892 
893  default:
894  break;
895  }
896 
897 #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
898 
899  if (!pj_ansi_stricmp(tp->type_name, "tls") && info->ext_info &&
900  (state == PJSIP_TP_STATE_CONNECTED ||
901  ((pjsip_tls_state_info*)info->ext_info)->
902  ssl_sock_info->verify_status != PJ_SUCCESS))
903  {
905  pj_ssl_sock_info *ssl_sock_info = tls_info->ssl_sock_info;
906  char buf[2048];
907  const char *verif_msgs[32];
908  unsigned verif_msg_cnt;
909 
910  /* Dump server TLS cipher */
911  PJ_LOG(4,(THIS_FILE, "TLS cipher used: 0x%06X/%s",
912  ssl_sock_info->cipher,
913  pj_ssl_cipher_name(ssl_sock_info->cipher) ));
914 
915  /* Dump server TLS certificate */
916  pj_ssl_cert_info_dump(ssl_sock_info->remote_cert_info, " ",
917  buf, sizeof(buf));
918  PJ_LOG(4,(THIS_FILE, "TLS cert info of %s:\n%s", host_port, buf));
919 
920  /* Dump server TLS certificate verification result */
921  verif_msg_cnt = PJ_ARRAY_SIZE(verif_msgs);
922  pj_ssl_cert_get_verify_status_strings(ssl_sock_info->verify_status,
923  verif_msgs, &verif_msg_cnt);
924  PJ_LOG(3,(THIS_FILE, "TLS cert verification result of %s : %s",
925  host_port,
926  (verif_msg_cnt == 1? verif_msgs[0]:"")));
927  if (verif_msg_cnt > 1) {
928  unsigned i;
929  for (i = 0; i < verif_msg_cnt; ++i)
930  PJ_LOG(3,(THIS_FILE, "- %s", verif_msgs[i]));
931  }
932 
933  if (ssl_sock_info->verify_status &&
934  !app_config.udp_cfg.tls_setting.verify_server)
935  {
936  PJ_LOG(3,(THIS_FILE, "PJSUA is configured to ignore TLS cert "
937  "verification errors"));
938  }
939  }
940 
941 #endif
942 
943 }
944 
945 /*
946  * Notification on ICE error.
947  */
948 static void on_ice_transport_error(int index, pj_ice_strans_op op,
949  pj_status_t status, void *param)
950 {
951  PJ_UNUSED_ARG(op);
952  PJ_UNUSED_ARG(param);
953  PJ_PERROR(1,(THIS_FILE, status,
954  "ICE keep alive failure for transport %d", index));
955 }
956 
957 /*
958  * Notification on sound device operation.
959  */
960 static pj_status_t on_snd_dev_operation(int operation)
961 {
962  PJ_LOG(3,(THIS_FILE, "Turning sound device %s", (operation? "ON":"OFF")));
963  return PJ_SUCCESS;
964 }
965 
966 /* Callback on media events */
967 static void on_call_media_event(pjsua_call_id call_id,
968  unsigned med_idx,
969  pjmedia_event *event)
970 {
971  char event_name[5];
972 
973  PJ_LOG(5,(THIS_FILE, "Event %s",
974  pjmedia_fourcc_name(event->type, event_name)));
975 
976 #if PJSUA_HAS_VIDEO
977  if (event->type == PJMEDIA_EVENT_FMT_CHANGED) {
978  /* Adjust renderer window size to original video size */
979  pjsua_call_info ci;
980 
981  pjsua_call_get_info(call_id, &ci);
982 
983  if ((ci.media[med_idx].type == PJMEDIA_TYPE_VIDEO) &&
984  (ci.media[med_idx].dir & PJMEDIA_DIR_DECODING))
985  {
986  pjsua_vid_win_id wid;
987  pjmedia_rect_size size;
988  pjsua_vid_win_info win_info;
989 
990  wid = ci.media[med_idx].stream.vid.win_in;
991  pjsua_vid_win_get_info(wid, &win_info);
992 
993  size = event->data.fmt_changed.new_fmt.det.vid.size;
994  if (size.w != win_info.size.w || size.h != win_info.size.h) {
995  pjsua_vid_win_set_size(wid, &size);
996 
997  /* Re-arrange video windows */
998  arrange_window(PJSUA_INVALID_ID);
999  }
1000  }
1001  }
1002 #else
1003  PJ_UNUSED_ARG(call_id);
1004  PJ_UNUSED_ARG(med_idx);
1005  PJ_UNUSED_ARG(event);
1006 #endif
1007 }
1008 
1009 #ifdef TRANSPORT_ADAPTER_SAMPLE
1010 /*
1011  * This callback is called when media transport needs to be created.
1012  */
1013 static pjmedia_transport* on_create_media_transport(pjsua_call_id call_id,
1014  unsigned media_idx,
1015  pjmedia_transport *base_tp,
1016  unsigned flags)
1017 {
1018  pjmedia_transport *adapter;
1019  pj_status_t status;
1020 
1021  /* Create the adapter */
1023  NULL, base_tp,
1024  (flags & PJSUA_MED_TP_CLOSE_MEMBER),
1025  &adapter);
1026  if (status != PJ_SUCCESS) {
1027  PJ_PERROR(1,(THIS_FILE, status, "Error creating adapter"));
1028  return NULL;
1029  }
1030 
1031  PJ_LOG(3,(THIS_FILE, "Media transport is created for call %d media %d",
1032  call_id, media_idx));
1033 
1034  return adapter;
1035 }
1036 #endif
1037 
1038 /* Playfile done notification, set timer to hangup calls */
1039 pj_status_t on_playfile_done(pjmedia_port *port, void *usr_data)
1040 {
1041  pj_time_val delay;
1042 
1043  PJ_UNUSED_ARG(port);
1044  PJ_UNUSED_ARG(usr_data);
1045 
1046  /* Just rewind WAV when it is played outside of call */
1047  if (pjsua_call_get_count() == 0) {
1048  pjsua_player_set_pos(app_config.wav_id, 0);
1049  return PJ_SUCCESS;
1050  }
1051 
1052  /* Timer is already active */
1053  if (app_config.auto_hangup_timer.id == 1)
1054  return PJ_SUCCESS;
1055 
1056  app_config.auto_hangup_timer.id = 1;
1057  delay.sec = 0;
1058  delay.msec = 200; /* Give 200 ms before hangup */
1060  &app_config.auto_hangup_timer,
1061  &delay);
1062 
1063  return PJ_SUCCESS;
1064 }
1065 
1066 /* Auto hangup timer callback */
1067 static void hangup_timeout_callback(pj_timer_heap_t *timer_heap,
1068  struct pj_timer_entry *entry)
1069 {
1070  PJ_UNUSED_ARG(timer_heap);
1071  PJ_UNUSED_ARG(entry);
1072 
1073  app_config.auto_hangup_timer.id = 0;
1075 }
1076 
1077 /*
1078  * A simple registrar, invoked by default_mod_on_rx_request()
1079  */
1080 static void simple_registrar(pjsip_rx_data *rdata)
1081 {
1082  pjsip_tx_data *tdata;
1083  const pjsip_expires_hdr *exp;
1084  const pjsip_hdr *h;
1085  unsigned cnt = 0;
1087  pj_status_t status;
1088 
1090  rdata, 200, NULL, &tdata);
1091  if (status != PJ_SUCCESS)
1092  return;
1093 
1095  PJSIP_H_EXPIRES, NULL);
1096 
1097  h = rdata->msg_info.msg->hdr.next;
1098  while (h != &rdata->msg_info.msg->hdr) {
1099  if (h->type == PJSIP_H_CONTACT) {
1100  const pjsip_contact_hdr *c = (const pjsip_contact_hdr*)h;
1101  int e = c->expires;
1102 
1103  if (e < 0) {
1104  if (exp)
1105  e = exp->ivalue;
1106  else
1107  e = 3600;
1108  }
1109 
1110  if (e > 0) {
1112  tdata->pool, h);
1113  nc->expires = e;
1114  pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)nc);
1115  ++cnt;
1116  }
1117  }
1118  h = h->next;
1119  }
1120 
1121  srv = pjsip_generic_string_hdr_create(tdata->pool, NULL, NULL);
1122  srv->name = pj_str("Server");
1123  srv->hvalue = pj_str("pjsua simple registrar");
1124  pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)srv);
1125 
1127  rdata, tdata, NULL, NULL);
1128 }
1129 
1130 /*****************************************************************************
1131  * A simple module to handle otherwise unhandled request. We will register
1132  * this with the lowest priority.
1133  */
1134 
1135 /* Notification on incoming request */
1136 static pj_bool_t default_mod_on_rx_request(pjsip_rx_data *rdata)
1137 {
1138  pjsip_tx_data *tdata;
1139  pjsip_status_code status_code;
1140  pj_status_t status;
1141 
1142  /* Don't respond to ACK! */
1143  if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method,
1144  &pjsip_ack_method) == 0)
1145  return PJ_TRUE;
1146 
1147  /* Simple registrar */
1148  if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method,
1149  &pjsip_register_method) == 0)
1150  {
1151  simple_registrar(rdata);
1152  return PJ_TRUE;
1153  }
1154 
1155  /* Create basic response. */
1156  if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method,
1157  &pjsip_notify_method) == 0)
1158  {
1159  /* Unsolicited NOTIFY's, send with Bad Request */
1160  status_code = PJSIP_SC_BAD_REQUEST;
1161  } else {
1162  /* Probably unknown method */
1163  status_code = PJSIP_SC_METHOD_NOT_ALLOWED;
1164  }
1166  rdata, status_code,
1167  NULL, &tdata);
1168  if (status != PJ_SUCCESS) {
1169  pjsua_perror(THIS_FILE, "Unable to create response", status);
1170  return PJ_TRUE;
1171  }
1172 
1173  /* Add Allow if we're responding with 405 */
1174  if (status_code == PJSIP_SC_METHOD_NOT_ALLOWED) {
1175  const pjsip_hdr *cap_hdr;
1177  PJSIP_H_ALLOW, NULL);
1178  if (cap_hdr) {
1180  tdata->pool, cap_hdr));
1181  }
1182  }
1183 
1184  /* Add User-Agent header */
1185  {
1186  pj_str_t user_agent;
1187  char tmp[80];
1188  const pj_str_t USER_AGENT = { "User-Agent", 10};
1189  pjsip_hdr *h;
1190 
1191  pj_ansi_snprintf(tmp, sizeof(tmp), "PJSUA v%s/%s",
1192  pj_get_version(), PJ_OS_NAME);
1193  pj_strdup2_with_null(tdata->pool, &user_agent, tmp);
1194 
1196  &USER_AGENT,
1197  &user_agent);
1198  pjsip_msg_add_hdr(tdata->msg, h);
1199  }
1200 
1202  NULL, NULL);
1203 
1204  return PJ_TRUE;
1205 }
1206 
1207 /* The module instance. */
1208 static pjsip_module mod_default_handler =
1209 {
1210  NULL, NULL, /* prev, next. */
1211  { "mod-default-handler", 19 }, /* Name. */
1212  -1, /* Id */
1213  PJSIP_MOD_PRIORITY_APPLICATION+99, /* Priority */
1214  NULL, /* load() */
1215  NULL, /* start() */
1216  NULL, /* stop() */
1217  NULL, /* unload() */
1218  &default_mod_on_rx_request, /* on_rx_request() */
1219  NULL, /* on_rx_response() */
1220  NULL, /* on_tx_request. */
1221  NULL, /* on_tx_response() */
1222  NULL, /* on_tsx_state() */
1223 
1224 };
1225 
1228 /* Called on CLI (re)started, e.g: initial start, after iOS bg */
1229 void cli_on_started(pj_status_t status)
1230 {
1231  /* Notify app */
1232  if (app_cfg.on_started) {
1233  if (status == PJ_SUCCESS) {
1234  char info[128];
1235  cli_get_info(info, sizeof(info));
1236  if (app_cfg.on_started) {
1237  (*app_cfg.on_started)(status, info);
1238  }
1239  } else {
1240  if (app_cfg.on_started) {
1241  (*app_cfg.on_started)(status, NULL);
1242  }
1243  }
1244  }
1245 }
1246 
1247 /* Called on CLI quit */
1248 void cli_on_stopped(pj_bool_t restart, int argc, char* argv[])
1249 {
1250  /* Notify app */
1251  if (app_cfg.on_stopped)
1252  (*app_cfg.on_stopped)(restart, argc, argv);
1253 }
1254 
1255 
1256 /* Called on pjsua legacy quit */
1257 void legacy_on_stopped(pj_bool_t restart)
1258 {
1259  /* Notify app */
1260  if (app_cfg.on_stopped)
1261  (*app_cfg.on_stopped)(restart, 1, NULL);
1262 }
1263 
1264 /*****************************************************************************
1265  * Public API
1266  */
1267 
1268 int stdout_refresh_proc(void *arg)
1269 {
1270  extern char *stdout_refresh_text;
1271 
1272  PJ_UNUSED_ARG(arg);
1273 
1274  /* Set thread to lowest priority so that it doesn't clobber
1275  * stdout output
1276  */
1279 
1280  while (!stdout_refresh_quit) {
1281  pj_thread_sleep(stdout_refresh * 1000);
1282  puts(stdout_refresh_text);
1283  fflush(stdout);
1284  }
1285 
1286  return 0;
1287 }
1288 
1289 static pj_status_t app_init()
1290 {
1291  pjsua_transport_id transport_id = -1;
1292  pjsua_transport_config tcp_cfg;
1293  unsigned i;
1294  pj_pool_t *tmp_pool;
1295  pj_status_t status;
1296 
1298  status = pjsua_create();
1299  if (status != PJ_SUCCESS)
1300  return status;
1301 
1302  /* Create pool for application */
1303  app_config.pool = pjsua_pool_create("pjsua-app", 1000, 1000);
1304  tmp_pool = pjsua_pool_create("tmp-pjsua", 1000, 1000);;
1305 
1306  /* Init CLI & its FE settings */
1307  if (!app_running) {
1308  pj_cli_cfg_default(&app_config.cli_cfg.cfg);
1309  pj_cli_telnet_cfg_default(&app_config.cli_cfg.telnet_cfg);
1310  pj_cli_console_cfg_default(&app_config.cli_cfg.console_cfg);
1311  app_config.cli_cfg.telnet_cfg.on_started = cli_on_started;
1312  }
1313 
1315  status = load_config(app_cfg.argc, app_cfg.argv, &uri_arg);
1316  if (status != PJ_SUCCESS) {
1317  pj_pool_release(tmp_pool);
1318  return status;
1319  }
1320 
1321  /* Initialize application callbacks */
1322  app_config.cfg.cb.on_call_state = &on_call_state;
1323  app_config.cfg.cb.on_call_media_state = &on_call_media_state;
1324  app_config.cfg.cb.on_incoming_call = &on_incoming_call;
1325  app_config.cfg.cb.on_call_tsx_state = &on_call_tsx_state;
1326  app_config.cfg.cb.on_dtmf_digit = &call_on_dtmf_callback;
1327  app_config.cfg.cb.on_call_redirected = &call_on_redirected;
1328  app_config.cfg.cb.on_reg_state = &on_reg_state;
1329  app_config.cfg.cb.on_incoming_subscribe = &on_incoming_subscribe;
1330  app_config.cfg.cb.on_buddy_state = &on_buddy_state;
1331  app_config.cfg.cb.on_buddy_evsub_state = &on_buddy_evsub_state;
1332  app_config.cfg.cb.on_pager = &on_pager;
1333  app_config.cfg.cb.on_typing = &on_typing;
1334  app_config.cfg.cb.on_call_transfer_status = &on_call_transfer_status;
1335  app_config.cfg.cb.on_call_replaced = &on_call_replaced;
1336  app_config.cfg.cb.on_nat_detect = &on_nat_detect;
1337  app_config.cfg.cb.on_mwi_info = &on_mwi_info;
1338  app_config.cfg.cb.on_transport_state = &on_transport_state;
1339  app_config.cfg.cb.on_ice_transport_error = &on_ice_transport_error;
1340  app_config.cfg.cb.on_snd_dev_operation = &on_snd_dev_operation;
1341  app_config.cfg.cb.on_call_media_event = &on_call_media_event;
1342 #ifdef TRANSPORT_ADAPTER_SAMPLE
1343  app_config.cfg.cb.on_create_media_transport = &on_create_media_transport;
1344 #endif
1345 
1346  /* Set sound device latency */
1347  if (app_config.capture_lat > 0)
1348  app_config.media_cfg.snd_rec_latency = app_config.capture_lat;
1349  if (app_config.playback_lat)
1350  app_config.media_cfg.snd_play_latency = app_config.playback_lat;
1351 
1352  if (app_cfg.on_config_init)
1353  (*app_cfg.on_config_init)(&app_config);
1354 
1355  /* Initialize pjsua */
1356  status = pjsua_init(&app_config.cfg, &app_config.log_cfg,
1357  &app_config.media_cfg);
1358  if (status != PJ_SUCCESS) {
1359  pj_pool_release(tmp_pool);
1360  return status;
1361  }
1362 
1363  /* Initialize our module to handle otherwise unhandled request */
1365  &mod_default_handler);
1366  if (status != PJ_SUCCESS)
1367  return status;
1368 
1369 #ifdef STEREO_DEMO
1370  stereo_demo();
1371 #endif
1372 
1373  /* Initialize calls data */
1374  for (i=0; i<PJ_ARRAY_SIZE(app_config.call_data); ++i) {
1375  app_config.call_data[i].timer.id = PJSUA_INVALID_ID;
1376  app_config.call_data[i].timer.cb = &call_timeout_callback;
1377  }
1378 
1379  /* Optionally registers WAV file */
1380  for (i=0; i<app_config.wav_count; ++i) {
1381  pjsua_player_id wav_id;
1382  unsigned play_options = 0;
1383 
1384  if (app_config.auto_play_hangup)
1385  play_options |= PJMEDIA_FILE_NO_LOOP;
1386 
1387  status = pjsua_player_create(&app_config.wav_files[i], play_options,
1388  &wav_id);
1389  if (status != PJ_SUCCESS)
1390  goto on_error;
1391 
1392  if (app_config.wav_id == PJSUA_INVALID_ID) {
1393  app_config.wav_id = wav_id;
1394  app_config.wav_port = pjsua_player_get_conf_port(app_config.wav_id);
1395  if (app_config.auto_play_hangup) {
1396  pjmedia_port *port;
1397 
1398  pjsua_player_get_port(app_config.wav_id, &port);
1399  status = pjmedia_wav_player_set_eof_cb(port, NULL,
1400  &on_playfile_done);
1401  if (status != PJ_SUCCESS)
1402  goto on_error;
1403 
1404  pj_timer_entry_init(&app_config.auto_hangup_timer, 0, NULL,
1405  &hangup_timeout_callback);
1406  }
1407  }
1408  }
1409 
1410  /* Optionally registers tone players */
1411  for (i=0; i<app_config.tone_count; ++i) {
1412  pjmedia_port *tport;
1413  char name[80];
1414  pj_str_t label;
1415  pj_status_t status2;
1416 
1417  pj_ansi_snprintf(name, sizeof(name), "tone-%d,%d",
1418  app_config.tones[i].freq1,
1419  app_config.tones[i].freq2);
1420  label = pj_str(name);
1421  status2 = pjmedia_tonegen_create2(app_config.pool, &label,
1422  8000, 1, 160, 16,
1423  PJMEDIA_TONEGEN_LOOP, &tport);
1424  if (status2 != PJ_SUCCESS) {
1425  pjsua_perror(THIS_FILE, "Unable to create tone generator", status);
1426  goto on_error;
1427  }
1428 
1429  status2 = pjsua_conf_add_port(app_config.pool, tport,
1430  &app_config.tone_slots[i]);
1431  pj_assert(status2 == PJ_SUCCESS);
1432 
1433  status2 = pjmedia_tonegen_play(tport, 1, &app_config.tones[i], 0);
1434  pj_assert(status2 == PJ_SUCCESS);
1435  }
1436 
1437  /* Optionally create recorder file, if any. */
1438  if (app_config.rec_file.slen) {
1439  status = pjsua_recorder_create(&app_config.rec_file, 0, NULL, 0, 0,
1440  &app_config.rec_id);
1441  if (status != PJ_SUCCESS)
1442  goto on_error;
1443 
1444  app_config.rec_port = pjsua_recorder_get_conf_port(app_config.rec_id);
1445  }
1446 
1447  pj_memcpy(&tcp_cfg, &app_config.udp_cfg, sizeof(tcp_cfg));
1448 
1449  /* Create ringback tones */
1450  if (app_config.no_tones == PJ_FALSE) {
1451  unsigned samples_per_frame;
1452  pjmedia_tone_desc tone[RING_CNT+RINGBACK_CNT];
1453  pj_str_t name;
1454 
1455  samples_per_frame = app_config.media_cfg.audio_frame_ptime *
1456  app_config.media_cfg.clock_rate *
1457  app_config.media_cfg.channel_count / 1000;
1458 
1459  /* Ringback tone (call is ringing) */
1460  name = pj_str("ringback");
1461  status = pjmedia_tonegen_create2(app_config.pool, &name,
1462  app_config.media_cfg.clock_rate,
1463  app_config.media_cfg.channel_count,
1464  samples_per_frame,
1465  16, PJMEDIA_TONEGEN_LOOP,
1466  &app_config.ringback_port);
1467  if (status != PJ_SUCCESS)
1468  goto on_error;
1469 
1470  pj_bzero(&tone, sizeof(tone));
1471  for (i=0; i<RINGBACK_CNT; ++i) {
1472  tone[i].freq1 = RINGBACK_FREQ1;
1473  tone[i].freq2 = RINGBACK_FREQ2;
1474  tone[i].on_msec = RINGBACK_ON;
1475  tone[i].off_msec = RINGBACK_OFF;
1476  }
1477  tone[RINGBACK_CNT-1].off_msec = RINGBACK_INTERVAL;
1478 
1479  pjmedia_tonegen_play(app_config.ringback_port, RINGBACK_CNT, tone,
1481 
1482 
1483  status = pjsua_conf_add_port(app_config.pool, app_config.ringback_port,
1484  &app_config.ringback_slot);
1485  if (status != PJ_SUCCESS)
1486  goto on_error;
1487 
1488  /* Ring (to alert incoming call) */
1489  name = pj_str("ring");
1490  status = pjmedia_tonegen_create2(app_config.pool, &name,
1491  app_config.media_cfg.clock_rate,
1492  app_config.media_cfg.channel_count,
1493  samples_per_frame,
1494  16, PJMEDIA_TONEGEN_LOOP,
1495  &app_config.ring_port);
1496  if (status != PJ_SUCCESS)
1497  goto on_error;
1498 
1499  for (i=0; i<RING_CNT; ++i) {
1500  tone[i].freq1 = RING_FREQ1;
1501  tone[i].freq2 = RING_FREQ2;
1502  tone[i].on_msec = RING_ON;
1503  tone[i].off_msec = RING_OFF;
1504  }
1505  tone[RING_CNT-1].off_msec = RING_INTERVAL;
1506 
1507  pjmedia_tonegen_play(app_config.ring_port, RING_CNT,
1508  tone, PJMEDIA_TONEGEN_LOOP);
1509 
1510  status = pjsua_conf_add_port(app_config.pool, app_config.ring_port,
1511  &app_config.ring_slot);
1512  if (status != PJ_SUCCESS)
1513  goto on_error;
1514 
1515  }
1516 
1517  /* Create AVI player virtual devices */
1518  if (app_config.avi_cnt) {
1519 #if PJMEDIA_HAS_VIDEO && PJMEDIA_VIDEO_DEV_HAS_AVI
1520  pjmedia_vid_dev_factory *avi_factory;
1521 
1523  app_config.avi_cnt,
1524  &avi_factory);
1525  if (status != PJ_SUCCESS) {
1526  PJ_PERROR(1,(THIS_FILE, status, "Error creating AVI factory"));
1527  goto on_error;
1528  }
1529 
1530  for (i=0; i<app_config.avi_cnt; ++i) {
1531  pjmedia_avi_dev_param avdp;
1532  pjmedia_vid_dev_index avid;
1533  unsigned strm_idx, strm_cnt;
1534 
1535  app_config.avi[i].dev_id = PJMEDIA_VID_INVALID_DEV;
1536  app_config.avi[i].slot = PJSUA_INVALID_ID;
1537 
1539  avdp.path = app_config.avi[i].path;
1540 
1541  status = pjmedia_avi_dev_alloc(avi_factory, &avdp, &avid);
1542  if (status != PJ_SUCCESS) {
1543  PJ_PERROR(1,(THIS_FILE, status,
1544  "Error creating AVI player for %.*s",
1545  (int)avdp.path.slen, avdp.path.ptr));
1546  goto on_error;
1547  }
1548 
1549  PJ_LOG(4,(THIS_FILE, "AVI player %.*s created, dev_id=%d",
1550  (int)avdp.title.slen, avdp.title.ptr, avid));
1551 
1552  app_config.avi[i].dev_id = avid;
1553  if (app_config.avi_def_idx == PJSUA_INVALID_ID)
1554  app_config.avi_def_idx = i;
1555 
1557  for (strm_idx=0; strm_idx<strm_cnt; ++strm_idx) {
1558  pjmedia_port *aud;
1559  pjmedia_format *fmt;
1560  pjsua_conf_port_id slot;
1561  char fmt_name[5];
1562 
1564  strm_idx);
1565  fmt = &aud->info.fmt;
1566 
1567  pjmedia_fourcc_name(fmt->id, fmt_name);
1568 
1569  if (fmt->id == PJMEDIA_FORMAT_PCM) {
1570  status = pjsua_conf_add_port(app_config.pool, aud,
1571  &slot);
1572  if (status == PJ_SUCCESS) {
1573  PJ_LOG(4,(THIS_FILE,
1574  "AVI %.*s: audio added to slot %d",
1575  (int)avdp.title.slen, avdp.title.ptr,
1576  slot));
1577  app_config.avi[i].slot = slot;
1578  }
1579  } else {
1580  PJ_LOG(4,(THIS_FILE,
1581  "AVI %.*s: audio ignored, format=%s",
1582  (int)avdp.title.slen, avdp.title.ptr,
1583  fmt_name));
1584  }
1585  }
1586  }
1587 #else
1588  PJ_LOG(2,(THIS_FILE,
1589  "Warning: --play-avi is ignored because AVI is disabled"));
1590 #endif /* PJMEDIA_VIDEO_DEV_HAS_AVI */
1591  }
1592 
1593  /* Add UDP transport unless it's disabled. */
1594  if (!app_config.no_udp) {
1595  pjsua_acc_id aid;
1597 
1598  status = pjsua_transport_create(type,
1599  &app_config.udp_cfg,
1600  &transport_id);
1601  if (status != PJ_SUCCESS)
1602  goto on_error;
1603 
1604  /* Add local account */
1605  pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
1606 
1607  /* Adjust local account config based on pjsua app config */
1608  {
1609  pjsua_acc_config acc_cfg;
1610  pjsua_acc_get_config(aid, tmp_pool, &acc_cfg);
1611 
1612  app_config_init_video(&acc_cfg);
1613  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1614  pjsua_acc_modify(aid, &acc_cfg);
1615  }
1616 
1617  //pjsua_acc_set_transport(aid, transport_id);
1618  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1619 
1620  if (app_config.udp_cfg.port == 0) {
1622  pj_sockaddr_in *a;
1623 
1624  pjsua_transport_get_info(transport_id, &ti);
1625  a = (pj_sockaddr_in*)&ti.local_addr;
1626 
1627  tcp_cfg.port = pj_ntohs(a->sin_port);
1628  }
1629  }
1630 
1631  /* Add UDP IPv6 transport unless it's disabled. */
1632  if (!app_config.no_udp && app_config.ipv6) {
1633  pjsua_acc_id aid;
1635  pjsua_transport_config udp_cfg;
1636 
1637  udp_cfg = app_config.udp_cfg;
1638  if (udp_cfg.port == 0)
1639  udp_cfg.port = 5060;
1640  else
1641  udp_cfg.port += 10;
1642  status = pjsua_transport_create(type,
1643  &udp_cfg,
1644  &transport_id);
1645  if (status != PJ_SUCCESS)
1646  goto on_error;
1647 
1648  /* Add local account */
1649  pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
1650 
1651  /* Adjust local account config based on pjsua app config */
1652  {
1653  pjsua_acc_config acc_cfg;
1654  pjsua_acc_get_config(aid, tmp_pool, &acc_cfg);
1655 
1656  app_config_init_video(&acc_cfg);
1657  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1659  pjsua_acc_modify(aid, &acc_cfg);
1660  }
1661 
1662  //pjsua_acc_set_transport(aid, transport_id);
1663  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1664 
1665  if (app_config.udp_cfg.port == 0) {
1667 
1668  pjsua_transport_get_info(transport_id, &ti);
1669  tcp_cfg.port = pj_sockaddr_get_port(&ti.local_addr);
1670  }
1671  }
1672 
1673  /* Add TCP transport unless it's disabled */
1674  if (!app_config.no_tcp) {
1675  pjsua_acc_id aid;
1676 
1678  &tcp_cfg,
1679  &transport_id);
1680  if (status != PJ_SUCCESS)
1681  goto on_error;
1682 
1683  /* Add local account */
1684  pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
1685 
1686  /* Adjust local account config based on pjsua app config */
1687  {
1688  pjsua_acc_config acc_cfg;
1689  pjsua_acc_get_config(aid, tmp_pool, &acc_cfg);
1690 
1691  app_config_init_video(&acc_cfg);
1692  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1693  pjsua_acc_modify(aid, &acc_cfg);
1694  }
1695 
1696  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1697 
1698  }
1699 
1700  /* Add TCP IPv6 transport unless it's disabled. */
1701  if (!app_config.no_tcp && app_config.ipv6) {
1702  pjsua_acc_id aid;
1704 
1705  tcp_cfg.port += 10;
1706 
1707  status = pjsua_transport_create(type,
1708  &tcp_cfg,
1709  &transport_id);
1710  if (status != PJ_SUCCESS)
1711  goto on_error;
1712 
1713  /* Add local account */
1714  pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
1715 
1716  /* Adjust local account config based on pjsua app config */
1717  {
1718  pjsua_acc_config acc_cfg;
1719  pjsua_acc_get_config(aid, tmp_pool, &acc_cfg);
1720 
1721  app_config_init_video(&acc_cfg);
1722  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1724  pjsua_acc_modify(aid, &acc_cfg);
1725  }
1726 
1727  //pjsua_acc_set_transport(aid, transport_id);
1728  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1729  }
1730 
1731 
1732 #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
1733  /* Add TLS transport when application wants one */
1734  if (app_config.use_tls) {
1735 
1736  pjsua_acc_id acc_id;
1737 
1738  /* Copy the QoS settings */
1739  tcp_cfg.tls_setting.qos_type = tcp_cfg.qos_type;
1740  pj_memcpy(&tcp_cfg.tls_setting.qos_params, &tcp_cfg.qos_params,
1741  sizeof(tcp_cfg.qos_params));
1742 
1743  /* Set TLS port as TCP port+1 */
1744  tcp_cfg.port++;
1746  &tcp_cfg,
1747  &transport_id);
1748  tcp_cfg.port--;
1749  if (status != PJ_SUCCESS)
1750  goto on_error;
1751 
1752  /* Add local account */
1753  pjsua_acc_add_local(transport_id, PJ_FALSE, &acc_id);
1754 
1755  /* Adjust local account config based on pjsua app config */
1756  {
1757  pjsua_acc_config acc_cfg;
1758  pjsua_acc_get_config(acc_id, tmp_pool, &acc_cfg);
1759 
1760  app_config_init_video(&acc_cfg);
1761  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1762  pjsua_acc_modify(acc_id, &acc_cfg);
1763  }
1764 
1766  }
1767 
1768  /* Add TLS IPv6 transport unless it's disabled. */
1769  if (app_config.use_tls && app_config.ipv6) {
1770  pjsua_acc_id aid;
1772 
1773  tcp_cfg.port += 10;
1774 
1775  status = pjsua_transport_create(type,
1776  &tcp_cfg,
1777  &transport_id);
1778  if (status != PJ_SUCCESS)
1779  goto on_error;
1780 
1781  /* Add local account */
1782  pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
1783 
1784  /* Adjust local account config based on pjsua app config */
1785  {
1786  pjsua_acc_config acc_cfg;
1787  pjsua_acc_get_config(aid, tmp_pool, &acc_cfg);
1788 
1789  app_config_init_video(&acc_cfg);
1790  acc_cfg.rtp_cfg = app_config.rtp_cfg;
1792  pjsua_acc_modify(aid, &acc_cfg);
1793  }
1794 
1795  //pjsua_acc_set_transport(aid, transport_id);
1796  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1797  }
1798 
1799 #endif
1800 
1801  if (transport_id == -1) {
1802  PJ_LOG(1,(THIS_FILE, "Error: no transport is configured"));
1803  status = -1;
1804  goto on_error;
1805  }
1806 
1807 
1808  /* Add accounts */
1809  for (i=0; i<app_config.acc_cnt; ++i) {
1810  app_config.acc_cfg[i].rtp_cfg = app_config.rtp_cfg;
1811  app_config.acc_cfg[i].reg_retry_interval = 300;
1812  app_config.acc_cfg[i].reg_first_retry_interval = 60;
1813 
1814  app_config_init_video(&app_config.acc_cfg[i]);
1815 
1816  status = pjsua_acc_add(&app_config.acc_cfg[i], PJ_TRUE, NULL);
1817  if (status != PJ_SUCCESS)
1818  goto on_error;
1819  pjsua_acc_set_online_status(current_acc, PJ_TRUE);
1820  }
1821 
1822  /* Add buddies */
1823  for (i=0; i<app_config.buddy_cnt; ++i) {
1824  status = pjsua_buddy_add(&app_config.buddy_cfg[i], NULL);
1825  if (status != PJ_SUCCESS) {
1826  PJ_PERROR(1,(THIS_FILE, status, "Error adding buddy"));
1827  goto on_error;
1828  }
1829  }
1830 
1831  /* Optionally disable some codec */
1832  for (i=0; i<app_config.codec_dis_cnt; ++i) {
1833  pjsua_codec_set_priority(&app_config.codec_dis[i],
1835 #if PJSUA_HAS_VIDEO
1836  pjsua_vid_codec_set_priority(&app_config.codec_dis[i],
1838 #endif
1839  }
1840 
1841  /* Optionally set codec orders */
1842  for (i=0; i<app_config.codec_cnt; ++i) {
1843  pjsua_codec_set_priority(&app_config.codec_arg[i],
1845 #if PJSUA_HAS_VIDEO
1846  pjsua_vid_codec_set_priority(&app_config.codec_arg[i],
1848 #endif
1849  }
1850 
1851  /* Use null sound device? */
1852 #ifndef STEREO_DEMO
1853  if (app_config.null_audio) {
1854  status = pjsua_set_null_snd_dev();
1855  if (status != PJ_SUCCESS)
1856  return status;
1857  }
1858 #endif
1859 
1860  if (app_config.capture_dev != PJSUA_INVALID_ID ||
1861  app_config.playback_dev != PJSUA_INVALID_ID)
1862  {
1863  status = pjsua_set_snd_dev(app_config.capture_dev,
1864  app_config.playback_dev);
1865  if (status != PJ_SUCCESS)
1866  goto on_error;
1867  }
1868 
1869  /* Init call setting */
1870  pjsua_call_setting_default(&call_opt);
1871  call_opt.aud_cnt = app_config.aud_cnt;
1872  call_opt.vid_cnt = app_config.vid.vid_cnt;
1873 
1874  pj_pool_release(tmp_pool);
1875  return PJ_SUCCESS;
1876 
1877 on_error:
1878  pj_pool_release(tmp_pool);
1879  app_destroy();
1880  return status;
1881 }
1882 
1883 pj_status_t pjsua_app_init(const pjsua_app_cfg_t *cfg)
1884 {
1885  pj_status_t status;
1886  pj_memcpy(&app_cfg, cfg, sizeof(app_cfg));
1887 
1888  status = app_init();
1889  if (status != PJ_SUCCESS)
1890  return status;
1891 
1892  /* Init CLI if configured */
1893  if (app_config.use_cli) {
1894  status = cli_init();
1895  }
1896  return status;
1897 }
1898 
1899 pj_status_t pjsua_app_run(pj_bool_t wait_telnet_cli)
1900 {
1901  pj_thread_t *stdout_refresh_thread = NULL;
1902  pj_status_t status;
1903 
1904  /* Start console refresh thread */
1905  if (stdout_refresh > 0) {
1906  pj_thread_create(app_config.pool, "stdout", &stdout_refresh_proc,
1907  NULL, 0, 0, &stdout_refresh_thread);
1908  }
1909 
1910  status = pjsua_start();
1911  if (status != PJ_SUCCESS)
1912  goto on_return;
1913 
1914  if (app_config.use_cli && (app_config.cli_cfg.cli_fe & CLI_FE_TELNET)) {
1915  char info[128];
1916  cli_get_info(info, sizeof(info));
1917  if (app_cfg.on_started) {
1918  (*app_cfg.on_started)(status, info);
1919  }
1920  } else {
1921  if (app_cfg.on_started) {
1922  (*app_cfg.on_started)(status, "Ready");
1923  }
1924  }
1925 
1926  /* If user specifies URI to call, then call the URI */
1927  if (uri_arg.slen) {
1928  pjsua_call_setting_default(&call_opt);
1929  call_opt.aud_cnt = app_config.aud_cnt;
1930  call_opt.vid_cnt = app_config.vid.vid_cnt;
1931 
1932  pjsua_call_make_call(current_acc, &uri_arg, &call_opt, NULL,
1933  NULL, NULL);
1934  }
1935 
1936  app_running = PJ_TRUE;
1937 
1938  if (app_config.use_cli)
1939  cli_main(wait_telnet_cli);
1940  else
1941  legacy_main();
1942 
1943  status = PJ_SUCCESS;
1944 
1945 on_return:
1946  if (stdout_refresh_thread) {
1947  stdout_refresh_quit = PJ_TRUE;
1948  pj_thread_join(stdout_refresh_thread);
1949  pj_thread_destroy(stdout_refresh_thread);
1950  stdout_refresh_quit = PJ_FALSE;
1951  }
1952  return status;
1953 }
1954 
1955 static pj_status_t app_destroy()
1956 {
1957  pj_status_t status = PJ_SUCCESS;
1958  unsigned i;
1959  pj_bool_t use_cli = PJ_FALSE;
1960  int cli_fe = 0;
1961  pj_uint16_t cli_telnet_port = 0;
1962 
1963 #ifdef STEREO_DEMO
1964  if (app_config.snd) {
1965  pjmedia_snd_port_destroy(app_config.snd);
1966  app_config.snd = NULL;
1967  }
1968  if (app_config.sc_ch1) {
1969  pjsua_conf_remove_port(app_config.sc_ch1_slot);
1970  app_config.sc_ch1_slot = PJSUA_INVALID_ID;
1971  pjmedia_port_destroy(app_config.sc_ch1);
1972  app_config.sc_ch1 = NULL;
1973  }
1974  if (app_config.sc) {
1975  pjmedia_port_destroy(app_config.sc);
1976  app_config.sc = NULL;
1977  }
1978 #endif
1979 
1980  /* Close avi devs and ports */
1981  for (i=0; i<app_config.avi_cnt; ++i) {
1982  if (app_config.avi[i].slot != PJSUA_INVALID_ID)
1983  pjsua_conf_remove_port(app_config.avi[i].slot);
1984 #if PJMEDIA_HAS_VIDEO && PJMEDIA_VIDEO_DEV_HAS_AVI
1985  if (app_config.avi[i].dev_id != PJMEDIA_VID_INVALID_DEV)
1986  pjmedia_avi_dev_free(app_config.avi[i].dev_id);
1987 #endif
1988  }
1989 
1990  /* Close ringback port */
1991  if (app_config.ringback_port &&
1992  app_config.ringback_slot != PJSUA_INVALID_ID)
1993  {
1994  pjsua_conf_remove_port(app_config.ringback_slot);
1995  app_config.ringback_slot = PJSUA_INVALID_ID;
1996  pjmedia_port_destroy(app_config.ringback_port);
1997  app_config.ringback_port = NULL;
1998  }
1999 
2000  /* Close ring port */
2001  if (app_config.ring_port && app_config.ring_slot != PJSUA_INVALID_ID) {
2002  pjsua_conf_remove_port(app_config.ring_slot);
2003  app_config.ring_slot = PJSUA_INVALID_ID;
2004  pjmedia_port_destroy(app_config.ring_port);
2005  app_config.ring_port = NULL;
2006  }
2007 
2008  /* Close tone generators */
2009  for (i=0; i<app_config.tone_count; ++i) {
2010  pjsua_conf_remove_port(app_config.tone_slots[i]);
2011  }
2012 
2013  pj_pool_safe_release(&app_config.pool);
2014 
2015  status = pjsua_destroy();
2016 
2017  if (app_config.use_cli) {
2018  use_cli = app_config.use_cli;
2019  cli_fe = app_config.cli_cfg.cli_fe;
2020  cli_telnet_port = app_config.cli_cfg.telnet_cfg.port;
2021  }
2022 
2023  /* Reset config */
2024  pj_bzero(&app_config, sizeof(app_config));
2025 
2026  if (use_cli) {
2027  app_config.use_cli = use_cli;
2028  app_config.cli_cfg.cli_fe = cli_fe;
2029  app_config.cli_cfg.telnet_cfg.port = cli_telnet_port;
2030  }
2031 
2032  return status;
2033 }
2034 
2035 pj_status_t pjsua_app_destroy()
2036 {
2037  pj_status_t status;
2038 
2039  status = app_destroy();
2040 
2041  if (app_config.use_cli) {
2042  cli_destroy();
2043  }
2044 
2045  return status;
2046 }
2047 
2050 #ifdef STEREO_DEMO
2051 /*
2052  * In this stereo demo, we open the sound device in stereo mode and
2053  * arrange the attachment to the PJSUA-LIB conference bridge as such
2054  * so that channel0/left channel of the sound device corresponds to
2055  * slot 0 in the bridge, and channel1/right channel of the sound
2056  * device corresponds to slot 1 in the bridge. Then user can independently
2057  * feed different media to/from the speakers/microphones channels, by
2058  * connecting them to slot 0 or 1 respectively.
2059  *
2060  * Here's how the connection looks like:
2061  *
2062  +-----------+ stereo +-----------------+ 2x mono +-----------+
2063  | AUDIO DEV |<------>| SPLITCOMB left|<------->|#0 BRIDGE |
2064  +-----------+ | right|<------->|#1 |
2065  +-----------------+ +-----------+
2066  */
2067 static void stereo_demo()
2068 {
2069  pjmedia_port *conf;
2070  pj_status_t status;
2071 
2072  /* Disable existing sound device */
2073  conf = pjsua_set_no_snd_dev();
2074 
2075  /* Create stereo-mono splitter/combiner */
2076  status = pjmedia_splitcomb_create(app_config.pool,
2077  PJMEDIA_PIA_SRATE(&conf->info) /* clock rate */,
2078  2 /* stereo */,
2079  2 * PJMEDIA_PIA_SPF(&conf->info),
2080  PJMEDIA_PIA_BITS(&conf->info),
2081  0 /* options */,
2082  &app_config.sc);
2083  pj_assert(status == PJ_SUCCESS);
2084 
2085  /* Connect channel0 (left channel?) to conference port slot0 */
2086  status = pjmedia_splitcomb_set_channel(app_config.sc, 0 /* ch0 */,
2087  0 /*options*/,
2088  conf);
2089  pj_assert(status == PJ_SUCCESS);
2090 
2091  /* Create reverse channel for channel1 (right channel?)... */
2092  status = pjmedia_splitcomb_create_rev_channel(app_config.pool,
2093  app_config.sc,
2094  1 /* ch1 */,
2095  0 /* options */,
2096  &app_config.sc_ch1);
2097  pj_assert(status == PJ_SUCCESS);
2098 
2099  /* .. and register it to conference bridge (it would be slot1
2100  * if there's no other devices connected to the bridge)
2101  */
2102  status = pjsua_conf_add_port(app_config.pool, app_config.sc_ch1,
2103  &app_config.sc_ch1_slot);
2104  pj_assert(status == PJ_SUCCESS);
2105 
2106  /* Create sound device */
2107  status = pjmedia_snd_port_create(app_config.pool, -1, -1,
2108  PJMEDIA_PIA_SRATE(&conf->info),
2109  2 /* stereo */,
2110  2 * PJMEDIA_PIA_SPF(&conf->info),
2111  PJMEDIA_PIA_BITS(&conf->info),
2112  0, &app_config.snd);
2113 
2114  pj_assert(status == PJ_SUCCESS);
2115 
2116 
2117  /* Connect the splitter to the sound device */
2118  status = pjmedia_snd_port_connect(app_config.snd, app_config.sc);
2119  pj_assert(status == PJ_SUCCESS);
2120 }
2121 #endif
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)
pj_bool_t rem_offerer
Definition: pjsua-lib/pjsua.h:4224
int pjsip_uri_print(pjsip_uri_context_e context, const void *uri, char *buf, pj_size_t size)
Definition: sip_uri.h:299
PJ_BEGIN_DECL pj_status_t pjmedia_splitcomb_create(pj_pool_t *pool, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_port **p_splitcomb)
pjsip_host_port remote_name
Definition: sip_transport.h:797
void pjsip_endpt_cancel_timer(pjsip_endpoint *endpt, pj_timer_entry *entry)
struct pjsip_request_line req
Definition: sip_msg.h:792
int pj_stricmp(const pj_str_t *str1, const pj_str_t *str2)
struct pj_timer_heap_t pj_timer_heap_t
pjsip_hdr hdr
Definition: sip_msg.h:799
pj_ssize_t slen
pj_uint16_t pj_ntohs(pj_uint16_t netshort)
Definition: sip_transport.h:508
pjsip_rx_data * rdata
Definition: pjsua-lib/pjsua.h:472
pj_status_t pjsua_vid_win_set_size(pjsua_vid_win_id wid, const pjmedia_rect_size *size)
char * ptr
pjmedia_port_info info
pj_str_t subtype
Definition: sip_msg.h:517
void pj_pool_release(pj_pool_t *pool)
unsigned vid_cnt
Definition: pjsua-lib/pjsua.h:655
Definition: sip_types.h:74
pjmedia_format fmt
void pjsua_msg_data_init(pjsua_msg_data *msg_data)
Definition: sip_types.h:98
pj_status_t pjsua_vid_win_get_info(pjsua_vid_win_id wid, pjsua_vid_win_info *wi)
int pj_bool_t
Definition: pjsua-lib/pjsua.h:1808
pjsip_method method
Definition: sip_transaction.h:99
struct pj_thread_t pj_thread_t
const pjsip_method pjsip_ack_method
Definition: sip_msg.h:95
void pj_list_push_back(pj_list_type *list, pj_list_type *node)
pj_qos_params qos_params
Definition: pjsua-lib/pjsua.h:2394
pj_thread_t * pj_thread_this(void)
pj_status_t pj_thread_set_prio(pj_thread_t *thread, int prio)
void * pj_memcpy(void *dst, const void *src, pj_size_t size)
pj_uint16_t sin_port
Definition: sip_transport_tls.h:297
Definition: pjsua-lib/pjsua.h:4150
pj_status_t pjsua_recorder_create(const pj_str_t *filename, unsigned enc_type, void *enc_param, pj_ssize_t max_size, unsigned options, pjsua_recorder_id *p_id)
pj_status_t pjsua_set_snd_dev(int capture_dev, int playback_dev)
Definition: sip_msg.h:77
Definition: sip_msg.h:64
pj_status_t pjmedia_port_destroy(pjmedia_port *port)
pj_sockaddr local_addr
Definition: pjsua-lib/pjsua.h:2466
pj_status_t pjsua_conf_disconnect(pjsua_conf_port_id source, pjsua_conf_port_id sink)
pj_pool_t * pool
Definition: sip_transport.h:514
pjmedia_rect_size size
Definition: pjsua-lib/pjsua.h:7037
pj_status_t pjsua_acc_get_config(pjsua_acc_id acc_id, pj_pool_t *pool, pjsua_acc_config *acc_cfg)
pjsip_role_e role
Definition: sip_transaction.h:98
pjsip_status_code last_status
Definition: pjsua-lib/pjsua.h:4186
const pjsip_method pjsip_notify_method
Definition: evsub.h:208
int pjsua_transport_id
Definition: pjsua-lib/pjsua.h:2319
pj_status_t pjsua_player_create(const pj_str_t *filename, unsigned options, pjsua_player_id *p_id)
Definition: sip_uri.h:222
pjsip_tsx_state_e state
Definition: sip_transaction.h:110
pj_str_t local_info
Definition: pjsua-lib/pjsua.h:4162
int pjsua_acc_id
Definition: pjsua-lib/pjsua.h:266
pj_status_t pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port)
pj_str_t reason
Definition: sip_msg.h:393
Definition: pjsua-lib/pjsua.h:7004
pjsip_hdr hdr_list
Definition: pjsua-lib/pjsua.h:1823
Definition: pjsua-lib/pjsua.h:2916
void pjmedia_avi_dev_param_default(pjmedia_avi_dev_param *p)
struct pjsip_event::@9::@11 tsx_state
Definition: sip_msg.h:1356
Definition: sip_msg.h:606
pjmedia_port * pjsua_set_no_snd_dev(void)
pj_status_t pjsua_conf_add_port(pj_pool_t *pool, pjmedia_port *port, pjsua_conf_port_id *p_id)
pjmedia_event_type type
unsigned len
Definition: sip_msg.h:643
#define PJ_PERROR(level, arg)
void pjsua_call_setting_default(pjsua_call_setting *opt)
pj_status_t pjsua_transport_get_info(pjsua_transport_id id, pjsua_transport_info *info)
Definition: sip_transport.h:1417
#define PJSIP_MAX_URL_SIZE
Definition: sip_config.h:320
pjsip_inv_state state
Definition: pjsua-lib/pjsua.h:4180
void pjsip_msg_add_hdr(pjsip_msg *msg, pjsip_hdr *hdr)
Definition: sip_msg.h:904
pj_str_t hvalue
Definition: sip_msg.h:998
#define PJ_LOG(level, arg)
pjsip_event_id_e type
Definition: sip_event.h:88
void pjsua_perror(const char *sender, const char *title, pj_status_t status)
pj_pool_t * pjsua_pool_create(const char *name, pj_size_t init_size, pj_size_t increment)
int code
Definition: sip_msg.h:392
pj_status_t pjmedia_wav_player_set_eof_cb(pjmedia_port *port, void *user_data, pj_status_t(*cb)(pjmedia_port *port, void *usr_data))
PJ_BEGIN_DECL pj_status_t pjmedia_tp_adapter_create(pjmedia_endpt *endpt, const char *name, pjmedia_transport *base_tp, pj_bool_t del_base, pjmedia_transport **p_tp)
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 pjmedia_tonegen_play(pjmedia_port *tonegen, unsigned count, const pjmedia_tone_desc tones[], unsigned options)
int pj_status_t
Definition: sip_transport.h:1397
pj_str_t status_text
Definition: pjsua-lib/pjsua.h:5224
char * type_name
Definition: sip_transport.h:790
pj_int32_t expires
Definition: sip_msg.h:1362
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)
Definition: pjsua-lib/pjsua.h:4056
pjsip_transport_type_e
Definition: sip_types.h:62
Definition: pjsua-lib/pjsua.h:2907
pj_status_t pj_ssl_cert_get_verify_status_strings(pj_uint32_t verify_status, const char *error_strings[], unsigned *count)
unsigned aud_cnt
Definition: pjsua-lib/pjsua.h:647
pj_status_t pjsua_start(void)
pj_status_t pjmedia_avi_dev_free(pjmedia_vid_dev_index id)
pj_status_t status
Definition: sip_transport.h:1421
pjsip_endpoint * endpt
Definition: sip_transaction.h:87
Definition: pjsua-lib/pjsua.h:4061
int pjsua_call_id
Definition: pjsua-lib/pjsua.h:263
pj_status_t pjsua_init(const pjsua_config *ua_cfg, const pjsua_logging_config *log_cfg, const pjsua_media_config *media_cfg)
pjsip_tls_setting tls_setting
Definition: pjsua-lib/pjsua.h:2376
pj_int32_t pjmedia_vid_dev_index
pj_status_t pjsip_tsx_send_msg(pjsip_transaction *tsx, pjsip_tx_data *tdata)
pj_qos_type qos_type
Definition: pjsua-lib/pjsua.h:2385
pjsua_transport_config rtp_cfg
Definition: pjsua-lib/pjsua.h:3346
pj_str_t uri
Definition: pjsua-lib/pjsua.h:5208
pj_status_t pjsua_vid_codec_set_priority(const pj_str_t *codec_id, pj_uint8_t priority)
Definition: sip_event.h:81
struct pjsua_call_media_info::@31::@32 aud
pjmedia_avi_streams * avi_streams
pj_status_t pjmedia_splitcomb_create_rev_channel(pj_pool_t *pool, pjmedia_port *splitcomb, unsigned ch_num, unsigned options, pjmedia_port **p_chport)
int pj_thread_get_prio_min(pj_thread_t *thread)
typedefPJ_BEGIN_DECL struct pjsip_evsub pjsip_evsub
Definition: evsub.h:51
int port
Definition: sip_types.h:221
pj_str_t info
pj_qos_params qos_params
Definition: sip_transport_tls.h:262
Definition: sip_transport.h:776
const char * pj_get_version(void)
Definition: sip_types.h:95
pj_status_t pjmedia_avi_dev_alloc(pjmedia_vid_dev_factory *f, pjmedia_avi_dev_param *param, pjmedia_vid_dev_index *p_id)
void pj_pool_safe_release(pj_pool_t **ppool)
pj_str_t last_status_text
Definition: pjsua-lib/pjsua.h:4189
const pjsip_method pjsip_register_method
Definition: sip_msg.h:101
pjsip_hdr_e type
Definition: sip_msg.h:326
pjmedia_avi_stream * pjmedia_avi_streams_get_stream(pjmedia_avi_streams *streams, unsigned idx)
Definition: sip_transaction.h:66
pjsip_media_type media
Definition: sip_msg.h:1400
Definition: sip_transport.h:281
pjsua_conf_port_id pjsua_recorder_get_conf_port(pjsua_recorder_id id)
Definition: sip_types.h:186
pj_status_t pjsip_endpt_register_module(pjsip_endpoint *endpt, pjsip_module *module)
pj_status_t pjsua_call_hangup(pjsua_call_id call_id, unsigned code, const pj_str_t *reason, const pjsua_msg_data *msg_data)
pjsua_call_media_info media[PJMEDIA_MAX_SDP_MEDIA]
Definition: pjsua-lib/pjsua.h:4204
void pj_cli_console_cfg_default(pj_cli_console_cfg *param)
pjsip_msg * msg
Definition: sip_transport.h:542
pjsua_conf_port_id pjsua_call_get_conf_port(pjsua_call_id call_id)
pj_ssl_sock_info * ssl_sock_info
Definition: sip_transport_tls.h:302
Definition: sip_inv.h:96
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)
pjsip_msg_body * body
Definition: sip_msg.h:804
pj_pool_factory * pjsua_get_pool_factory(void)
unsigned media_cnt
Definition: pjsua-lib/pjsua.h:4201
pjsua_conf_port_id pjsua_player_get_conf_port(pjsua_player_id id)
struct pjsip_rx_data::@24 msg_info
pj_str_t host
Definition: sip_types.h:220
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_str_t state_text
Definition: pjsua-lib/pjsua.h:4183
pj_status_t pjsua_conf_remove_port(pjsua_conf_port_id port_id)
Definition: sip_transport.h:1394
pj_str_t type
Definition: sip_msg.h:516
int pjsua_player_id
Definition: pjsua-lib/pjsua.h:272
pj_int32_t ivalue
Definition: sip_msg.h:1071
pj_status_t pjsua_create(void)
Definition: pjsua-lib/pjsua.h:583
Definition: sip_inv.h:95
Definition: sip_event.h:55
pjsip_status_code
Definition: sip_msg.h:403
pjsip_media_type content_type
Definition: sip_msg.h:620
pj_uint32_t flags
Definition: pjsua-lib/pjsua.h:4076
union pjsip_event::@9 body
int pjsip_method_cmp(const pjsip_method *m1, const pjsip_method *m2)
pj_status_t pjsua_transport_create(pjsip_transport_type_e type, const pjsua_transport_config *cfg, pjsua_transport_id *p_id)
unsigned pjsua_call_get_count(void)
pj_str_t pj_str(char *str)
const char * sub_state_name
Definition: pjsua-lib/pjsua.h:5245
Definition: sip_types.h:92
union pjsua_call_media_info::@31 stream
pjsip_msg * msg
Definition: sip_transport.h:351
Definition: sip_uri.h:156
pj_status_t pjsua_codec_set_priority(const pj_str_t *codec_id, pj_uint8_t priority)
const char * pjmedia_fourcc_name(pj_uint32_t sig, char buf[])
pjmedia_dir dir
Definition: pjsua-lib/pjsua.h:4115
pj_bool_t pjsua_call_has_media(pjsua_call_id call_id)
Definition: sip_types.h:71
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 pjmedia_avi_dev_create_factory(pj_pool_factory *pf, unsigned max_dev, pjmedia_vid_dev_factory **p_ret)
pjsua_call_media_status status
Definition: pjsua-lib/pjsua.h:4118
pj_status_t pjsip_endpt_schedule_timer(pjsip_endpoint *endpt, pj_timer_entry *entry, const pj_time_val *delay)
pjsua_ipv6_use ipv6_media_use
Definition: pjsua-lib/pjsua.h:3351
void pj_bzero(void *dst, pj_size_t size)
void * data
Definition: sip_msg.h:633
Definition: pjsua-lib/pjsua.h:468
pj_status_t pjsua_set_null_snd_dev(void)
unsigned port
Definition: pjsua-lib/pjsua.h:2336
struct pjsua_call_media_info::@31::@33 vid
pj_str_t status_text
Definition: sip_transaction.h:109
Definition: sip_event.h:52
unsigned char pj_uint8_t
int pjsua_buddy_id
Definition: pjsua-lib/pjsua.h:269
struct pjsip_endpoint pjsip_endpoint
Definition: sip_types.h:106
Definition: sip_transaction.h:70
#define pj_assert(expr)
pj_ice_strans_op
pj_status_t pjsua_buddy_get_info(pjsua_buddy_id buddy_id, pjsua_buddy_info *info)
Definition: sip_msg.h:780
struct pjsip_status_line status
Definition: sip_msg.h:795
pj_str_t sub_term_reason
Definition: pjsua-lib/pjsua.h:5260
char * pjsip_rx_data_get_info(pjsip_rx_data *rdata)
pjsip_transport_state
Definition: sip_transport.h:1392
#define PJSUA_MAX_CALLS
Definition: pjsua-lib/pjsua.h:4031
pj_status_t pjsua_acc_set_online_status(pjsua_acc_id acc_id, pj_bool_t is_online)
#define PJ_ARRAY_SIZE(a)
Definition: sip_msg.h:1066
pj_uint16_t pj_sockaddr_get_port(const pj_sockaddr_t *addr)
pj_status_t pjsua_acc_modify(pjsua_acc_id acc_id, const pjsua_acc_config *acc_cfg)
pj_str_t remote_info
Definition: pjsua-lib/pjsua.h:4168
void * pjsip_msg_find_hdr(const pjsip_msg *msg, pjsip_hdr_e type, const void *start)
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)
union pjsip_msg::@17 line
const char * pjsip_evsub_get_state_name(pjsip_evsub *sub)
const char * pjmedia_type_name(pjmedia_type t)
pj_timer_entry * pj_timer_entry_init(pj_timer_entry *entry, int id, void *user_data, pj_timer_heap_callback *cb)
unsigned PJMEDIA_PIA_SPF(const pjmedia_port_info *pia)
Definition: sip_types.h:68
Definition: pjsua-lib/pjsua.h:2431
pj_status_t pjmedia_snd_port_connect(pjmedia_snd_port *snd_port, pjmedia_port *port)
pj_status_t pjmedia_tonegen_rewind(pjmedia_port *tonegen)
pjsip_role_e role
Definition: pjsua-lib/pjsua.h:4156
Definition: sip_msg.h:993
void pjsua_call_hangup_all(void)
int pjsua_conf_port_id
Definition: pjsua-lib/pjsua.h:278
pjsip_ctype_hdr * ctype
Definition: sip_transport.h:383
Definition: sip_util.h:105
pj_uint32_t id
Definition: pjsua-lib/pjsua.h:4071
pj_status_t pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg, pjsua_buddy_id *p_buddy_id)
pj_str_t * pj_strdup2_with_null(pj_pool_t *pool, pj_str_t *dst, const char *src)
int id
pj_status_t pj_thread_join(pj_thread_t *thread)
unsigned PJMEDIA_PIA_SRATE(const pjmedia_port_info *pia)
const pjsip_hdr * pjsip_endpt_get_capability(pjsip_endpoint *endpt, int htype, const pj_str_t *hname)
unsigned sub_term_code
Definition: pjsua-lib/pjsua.h:5254
Definition: sip_msg.h:1397
pj_status_t pj_thread_destroy(pj_thread_t *thread)
pj_status_t pjsua_destroy(void)
Definition: sip_msg.h:324
unsigned PJMEDIA_PIA_BITS(const pjmedia_port_info *pia)
pjmedia_type type
Definition: pjsua-lib/pjsua.h:4112
unsigned pjmedia_avi_streams_get_num_streams(pjmedia_avi_streams *streams)
void * pjsip_hdr_clone(pj_pool_t *pool, const void *hdr)
Definition: sip_module.h:54
void * ext_info
Definition: sip_transport.h:1426
int pjsua_vid_win_id
Definition: pjsua-lib/pjsua.h:4044
pj_status_t pjmedia_tonegen_create2(pj_pool_t *pool, const pj_str_t *name, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_port **p_port)
pj_status_t pjmedia_splitcomb_set_channel(pjmedia_port *splitcomb, unsigned ch_num, unsigned options, pjmedia_port *port)
pj_status_t pj_thread_sleep(unsigned msec)
pjsip_generic_string_hdr * pjsip_generic_string_hdr_create(pj_pool_t *pool, const pj_str_t *hname, const pj_str_t *hvalue)
pjsip_endpoint * pjsua_get_pjsip_endpt(void)
unsigned rem_vid_cnt
Definition: pjsua-lib/pjsua.h:4230
const char * pjsip_event_str(pjsip_event_id_e e)
pj_qos_type qos_type
Definition: sip_transport_tls.h:253
Definition: sip_transaction.h:68
pjmedia_endpt * pjsua_get_pjmedia_endpt(void)
Definition: pjsua-lib/pjsua.h:624
pjsua_call_id id
Definition: pjsua-lib/pjsua.h:4153
const char * pj_ssl_cipher_name(pj_ssl_cipher cipher)
void pj_cli_telnet_cfg_default(pj_cli_telnet_cfg *param)
pj_status_t pjsua_enum_calls(pjsua_call_id ids[], unsigned *count)
pjsip_redirect_op
Definition: sip_util.h:80
pjsua_call_media_status media_status
Definition: pjsua-lib/pjsua.h:4192
pj_str_t name
Definition: sip_msg.h:996
Definition: sip_types.h:185
unsigned short pj_uint16_t
void pj_cli_cfg_default(pj_cli_cfg *param)
pj_status_t pjsua_player_get_port(pjsua_player_id id, pjmedia_port **p_port)
Definition: pjsua-lib/pjsua.h:2328
pj_status_t pjsua_call_get_info(pjsua_call_id call_id, pjsua_call_info *info)
int pjsua_call_get_vid_stream_idx(pjsua_call_id call_id)
void pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *h, pj_str_t *hname, pj_str_t *hvalue)
Definition: pjsua-lib/pjsua.h:5198
pjsip_method method
Definition: sip_msg.h:382
Definition: sip_inv.h:93
pj_status_t pjsua_player_set_pos(pjsua_player_id id, pj_uint32_t samples)
pj_status_t pjsua_acc_add(const pjsua_acc_config *acc_cfg, pj_bool_t is_default, pjsua_acc_id *p_acc_id)
#define PJ_UNUSED_ARG(arg)
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)
Definition: sip_transaction.h:80
Definition: sip_event.h:61
unsigned rem_aud_cnt
Definition: pjsua-lib/pjsua.h:4227
Definition: pjsua_internal.h:206
pj_status_t pjsua_conf_connect(pjsua_conf_port_id source, pjsua_conf_port_id sink)
int status_code
Definition: sip_transaction.h:108
Definition: sip_module.h:211

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
Copyright (C) 2006-2008 Teluu Inc.