Changeset 2008 for pjproject/trunk
- Timestamp:
- Jun 12, 2008 1:30:39 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2007 r2008 93 93 #define current_acc pjsua_acc_get_default() 94 94 static pjsua_call_id current_call = PJSUA_INVALID_ID; 95 static pj_bool_t cmd_echo; 96 static int stdout_refresh = -1; 97 static const char *stdout_refresh_text = "STDOUT_REFRESH"; 98 static pj_bool_t stdout_refresh_quit = PJ_FALSE; 95 99 static pj_str_t uri_arg; 96 100 … … 420 424 OPT_CAPTURE_DEV, OPT_PLAYBACK_DEV, 421 425 OPT_CAPTURE_LAT, OPT_PLAYBACK_LAT, 426 OPT_STDOUT_REFRESH, OPT_STDOUT_REFRESH_TEXT, 422 427 OPT_AUTO_UPDATE_NAT,OPT_USE_COMPACT_FORM,OPT_DIS_CODEC 423 428 }; … … 508 513 { "capture-lat", 1, 0, OPT_CAPTURE_LAT}, 509 514 { "playback-lat", 1, 0, OPT_PLAYBACK_LAT}, 515 { "stdout-refresh", 1, 0, OPT_STDOUT_REFRESH}, 516 { "stdout-refresh-text", 1, 0, OPT_STDOUT_REFRESH_TEXT}, 510 517 { NULL, 0, 0, 0} 511 518 }; … … 1084 1091 case OPT_PLAYBACK_DEV: 1085 1092 cfg->playback_dev = atoi(pj_optarg); 1093 break; 1094 1095 case OPT_STDOUT_REFRESH: 1096 stdout_refresh = atoi(pj_optarg); 1097 break; 1098 1099 case OPT_STDOUT_REFRESH_TEXT: 1100 stdout_refresh_text = pj_optarg; 1086 1101 break; 1087 1102 … … 2276 2291 puts("| S Send arbitrary REQUEST | Cp Codec priorities | f Save config |"); 2277 2292 puts("+------------------------------+--------------------------+-------------------+"); 2278 puts("| q QUIT sleep N: console sleep for N msn: detect NAT type |");2293 puts("| q QUIT sleep MS echo [0|1] n: detect NAT type |"); 2279 2294 puts("+=============================================================================+"); 2280 2295 … … 2648 2663 } 2649 2664 2665 if (cmd_echo) { 2666 printf("%s", menuin); 2667 } 2668 2650 2669 switch (menuin[0]) { 2651 2670 … … 3309 3328 3310 3329 send_request(text, &tmp); 3330 break; 3331 3332 case 'e': 3333 if (pj_ansi_strnicmp(menuin, "echo", 4)==0) { 3334 pj_str_t tmp; 3335 3336 tmp.ptr = menuin+5; 3337 tmp.slen = pj_ansi_strlen(menuin)-6; 3338 3339 if (tmp.slen < 1) { 3340 puts("Usage: echo [0|1]"); 3341 break; 3342 } 3343 3344 cmd_echo = pj_strtoul(&tmp); 3345 } 3311 3346 break; 3312 3347 … … 3768 3803 3769 3804 3805 static int stdout_refresh_proc(void *arg) 3806 { 3807 PJ_UNUSED_ARG(arg); 3808 3809 /* Set thread to lowest priority so that it doesn't clobber 3810 * stdout output 3811 */ 3812 pj_thread_set_prio(pj_thread_this(), 3813 pj_thread_get_prio_min(pj_thread_this())); 3814 3815 while (!stdout_refresh_quit) { 3816 pj_thread_sleep(stdout_refresh * 1000); 3817 puts(stdout_refresh_text); 3818 fflush(stdout); 3819 } 3820 3821 return 0; 3822 } 3823 3770 3824 pj_status_t app_main(void) 3771 3825 { 3826 pj_thread_t *stdout_refresh_thread = NULL; 3772 3827 pj_status_t status; 3773 3828 … … 3779 3834 } 3780 3835 3836 /* Start console refresh thread */ 3837 if (stdout_refresh > 0) { 3838 pj_thread_create(app_config.pool, "stdout", &stdout_refresh_proc, 3839 NULL, 0, 0, &stdout_refresh_thread); 3840 } 3841 3781 3842 console_app_main(&uri_arg); 3843 3844 if (stdout_refresh_thread) { 3845 stdout_refresh_quit = PJ_TRUE; 3846 pj_thread_join(stdout_refresh_thread); 3847 pj_thread_destroy(stdout_refresh_thread); 3848 } 3782 3849 3783 3850 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.