- Timestamp:
- Jun 13, 2008 5:01:46 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2008 r2018 202 202 puts (" --capture-lat=N Audio capture latency, in ms (default=10)"); 203 203 puts (" --playback-lat=N Audio playback latency, in ms (default=100)"); 204 puts (" --snd-auto-close=N Auto close audio device when it is idle for N seconds."); 205 puts (" Specify N=-1 (default) to disable this feature."); 206 puts (" Specify N=0 for instant close when unused."); 204 207 205 208 puts (""); … … 401 404 int option_index; 402 405 enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL, 403 OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, 406 OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_SND_AUTO_CLOSE, 404 407 OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 405 408 OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT, … … 515 518 { "stdout-refresh", 1, 0, OPT_STDOUT_REFRESH}, 516 519 { "stdout-refresh-text", 1, 0, OPT_STDOUT_REFRESH_TEXT}, 520 { "snd-auto-close", 1, 0, OPT_SND_AUTO_CLOSE}, 517 521 { NULL, 0, 0, 0} 518 522 }; … … 1107 1111 case OPT_PLAYBACK_LAT: 1108 1112 cfg->playback_lat = atoi(pj_optarg); 1113 break; 1114 1115 case OPT_SND_AUTO_CLOSE: 1116 cfg->media_cfg.snd_auto_close_time = atoi(pj_optarg); 1109 1117 break; 1110 1118 … … 1503 1511 if (config->playback_dev != PJSUA_INVALID_ID) { 1504 1512 pj_ansi_sprintf(line, "--playback-dev %d\n", config->playback_dev); 1513 pj_strcat2(&cfg, line); 1514 } 1515 if (config->media_cfg.snd_auto_close_time != -1) { 1516 pj_ansi_sprintf(line, "--snd-auto-close %d\n", 1517 config->media_cfg.snd_auto_close_time); 1505 1518 pj_strcat2(&cfg, line); 1506 1519 } … … 3787 3800 #endif 3788 3801 3789 if (app_config.capture_dev != PJSUA_INVALID_ID 3790 || app_config.playback_dev != PJSUA_INVALID_ID) { 3791 status 3792 = pjsua_set_snd_dev(app_config.capture_dev, app_config.playback_dev); 3802 if (app_config.capture_dev != PJSUA_INVALID_ID || 3803 app_config.playback_dev != PJSUA_INVALID_ID) 3804 { 3805 status = pjsua_set_snd_dev(app_config.capture_dev, 3806 app_config.playback_dev); 3793 3807 if (status != PJ_SUCCESS) 3794 3808 goto on_error; -
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r1979 r2018 335 335 med_cfg.ec_tail_len = 0; 336 336 med_cfg.enable_ice = USE_ICE; 337 med_cfg.snd_auto_close_time = 5; // wait for 5 seconds idle before sound dev get auto-closed 337 338 338 339 status = pjsua_init(&cfg, &log_cfg, &med_cfg); -
pjproject/trunk/pjsip-apps/src/symbian_ua_gui/src/symbian_ua.cpp
r1979 r2018 327 327 med_cfg.ec_tail_len = 0; 328 328 med_cfg.enable_ice = USE_ICE; 329 med_cfg.snd_auto_close_time = 5; // wait for 5 seconds idle before sound dev get auto-closed 329 330 330 331 pjsua_logging_config log_cfg; -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2004 r2018 3909 3909 */ 3910 3910 pj_stun_auth_cred turn_auth_cred; 3911 3912 /** 3913 * Specify idle time of sound device before it is automatically closed, 3914 * in seconds. 3915 * 3916 * Default : -1 (Disable the auto-close feature of sound device) 3917 */ 3918 int snd_auto_close_time; 3911 3919 }; 3912 3920 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r1990 r2018 237 237 int play_dev; /**< Playback device ID. */ 238 238 pj_bool_t no_snd; /**< No sound (app will manage it) */ 239 pj_pool_t *snd_pool; /**< Sound's private pool. */ 239 240 pjmedia_snd_port *snd_port; /**< Sound port. */ 241 pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */ 240 242 pjmedia_master_port *null_snd; /**< Master port for null sound. */ 241 243 pjmedia_port *null_port; /**< Null port. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1990 r2018 172 172 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN; 173 173 cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1; 174 cfg->snd_auto_close_time = -1; 174 175 175 176 cfg->turn_conn_type = PJ_TURN_TP_UDP; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r2004 r2018 23 23 #define THIS_FILE "pjsua_media.c" 24 24 25 #define DEFAULT_RTP_PORT 4000 25 #define DEFAULT_RTP_PORT 4000 26 27 #define NULL_SND_DEV_ID -99 26 28 27 29 #ifndef PJSUA_REQUIRE_CONSECUTIVE_RTCP_PORT … … 424 426 } 425 427 428 /* Timer callback to close sound device */ 429 static void close_snd_timer_cb( pj_timer_heap_t *th, 430 pj_timer_entry *entry) 431 { 432 PJ_UNUSED_ARG(th); 433 434 PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds", 435 pjsua_var.media_cfg.snd_auto_close_time)); 436 437 entry->id = PJ_FALSE; 438 439 close_snd_dev(); 440 } 441 426 442 427 443 /* … … 445 461 } 446 462 447 /* Create sound port if none is created yet */ 448 if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL && 449 !pjsua_var.no_snd) 450 { 451 status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev); 452 if (status != PJ_SUCCESS) { 453 pjsua_perror(THIS_FILE, "Error opening sound device", status); 454 return status; 455 } 456 } 463 pj_timer_entry_init(&pjsua_var.snd_idle_timer, PJ_FALSE, NULL, 464 &close_snd_timer_cb); 457 465 458 466 return PJ_SUCCESS; … … 1328 1336 pjsua_conf_port_id sink) 1329 1337 { 1338 /* If sound device idle timer is active, cancel it first. */ 1339 if (pjsua_var.snd_idle_timer.id) { 1340 pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer); 1341 pjsua_var.snd_idle_timer.id = PJ_FALSE; 1342 } 1343 1344 /* Create sound port if none is instantiated */ 1345 if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL && 1346 !pjsua_var.no_snd) 1347 { 1348 pj_status_t status; 1349 1350 status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev); 1351 if (status != PJ_SUCCESS) { 1352 pjsua_perror(THIS_FILE, "Error opening sound device", status); 1353 return status; 1354 } 1355 } 1356 1330 1357 return pjmedia_conf_connect_port(pjsua_var.mconf, source, sink, 0); 1331 1358 } … … 1338 1365 pjsua_conf_port_id sink) 1339 1366 { 1340 return pjmedia_conf_disconnect_port(pjsua_var.mconf, source, sink); 1367 pj_status_t status; 1368 1369 status = pjmedia_conf_disconnect_port(pjsua_var.mconf, source, sink); 1370 if (status != PJ_SUCCESS) 1371 return status; 1372 1373 /* If no port is connected, sound device must be idle. Activate sound 1374 * device auto-close timer. 1375 */ 1376 if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL) && 1377 pjsua_var.snd_idle_timer.id==PJ_FALSE && 1378 pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 && 1379 pjsua_var.media_cfg.snd_auto_close_time >= 0) 1380 { 1381 pj_time_val delay; 1382 1383 delay.msec = 0; 1384 delay.sec = pjsua_var.media_cfg.snd_auto_close_time; 1385 1386 pjsua_var.snd_idle_timer.id = PJ_TRUE; 1387 pjsip_endpt_schedule_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer, 1388 &delay); 1389 } 1390 1391 return status; 1341 1392 } 1342 1393 … … 1844 1895 pjsua_var.null_snd = NULL; 1845 1896 } 1897 1898 if (pjsua_var.snd_pool) 1899 pj_pool_release(pjsua_var.snd_pool); 1900 pjsua_var.snd_pool = NULL; 1846 1901 } 1847 1902 … … 1864 1919 pj_status_t status = -1; 1865 1920 1921 /* Check if NULL sound device is used */ 1922 if (NULL_SND_DEV_ID == capture_dev || NULL_SND_DEV_ID == playback_dev) { 1923 return pjsua_set_null_snd_dev(); 1924 } 1925 1866 1926 /* Close existing sound port */ 1867 1927 close_snd_dev(); 1868 1928 1929 /* Create memory pool for sound device. */ 1930 pjsua_var.snd_pool = pjsua_pool_create("pjsua_snd", 4000, 4000); 1931 PJ_ASSERT_RETURN(pjsua_var.snd_pool, PJ_ENOMEM); 1869 1932 1870 1933 /* Set default clock rate */ … … 1888 1951 /* Create the sound device. Sound port will start immediately. */ 1889 1952 fps = 1000 / pjsua_var.media_cfg.audio_frame_ptime; 1890 status = pjmedia_snd_port_create(pjsua_var. pool, capture_dev,1953 status = pjmedia_snd_port_create(pjsua_var.snd_pool, capture_dev, 1891 1954 playback_dev, 1892 1955 clock_rates[i], … … 1915 1978 } 1916 1979 1917 status = pjmedia_resample_port_create(pjsua_var. pool,1980 status = pjmedia_resample_port_create(pjsua_var.snd_pool, 1918 1981 conf_port, 1919 1982 selected_clock_rate, … … 1949 2012 1950 2013 /* Set AEC */ 1951 pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var. pool,2014 pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var.snd_pool, 1952 2015 pjsua_var.media_cfg.ec_tail_len, 1953 2016 pjsua_var.media_cfg.ec_options); … … 2020 2083 close_snd_dev(); 2021 2084 2085 /* Create memory pool for sound device. */ 2086 pjsua_var.snd_pool = pjsua_pool_create("pjsua_snd", 4000, 4000); 2087 PJ_ASSERT_RETURN(pjsua_var.snd_pool, PJ_ENOMEM); 2088 2022 2089 PJ_LOG(4,(THIS_FILE, "Opening null sound device..")); 2023 2090 … … 2029 2096 * a null port. 2030 2097 */ 2031 status = pjmedia_master_port_create(pjsua_var. pool, pjsua_var.null_port,2098 status = pjmedia_master_port_create(pjsua_var.snd_pool, pjsua_var.null_port, 2032 2099 conf_port, 0, &pjsua_var.null_snd); 2033 2100 if (status != PJ_SUCCESS) { … … 2040 2107 status = pjmedia_master_port_start(pjsua_var.null_snd); 2041 2108 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 2109 2110 pjsua_var.cap_dev = NULL_SND_DEV_ID; 2111 pjsua_var.play_dev = NULL_SND_DEV_ID; 2042 2112 2043 2113 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.