Ignore:
Timestamp:
Feb 18, 2009 2:28:49 PM (10 years ago)
Author:
nanang
Message:
  • Added APS-direct sound device management into pjsua-lib (and removed it from apps).
  • Fixed bug in conf_switch.c to always update ts_rx (even if port is not transmitting).
  • Minor updates: 'fmt_id' to 'id', added transmitter_Cnt in conf port info, explicit mapping in Symbian audio APS impl from pjmedia_format_id to Symbian APS fourcc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjsip-apps/src/pjsua/pjsua_app.c

    r2457 r2460  
    24022402} 
    24032403 
    2404 #ifdef PJSUA_SIMULATE_APS_DIRECT 
    2405 /* To simulate APS direct, add these to config_site.h: 
    2406 #define PJSUA_SIMULATE_APS_DIRECT 
    2407 #ifdef PJSUA_SIMULATE_APS_DIRECT 
    2408     #define PJMEDIA_CONF_USE_SWITCH_BOARD       1 
    2409     #define PJMEDIA_HAS_PASSTHROUGH_CODECS      1 
    2410  
    2411     #define PJMEDIA_HAS_L16_CODEC               0 
    2412     #define PJMEDIA_HAS_GSM_CODEC               0 
    2413     #define PJMEDIA_HAS_SPEEX_CODEC             0 
    2414     #define PJMEDIA_HAS_ILBC_CODEC              0 
    2415     #define PJMEDIA_HAS_G722_CODEC              0 
    2416     #define PJMEDIA_HAS_INTEL_IPP               0 
    2417  
    2418     #define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR   0 
    2419     #define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729  0 
    2420     #define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC  0 
    2421 #endif 
    2422 */ 
    2423  
    2424 /* Global sound port. */ 
    2425 static pjmedia_snd_port *g_snd_port; 
    2426  
    2427  
    2428 /* Reopen sound device on on_stream_created() pjsua callback. */ 
    2429 static void on_call_stream_created(pjsua_call_id call_id,  
    2430                                    pjmedia_session *sess, 
    2431                                    unsigned stream_idx,  
    2432                                    pjmedia_port **p_port) 
    2433 { 
    2434     pjmedia_port *conf; 
    2435     pjmedia_session_info sess_info; 
    2436     pjmedia_port *port; 
    2437     pjmedia_stream_info *strm_info; 
    2438     pjmedia_snd_setting setting; 
    2439     unsigned samples_per_frame; 
    2440     pj_status_t status; 
    2441  
    2442     PJ_UNUSED_ARG(call_id); 
    2443     PJ_UNUSED_ARG(p_port); 
    2444  
    2445     /* Get active format for this stream, based on SDP negotiation result. */     
    2446     pjmedia_session_get_info(sess, &sess_info); 
    2447     strm_info = &sess_info.stream_info[stream_idx]; 
    2448  
    2449     pjmedia_session_get_port(sess, stream_idx, &port); 
    2450  
    2451     /* Init sound device setting based on stream info. */ 
    2452     pj_bzero(&setting, sizeof(setting)); 
    2453     setting.format = port->info.format; 
    2454     setting.cng = strm_info->param->setting.cng; 
    2455     setting.plc = strm_info->param->setting.plc; 
    2456  
    2457     /* Close sound device and get the conference port. */ 
    2458     conf = pjsua_set_no_snd_dev(); 
    2459      
    2460     samples_per_frame = strm_info->param->info.clock_rate * 
    2461                         strm_info->param->info.frm_ptime * 
    2462                         strm_info->param->setting.frm_per_pkt * 
    2463                         strm_info->param->info.channel_cnt / 
    2464                         1000; 
    2465  
    2466     /* Reset conference port attributes. */ 
    2467     conf->info.samples_per_frame = samples_per_frame; 
    2468     conf->info.clock_rate = strm_info->param->info.clock_rate; 
    2469     conf->info.channel_count = 1; 
    2470     conf->info.bits_per_sample = 16; 
    2471  
    2472     /* Reopen sound device. */ 
    2473     status = pjmedia_snd_port_create2(app_config.pool,  
    2474                                       PJMEDIA_DIR_CAPTURE_PLAYBACK, 
    2475                                       -1, 
    2476                                       -1, 
    2477                                       strm_info->param->info.clock_rate, 
    2478                                       strm_info->param->info.channel_cnt, 
    2479                                       samples_per_frame, 
    2480                                       16, 
    2481                                       &setting, 
    2482                                       &g_snd_port); 
    2483     if (status != PJ_SUCCESS) { 
    2484         pjsua_perror(THIS_FILE, "Error opening sound device", status); 
    2485         return; 
    2486     } 
    2487  
    2488     /* Connect sound to conference port. */ 
    2489     pjmedia_snd_port_connect(g_snd_port, conf); 
    2490 } 
    2491  
    2492 static void on_call_stream_destroyed(pjsua_call_id call_id, 
    2493                                      pjmedia_session *sess,  
    2494                                      unsigned stream_idx) 
    2495 { 
    2496     PJ_UNUSED_ARG(call_id); 
    2497     PJ_UNUSED_ARG(sess); 
    2498     PJ_UNUSED_ARG(stream_idx); 
    2499  
    2500     if (g_snd_port) { 
    2501         pjmedia_snd_port_destroy(g_snd_port); 
    2502         g_snd_port = NULL; 
    2503     } 
    2504 } 
    2505  
    2506 #endif 
    2507  
    25082404/* 
    25092405 * DTMF callback. 
     
    41514047    app_config.cfg.cb.on_call_state = &on_call_state; 
    41524048    app_config.cfg.cb.on_call_media_state = &on_call_media_state; 
    4153 #ifdef PJSUA_SIMULATE_APS_DIRECT 
    4154     app_config.cfg.cb.on_stream_created = &on_call_stream_created; 
    4155     app_config.cfg.cb.on_stream_destroyed = &on_call_stream_destroyed; 
    4156 #endif 
    41574049    app_config.cfg.cb.on_incoming_call = &on_incoming_call; 
    41584050    app_config.cfg.cb.on_call_tsx_state = &on_call_tsx_state; 
Note: See TracChangeset for help on using the changeset viewer.