- Timestamp:
- Feb 5, 2009 10:59:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp
r2394 r2438 91 91 static pjsua_buddy_id g_buddy_id = PJSUA_INVALID_ID; 92 92 93 static pj_pool_t *app_pool; 94 static pjmedia_snd_port *snd_port; 95 93 96 94 97 /* Callback called by the library upon receiving incoming call */ … … 130 133 if (call_id == g_call_id) 131 134 g_call_id = PJSUA_INVALID_ID; 135 if (snd_port) { 136 pjmedia_snd_port_destroy(snd_port); 137 snd_port = NULL; 138 } 132 139 } else if (ci.state != PJSIP_INV_STATE_INCOMING) { 133 140 if (g_call_id == PJSUA_INVALID_ID) … … 250 257 } 251 258 259 /* Notification that stream is created. */ 260 static void on_stream_created(pjsua_call_id call_id, 261 pjmedia_session *sess, 262 unsigned stream_idx, 263 pjmedia_port **p_port) 264 { 265 pjmedia_port *conf; 266 pjmedia_session_info sess_info; 267 pjmedia_stream_info *strm_info; 268 pjmedia_snd_setting setting; 269 unsigned samples_per_frame; 270 pj_status_t status; 271 272 status = pjmedia_session_get_info(sess, &sess_info); 273 if (status != PJ_SUCCESS) { 274 PJ_LOG(1,(THIS_FILE, "on_stream_created() failed to get session info, " 275 "status=%d", status)); 276 return; 277 } 278 279 strm_info = &sess_info.stream_info[stream_idx]; 280 if (strm_info->type != PJMEDIA_TYPE_AUDIO) 281 return; 282 283 /* Don't need to reopen sound device when the session doesn't use 284 * PCM format. 285 */ 286 if (strm_info->param->info.format.u32 == 0 || 287 strm_info->param->info.format.u32 == PJMEDIA_FOURCC_L16) 288 { 289 return; 290 } 291 292 pj_bzero(&setting, sizeof(setting)); 293 setting.format = strm_info->param->info.format; 294 setting.bitrate = strm_info->param->info.avg_bps; 295 setting.cng = strm_info->param->setting.cng; 296 setting.vad = strm_info->param->setting.vad; 297 setting.plc = strm_info->param->setting.plc; 298 299 /* Reopen sound device. */ 300 conf = pjsua_set_no_snd_dev(); 301 302 samples_per_frame = conf->info.samples_per_frame; 303 304 status = pjmedia_snd_port_create2(app_pool, 305 PJMEDIA_DIR_CAPTURE_PLAYBACK, 306 0, 307 0, 308 8000, 309 1, 310 samples_per_frame, 311 16, 312 &setting, 313 &snd_port); 314 if (status != PJ_SUCCESS) { 315 PJ_LOG(1,(THIS_FILE, "on_stream_created() failed to reopen sound " 316 "device, status=%d", status)); 317 return; 318 } 319 320 status = pjmedia_snd_port_connect(snd_port, conf); 321 if (status != PJ_SUCCESS) { 322 PJ_LOG(1,(THIS_FILE, "on_stream_created() failed to connect sound " 323 "device to conference, status=%d", status)); 324 return; 325 } 326 } 252 327 253 328 //#include<e32debug.h> … … 290 365 } 291 366 367 /* Create pool for application */ 368 app_pool = pjsua_pool_create("pjsua-app", 1000, 1000); 369 292 370 /* Init pjsua */ 293 371 pjsua_config cfg; … … 310 388 cfg.cb.on_call_replaced = &on_call_replaced; 311 389 cfg.cb.on_nat_detect = &on_nat_detect; 390 cfg.cb.on_stream_created = &on_stream_created; 312 391 313 392 if (SIP_PROXY) { … … 338 417 med_cfg.has_ioqueue = PJ_FALSE; 339 418 med_cfg.clock_rate = 8000; 340 #if defined(PJMEDIA_SYM_SND_USE_APS) && (PJMEDIA_SYM_SND_USE_APS==1)341 med_cfg.audio_frame_ptime = 20;342 #else343 419 med_cfg.audio_frame_ptime = 40; 344 #endif345 420 med_cfg.ec_tail_len = 0; 346 421 med_cfg.enable_ice = USE_ICE; 347 med_cfg.snd_auto_close_time = 5; // wait for 5seconds idle before sound dev get auto-closed422 med_cfg.snd_auto_close_time = 0; // wait for 0 seconds idle before sound dev get auto-closed 348 423 349 424 status = pjsua_init(&cfg, &log_cfg, &med_cfg); … … 803 878 #endif 804 879 880 // Let pjsua destroys app pool, since the pool may still be used by app 881 // until pjsua_destroy() finished. 882 // e.g: quitting app when there is an active call may cause sound port 883 // memory destroyed before sound port itself gets closed/destroyed. 884 /* 885 // Release application pool 886 if (app_pool) { 887 pj_pool_release(app_pool); 888 app_pool = NULL; 889 } 890 */ 891 805 892 // Shutdown pjsua 806 893 pjsua_destroy();
Note: See TracChangeset
for help on using the changeset viewer.