Ignore:
Timestamp:
Feb 27, 2009 5:37:35 PM (15 years ago)
Author:
nanang
Message:

Added one new pjsua-lib API to get audio device stream instance, also added its usage sample for audio routing in symbian_ua.

Location:
pjproject/branches/projects/aps-direct
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp

    r2475 r2480  
    491491            "  a    Answer call\n" 
    492492            "  g    Hangup all calls\n" 
    493 #if PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND 
    494             "  t    Switch audio route\n" 
    495 #endif 
     493            "  t    Toggle audio route\n" 
    496494#if !defined(PJMEDIA_CONF_USE_SWITCH_BOARD) || PJMEDIA_CONF_USE_SWITCH_BOARD==0 
    497             "  j    Start/stop loopback audio device\n" 
     495            "  j    Toggle loopback audio\n" 
    498496#endif 
    499497            "  s    Subscribe " SIP_DST_URI "\n" 
     
    523521    switch (kc) { 
    524522     
    525 #   if 0  && PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND 
    526523    case 't': 
    527         do { 
    528             static pjmedia_snd_route route = PJMEDIA_AUD_DEV_ROUTE_DEFAULT; 
    529              
    530             if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER) 
    531                 route = PJMEDIA_AUD_DEV_ROUTE_EARPIECE; 
    532             else 
    533                 route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; 
    534  
    535             pjsua_set_snd_route(route); 
    536         } while(0); 
     524        { 
     525            pjmedia_aud_stream *aud_stream = pjsua_get_aud_stream(); 
     526 
     527            if (aud_stream) { 
     528                pjmedia_aud_dev_route route; 
     529                pj_status_t status; 
     530                 
     531                status = pjmedia_aud_stream_get_cap( 
     532                                            aud_stream, 
     533                                            PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 
     534                                            &route); 
     535                if (status == PJ_SUCCESS) { 
     536                    if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER) 
     537                        route = PJMEDIA_AUD_DEV_ROUTE_EARPIECE; 
     538                    else 
     539                        route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; 
     540 
     541                    status = pjmedia_aud_stream_set_cap( 
     542                                        aud_stream, 
     543                                        PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 
     544                                        &route); 
     545                } 
     546 
     547                if (status != PJ_SUCCESS) 
     548                    pjsua_perror(THIS_FILE, "Error switch audio route", status); 
     549            } else { 
     550                PJ_LOG(3,(THIS_FILE, "No active sound device.")); 
     551            } 
     552        } 
    537553        break; 
    538 #   endif 
    539554         
    540555    case 'j': 
    541         do { 
     556        { 
    542557            static pj_bool_t loopback_active = PJ_FALSE; 
    543558            if (!loopback_active) 
     
    546561                pjsua_conf_disconnect(0, 0); 
    547562            loopback_active = !loopback_active; 
    548         } while (0); 
     563        } 
    549564        break; 
    550565         
  • pjproject/branches/projects/aps-direct/pjsip/include/pjsua-lib/pjsua.h

    r2468 r2480  
    49444944 
    49454945 
     4946/** 
     4947 * Get active audio device stream instance. 
     4948 * 
     4949 * @return              Audio device stream instance if any, otherwise  
     4950 *                      NULL will be returned. 
     4951 */ 
     4952PJ_DECL(pjmedia_aud_stream*) pjsua_get_aud_stream(); 
     4953 
     4954 
    49464955/***************************************************************************** 
    49474956 * Codecs. 
  • pjproject/branches/projects/aps-direct/pjsip/src/pjsua-lib/pjsua_media.c

    r2469 r2480  
    26522652 
    26532653 
     2654/* 
     2655 * Get active sound port instance. 
     2656 */ 
     2657PJ_DEF(pjmedia_aud_stream*) pjsua_get_aud_stream() 
     2658{ 
     2659    pjmedia_aud_stream *aud_stream = NULL; 
     2660 
     2661    if (pjsua_var.snd_port) 
     2662        aud_stream = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port); 
     2663 
     2664    return aud_stream; 
     2665} 
     2666 
     2667 
    26542668/***************************************************************************** 
    26552669 * Codecs. 
Note: See TracChangeset for help on using the changeset viewer.