| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <pjsua-lib/pjsua.h> |
| 21 |
#include "pjsua_app_common.h" |
| 22 |
|
| 23 |
#define THIS_FILE "pjsua_app_legacy.c" |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ |
| 32 |
(defined (_MSC_VER) && _MSC_VER >= 1400) |
| 33 |
|
| 34 |
# define printf(...) {printf(__VA_ARGS__);fflush(stdout);} |
| 35 |
# define puts(s) {puts(s);fflush(stdout);} |
| 36 |
#endif |
| 37 |
|
| 38 |
|
| 39 |
static pj_bool_t cmd_echo; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
static void print_buddy_list() |
| 45 |
{ |
| 46 |
pjsua_buddy_id ids[64]; |
| 47 |
int i; |
| 48 |
unsigned count = PJ_ARRAY_SIZE(ids); |
| 49 |
|
| 50 |
puts("Buddy list:"); |
| 51 |
|
| 52 |
pjsua_enum_buddies(ids, &count); |
| 53 |
|
| 54 |
if (count == 0) { |
| 55 |
puts(" -none-"); |
| 56 |
} else { |
| 57 |
for (i=0; i<(int)count; ++i) { |
| 58 |
pjsua_buddy_info info; |
| 59 |
|
| 60 |
if (pjsua_buddy_get_info(ids[i], &info) != PJ_SUCCESS) |
| 61 |
continue; |
| 62 |
|
| 63 |
printf(" [%2d] <%.*s> %.*s\n", |
| 64 |
ids[i]+1, |
| 65 |
(int)info.status_text.slen, |
| 66 |
info.status_text.ptr, |
| 67 |
(int)info.uri.slen, |
| 68 |
info.uri.ptr); |
| 69 |
} |
| 70 |
} |
| 71 |
puts(""); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
static void ui_input_url(const char *title, char *buf, pj_size_t len, |
| 78 |
input_result *result, pj_bool_t allow_all) |
| 79 |
{ |
| 80 |
result->nb_result = PJSUA_APP_NO_NB; |
| 81 |
result->uri_result = NULL; |
| 82 |
|
| 83 |
print_buddy_list(); |
| 84 |
|
| 85 |
printf("Choices:\n" |
| 86 |
" 0 For current dialog.\n"); |
| 87 |
if (pjsua_get_buddy_count() > 0) { |
| 88 |
if (allow_all) { |
| 89 |
printf(" -1 All %d buddies in buddy list\n", |
| 90 |
pjsua_get_buddy_count()); |
| 91 |
} |
| 92 |
printf(" [1 -%2d] Select from buddy list\n", |
| 93 |
pjsua_get_buddy_count()); |
| 94 |
} |
| 95 |
printf(" URL An URL\n" |
| 96 |
" <Enter> Empty input (or 'q') to cancel\n"); |
| 97 |
printf("%s: ", title); |
| 98 |
|
| 99 |
fflush(stdout); |
| 100 |
if (fgets(buf, (int)len, stdin) == NULL) |
| 101 |
return; |
| 102 |
len = strlen(buf); |
| 103 |
|
| 104 |
|
| 105 |
while (pj_isspace(*buf)) { |
| 106 |
++buf; |
| 107 |
--len; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
while (len && (buf[len-1] == '\r' || buf[len-1] == '\n')) |
| 112 |
buf[--len] = '\0'; |
| 113 |
|
| 114 |
if (len == 0 || buf[0]=='q') |
| 115 |
return; |
| 116 |
|
| 117 |
if (pj_isdigit(*buf) || *buf=='-') { |
| 118 |
|
| 119 |
unsigned i; |
| 120 |
|
| 121 |
if (*buf=='-') |
| 122 |
i = 1; |
| 123 |
else |
| 124 |
i = 0; |
| 125 |
|
| 126 |
for (; i<len; ++i) { |
| 127 |
if (!pj_isdigit(buf[i])) { |
| 128 |
puts("Invalid input"); |
| 129 |
return; |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
result->nb_result = my_atoi(buf); |
| 134 |
|
| 135 |
if (result->nb_result >= 0 && |
| 136 |
result->nb_result <= (int)pjsua_get_buddy_count()) |
| 137 |
{ |
| 138 |
return; |
| 139 |
} |
| 140 |
if (result->nb_result == -1) |
| 141 |
return; |
| 142 |
|
| 143 |
puts("Invalid input"); |
| 144 |
result->nb_result = PJSUA_APP_NO_NB; |
| 145 |
return; |
| 146 |
|
| 147 |
} else { |
| 148 |
pj_status_t status; |
| 149 |
|
| 150 |
if ((status=pjsua_verify_url(buf)) != PJ_SUCCESS) { |
| 151 |
pjsua_perror(THIS_FILE, "Invalid URL", status); |
| 152 |
return; |
| 153 |
} |
| 154 |
|
| 155 |
result->uri_result = buf; |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
static pj_bool_t simple_input(const char *title, char *buf, pj_size_t len) |
| 160 |
{ |
| 161 |
char *p; |
| 162 |
|
| 163 |
printf("%s (empty to cancel): ", title); fflush(stdout); |
| 164 |
if (fgets(buf, (int)len, stdin) == NULL) |
| 165 |
return PJ_FALSE; |
| 166 |
|
| 167 |
|
| 168 |
for (p=buf; ; ++p) { |
| 169 |
if (*p=='\r' || *p=='\n') *p='\0'; |
| 170 |
else if (!*p) break; |
| 171 |
} |
| 172 |
|
| 173 |
if (!*buf) |
| 174 |
return PJ_FALSE; |
| 175 |
|
| 176 |
return PJ_TRUE; |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
static void print_acc_status(int acc_id) |
| 183 |
{ |
| 184 |
char buf[80]; |
| 185 |
pjsua_acc_info info; |
| 186 |
|
| 187 |
pjsua_acc_get_info(acc_id, &info); |
| 188 |
|
| 189 |
if (!info.has_registration) { |
| 190 |
pj_ansi_snprintf(buf, sizeof(buf), "%.*s", |
| 191 |
(int)info.status_text.slen, |
| 192 |
info.status_text.ptr); |
| 193 |
|
| 194 |
} else { |
| 195 |
pj_ansi_snprintf(buf, sizeof(buf), |
| 196 |
"%d/%.*s (expires=%d)", |
| 197 |
info.status, |
| 198 |
(int)info.status_text.slen, |
| 199 |
info.status_text.ptr, |
| 200 |
info.expires); |
| 201 |
|
| 202 |
} |
| 203 |
|
| 204 |
printf(" %c[%2d] %.*s: %s\n", (acc_id==current_acc?'*':' '), |
| 205 |
acc_id, (int)info.acc_uri.slen, info.acc_uri.ptr, buf); |
| 206 |
printf(" Online status: %.*s\n", |
| 207 |
(int)info.online_status_text.slen, |
| 208 |
info.online_status_text.ptr); |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
static void keystroke_help() |
| 215 |
{ |
| 216 |
pjsua_acc_id acc_ids[16]; |
| 217 |
unsigned count = PJ_ARRAY_SIZE(acc_ids); |
| 218 |
int i; |
| 219 |
|
| 220 |
printf(">>>>\n"); |
| 221 |
|
| 222 |
pjsua_enum_accs(acc_ids, &count); |
| 223 |
|
| 224 |
printf("Account list:\n"); |
| 225 |
for (i=0; i<(int)count; ++i) |
| 226 |
print_acc_status(acc_ids[i]); |
| 227 |
|
| 228 |
print_buddy_list(); |
| 229 |
|
| 230 |
|
| 231 |
puts("+=============================================================================+"); |
| 232 |
puts("| Call Commands: | Buddy, IM & Presence: | Account: |"); |
| 233 |
puts("| | | |"); |
| 234 |
puts("| m Make new call | +b Add new buddy | +a Add new accnt.|"); |
| 235 |
puts("| M Make multiple calls | -b Delete buddy | -a Delete accnt. |"); |
| 236 |
puts("| a Answer call | i Send IM | !a Modify accnt. |"); |
| 237 |
puts("| h Hangup call (ha=all) | s Subscribe presence | rr (Re-)register |"); |
| 238 |
puts("| H Hold call | u Unsubscribe presence | ru Unregister |"); |
| 239 |
puts("| o Toggle call SDP offer | D Subscribe dlg event | |"); |
| 240 |
puts("| | Du Unsub dlg event | |"); |
| 241 |
puts("| v re-inVite (release hold) | t Toggle online status | > Cycle next ac.|"); |
| 242 |
puts("| U send UPDATE | T Set online status | < Cycle prev ac.|"); |
| 243 |
puts("| ],[ Select next/prev call +--------------------------+-------------------+"); |
| 244 |
puts("| x Xfer call | Media Commands: | Status & Config: |"); |
| 245 |
puts("| X Xfer with Replaces | | |"); |
| 246 |
puts("| # Send RFC 2833 DTMF | cl List ports | d Dump status |"); |
| 247 |
puts("| * Send DTMF with INFO | cc Connect port | dd Dump detailed |"); |
| 248 |
puts("| rt Send real-time text | cd Disconnect port | dc Dump config |"); |
| 249 |
puts("| dq Dump curr. call quality | V Adjust audio Volume | f Save config |"); |
| 250 |
puts("| S Send arbitrary REQUEST | Cp Codec priorities | |"); |
| 251 |
puts("+-----------------------------------------------------------------------------+"); |
| 252 |
#if PJSUA_HAS_VIDEO |
| 253 |
puts("| Video: \"vid help\" for more info |"); |
| 254 |
puts("+-----------------------------------------------------------------------------+"); |
| 255 |
#endif |
| 256 |
puts("| q QUIT L ReLoad I IP change n detect NAT type |"); |
| 257 |
puts("| sleep MS echo [0|1|txt] |"); |
| 258 |
puts("+=============================================================================+"); |
| 259 |
|
| 260 |
i = pjsua_call_get_count(); |
| 261 |
printf("You have %d active call%s\n", i, (i>1?"s":"")); |
| 262 |
|
| 263 |
if (current_call != PJSUA_INVALID_ID) { |
| 264 |
pjsua_call_info ci; |
| 265 |
if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS) |
| 266 |
printf("Current call id=%d to %.*s [%.*s]\n", current_call, |
| 267 |
(int)ci.remote_info.slen, ci.remote_info.ptr, |
| 268 |
(int)ci.state_text.slen, ci.state_text.ptr); |
| 269 |
} |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
#if PJSUA_HAS_VIDEO |
| 274 |
static void vid_show_help() |
| 275 |
{ |
| 276 |
pj_bool_t vid_enabled = (app_config.vid.vid_cnt > 0); |
| 277 |
|
| 278 |
puts("+=============================================================================+"); |
| 279 |
puts("| Video commands: |"); |
| 280 |
puts("| |"); |
| 281 |
puts("| vid help Show this help screen |"); |
| 282 |
puts("| vid enable|disable Enable or disable video in next offer/answer |"); |
| 283 |
puts("| vid acc show Show current account video settings |"); |
| 284 |
puts("| vid acc autorx on|off Automatically show incoming video on/off |"); |
| 285 |
puts("| vid acc autotx on|off Automatically offer video on/off |"); |
| 286 |
puts("| vid acc cap ID Set default capture device for current acc |"); |
| 287 |
puts("| vid acc rend ID Set default renderer device for current acc |"); |
| 288 |
puts("| vid call rx on|off N Enable/disable video RX for stream N in curr call |"); |
| 289 |
puts("| vid call tx on|off N Enable/disable video TX for stream N in curr call |"); |
| 290 |
puts("| vid call add Add video stream for current call |"); |
| 291 |
puts("| vid call enable|disable N Enable/disable stream #N in current call |"); |
| 292 |
puts("| vid call cap N ID Set capture dev ID for stream #N in current call |"); |
| 293 |
puts("| vid dev list List all video devices |"); |
| 294 |
puts("| vid dev refresh Refresh video device list |"); |
| 295 |
puts("| vid dev prev on|off ID Enable/disable preview for specified device ID |"); |
| 296 |
puts("| vid codec list List video codecs |"); |
| 297 |
puts("| vid codec prio ID PRIO Set codec ID priority to PRIO |"); |
| 298 |
puts("| vid codec fps ID NUM DEN Set codec ID framerate to (NUM/DEN) fps |"); |
| 299 |
puts("| vid codec bw ID AVG MAX Set codec ID bitrate to AVG & MAX kbps |"); |
| 300 |
puts("| vid codec size ID W H Set codec ID size/resolution to W x H |"); |
| 301 |
puts("| vid win list List all active video windows |"); |
| 302 |
puts("| vid win arrange Auto arrange windows |"); |
| 303 |
puts("| vid win show|hide ID Show/hide the specified video window ID |"); |
| 304 |
puts("| vid win move ID X Y Move window ID to position X,Y |"); |
| 305 |
puts("| vid win resize ID w h Resize window ID to the specified width, height |"); |
| 306 |
puts("| vid win full off|on|dt ID Set fullscreen off/on/desktop for window ID |"); |
| 307 |
puts("| vid conf list List all video ports in video conference bridge |"); |
| 308 |
puts("| vid conf cc P Q Connect port P to Q in the video conf bridge |"); |
| 309 |
puts("| vid conf cd P Q Disconnect port P to Q in the video conf bridge |"); |
| 310 |
puts("+=============================================================================+"); |
| 311 |
printf("| Video will be %s in the next offer/answer %s |\n", |
| 312 |
(vid_enabled? "enabled" : "disabled"), (vid_enabled? " " : "")); |
| 313 |
puts("+=============================================================================+"); |
| 314 |
} |
| 315 |
|
| 316 |
static void vid_handle_menu(char *menuin) |
| 317 |
{ |
| 318 |
char *argv[8] = {NULL}; |
| 319 |
int argc = 0; |
| 320 |
|
| 321 |
|
| 322 |
argv[argc] = strtok(menuin, " \t\r\n"); |
| 323 |
while (argv[argc] && *argv[argc]) { |
| 324 |
argc++; |
| 325 |
argv[argc] = strtok(NULL, " \t\r\n"); |
| 326 |
} |
| 327 |
|
| 328 |
if (argc == 1 || strcmp(argv[1], "help")==0) { |
| 329 |
vid_show_help(); |
| 330 |
} else if (argc == 2 && (strcmp(argv[1], "enable")==0 || |
| 331 |
strcmp(argv[1], "disable")==0)) |
| 332 |
{ |
| 333 |
pj_bool_t enabled = (strcmp(argv[1], "enable")==0); |
| 334 |
app_config.vid.vid_cnt = (enabled ? 1 : 0); |
| 335 |
PJ_LOG(3,(THIS_FILE, "Video will be %s in next offer/answer", |
| 336 |
(enabled?"enabled":"disabled"))); |
| 337 |
} else if (strcmp(argv[1], "acc")==0) { |
| 338 |
pjsua_acc_config acc_cfg; |
| 339 |
pj_bool_t changed = PJ_FALSE; |
| 340 |
pj_pool_t *tmp_pool = pjsua_pool_create("tmp-pjsua", 1000, 1000); |
| 341 |
|
| 342 |
pjsua_acc_get_config(current_acc, tmp_pool, &acc_cfg); |
| 343 |
|
| 344 |
if (argc == 3 && strcmp(argv[2], "show")==0) { |
| 345 |
app_config_show_video(current_acc, &acc_cfg); |
| 346 |
} else if (argc == 4 && strcmp(argv[2], "autorx")==0) { |
| 347 |
int on = (strcmp(argv[3], "on")==0); |
| 348 |
acc_cfg.vid_in_auto_show = on; |
| 349 |
changed = PJ_TRUE; |
| 350 |
} else if (argc == 4 && strcmp(argv[2], "autotx")==0) { |
| 351 |
int on = (strcmp(argv[3], "on")==0); |
| 352 |
acc_cfg.vid_out_auto_transmit = on; |
| 353 |
changed = PJ_TRUE; |
| 354 |
} else if (argc == 4 && strcmp(argv[2], "cap")==0) { |
| 355 |
int dev = atoi(argv[3]); |
| 356 |
acc_cfg.vid_cap_dev = dev; |
| 357 |
changed = PJ_TRUE; |
| 358 |
} else if (argc == 4 && strcmp(argv[2], "rend")==0) { |
| 359 |
int dev = atoi(argv[3]); |
| 360 |
acc_cfg.vid_rend_dev = dev; |
| 361 |
changed = PJ_TRUE; |
| 362 |
} else { |
| 363 |
pj_pool_release(tmp_pool); |
| 364 |
goto on_error; |
| 365 |
} |
| 366 |
|
| 367 |
if (changed) { |
| 368 |
pj_status_t status = pjsua_acc_modify(current_acc, &acc_cfg); |
| 369 |
if (status != PJ_SUCCESS) |
| 370 |
PJ_PERROR(1,(THIS_FILE, status, "Error modifying account %d", |
| 371 |
current_acc)); |
| 372 |
} |
| 373 |
pj_pool_release(tmp_pool); |
| 374 |
|
| 375 |
} else if (strcmp(argv[1], "call")==0) { |
| 376 |
pjsua_call_vid_strm_op_param param; |
| 377 |
pj_status_t status = PJ_SUCCESS; |
| 378 |
|
| 379 |
pjsua_call_vid_strm_op_param_default(¶m); |
| 380 |
|
| 381 |
if (argc == 5 && strcmp(argv[2], "rx")==0) { |
| 382 |
pjsua_stream_info si; |
| 383 |
pj_bool_t on = (strcmp(argv[3], "on") == 0); |
| 384 |
|
| 385 |
param.med_idx = atoi(argv[4]); |
| 386 |
if (pjsua_call_get_stream_info(current_call, param.med_idx, &si) || |
| 387 |
si.type != PJMEDIA_TYPE_VIDEO) |
| 388 |
{ |
| 389 |
PJ_PERROR(1,(THIS_FILE, PJ_EINVAL, "Invalid stream")); |
| 390 |
return; |
| 391 |
} |
| 392 |
|
| 393 |
if (on) param.dir = (si.info.vid.dir | PJMEDIA_DIR_DECODING); |
| 394 |
else param.dir = (si.info.vid.dir & PJMEDIA_DIR_ENCODING); |
| 395 |
|
| 396 |
status = pjsua_call_set_vid_strm(current_call, |
| 397 |
PJSUA_CALL_VID_STRM_CHANGE_DIR, |
| 398 |
¶m); |
| 399 |
} |
| 400 |
else if (argc == 5 && strcmp(argv[2], "tx")==0) { |
| 401 |
pj_bool_t on = (strcmp(argv[3], "on") == 0); |
| 402 |
pjsua_call_vid_strm_op op = on? PJSUA_CALL_VID_STRM_START_TRANSMIT : |
| 403 |
PJSUA_CALL_VID_STRM_STOP_TRANSMIT; |
| 404 |
|
| 405 |
param.med_idx = atoi(argv[4]); |
| 406 |
|
| 407 |
status = pjsua_call_set_vid_strm(current_call, op, ¶m); |
| 408 |
} |
| 409 |
else if (argc == 3 && strcmp(argv[2], "add")==0) { |
| 410 |
status = pjsua_call_set_vid_strm(current_call, |
| 411 |
PJSUA_CALL_VID_STRM_ADD, NULL); |
| 412 |
} |
| 413 |
else if (argc >= 3 && |
| 414 |
(strcmp(argv[2], "disable")==0 || strcmp(argv[2], "enable")==0)) |
| 415 |
{ |
| 416 |
pj_bool_t enable = (strcmp(argv[2], "enable") == 0); |
| 417 |
pjsua_call_vid_strm_op op = enable? PJSUA_CALL_VID_STRM_CHANGE_DIR : |
| 418 |
PJSUA_CALL_VID_STRM_REMOVE; |
| 419 |
|
| 420 |
param.med_idx = argc >= 4? atoi(argv[3]) : -1; |
| 421 |
param.dir = PJMEDIA_DIR_ENCODING_DECODING; |
| 422 |
status = pjsua_call_set_vid_strm(current_call, op, ¶m); |
| 423 |
} |
| 424 |
else if (argc >= 3 && strcmp(argv[2], "cap")==0) { |
| 425 |
param.med_idx = argc >= 4? atoi(argv[3]) : -1; |
| 426 |
param.cap_dev = argc >= 5? atoi(argv[4]) : PJMEDIA_VID_DEFAULT_CAPTURE_DEV; |
| 427 |
status = pjsua_call_set_vid_strm(current_call, |
| 428 |
PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, |
| 429 |
¶m); |
| 430 |
} else |
| 431 |
goto on_error; |
| 432 |
|
| 433 |
if (status != PJ_SUCCESS) { |
| 434 |
PJ_PERROR(1,(THIS_FILE, status, "Error modifying video stream")); |
| 435 |
} |
| 436 |
|
| 437 |
} else if (argc >= 3 && strcmp(argv[1], "dev")==0) { |
| 438 |
if (strcmp(argv[2], "list")==0) { |
| 439 |
vid_list_devs(); |
| 440 |
} else if (strcmp(argv[2], "refresh")==0) { |
| 441 |
pjmedia_vid_dev_refresh(); |
| 442 |
} else if (strcmp(argv[2], "prev")==0) { |
| 443 |
if (argc != 5) { |
| 444 |
goto on_error; |
| 445 |
} else { |
| 446 |
pj_bool_t on = (strcmp(argv[3], "on") == 0); |
| 447 |
int dev_id = atoi(argv[4]); |
| 448 |
if (on) { |
| 449 |
pjsua_vid_preview_param param; |
| 450 |
|
| 451 |
pjsua_vid_preview_param_default(¶m); |
| 452 |
param.wnd_flags = PJMEDIA_VID_DEV_WND_BORDER | |
| 453 |
PJMEDIA_VID_DEV_WND_RESIZABLE; |
| 454 |
pjsua_vid_preview_start(dev_id, ¶m); |
| 455 |
arrange_window(pjsua_vid_preview_get_win(dev_id)); |
| 456 |
} else { |
| 457 |
pjsua_vid_win_id wid; |
| 458 |
wid = pjsua_vid_preview_get_win(dev_id); |
| 459 |
if (wid != PJSUA_INVALID_ID) { |
| 460 |
|
| 461 |
|
| 462 |
pjsua_vid_win_set_show(wid, PJ_FALSE); |
| 463 |
pjsua_vid_preview_stop(dev_id); |
| 464 |
} |
| 465 |
} |
| 466 |
} |
| 467 |
} else |
| 468 |
goto on_error; |
| 469 |
} else if (strcmp(argv[1], "win")==0) { |
| 470 |
pj_status_t status = PJ_SUCCESS; |
| 471 |
|
| 472 |
if (argc==3 && strcmp(argv[2], "list")==0) { |
| 473 |
pjsua_vid_win_id wids[PJSUA_MAX_VID_WINS]; |
| 474 |
unsigned i, cnt = PJ_ARRAY_SIZE(wids); |
| 475 |
|
| 476 |
pjsua_vid_enum_wins(wids, &cnt); |
| 477 |
|
| 478 |
PJ_LOG(3,(THIS_FILE, "Found %d video windows:", cnt)); |
| 479 |
PJ_LOG(3,(THIS_FILE, "WID show pos size")); |
| 480 |
PJ_LOG(3,(THIS_FILE, "------------------------------")); |
| 481 |
for (i = 0; i < cnt; ++i) { |
| 482 |
pjsua_vid_win_info wi; |
| 483 |
pjsua_vid_win_get_info(wids[i], &wi); |
| 484 |
PJ_LOG(3,(THIS_FILE, "%3d %c (%d,%d) %dx%d", |
| 485 |
wids[i], (wi.show?'Y':'N'), wi.pos.x, wi.pos.y, |
| 486 |
wi.size.w, wi.size.h)); |
| 487 |
} |
| 488 |
} else if (argc==4 && (strcmp(argv[2], "show")==0 || |
| 489 |
strcmp(argv[2], "hide")==0)) |
| 490 |
{ |
| 491 |
pj_bool_t show = (strcmp(argv[2], "show")==0); |
| 492 |
pjsua_vid_win_id wid = atoi(argv[3]); |
| 493 |
status = pjsua_vid_win_set_show(wid, show); |
| 494 |
} else if (argc==6 && strcmp(argv[2], "move")==0) { |
| 495 |
pjsua_vid_win_id wid = atoi(argv[3]); |
| 496 |
pjmedia_coord pos; |
| 497 |
|
| 498 |
pos.x = atoi(argv[4]); |
| 499 |
pos.y = atoi(argv[5]); |
| 500 |
status = pjsua_vid_win_set_pos(wid, &pos); |
| 501 |
} else if (argc==6 && strcmp(argv[2], "resize")==0) { |
| 502 |
pjsua_vid_win_id wid = atoi(argv[3]); |
| 503 |
pjmedia_rect_size size; |
| 504 |
|
| 505 |
size.w = atoi(argv[4]); |
| 506 |
size.h = atoi(argv[5]); |
| 507 |
status = pjsua_vid_win_set_size(wid, &size); |
| 508 |
} else if (argc==3 && strcmp(argv[2], "arrange")==0) { |
| 509 |
arrange_window(PJSUA_INVALID_ID); |
| 510 |
} else if (argc==5 && (strcmp(argv[2], "full")==0)) |
| 511 |
{ |
| 512 |
pjsua_vid_win_id wid = atoi(argv[4]); |
| 513 |
pjmedia_vid_dev_fullscreen_flag mode = PJMEDIA_VID_DEV_WINDOWED; |
| 514 |
if (strcmp(argv[3], "on")==0) |
| 515 |
mode = PJMEDIA_VID_DEV_FULLSCREEN; |
| 516 |
else if (strcmp(argv[3], "dt")==0) |
| 517 |
mode = PJMEDIA_VID_DEV_FULLSCREEN_DESKTOP; |
| 518 |
status = pjsua_vid_win_set_fullscreen(wid, mode); |
| 519 |
} else |
| 520 |
goto on_error; |
| 521 |
|
| 522 |
if (status != PJ_SUCCESS) { |
| 523 |
PJ_PERROR(1,(THIS_FILE, status, "Window operation error")); |
| 524 |
} |
| 525 |
|
| 526 |
} else if (strcmp(argv[1], "codec")==0) { |
| 527 |
pjsua_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; |
| 528 |
unsigned count = PJ_ARRAY_SIZE(ci); |
| 529 |
pj_status_t status; |
| 530 |
|
| 531 |
if (argc==3 && strcmp(argv[2], "list")==0) { |
| 532 |
status = pjsua_vid_enum_codecs(ci, &count); |
| 533 |
if (status != PJ_SUCCESS) { |
| 534 |
PJ_PERROR(1,(THIS_FILE, status, "Error enumerating codecs")); |
| 535 |
} else { |
| 536 |
unsigned i; |
| 537 |
PJ_LOG(3,(THIS_FILE, "Found %d video codecs:", count)); |
| 538 |
PJ_LOG(3,(THIS_FILE, "codec id prio fps bw(kbps) size")); |
| 539 |
PJ_LOG(3,(THIS_FILE, "------------------------------------------")); |
| 540 |
for (i=0; i<count; ++i) { |
| 541 |
pjmedia_vid_codec_param cp; |
| 542 |
pjmedia_video_format_detail *vfd; |
| 543 |
|
| 544 |
status = pjsua_vid_codec_get_param(&ci[i].codec_id, &cp); |
| 545 |
if (status != PJ_SUCCESS) |
| 546 |
continue; |
| 547 |
|
| 548 |
vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, |
| 549 |
PJ_TRUE); |
| 550 |
PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %4d/%4d %dx%d", |
| 551 |
(int)ci[i].codec_id.slen, ci[i].codec_id.ptr, |
| 552 |
13-(int)ci[i].codec_id.slen, " ", |
| 553 |
ci[i].priority, |
| 554 |
(vfd->fps.num*1.0/vfd->fps.denum), |
| 555 |
vfd->avg_bps/1000, vfd->max_bps/1000, |
| 556 |
vfd->size.w, vfd->size.h)); |
| 557 |
} |
| 558 |
} |
| 559 |
} else if (argc==5 && strcmp(argv[2], "prio")==0) { |
| 560 |
pj_str_t cid; |
| 561 |
int prio; |
| 562 |
cid = pj_str(argv[3]); |
| 563 |
prio = atoi(argv[4]); |
| 564 |
status = pjsua_vid_codec_set_priority(&cid, (pj_uint8_t)prio); |
| 565 |
if (status != PJ_SUCCESS) |
| 566 |
PJ_PERROR(1,(THIS_FILE, status, "Set codec priority error")); |
| 567 |
} else if (argc==6 && strcmp(argv[2], "fps")==0) { |
| 568 |
pjmedia_vid_codec_param cp; |
| 569 |
pj_str_t cid; |
| 570 |
int M, N; |
| 571 |
cid = pj_str(argv[3]); |
| 572 |
M = atoi(argv[4]); |
| 573 |
N = atoi(argv[5]); |
| 574 |
status = pjsua_vid_codec_get_param(&cid, &cp); |
| 575 |
if (status == PJ_SUCCESS) { |
| 576 |
cp.enc_fmt.det.vid.fps.num = M; |
| 577 |
cp.enc_fmt.det.vid.fps.denum = N; |
| 578 |
status = pjsua_vid_codec_set_param(&cid, &cp); |
| 579 |
} |
| 580 |
if (status != PJ_SUCCESS) |
| 581 |
PJ_PERROR(1,(THIS_FILE, status, "Set codec framerate error")); |
| 582 |
} else if (argc==6 && strcmp(argv[2], "bw")==0) { |
| 583 |
pjmedia_vid_codec_param cp; |
| 584 |
pj_str_t cid; |
| 585 |
int M, N; |
| 586 |
cid = pj_str(argv[3]); |
| 587 |
M = atoi(argv[4]); |
| 588 |
N = atoi(argv[5]); |
| 589 |
status = pjsua_vid_codec_get_param(&cid, &cp); |
| 590 |
if (status == PJ_SUCCESS) { |
| 591 |
cp.enc_fmt.det.vid.avg_bps = M * 1000; |
| 592 |
cp.enc_fmt.det.vid.max_bps = N * 1000; |
| 593 |
status = pjsua_vid_codec_set_param(&cid, &cp); |
| 594 |
} |
| 595 |
if (status != PJ_SUCCESS) |
| 596 |
PJ_PERROR(1,(THIS_FILE, status, "Set codec bitrate error")); |
| 597 |
} else if (argc==6 && strcmp(argv[2], "size")==0) { |
| 598 |
pjmedia_vid_codec_param cp; |
| 599 |
pj_str_t cid; |
| 600 |
int M, N; |
| 601 |
cid = pj_str(argv[3]); |
| 602 |
M = atoi(argv[4]); |
| 603 |
N = atoi(argv[5]); |
| 604 |
status = pjsua_vid_codec_get_param(&cid, &cp); |
| 605 |
if (status == PJ_SUCCESS) { |
| 606 |
cp.enc_fmt.det.vid.size.w = M; |
| 607 |
cp.enc_fmt.det.vid.size.h = N; |
| 608 |
status = pjsua_vid_codec_set_param(&cid, &cp); |
| 609 |
} |
| 610 |
if (status != PJ_SUCCESS) |
| 611 |
PJ_PERROR(1,(THIS_FILE, status, "Set codec size error")); |
| 612 |
} else |
| 613 |
goto on_error; |
| 614 |
} else if (strcmp(argv[1], "conf")==0) { |
| 615 |
pj_status_t status; |
| 616 |
|
| 617 |
if (argc==3 && strcmp(argv[2], "list")==0) { |
| 618 |
pjsua_conf_port_id id[100]; |
| 619 |
unsigned count = PJ_ARRAY_SIZE(id); |
| 620 |
|
| 621 |
status = pjsua_vid_conf_enum_ports(id, &count); |
| 622 |
if (status != PJ_SUCCESS) { |
| 623 |
PJ_PERROR(1,(THIS_FILE, status, |
| 624 |
"Failed enumerating video conf bridge ports")); |
| 625 |
} else { |
| 626 |
unsigned i; |
| 627 |
printf(" Video conference has %d ports:\n", count); |
| 628 |
printf(" id name format rx-from tx-to \n"); |
| 629 |
printf(" ------------------------------------------------------------------\n"); |
| 630 |
for (i=0; i<count; ++i) { |
| 631 |
char li_list[PJSUA_MAX_CALLS*4]; |
| 632 |
char tr_list[PJSUA_MAX_CALLS*4]; |
| 633 |
char s[32]; |
| 634 |
unsigned j; |
| 635 |
pjsua_vid_conf_port_info info; |
| 636 |
pjmedia_rect_size *size; |
| 637 |
pjmedia_ratio *fps; |
| 638 |
|
| 639 |
pjsua_vid_conf_get_port_info(id[i], &info); |
| 640 |
size = &info.format.det.vid.size; |
| 641 |
fps = &info.format.det.vid.fps; |
| 642 |
|
| 643 |
li_list[0] = '\0'; |
| 644 |
for (j=0; j<info.listener_cnt; ++j) { |
| 645 |
char str_info[10]; |
| 646 |
pj_ansi_snprintf(str_info, sizeof(str_info), "%d%s", |
| 647 |
info.listeners[j], |
| 648 |
(j==info.listener_cnt-1)?"":","); |
| 649 |
pj_ansi_strxcat(li_list, str_info, sizeof(li_list)); |
| 650 |
} |
| 651 |
tr_list[0] = '\0'; |
| 652 |
for (j=0; j<info.transmitter_cnt; ++j) { |
| 653 |
char str_info[10]; |
| 654 |
pj_ansi_snprintf(str_info, sizeof(str_info), "%d%s", |
| 655 |
info.transmitters[j], |
| 656 |
(j==info.transmitter_cnt-1)?"":","); |
| 657 |
pj_ansi_strxcat(tr_list, str_info, sizeof(tr_list)); |
| 658 |
} |
| 659 |
pjmedia_fourcc_name(info.format.id, s); |
| 660 |
s[4] = ' '; |
| 661 |
pj_ansi_snprintf(s+5, sizeof(s)-5, "%dx%d@%.1f", |
| 662 |
size->w, size->h, |
| 663 |
(float)(fps->num*1.0/fps->denum)); |
| 664 |
printf("%3d %.*s%.*s %s%.*s %s%.*s %s\n", |
| 665 |
id[i], |
| 666 |
(int)info.name.slen, info.name.ptr, |
| 667 |
22-(int)info.name.slen, " ", |
| 668 |
s, |
| 669 |
20-(int)pj_ansi_strlen(s), " ", |
| 670 |
tr_list, |
| 671 |
12-(int)pj_ansi_strlen(tr_list), " ", |
| 672 |
li_list); |
| 673 |
} |
| 674 |
} |
| 675 |
} else if (argc==5 && strcmp(argv[2], "cc")==0) { |
| 676 |
int P, Q; |
| 677 |
P = atoi(argv[3]); |
| 678 |
Q = atoi(argv[4]); |
| 679 |
pjsua_vid_conf_connect(P, Q, NULL); |
| 680 |
} else if (argc==5 && strcmp(argv[2], "cd")==0) { |
| 681 |
int P, Q; |
| 682 |
P = atoi(argv[3]); |
| 683 |
Q = atoi(argv[4]); |
| 684 |
pjsua_vid_conf_disconnect(P, Q); |
| 685 |
} else { |
| 686 |
goto on_error; |
| 687 |
} |
| 688 |
} else |
| 689 |
goto on_error; |
| 690 |
|
| 691 |
return; |
| 692 |
|
| 693 |
on_error: |
| 694 |
PJ_LOG(1,(THIS_FILE, "Invalid command, use 'vid help'")); |
| 695 |
} |
| 696 |
|
| 697 |
#endif |
| 698 |
|
| 699 |
|
| 700 |
static void ui_make_new_call() |
| 701 |
{ |
| 702 |
char buf[128]; |
| 703 |
pjsua_msg_data msg_data_; |
| 704 |
input_result result; |
| 705 |
pj_str_t tmp; |
| 706 |
pj_bool_t loop = PJ_FALSE; |
| 707 |
|
| 708 |
printf("(You currently have %d calls)\n", pjsua_call_get_count()); |
| 709 |
|
| 710 |
ui_input_url("Make call", buf, sizeof(buf), &result, PJ_TRUE); |
| 711 |
do { |
| 712 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 713 |
if (result.nb_result == -1) { |
| 714 |
loop = PJ_TRUE; |
| 715 |
result.nb_result = 1; |
| 716 |
} |
| 717 |
if (result.nb_result > (int)pjsua_get_buddy_count()) break; |
| 718 |
|
| 719 |
if (result.nb_result == 0) { |
| 720 |
puts("You can't do that with make call!"); |
| 721 |
return; |
| 722 |
} else { |
| 723 |
pjsua_buddy_info binfo; |
| 724 |
pjsua_buddy_get_info(result.nb_result-1, &binfo); |
| 725 |
tmp.ptr = buf; |
| 726 |
pj_strncpy(&tmp, &binfo.uri, sizeof(buf)); |
| 727 |
} |
| 728 |
|
| 729 |
} else if (result.uri_result) { |
| 730 |
tmp = pj_str(result.uri_result); |
| 731 |
} else { |
| 732 |
tmp.slen = 0; |
| 733 |
} |
| 734 |
|
| 735 |
pjsua_msg_data_init(&msg_data_); |
| 736 |
TEST_MULTIPART(&msg_data_); |
| 737 |
if (app_config.enable_loam) { |
| 738 |
call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; |
| 739 |
} |
| 740 |
pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, |
| 741 |
&msg_data_, ¤t_call); |
| 742 |
|
| 743 |
result.nb_result++; |
| 744 |
} while (loop); |
| 745 |
} |
| 746 |
|
| 747 |
static void ui_make_multi_call() |
| 748 |
{ |
| 749 |
char menuin[32]; |
| 750 |
int count; |
| 751 |
char buf[128]; |
| 752 |
input_result result; |
| 753 |
pj_str_t tmp; |
| 754 |
int i; |
| 755 |
|
| 756 |
printf("(You currently have %d calls)\n", pjsua_call_get_count()); |
| 757 |
|
| 758 |
if (!simple_input("Number of calls", menuin, sizeof(menuin))) |
| 759 |
return; |
| 760 |
|
| 761 |
count = my_atoi(menuin); |
| 762 |
if (count < 1) |
| 763 |
return; |
| 764 |
|
| 765 |
ui_input_url("Make call", buf, sizeof(buf), &result, PJ_FALSE); |
| 766 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 767 |
pjsua_buddy_info binfo; |
| 768 |
if (result.nb_result == -1 || result.nb_result == 0) { |
| 769 |
puts("You can't do that with make call!"); |
| 770 |
return; |
| 771 |
} |
| 772 |
pjsua_buddy_get_info(result.nb_result-1, &binfo); |
| 773 |
tmp.ptr = buf; |
| 774 |
pj_strncpy(&tmp, &binfo.uri, sizeof(buf)); |
| 775 |
} else { |
| 776 |
tmp = pj_str(result.uri_result); |
| 777 |
} |
| 778 |
|
| 779 |
if (app_config.enable_loam) { |
| 780 |
call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; |
| 781 |
} |
| 782 |
|
| 783 |
for (i=0; i<my_atoi(menuin); ++i) { |
| 784 |
pj_status_t status; |
| 785 |
|
| 786 |
status = pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, |
| 787 |
NULL, NULL); |
| 788 |
if (status != PJ_SUCCESS) |
| 789 |
break; |
| 790 |
} |
| 791 |
} |
| 792 |
|
| 793 |
static void ui_detect_nat_type() |
| 794 |
{ |
| 795 |
int i = pjsua_detect_nat_type(); |
| 796 |
if (i != PJ_SUCCESS) |
| 797 |
pjsua_perror(THIS_FILE, "Error", i); |
| 798 |
} |
| 799 |
|
| 800 |
static void ui_send_instant_message() |
| 801 |
{ |
| 802 |
char *uri = NULL; |
| 803 |
|
| 804 |
int i = -1; |
| 805 |
input_result result; |
| 806 |
char buf[128]; |
| 807 |
char text[128]; |
| 808 |
pj_str_t tmp; |
| 809 |
|
| 810 |
|
| 811 |
ui_input_url("Send IM to", buf, sizeof(buf), &result, PJ_FALSE); |
| 812 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 813 |
|
| 814 |
if (result.nb_result == -1) { |
| 815 |
puts("You can't send broadcast IM like that!"); |
| 816 |
return; |
| 817 |
|
| 818 |
} else if (result.nb_result == 0) { |
| 819 |
i = current_call; |
| 820 |
} else { |
| 821 |
pjsua_buddy_info binfo; |
| 822 |
pjsua_buddy_get_info(result.nb_result-1, &binfo); |
| 823 |
tmp.ptr = buf; |
| 824 |
pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(buf)); |
| 825 |
uri = buf; |
| 826 |
} |
| 827 |
|
| 828 |
} else if (result.uri_result) { |
| 829 |
uri = result.uri_result; |
| 830 |
} |
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
if (!app_config.no_mci) { |
| 835 |
if (i != -1) |
| 836 |
pjsua_call_send_typing_ind(i, PJ_TRUE, NULL); |
| 837 |
else { |
| 838 |
pj_str_t tmp_uri = pj_str(uri); |
| 839 |
pjsua_im_typing(current_acc, &tmp_uri, PJ_TRUE, NULL); |
| 840 |
} |
| 841 |
} |
| 842 |
|
| 843 |
|
| 844 |
if (!simple_input("Message", text, sizeof(text))) { |
| 845 |
if (!app_config.no_mci) { |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
if (i != -1) |
| 851 |
pjsua_call_send_typing_ind(i, PJ_FALSE, NULL); |
| 852 |
else { |
| 853 |
pj_str_t tmp_uri = pj_str(uri); |
| 854 |
pjsua_im_typing(current_acc, &tmp_uri, PJ_FALSE, NULL); |
| 855 |
} |
| 856 |
return; |
| 857 |
} |
| 858 |
} |
| 859 |
|
| 860 |
tmp = pj_str(text); |
| 861 |
|
| 862 |
|
| 863 |
if (i != -1) |
| 864 |
pjsua_call_send_im(i, NULL, &tmp, NULL, NULL); |
| 865 |
else { |
| 866 |
pj_str_t tmp_uri = pj_str(uri); |
| 867 |
pjsua_im_send(current_acc, &tmp_uri, NULL, &tmp, NULL, NULL); |
| 868 |
} |
| 869 |
} |
| 870 |
|
| 871 |
static void ui_answer_call() |
| 872 |
{ |
| 873 |
pjsua_call_info call_info; |
| 874 |
char buf[128]; |
| 875 |
pjsua_msg_data msg_data_; |
| 876 |
|
| 877 |
if (current_call != -1) { |
| 878 |
pjsua_call_get_info(current_call, &call_info); |
| 879 |
} else { |
| 880 |
|
| 881 |
call_info.role = PJSIP_ROLE_UAC; |
| 882 |
call_info.state = PJSIP_INV_STATE_DISCONNECTED; |
| 883 |
} |
| 884 |
|
| 885 |
if (current_call == -1 || |
| 886 |
call_info.role != PJSIP_ROLE_UAS || |
| 887 |
call_info.state >= PJSIP_INV_STATE_CONNECTING) |
| 888 |
{ |
| 889 |
puts("No pending incoming call"); |
| 890 |
fflush(stdout); |
| 891 |
return; |
| 892 |
|
| 893 |
} else { |
| 894 |
int st_code; |
| 895 |
char contact[120]; |
| 896 |
pj_str_t hname = { "Contact", 7 }; |
| 897 |
pj_str_t hvalue; |
| 898 |
pjsip_generic_string_hdr hcontact; |
| 899 |
|
| 900 |
if (!simple_input("Answer with code (100-699)", buf, sizeof(buf))) |
| 901 |
return; |
| 902 |
|
| 903 |
st_code = my_atoi(buf); |
| 904 |
if (st_code < 100) |
| 905 |
return; |
| 906 |
|
| 907 |
pjsua_msg_data_init(&msg_data_); |
| 908 |
|
| 909 |
if (st_code/100 == 3) { |
| 910 |
if (!simple_input("Enter URL to be put in Contact", |
| 911 |
contact, sizeof(contact))) |
| 912 |
return; |
| 913 |
hvalue = pj_str(contact); |
| 914 |
pjsip_generic_string_hdr_init2(&hcontact, &hname, &hvalue); |
| 915 |
|
| 916 |
pj_list_push_back(&msg_data_.hdr_list, &hcontact); |
| 917 |
} |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
if (current_call == -1) { |
| 925 |
puts("Call has been disconnected"); |
| 926 |
fflush(stdout); |
| 927 |
return; |
| 928 |
} |
| 929 |
|
| 930 |
pjsua_call_answer2(current_call, &call_opt, st_code, NULL, &msg_data_); |
| 931 |
} |
| 932 |
} |
| 933 |
|
| 934 |
static void ui_hangup_call(char menuin[]) |
| 935 |
{ |
| 936 |
if (current_call == -1) { |
| 937 |
puts("No current call"); |
| 938 |
fflush(stdout); |
| 939 |
return; |
| 940 |
|
| 941 |
} else if (menuin[1] == 'a') { |
| 942 |
|
| 943 |
pjsua_call_hangup_all(); |
| 944 |
} else { |
| 945 |
|
| 946 |
pjsua_call_hangup(current_call, 0, NULL, NULL); |
| 947 |
} |
| 948 |
} |
| 949 |
|
| 950 |
static void ui_cycle_dialog(char menuin[]) |
| 951 |
{ |
| 952 |
if (menuin[0] == ']') { |
| 953 |
find_next_call(); |
| 954 |
|
| 955 |
} else { |
| 956 |
find_prev_call(); |
| 957 |
} |
| 958 |
|
| 959 |
if (current_call != -1) { |
| 960 |
pjsua_call_info call_info; |
| 961 |
|
| 962 |
pjsua_call_get_info(current_call, &call_info); |
| 963 |
PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", |
| 964 |
(int)call_info.remote_info.slen, |
| 965 |
call_info.remote_info.ptr)); |
| 966 |
|
| 967 |
} else { |
| 968 |
PJ_LOG(3,(THIS_FILE,"No current dialog")); |
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
static void ui_cycle_account() |
| 973 |
{ |
| 974 |
int i; |
| 975 |
char buf[128]; |
| 976 |
|
| 977 |
if (!simple_input("Enter account ID to select", buf, sizeof(buf))) |
| 978 |
return; |
| 979 |
|
| 980 |
i = my_atoi(buf); |
| 981 |
if (pjsua_acc_is_valid(i)) { |
| 982 |
pjsua_acc_set_default(i); |
| 983 |
PJ_LOG(3,(THIS_FILE, "Current account changed to %d", i)); |
| 984 |
} else { |
| 985 |
PJ_LOG(3,(THIS_FILE, "Invalid account id %d", i)); |
| 986 |
} |
| 987 |
} |
| 988 |
|
| 989 |
static void ui_add_buddy() |
| 990 |
{ |
| 991 |
char buf[128]; |
| 992 |
pjsua_buddy_config buddy_cfg; |
| 993 |
pjsua_buddy_id buddy_id; |
| 994 |
pj_status_t status; |
| 995 |
|
| 996 |
if (!simple_input("Enter buddy's URI:", buf, sizeof(buf))) |
| 997 |
return; |
| 998 |
|
| 999 |
if (pjsua_verify_url(buf) != PJ_SUCCESS) { |
| 1000 |
printf("Invalid URI '%s'\n", buf); |
| 1001 |
return; |
| 1002 |
} |
| 1003 |
|
| 1004 |
pj_bzero(&buddy_cfg, sizeof(pjsua_buddy_config)); |
| 1005 |
|
| 1006 |
buddy_cfg.uri = pj_str(buf); |
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
status = pjsua_buddy_add(&buddy_cfg, &buddy_id); |
| 1013 |
if (status == PJ_SUCCESS) { |
| 1014 |
printf("New buddy '%s' added at index %d\n", |
| 1015 |
buf, buddy_id+1); |
| 1016 |
} |
| 1017 |
} |
| 1018 |
|
| 1019 |
static void ui_add_account(pjsua_transport_config *rtp_cfg) |
| 1020 |
{ |
| 1021 |
char id[80], registrar[80], realm[80], uname[80], passwd[30]; |
| 1022 |
pjsua_acc_config acc_cfg; |
| 1023 |
pj_status_t status; |
| 1024 |
|
| 1025 |
if (!simple_input("Your SIP URL:", id, sizeof(id))) |
| 1026 |
return; |
| 1027 |
if (!simple_input("URL of the registrar:", registrar, sizeof(registrar))) |
| 1028 |
return; |
| 1029 |
if (!simple_input("Auth Realm:", realm, sizeof(realm))) |
| 1030 |
return; |
| 1031 |
if (!simple_input("Auth Username:", uname, sizeof(uname))) |
| 1032 |
return; |
| 1033 |
if (!simple_input("Auth Password:", passwd, sizeof(passwd))) |
| 1034 |
return; |
| 1035 |
|
| 1036 |
pjsua_acc_config_default(&acc_cfg); |
| 1037 |
acc_cfg.id = pj_str(id); |
| 1038 |
acc_cfg.reg_uri = pj_str(registrar); |
| 1039 |
acc_cfg.cred_count = 1; |
| 1040 |
acc_cfg.cred_info[0].scheme = pjsip_DIGEST_STR; |
| 1041 |
acc_cfg.cred_info[0].realm = pj_str(realm); |
| 1042 |
acc_cfg.cred_info[0].username = pj_str(uname); |
| 1043 |
acc_cfg.cred_info[0].data_type = 0; |
| 1044 |
acc_cfg.cred_info[0].data = pj_str(passwd); |
| 1045 |
|
| 1046 |
acc_cfg.rtp_cfg = *rtp_cfg; |
| 1047 |
acc_cfg.txt_red_level = app_config.txt_red_level; |
| 1048 |
app_config_init_video(&acc_cfg); |
| 1049 |
|
| 1050 |
status = pjsua_acc_add(&acc_cfg, PJ_TRUE, NULL); |
| 1051 |
if (status != PJ_SUCCESS) { |
| 1052 |
pjsua_perror(THIS_FILE, "Error adding new account", status); |
| 1053 |
} |
| 1054 |
} |
| 1055 |
|
| 1056 |
static void ui_delete_buddy() |
| 1057 |
{ |
| 1058 |
char buf[128]; |
| 1059 |
int i; |
| 1060 |
|
| 1061 |
if (!simple_input("Enter buddy ID to delete", buf, sizeof(buf))) |
| 1062 |
return; |
| 1063 |
|
| 1064 |
i = my_atoi(buf) - 1; |
| 1065 |
|
| 1066 |
if (!pjsua_buddy_is_valid(i)) { |
| 1067 |
printf("Invalid buddy id %d\n", i); |
| 1068 |
} else { |
| 1069 |
pjsua_buddy_del(i); |
| 1070 |
printf("Buddy %d deleted\n", i); |
| 1071 |
} |
| 1072 |
} |
| 1073 |
|
| 1074 |
static void ui_delete_account() |
| 1075 |
{ |
| 1076 |
char buf[128]; |
| 1077 |
int i; |
| 1078 |
|
| 1079 |
if (!simple_input("Enter account ID to delete", buf, sizeof(buf))) |
| 1080 |
return; |
| 1081 |
|
| 1082 |
i = my_atoi(buf); |
| 1083 |
|
| 1084 |
if (!pjsua_acc_is_valid(i)) { |
| 1085 |
printf("Invalid account id %d\n", i); |
| 1086 |
} else { |
| 1087 |
pjsua_acc_del(i); |
| 1088 |
printf("Account %d deleted\n", i); |
| 1089 |
} |
| 1090 |
} |
| 1091 |
|
| 1092 |
static void ui_call_hold() |
| 1093 |
{ |
| 1094 |
if (current_call != -1) { |
| 1095 |
pjsua_call_set_hold(current_call, NULL); |
| 1096 |
} else { |
| 1097 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1098 |
} |
| 1099 |
} |
| 1100 |
|
| 1101 |
static void ui_call_reinvite() |
| 1102 |
{ |
| 1103 |
call_opt.flag |= PJSUA_CALL_UNHOLD; |
| 1104 |
pjsua_call_reinvite2(current_call, &call_opt, NULL); |
| 1105 |
} |
| 1106 |
|
| 1107 |
static void ui_send_update() |
| 1108 |
{ |
| 1109 |
if (current_call != -1) { |
| 1110 |
if (app_config.enable_loam) { |
| 1111 |
call_opt.flag |= PJSUA_CALL_NO_SDP_OFFER; |
| 1112 |
} |
| 1113 |
pjsua_call_update2(current_call, &call_opt, NULL); |
| 1114 |
} else { |
| 1115 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1116 |
} |
| 1117 |
} |
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
static void ui_manage_codec_prio() |
| 1123 |
{ |
| 1124 |
pjsua_codec_info c[32]; |
| 1125 |
unsigned i, count = PJ_ARRAY_SIZE(c); |
| 1126 |
char input[32]; |
| 1127 |
char *codec, *prio; |
| 1128 |
pj_str_t id; |
| 1129 |
int new_prio; |
| 1130 |
pj_status_t status; |
| 1131 |
|
| 1132 |
printf("List of audio codecs:\n"); |
| 1133 |
pjsua_enum_codecs(c, &count); |
| 1134 |
for (i=0; i<count; ++i) { |
| 1135 |
printf(" %d\t%.*s\n", c[i].priority, (int)c[i].codec_id.slen, |
| 1136 |
c[i].codec_id.ptr); |
| 1137 |
} |
| 1138 |
|
| 1139 |
#if PJSUA_HAS_VIDEO |
| 1140 |
puts(""); |
| 1141 |
printf("List of video codecs:\n"); |
| 1142 |
pjsua_vid_enum_codecs(c, &count); |
| 1143 |
for (i=0; i<count; ++i) { |
| 1144 |
printf(" %d\t%.*s%s%.*s\n", c[i].priority, |
| 1145 |
(int)c[i].codec_id.slen, |
| 1146 |
c[i].codec_id.ptr, |
| 1147 |
c[i].desc.slen? " - ":"", |
| 1148 |
(int)c[i].desc.slen, |
| 1149 |
c[i].desc.ptr); |
| 1150 |
} |
| 1151 |
#endif |
| 1152 |
|
| 1153 |
puts(""); |
| 1154 |
puts("Enter codec id and its new priority (e.g. \"speex/16000 200\", " |
| 1155 |
"""\"H263 200\"),"); |
| 1156 |
puts("or empty to cancel."); |
| 1157 |
|
| 1158 |
printf("Codec name (\"*\" for all) and priority: "); |
| 1159 |
if (fgets(input, sizeof(input), stdin) == NULL) |
| 1160 |
return; |
| 1161 |
if (input[0]=='\r' || input[0]=='\n') { |
| 1162 |
puts("Done"); |
| 1163 |
return; |
| 1164 |
} |
| 1165 |
|
| 1166 |
codec = strtok(input, " \t\r\n"); |
| 1167 |
prio = strtok(NULL, " \r\n"); |
| 1168 |
|
| 1169 |
if (!codec || !prio) { |
| 1170 |
puts("Invalid input"); |
| 1171 |
return; |
| 1172 |
} |
| 1173 |
|
| 1174 |
new_prio = atoi(prio); |
| 1175 |
if (new_prio < 0) |
| 1176 |
new_prio = 0; |
| 1177 |
else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) |
| 1178 |
new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; |
| 1179 |
|
| 1180 |
status = pjsua_codec_set_priority(pj_cstr(&id, codec), |
| 1181 |
(pj_uint8_t)new_prio); |
| 1182 |
#if PJSUA_HAS_VIDEO |
| 1183 |
if (status != PJ_SUCCESS) { |
| 1184 |
status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec), |
| 1185 |
(pj_uint8_t)new_prio); |
| 1186 |
} |
| 1187 |
#endif |
| 1188 |
if (status != PJ_SUCCESS) |
| 1189 |
pjsua_perror(THIS_FILE, "Error setting codec priority", status); |
| 1190 |
} |
| 1191 |
|
| 1192 |
static void ui_call_transfer(pj_bool_t no_refersub) |
| 1193 |
{ |
| 1194 |
if (current_call == -1) { |
| 1195 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1196 |
} else { |
| 1197 |
int call = current_call; |
| 1198 |
char buf[128]; |
| 1199 |
pjsip_generic_string_hdr refer_sub; |
| 1200 |
pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 }; |
| 1201 |
pj_str_t STR_FALSE = { "false", 5 }; |
| 1202 |
pjsua_call_info ci; |
| 1203 |
input_result result; |
| 1204 |
pjsua_msg_data msg_data_; |
| 1205 |
|
| 1206 |
pjsua_call_get_info(current_call, &ci); |
| 1207 |
printf("Transferring current call [%d] %.*s\n", current_call, |
| 1208 |
(int)ci.remote_info.slen, ci.remote_info.ptr); |
| 1209 |
|
| 1210 |
ui_input_url("Transfer to URL", buf, sizeof(buf), &result, PJ_FALSE); |
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
if (call != current_call) { |
| 1215 |
puts("Call has been disconnected"); |
| 1216 |
return; |
| 1217 |
} |
| 1218 |
|
| 1219 |
pjsua_msg_data_init(&msg_data_); |
| 1220 |
if (no_refersub) { |
| 1221 |
|
| 1222 |
pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, |
| 1223 |
&STR_FALSE); |
| 1224 |
pj_list_push_back(&msg_data_.hdr_list, &refer_sub); |
| 1225 |
} |
| 1226 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 1227 |
if (result.nb_result == -1 || result.nb_result == 0) { |
| 1228 |
puts("You can't do that with transfer call!"); |
| 1229 |
} else { |
| 1230 |
pjsua_buddy_info binfo; |
| 1231 |
pjsua_buddy_get_info(result.nb_result-1, &binfo); |
| 1232 |
pjsua_call_xfer( current_call, &binfo.uri, &msg_data_); |
| 1233 |
} |
| 1234 |
|
| 1235 |
} else if (result.uri_result) { |
| 1236 |
pj_str_t tmp; |
| 1237 |
tmp = pj_str(result.uri_result); |
| 1238 |
pjsua_call_xfer( current_call, &tmp, &msg_data_); |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
|
| 1243 |
static void ui_call_transfer_replaces(pj_bool_t no_refersub) |
| 1244 |
{ |
| 1245 |
if (current_call == -1) { |
| 1246 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1247 |
} else { |
| 1248 |
int call = current_call; |
| 1249 |
int dst_call; |
| 1250 |
pjsip_generic_string_hdr refer_sub; |
| 1251 |
pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 }; |
| 1252 |
pj_str_t STR_FALSE = { "false", 5 }; |
| 1253 |
pjsua_call_id ids[PJSUA_MAX_CALLS]; |
| 1254 |
pjsua_call_info ci; |
| 1255 |
pjsua_msg_data msg_data_; |
| 1256 |
char buf[128]; |
| 1257 |
unsigned i, count; |
| 1258 |
|
| 1259 |
count = PJ_ARRAY_SIZE(ids); |
| 1260 |
pjsua_enum_calls(ids, &count); |
| 1261 |
|
| 1262 |
if (count <= 1) { |
| 1263 |
puts("There are no other calls"); |
| 1264 |
return; |
| 1265 |
} |
| 1266 |
|
| 1267 |
pjsua_call_get_info(current_call, &ci); |
| 1268 |
printf("Transfer call [%d] %.*s to one of the following:\n", |
| 1269 |
current_call, |
| 1270 |
(int)ci.remote_info.slen, ci.remote_info.ptr); |
| 1271 |
|
| 1272 |
for (i=0; i<count; ++i) { |
| 1273 |
pjsua_call_info call_info; |
| 1274 |
|
| 1275 |
if (ids[i] == call) |
| 1276 |
continue; |
| 1277 |
|
| 1278 |
pjsua_call_get_info(ids[i], &call_info); |
| 1279 |
printf("%d %.*s [%.*s]\n", |
| 1280 |
ids[i], |
| 1281 |
(int)call_info.remote_info.slen, |
| 1282 |
call_info.remote_info.ptr, |
| 1283 |
(int)call_info.state_text.slen, |
| 1284 |
call_info.state_text.ptr); |
| 1285 |
} |
| 1286 |
|
| 1287 |
if (!simple_input("Enter call number to be replaced", buf, sizeof(buf))) |
| 1288 |
return; |
| 1289 |
|
| 1290 |
dst_call = my_atoi(buf); |
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
if (call != current_call) { |
| 1295 |
puts("Call has been disconnected"); |
| 1296 |
return; |
| 1297 |
} |
| 1298 |
|
| 1299 |
|
| 1300 |
if (dst_call == call) { |
| 1301 |
puts("Destination call number must not be the same " |
| 1302 |
"as the call being transferred"); |
| 1303 |
return; |
| 1304 |
} |
| 1305 |
if (dst_call >= PJSUA_MAX_CALLS) { |
| 1306 |
puts("Invalid destination call number"); |
| 1307 |
return; |
| 1308 |
} |
| 1309 |
if (!pjsua_call_is_active(dst_call)) { |
| 1310 |
puts("Invalid destination call number"); |
| 1311 |
return; |
| 1312 |
} |
| 1313 |
|
| 1314 |
pjsua_msg_data_init(&msg_data_); |
| 1315 |
if (no_refersub) { |
| 1316 |
|
| 1317 |
pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, |
| 1318 |
&STR_FALSE); |
| 1319 |
pj_list_push_back(&msg_data_.hdr_list, &refer_sub); |
| 1320 |
} |
| 1321 |
|
| 1322 |
pjsua_call_xfer_replaces(call, dst_call, |
| 1323 |
PJSUA_XFER_NO_REQUIRE_REPLACES, |
| 1324 |
&msg_data_); |
| 1325 |
} |
| 1326 |
} |
| 1327 |
|
| 1328 |
static void ui_send_dtmf_2833() |
| 1329 |
{ |
| 1330 |
if (current_call == -1) { |
| 1331 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1332 |
} else if (!pjsua_call_has_media(current_call)) { |
| 1333 |
PJ_LOG(3,(THIS_FILE, "Media is not established yet!")); |
| 1334 |
} else { |
| 1335 |
pj_str_t digits; |
| 1336 |
int call = current_call; |
| 1337 |
pj_status_t status; |
| 1338 |
char buf[128]; |
| 1339 |
|
| 1340 |
#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 |
| 1341 |
if (!simple_input("DTMF strings to send (0-9*R#A-B)", buf, |
| 1342 |
sizeof(buf))) |
| 1343 |
#else |
| 1344 |
if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, |
| 1345 |
sizeof(buf))) |
| 1346 |
#endif |
| 1347 |
{ |
| 1348 |
return; |
| 1349 |
} |
| 1350 |
|
| 1351 |
if (call != current_call) { |
| 1352 |
puts("Call has been disconnected"); |
| 1353 |
return; |
| 1354 |
} |
| 1355 |
|
| 1356 |
digits = pj_str(buf); |
| 1357 |
status = pjsua_call_dial_dtmf(current_call, &digits); |
| 1358 |
if (status != PJ_SUCCESS) { |
| 1359 |
pjsua_perror(THIS_FILE, "Unable to send DTMF", status); |
| 1360 |
} else { |
| 1361 |
puts("DTMF digits enqueued for transmission"); |
| 1362 |
} |
| 1363 |
} |
| 1364 |
} |
| 1365 |
|
| 1366 |
static void ui_send_dtmf_info() |
| 1367 |
{ |
| 1368 |
if (current_call == -1) { |
| 1369 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1370 |
} else { |
| 1371 |
int call = current_call; |
| 1372 |
pj_status_t status; |
| 1373 |
char buf[128]; |
| 1374 |
pjsua_call_send_dtmf_param param; |
| 1375 |
|
| 1376 |
if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, |
| 1377 |
sizeof(buf))) |
| 1378 |
{ |
| 1379 |
return; |
| 1380 |
} |
| 1381 |
|
| 1382 |
if (call != current_call) { |
| 1383 |
puts("Call has been disconnected"); |
| 1384 |
return; |
| 1385 |
} |
| 1386 |
pjsua_call_send_dtmf_param_default(¶m); |
| 1387 |
param.digits = pj_str(buf); |
| 1388 |
param.method = PJSUA_DTMF_METHOD_SIP_INFO; |
| 1389 |
status = pjsua_call_send_dtmf(current_call, ¶m); |
| 1390 |
if (status != PJ_SUCCESS) { |
| 1391 |
pjsua_perror(THIS_FILE, "Error sending DTMF", status); |
| 1392 |
} |
| 1393 |
} |
| 1394 |
} |
| 1395 |
|
| 1396 |
static void ui_send_arbitrary_request() |
| 1397 |
{ |
| 1398 |
char text[128]; |
| 1399 |
char buf[128]; |
| 1400 |
char *uri; |
| 1401 |
input_result result; |
| 1402 |
pj_str_t tmp; |
| 1403 |
|
| 1404 |
if (pjsua_acc_get_count() == 0) { |
| 1405 |
puts("Sorry, need at least one account configured"); |
| 1406 |
return; |
| 1407 |
} |
| 1408 |
|
| 1409 |
puts("Send arbitrary request to remote host"); |
| 1410 |
|
| 1411 |
|
| 1412 |
if (!simple_input("Request method:",text,sizeof(text))) |
| 1413 |
return; |
| 1414 |
|
| 1415 |
|
| 1416 |
uri = NULL; |
| 1417 |
ui_input_url("Destination URI", buf, sizeof(buf), &result, PJ_FALSE); |
| 1418 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 1419 |
|
| 1420 |
if (result.nb_result == -1) { |
| 1421 |
puts("Sorry you can't do that!"); |
| 1422 |
return; |
| 1423 |
} else if (result.nb_result == 0) { |
| 1424 |
uri = NULL; |
| 1425 |
if (current_call == PJSUA_INVALID_ID) { |
| 1426 |
puts("No current call"); |
| 1427 |
return; |
| 1428 |
} |
| 1429 |
} else { |
| 1430 |
pjsua_buddy_info binfo; |
| 1431 |
pjsua_buddy_get_info(result.nb_result-1, &binfo); |
| 1432 |
tmp.ptr = buf; |
| 1433 |
pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(buf)); |
| 1434 |
uri = buf; |
| 1435 |
} |
| 1436 |
|
| 1437 |
} else if (result.uri_result) { |
| 1438 |
uri = result.uri_result; |
| 1439 |
} else { |
| 1440 |
return; |
| 1441 |
} |
| 1442 |
|
| 1443 |
if (uri) { |
| 1444 |
tmp = pj_str(uri); |
| 1445 |
send_request(text, &tmp); |
| 1446 |
} else { |
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
pj_str_t method = pj_str(text); |
| 1453 |
pjsua_call_send_request(current_call, &method, NULL); |
| 1454 |
} |
| 1455 |
} |
| 1456 |
|
| 1457 |
static void ui_toggle_call_sdp_offer() |
| 1458 |
{ |
| 1459 |
app_config.enable_loam = !app_config.enable_loam; |
| 1460 |
|
| 1461 |
printf("Subsequent calls and UPDATEs will contain SDP offer: "); |
| 1462 |
if (app_config.enable_loam) { |
| 1463 |
printf("NO.\n"); |
| 1464 |
} else { |
| 1465 |
printf("YES.\n"); |
| 1466 |
} |
| 1467 |
} |
| 1468 |
|
| 1469 |
static void ui_echo(char menuin[]) |
| 1470 |
{ |
| 1471 |
if (pj_ansi_strnicmp(menuin, "echo", 4)==0) { |
| 1472 |
pj_str_t tmp; |
| 1473 |
|
| 1474 |
tmp.ptr = menuin+5; |
| 1475 |
tmp.slen = pj_ansi_strlen(menuin)-6; |
| 1476 |
|
| 1477 |
if (tmp.slen < 1) { |
| 1478 |
puts("Usage: echo [0|1]"); |
| 1479 |
return; |
| 1480 |
} |
| 1481 |
cmd_echo = *tmp.ptr != '0' || tmp.slen!=1; |
| 1482 |
} |
| 1483 |
} |
| 1484 |
|
| 1485 |
static void ui_sleep(char menuin[]) |
| 1486 |
{ |
| 1487 |
if (pj_ansi_strnicmp(menuin, "sleep", 5)==0) { |
| 1488 |
pj_str_t tmp; |
| 1489 |
int delay; |
| 1490 |
|
| 1491 |
tmp.ptr = menuin+6; |
| 1492 |
tmp.slen = pj_ansi_strlen(menuin)-7; |
| 1493 |
|
| 1494 |
if (tmp.slen < 1) { |
| 1495 |
puts("Usage: sleep MSEC"); |
| 1496 |
return; |
| 1497 |
} |
| 1498 |
|
| 1499 |
delay = (int)pj_strtoul(&tmp); |
| 1500 |
if (delay < 0) delay = 0; |
| 1501 |
pj_thread_sleep(delay); |
| 1502 |
} |
| 1503 |
} |
| 1504 |
|
| 1505 |
static void ui_subscribe(char menuin[]) |
| 1506 |
{ |
| 1507 |
char buf[128]; |
| 1508 |
input_result result; |
| 1509 |
|
| 1510 |
ui_input_url("(un)Subscribe presence of", buf, sizeof(buf), &result, |
| 1511 |
PJ_TRUE); |
| 1512 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 1513 |
if (result.nb_result == -1) { |
| 1514 |
int i, count; |
| 1515 |
count = pjsua_get_buddy_count(); |
| 1516 |
for (i=0; i<count; ++i) |
| 1517 |
pjsua_buddy_subscribe_pres(i, menuin[0]=='s'); |
| 1518 |
} else if (result.nb_result == 0) { |
| 1519 |
puts("Sorry, can only subscribe to buddy's presence, " |
| 1520 |
"not from existing call"); |
| 1521 |
} else { |
| 1522 |
pjsua_buddy_subscribe_pres(result.nb_result-1, (menuin[0]=='s')); |
| 1523 |
} |
| 1524 |
|
| 1525 |
} else if (result.uri_result) { |
| 1526 |
puts("Sorry, can only subscribe to buddy's presence, " |
| 1527 |
"not arbitrary URL (for now)"); |
| 1528 |
} |
| 1529 |
} |
| 1530 |
|
| 1531 |
static void ui_subscribe_dlg_event(pj_bool_t sub) |
| 1532 |
{ |
| 1533 |
char buf[128]; |
| 1534 |
input_result result; |
| 1535 |
|
| 1536 |
ui_input_url("(un)Subscribe dialog event of", buf, sizeof(buf), &result, |
| 1537 |
PJ_TRUE); |
| 1538 |
if (result.nb_result != PJSUA_APP_NO_NB) { |
| 1539 |
if (result.nb_result == -1) { |
| 1540 |
int i, count; |
| 1541 |
count = pjsua_get_buddy_count(); |
| 1542 |
for (i=0; i<count; ++i) |
| 1543 |
pjsua_buddy_subscribe_dlg_event(i, sub); |
| 1544 |
} else if (result.nb_result == 0) { |
| 1545 |
puts("Sorry, can only subscribe to buddy's dialog event, " |
| 1546 |
"not from existing call"); |
| 1547 |
} else { |
| 1548 |
pjsua_buddy_subscribe_dlg_event(result.nb_result-1, sub); |
| 1549 |
} |
| 1550 |
|
| 1551 |
} else if (result.uri_result) { |
| 1552 |
puts("Sorry, can only subscribe to buddy's dialog event, " |
| 1553 |
"not arbitrary URL (for now)"); |
| 1554 |
} |
| 1555 |
} |
| 1556 |
|
| 1557 |
static void ui_register(char menuin[]) |
| 1558 |
{ |
| 1559 |
switch (menuin[1]) { |
| 1560 |
case 'r': |
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
pjsua_acc_set_registration(current_acc, PJ_TRUE); |
| 1565 |
break; |
| 1566 |
case 'u': |
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
pjsua_acc_set_registration(current_acc, PJ_FALSE); |
| 1571 |
break; |
| 1572 |
} |
| 1573 |
} |
| 1574 |
|
| 1575 |
static void ui_toggle_state() |
| 1576 |
{ |
| 1577 |
pjsua_acc_info acc_info; |
| 1578 |
|
| 1579 |
pjsua_acc_get_info(current_acc, &acc_info); |
| 1580 |
acc_info.online_status = !acc_info.online_status; |
| 1581 |
pjsua_acc_set_online_status(current_acc, acc_info.online_status); |
| 1582 |
printf("Setting %s online status to %s\n", |
| 1583 |
acc_info.acc_uri.ptr, |
| 1584 |
(acc_info.online_status?"online":"offline")); |
| 1585 |
} |
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
static void ui_change_online_status() |
| 1591 |
{ |
| 1592 |
char menuin[32]; |
| 1593 |
pj_bool_t online_status; |
| 1594 |
pjrpid_element elem; |
| 1595 |
int choice; |
| 1596 |
unsigned i; |
| 1597 |
|
| 1598 |
enum { |
| 1599 |
AVAILABLE, BUSY, OTP, IDLE, AWAY, BRB, OFFLINE, OPT_MAX |
| 1600 |
}; |
| 1601 |
|
| 1602 |
struct opt { |
| 1603 |
int id; |
| 1604 |
char *name; |
| 1605 |
} opts[] = { |
| 1606 |
{ AVAILABLE, "Available" }, |
| 1607 |
{ BUSY, "Busy"}, |
| 1608 |
{ OTP, "On the phone"}, |
| 1609 |
{ IDLE, "Idle"}, |
| 1610 |
{ AWAY, "Away"}, |
| 1611 |
{ BRB, "Be right back"}, |
| 1612 |
{ OFFLINE, "Offline"} |
| 1613 |
}; |
| 1614 |
|
| 1615 |
printf("\n" |
| 1616 |
"Choices:\n"); |
| 1617 |
for (i=0; i<(unsigned)PJ_ARRAY_SIZE(opts); ++i) { |
| 1618 |
printf(" %d %s\n", opts[i].id+1, opts[i].name); |
| 1619 |
} |
| 1620 |
|
| 1621 |
if (!simple_input("Select status", menuin, sizeof(menuin))) |
| 1622 |
return; |
| 1623 |
|
| 1624 |
choice = atoi(menuin) - 1; |
| 1625 |
if (choice < 0 || choice >= OPT_MAX) { |
| 1626 |
puts("Invalid selection"); |
| 1627 |
return; |
| 1628 |
} |
| 1629 |
|
| 1630 |
pj_bzero(&elem, sizeof(elem)); |
| 1631 |
elem.type = PJRPID_ELEMENT_TYPE_PERSON; |
| 1632 |
|
| 1633 |
online_status = PJ_TRUE; |
| 1634 |
|
| 1635 |
switch (choice) { |
| 1636 |
case AVAILABLE: |
| 1637 |
break; |
| 1638 |
case BUSY: |
| 1639 |
elem.activity = PJRPID_ACTIVITY_BUSY; |
| 1640 |
elem.note = pj_str("Busy"); |
| 1641 |
break; |
| 1642 |
case OTP: |
| 1643 |
elem.activity = PJRPID_ACTIVITY_BUSY; |
| 1644 |
elem.note = pj_str("On the phone"); |
| 1645 |
break; |
| 1646 |
case IDLE: |
| 1647 |
elem.activity = PJRPID_ACTIVITY_UNKNOWN; |
| 1648 |
elem.note = pj_str("Idle"); |
| 1649 |
break; |
| 1650 |
case AWAY: |
| 1651 |
elem.activity = PJRPID_ACTIVITY_AWAY; |
| 1652 |
elem.note = pj_str("Away"); |
| 1653 |
break; |
| 1654 |
case BRB: |
| 1655 |
elem.activity = PJRPID_ACTIVITY_UNKNOWN; |
| 1656 |
elem.note = pj_str("Be right back"); |
| 1657 |
break; |
| 1658 |
case OFFLINE: |
| 1659 |
online_status = PJ_FALSE; |
| 1660 |
break; |
| 1661 |
} |
| 1662 |
|
| 1663 |
pjsua_acc_set_online_status2(current_acc, online_status, &elem); |
| 1664 |
} |
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
static void ui_conf_list() |
| 1670 |
{ |
| 1671 |
unsigned i, count; |
| 1672 |
pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; |
| 1673 |
|
| 1674 |
printf("Conference ports:\n"); |
| 1675 |
|
| 1676 |
count = PJ_ARRAY_SIZE(id); |
| 1677 |
pjsua_enum_conf_ports(id, &count); |
| 1678 |
|
| 1679 |
for (i=0; i<count; ++i) { |
| 1680 |
char txlist[PJSUA_MAX_CALLS*4+10]; |
| 1681 |
unsigned j; |
| 1682 |
pjsua_conf_port_info info; |
| 1683 |
|
| 1684 |
pjsua_conf_get_port_info(id[i], &info); |
| 1685 |
|
| 1686 |
txlist[0] = '\0'; |
| 1687 |
for (j=0; j<info.listener_cnt; ++j) { |
| 1688 |
char s[10]; |
| 1689 |
pj_ansi_snprintf(s, sizeof(s), "#%d ", info.listeners[j]); |
| 1690 |
pj_ansi_strxcat(txlist, s, sizeof(txlist)); |
| 1691 |
} |
| 1692 |
printf("Port #%02d[%2dKHz/%dms/%d] %20.*s transmitting to: %s\n", |
| 1693 |
info.slot_id, |
| 1694 |
info.clock_rate/1000, |
| 1695 |
info.samples_per_frame*1000/info.channel_count/info.clock_rate, |
| 1696 |
info.channel_count, |
| 1697 |
(int)info.name.slen, |
| 1698 |
info.name.ptr, |
| 1699 |
txlist); |
| 1700 |
|
| 1701 |
} |
| 1702 |
puts(""); |
| 1703 |
} |
| 1704 |
|
| 1705 |
static void ui_conf_connect(char menuin[]) |
| 1706 |
{ |
| 1707 |
char tmp[10], src_port[10], dst_port[10]; |
| 1708 |
pj_status_t status; |
| 1709 |
int cnt; |
| 1710 |
const char *src_title, *dst_title; |
| 1711 |
|
| 1712 |
cnt = sscanf(menuin, "%s %s %s", tmp, src_port, dst_port); |
| 1713 |
|
| 1714 |
if (cnt != 3) { |
| 1715 |
ui_conf_list(); |
| 1716 |
|
| 1717 |
src_title = (menuin[1]=='c'? "Connect src port #": |
| 1718 |
"Disconnect src port #"); |
| 1719 |
dst_title = (menuin[1]=='c'? "To dst port #":"From dst port #"); |
| 1720 |
|
| 1721 |
if (!simple_input(src_title, src_port, sizeof(src_port))) |
| 1722 |
return; |
| 1723 |
|
| 1724 |
if (!simple_input(dst_title, dst_port, sizeof(dst_port))) |
| 1725 |
return; |
| 1726 |
} |
| 1727 |
|
| 1728 |
if (menuin[1]=='c') { |
| 1729 |
status = pjsua_conf_connect(my_atoi(src_port), my_atoi(dst_port)); |
| 1730 |
} else { |
| 1731 |
status = pjsua_conf_disconnect(my_atoi(src_port), my_atoi(dst_port)); |
| 1732 |
} |
| 1733 |
if (status == PJ_SUCCESS) { |
| 1734 |
puts("Success"); |
| 1735 |
} else { |
| 1736 |
puts("ERROR!!"); |
| 1737 |
} |
| 1738 |
} |
| 1739 |
|
| 1740 |
static void ui_adjust_volume() |
| 1741 |
{ |
| 1742 |
char buf[128]; |
| 1743 |
char text[128]; |
| 1744 |
snprintf(buf, sizeof(buf), "Adjust mic level: [%4.1fx] ", |
| 1745 |
app_config.mic_level); |
| 1746 |
if (simple_input(buf,text,sizeof(text))) { |
| 1747 |
char *err; |
| 1748 |
app_config.mic_level = (float)strtod(text, &err); |
| 1749 |
pjsua_conf_adjust_rx_level(0, app_config.mic_level); |
| 1750 |
} |
| 1751 |
snprintf(buf, sizeof(buf), "Adjust speaker level: [%4.1fx] ", |
| 1752 |
app_config.speaker_level); |
| 1753 |
if (simple_input(buf,text,sizeof(text))) { |
| 1754 |
char *err; |
| 1755 |
app_config.speaker_level = (float)strtod(text, &err); |
| 1756 |
pjsua_conf_adjust_tx_level(0, app_config.speaker_level); |
| 1757 |
} |
| 1758 |
} |
| 1759 |
|
| 1760 |
static void ui_dump_call_quality() |
| 1761 |
{ |
| 1762 |
if (current_call != PJSUA_INVALID_ID) { |
| 1763 |
log_call_dump(current_call); |
| 1764 |
} else { |
| 1765 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1766 |
} |
| 1767 |
} |
| 1768 |
|
| 1769 |
static void ui_dump_configuration() |
| 1770 |
{ |
| 1771 |
char settings[2000]; |
| 1772 |
int len; |
| 1773 |
|
| 1774 |
len = write_settings(&app_config, settings, sizeof(settings)); |
| 1775 |
if (len < 1) |
| 1776 |
PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); |
| 1777 |
else |
| 1778 |
PJ_LOG(3,(THIS_FILE, "Dumping configuration (%d bytes):\n%s\n", |
| 1779 |
len, settings)); |
| 1780 |
} |
| 1781 |
|
| 1782 |
static void ui_write_settings(const char *filename) |
| 1783 |
{ |
| 1784 |
char settings[2000]; |
| 1785 |
int len; |
| 1786 |
|
| 1787 |
len = write_settings(&app_config, settings, sizeof(settings)); |
| 1788 |
if (len < 1) |
| 1789 |
PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); |
| 1790 |
else { |
| 1791 |
pj_oshandle_t fd; |
| 1792 |
pj_status_t status; |
| 1793 |
|
| 1794 |
status = pj_file_open(app_config.pool, filename, PJ_O_WRONLY, &fd); |
| 1795 |
if (status != PJ_SUCCESS) { |
| 1796 |
pjsua_perror(THIS_FILE, "Unable to open file", status); |
| 1797 |
} else { |
| 1798 |
pj_ssize_t size = len; |
| 1799 |
pj_file_write(fd, settings, &size); |
| 1800 |
pj_file_close(fd); |
| 1801 |
|
| 1802 |
printf("Settings successfully written to '%s'\n", filename); |
| 1803 |
} |
| 1804 |
} |
| 1805 |
} |
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
static void ui_app_dump(pj_bool_t detail) |
| 1811 |
{ |
| 1812 |
pjsua_dump(detail); |
| 1813 |
} |
| 1814 |
|
| 1815 |
static void ui_call_redirect(char menuin[]) |
| 1816 |
{ |
| 1817 |
if (current_call == PJSUA_INVALID_ID) { |
| 1818 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1819 |
} else { |
| 1820 |
if (!pjsua_call_is_active(current_call)) { |
| 1821 |
PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); |
| 1822 |
} else if (menuin[1] == 'a') { |
| 1823 |
pjsua_call_process_redirect(current_call, |
| 1824 |
PJSIP_REDIRECT_ACCEPT_REPLACE); |
| 1825 |
} else if (menuin[1] == 'A') { |
| 1826 |
pjsua_call_process_redirect(current_call, |
| 1827 |
PJSIP_REDIRECT_ACCEPT); |
| 1828 |
} else if (menuin[1] == 'r') { |
| 1829 |
pjsua_call_process_redirect(current_call, |
| 1830 |
PJSIP_REDIRECT_REJECT); |
| 1831 |
} else { |
| 1832 |
pjsua_call_process_redirect(current_call, |
| 1833 |
PJSIP_REDIRECT_STOP); |
| 1834 |
} |
| 1835 |
} |
| 1836 |
} |
| 1837 |
|
| 1838 |
static void ui_handle_ip_change() |
| 1839 |
{ |
| 1840 |
pjsua_ip_change_param param; |
| 1841 |
pj_status_t status; |
| 1842 |
|
| 1843 |
pjsua_ip_change_param_default(¶m); |
| 1844 |
status = pjsua_handle_ip_change(¶m); |
| 1845 |
if (status != PJ_SUCCESS) { |
| 1846 |
pjsua_perror(THIS_FILE, "IP change failed", status); |
| 1847 |
} |
| 1848 |
} |
| 1849 |
|
| 1850 |
static void ui_send_rtt() |
| 1851 |
{ |
| 1852 |
char buf[100]; |
| 1853 |
pjsua_call_send_text_param param; |
| 1854 |
pj_status_t status; |
| 1855 |
|
| 1856 |
if (current_call == PJSUA_INVALID_ID) { |
| 1857 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 1858 |
return; |
| 1859 |
} |
| 1860 |
|
| 1861 |
if (!simple_input("Enter text to send", buf, sizeof(buf))) |
| 1862 |
return; |
| 1863 |
|
| 1864 |
pjsua_call_send_text_param_default(¶m); |
| 1865 |
param.text = pj_str(buf); |
| 1866 |
status = pjsua_call_send_text(current_call, ¶m); |
| 1867 |
if (status != PJ_SUCCESS) { |
| 1868 |
pjsua_perror(THIS_FILE, "Unable to send text", status); |
| 1869 |
} |
| 1870 |
|
| 1871 |
#if 0 |
| 1872 |
|
| 1873 |
pj_str_t abc = pj_str("abc"); |
| 1874 |
pj_str_t def = pj_str("defgh"); |
| 1875 |
pjsua_call_send_text(current_call, -1, &abc); |
| 1876 |
pjsua_call_send_text(current_call, -1, &def); |
| 1877 |
#endif |
| 1878 |
} |
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
void legacy_main(void) |
| 1884 |
{ |
| 1885 |
char menuin[80]; |
| 1886 |
char buf[128]; |
| 1887 |
|
| 1888 |
keystroke_help(); |
| 1889 |
|
| 1890 |
for (;;) { |
| 1891 |
|
| 1892 |
printf(">>> "); |
| 1893 |
fflush(stdout); |
| 1894 |
|
| 1895 |
if (fgets(menuin, sizeof(menuin), stdin) == NULL) { |
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
#if ((defined(PJ_WIN32) && PJ_WIN32!=0) || \ |
| 1903 |
(defined(PJ_WIN64) && PJ_WIN64!=0)) && \ |
| 1904 |
(!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0) |
| 1905 |
if (freopen ("CONIN$", "r", stdin) == NULL) { |
| 1906 |
#else |
| 1907 |
if (1) { |
| 1908 |
#endif |
| 1909 |
puts("Cannot switch back to console from file redirection"); |
| 1910 |
menuin[0] = 'q'; |
| 1911 |
menuin[1] = '\0'; |
| 1912 |
} else { |
| 1913 |
puts("Switched back to console from file redirection"); |
| 1914 |
continue; |
| 1915 |
} |
| 1916 |
} |
| 1917 |
|
| 1918 |
if (cmd_echo) { |
| 1919 |
printf("%s", menuin); |
| 1920 |
} |
| 1921 |
|
| 1922 |
|
| 1923 |
pjsua_call_setting_default(&call_opt); |
| 1924 |
call_opt.aud_cnt = app_config.aud_cnt; |
| 1925 |
call_opt.vid_cnt = app_config.vid.vid_cnt; |
| 1926 |
call_opt.txt_cnt = app_config.txt_cnt; |
| 1927 |
|
| 1928 |
switch (menuin[0]) { |
| 1929 |
|
| 1930 |
case 'm': |
| 1931 |
|
| 1932 |
ui_make_new_call(); |
| 1933 |
break; |
| 1934 |
|
| 1935 |
case 'M': |
| 1936 |
|
| 1937 |
ui_make_multi_call(); |
| 1938 |
break; |
| 1939 |
|
| 1940 |
case 'n': |
| 1941 |
ui_detect_nat_type(); |
| 1942 |
break; |
| 1943 |
|
| 1944 |
case 'i': |
| 1945 |
|
| 1946 |
ui_send_instant_message(); |
| 1947 |
break; |
| 1948 |
|
| 1949 |
case 'a': |
| 1950 |
ui_answer_call(); |
| 1951 |
break; |
| 1952 |
|
| 1953 |
case 'h': |
| 1954 |
ui_hangup_call(menuin); |
| 1955 |
break; |
| 1956 |
|
| 1957 |
case ']': |
| 1958 |
case '[': |
| 1959 |
|
| 1960 |
|
| 1961 |
|
| 1962 |
ui_cycle_dialog(menuin); |
| 1963 |
break; |
| 1964 |
|
| 1965 |
case '>': |
| 1966 |
case '<': |
| 1967 |
ui_cycle_account(); |
| 1968 |
break; |
| 1969 |
|
| 1970 |
case '+': |
| 1971 |
if (menuin[1] == 'b') { |
| 1972 |
ui_add_buddy(); |
| 1973 |
} else if (menuin[1] == 'a') { |
| 1974 |
ui_add_account(&app_config.rtp_cfg); |
| 1975 |
} else { |
| 1976 |
printf("Invalid input %s\n", menuin); |
| 1977 |
} |
| 1978 |
break; |
| 1979 |
|
| 1980 |
case '-': |
| 1981 |
if (menuin[1] == 'b') { |
| 1982 |
ui_delete_buddy(); |
| 1983 |
} else if (menuin[1] == 'a') { |
| 1984 |
ui_delete_account(); |
| 1985 |
} else { |
| 1986 |
printf("Invalid input %s\n", menuin); |
| 1987 |
} |
| 1988 |
break; |
| 1989 |
|
| 1990 |
case 'H': |
| 1991 |
|
| 1992 |
|
| 1993 |
|
| 1994 |
ui_call_hold(); |
| 1995 |
break; |
| 1996 |
|
| 1997 |
case 'o': |
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
ui_toggle_call_sdp_offer(); |
| 2002 |
break; |
| 2003 |
|
| 2004 |
case 'v': |
| 2005 |
#if PJSUA_HAS_VIDEO |
| 2006 |
if (menuin[1]=='i' && menuin[2]=='d' && menuin[3]==' ') { |
| 2007 |
vid_handle_menu(menuin); |
| 2008 |
} else |
| 2009 |
#endif |
| 2010 |
if (current_call != -1) { |
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
ui_call_reinvite(); |
| 2015 |
} else { |
| 2016 |
PJ_LOG(3,(THIS_FILE, "No current call")); |
| 2017 |
} |
| 2018 |
break; |
| 2019 |
|
| 2020 |
case 'U': |
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
ui_send_update(); |
| 2025 |
break; |
| 2026 |
|
| 2027 |
case 'C': |
| 2028 |
if (menuin[1] == 'p') { |
| 2029 |
ui_manage_codec_prio(); |
| 2030 |
} |
| 2031 |
break; |
| 2032 |
|
| 2033 |
case 'x': |
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
ui_call_transfer(app_config.no_refersub); |
| 2038 |
break; |
| 2039 |
|
| 2040 |
case 'X': |
| 2041 |
|
| 2042 |
|
| 2043 |
|
| 2044 |
ui_call_transfer_replaces(app_config.no_refersub); |
| 2045 |
break; |
| 2046 |
|
| 2047 |
case '#': |
| 2048 |
|
| 2049 |
|
| 2050 |
|
| 2051 |
ui_send_dtmf_2833(); |
| 2052 |
break; |
| 2053 |
|
| 2054 |
case '*': |
| 2055 |
|
| 2056 |
ui_send_dtmf_info(); |
| 2057 |
break; |
| 2058 |
|
| 2059 |
case 'S': |
| 2060 |
|
| 2061 |
|
| 2062 |
|
| 2063 |
ui_send_arbitrary_request(); |
| 2064 |
break; |
| 2065 |
|
| 2066 |
case 'e': |
| 2067 |
ui_echo(menuin); |
| 2068 |
break; |
| 2069 |
|
| 2070 |
case 's': |
| 2071 |
if (pj_ansi_strnicmp(menuin, "sleep", 5)==0) { |
| 2072 |
ui_sleep(menuin); |
| 2073 |
break; |
| 2074 |
} |
| 2075 |
|
| 2076 |
|
| 2077 |
case 'u': |
| 2078 |
|
| 2079 |
|
| 2080 |
|
| 2081 |
ui_subscribe(menuin); |
| 2082 |
break; |
| 2083 |
|
| 2084 |
case 'D': |
| 2085 |
|
| 2086 |
ui_subscribe_dlg_event(menuin[1] != 'u'); |
| 2087 |
break; |
| 2088 |
|
| 2089 |
case 'r': |
| 2090 |
if (menuin[1] == 't') { |
| 2091 |
ui_send_rtt(); |
| 2092 |
} else { |
| 2093 |
ui_register(menuin); |
| 2094 |
} |
| 2095 |
break; |
| 2096 |
|
| 2097 |
case 't': |
| 2098 |
ui_toggle_state(); |
| 2099 |
break; |
| 2100 |
|
| 2101 |
case 'T': |
| 2102 |
ui_change_online_status(); |
| 2103 |
break; |
| 2104 |
|
| 2105 |
case 'c': |
| 2106 |
switch (menuin[1]) { |
| 2107 |
case 'l': |
| 2108 |
ui_conf_list(); |
| 2109 |
break; |
| 2110 |
case 'c': |
| 2111 |
case 'd': |
| 2112 |
ui_conf_connect(menuin); |
| 2113 |
break; |
| 2114 |
} |
| 2115 |
break; |
| 2116 |
|
| 2117 |
case 'V': |
| 2118 |
|
| 2119 |
ui_adjust_volume(); |
| 2120 |
break; |
| 2121 |
|
| 2122 |
case 'd': |
| 2123 |
if (menuin[1] == 'c') { |
| 2124 |
ui_dump_configuration(); |
| 2125 |
} else if (menuin[1] == 'q') { |
| 2126 |
ui_dump_call_quality(); |
| 2127 |
} else { |
| 2128 |
ui_app_dump(menuin[1]=='d'); |
| 2129 |
} |
| 2130 |
break; |
| 2131 |
|
| 2132 |
case 'f': |
| 2133 |
if (simple_input("Enter output filename", buf, sizeof(buf))) { |
| 2134 |
ui_write_settings(buf); |
| 2135 |
} |
| 2136 |
break; |
| 2137 |
|
| 2138 |
case 'L': |
| 2139 |
case 'q': |
| 2140 |
legacy_on_stopped(menuin[0]=='L'); |
| 2141 |
goto on_exit; |
| 2142 |
|
| 2143 |
case 'R': |
| 2144 |
ui_call_redirect(menuin); |
| 2145 |
break; |
| 2146 |
|
| 2147 |
case 'I': |
| 2148 |
ui_handle_ip_change(); |
| 2149 |
break; |
| 2150 |
|
| 2151 |
default: |
| 2152 |
if (menuin[0] != '\n' && menuin[0] != '\r') { |
| 2153 |
printf("Invalid input %s", menuin); |
| 2154 |
} |
| 2155 |
keystroke_help(); |
| 2156 |
break; |
| 2157 |
} |
| 2158 |
} |
| 2159 |
|
| 2160 |
on_exit: |
| 2161 |
; |
| 2162 |
} |