Changeset 632 for pjproject


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.

Location:
pjproject/trunk
Files:
4 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 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r629 r632  
    22482248 
    22492249/** 
     2250 * Add arbitrary media port to PJSUA's conference bridge. Application 
     2251 * can use this function to add the media port that it creates. For 
     2252 * media ports that are created by PJSUA-LIB (such as calls, file player, 
     2253 * or file recorder), PJSUA-LIB will automatically add the port to 
     2254 * the bridge. 
     2255 * 
     2256 * @param pool          Pool to use. 
     2257 * @param port          Media port to be added to the bridge. 
     2258 * @param p_id          Optional pointer to receive the conference  
     2259 *                      slot id. 
     2260 * 
     2261 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     2262 */ 
     2263PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, 
     2264                                         pjmedia_port *port, 
     2265                                         pjsua_conf_port_id *p_id); 
     2266 
     2267 
     2268/** 
     2269 * Remove arbitrary slot from the conference bridge. Application should only 
     2270 * call this function if it registered the port manually. 
     2271 * 
     2272 * @param id            The slot id of the port to be removed. 
     2273 * 
     2274 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     2275 */ 
     2276PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id); 
     2277 
     2278 
     2279/** 
    22502280 * Establish unidirectional media flow from souce to sink. One source 
    22512281 * may transmit to multiple destinations/sink. And if multiple 
     
    24252455 
    24262456 
     2457/** 
     2458 * Disconnect the main conference bridge from any sound devices, and let 
     2459 * application connect the bridge to it's own sound device/master port. 
     2460 * 
     2461 * @return              The port interface of the conference bridge,  
     2462 *                      so that application can connect this to it's own 
     2463 *                      sound device or master port. 
     2464 */ 
     2465PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); 
     2466 
     2467 
    24272468/***************************************************************************** 
    24282469 * Codecs. 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r611 r632  
    205205    int                  cap_dev;   /**< Capture device ID.             */ 
    206206    int                  play_dev;  /**< Playback device ID.            */ 
     207    pj_bool_t            no_snd;    /**< No sound (app will manage it)  */ 
    207208    pjmedia_snd_port    *snd_port;  /**< Sound port.                    */ 
    208209    pjmedia_master_port *null_snd;  /**< Master port for null sound.    */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r582 r632  
    340340 
    341341    /* Create sound port if none is created yet */ 
    342     if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL) { 
     342    if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&  
     343        !pjsua_var.no_snd)  
     344    { 
    343345        status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev); 
    344346        if (status != PJ_SUCCESS) { 
     
    572574 
    573575/* 
     576 * Add arbitrary media port to PJSUA's conference bridge. 
     577 */ 
     578PJ_DEF(pj_status_t) pjsua_conf_add_port( pj_pool_t *pool, 
     579                                         pjmedia_port *port, 
     580                                         pjsua_conf_port_id *p_id) 
     581{ 
     582    pj_status_t status; 
     583 
     584    status = pjmedia_conf_add_port(pjsua_var.mconf, pool, 
     585                                   port, NULL, (unsigned*)p_id); 
     586    if (status != PJ_SUCCESS) { 
     587        if (p_id) 
     588            *p_id = PJSUA_INVALID_ID; 
     589    } 
     590 
     591    return status; 
     592} 
     593 
     594 
     595/* 
     596 * Remove arbitrary slot from the conference bridge. 
     597 */ 
     598PJ_DEF(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id) 
     599{ 
     600    return pjmedia_conf_remove_port(pjsua_var.mconf, (unsigned)id); 
     601} 
     602 
     603 
     604/* 
    574605 * Establish unidirectional media flow from souce to sink.  
    575606 */ 
     
    963994 
    964995 
     996 
     997/* 
     998 * Use no device! 
     999 */ 
     1000PJ_DEF(pjmedia_port*) pjsua_set_no_snd_dev(void) 
     1001{ 
     1002    /* Close existing sound device */ 
     1003    close_snd_dev(); 
     1004 
     1005    pjsua_var.no_snd = PJ_TRUE; 
     1006    return pjmedia_conf_get_master_port(pjsua_var.mconf); 
     1007} 
     1008 
     1009 
     1010 
    9651011/***************************************************************************** 
    9661012 * Codecs. 
Note: See TracChangeset for help on using the changeset viewer.