Ignore:
Timestamp:
Jul 27, 2006 10:04:56 PM (18 years ago)
Author:
bennylp
Message:

Added capability in pjsua to add application created media port to pjsua's conference bridge, also capability to use custom sound device in pjsua.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r629 r632  
    2222#define THIS_FILE       "pjsua.c" 
    2323 
     24//#define STEREO_DEMO 
    2425 
    2526 
     
    5556    unsigned                auto_answer; 
    5657    unsigned                duration; 
     58 
     59#ifdef STEREO_DEMO 
     60    pjmedia_snd_port       *snd; 
     61#endif 
     62 
    5763} app_config; 
    5864 
     
    6167static pjsua_call_id    current_call; 
    6268static pj_str_t         uri_arg; 
     69 
     70static void stereo_demo(); 
    6371 
    6472/***************************************************************************** 
     
    22002208        return status; 
    22012209 
     2210#ifdef STEREO_DEMO 
     2211    stereo_demo(); 
     2212#endif 
     2213 
    22022214    /* Optionally registers WAV file */ 
    22032215    if (app_config.wav_file.slen) { 
     
    22732285 
    22742286    /* Use null sound device? */ 
     2287#ifndef STEREO_DEMO 
    22752288    if (app_config.null_audio) { 
    22762289        status = pjsua_set_null_snd_dev(); 
     
    22782291            return status; 
    22792292    } 
     2293#endif 
    22802294 
    22812295    return PJ_SUCCESS; 
     
    23052319pj_status_t app_destroy(void) 
    23062320{ 
     2321#ifdef STEREO_DEMO 
     2322    if (app_config.snd) { 
     2323        pjmedia_snd_port_destroy(app_config.snd); 
     2324        app_config.snd = NULL; 
     2325    } 
     2326#endif 
     2327 
    23072328    if (app_config.pool) { 
    23082329        pj_pool_release(app_config.pool); 
     
    23122333    return pjsua_destroy(); 
    23132334} 
     2335 
     2336 
     2337#ifdef STEREO_DEMO 
     2338static void stereo_demo() 
     2339{ 
     2340    pjmedia_port *conf, *splitter, *ch1; 
     2341    unsigned clock; 
     2342    pj_status_t status; 
     2343 
     2344    /* Disable existing sound device */ 
     2345    conf = pjsua_set_no_snd_dev(); 
     2346 
     2347    clock = app_config.media_cfg.clock_rate; 
     2348 
     2349    /* Create stereo-mono splitter/combiner */ 
     2350    status = pjmedia_splitcomb_create(app_config.pool,  
     2351                                      clock /* clock rate */, 
     2352                                      2     /* stereo */, 
     2353                                      clock*2*10/1000/* 10ms samples * 2ch */, 
     2354                                      16    /* bits */, 
     2355                                      0     /* options */, 
     2356                                      &splitter); 
     2357    pj_assert(status == PJ_SUCCESS); 
     2358 
     2359    /* Connect channel0 (left channel?) to conference port slot0 */ 
     2360    status = pjmedia_splitcomb_set_channel(splitter, 0 /* ch0 */,  
     2361                                           0 /*options*/, 
     2362                                           conf); 
     2363    pj_assert(status == PJ_SUCCESS); 
     2364 
     2365    /* Create reverse channel for channel1 (right channel?)... */ 
     2366    status = pjmedia_splitcomb_create_rev_channel(app_config.pool, 
     2367                                                  splitter, 
     2368                                                  1  /* ch1 */, 
     2369                                                  0  /* options */, 
     2370                                                  &ch1); 
     2371    pj_assert(status == PJ_SUCCESS); 
     2372 
     2373    /* .. and register it to conference bridge (it would be slot1 
     2374     * if there's no other devices connected to the bridge) 
     2375     */ 
     2376    status = pjsua_conf_add_port(app_config.pool, ch1, NULL); 
     2377    pj_assert(status == PJ_SUCCESS); 
     2378     
     2379    /* Create sound device */ 
     2380    status = pjmedia_snd_port_create(app_config.pool, -1, -1,  
     2381                                     clock  /* clock rate */, 
     2382                                     2      /* stereo */, 
     2383                                     clock*2*10/1000 /* 10 ms samples * 2ch */, 
     2384                                     16     /* bits */, 
     2385                                     0, &app_config.snd); 
     2386    pj_assert(status == PJ_SUCCESS); 
     2387 
     2388 
     2389    /* Connect the splitter to the sound device */ 
     2390    status = pjmedia_snd_port_connect(app_config.snd, splitter); 
     2391    pj_assert(status == PJ_SUCCESS); 
     2392 
     2393} 
     2394#endif 
     2395 
Note: See TracChangeset for help on using the changeset viewer.