Changes between Version 6 and Version 7 of Nokia_APS_VAS_Direct


Ignore:
Timestamp:
Feb 14, 2009 12:56:49 PM (15 years ago)
Author:
nanang
Comment:

Updating sample codes, closing sound device to be done in on_stream_destroyed()

Legend:

Unmodified
Added
Removed
Modified
  • Nokia_APS_VAS_Direct

    v6 v7  
    123123 {{{ 
    124124/* Global sound port. */ 
    125 static pjmedia_snd_port *snd_port; 
     125static pjmedia_snd_port *g_snd_port; 
    126126 
    127127/* Reopen sound device on on_stream_created() pjsua callback. */ 
    128 static void on_stream_created(pjsua_call_id call_id,  
     128static void on_stream_created(pjsua_call_id,  
    129129                              pjmedia_session *sess, 
    130130                              unsigned stream_idx,  
    131                               pjmedia_port **) 
     131                              pjmedia_port**) 
    132132{ 
    133133    pjmedia_port *conf; 
     
    159159    /* Reset conference port attributes. */ 
    160160    conf->info.samples_per_frame = samples_per_frame; 
    161     conf->info.clock_rate = 8000; 
    162     conf->info.channel_count = 1; 
     161    conf->info.clock_rate = strm_info->param->info.clock_rate; 
     162    conf->info.channel_count = strm_info->param->info.channel_cnt; 
    163163    conf->info.bits_per_sample = 16; 
    164164 
     
    168168                             0, 
    169169                             0, 
    170                              8000, 
    171                              1, 
     170                             strm_info->param->info.clock_rate, 
     171                             strm_info->param->info.channel_cnt, 
    172172                             samples_per_frame, 
    173173                             16, 
    174174                             &setting, 
    175                              &snd_port); 
     175                             &g_snd_port); 
    176176 
    177177    /* Connect sound to conference port. */ 
    178     pjmedia_snd_port_connect(snd_port, conf); 
     178    pjmedia_snd_port_connect(g_snd_port, conf); 
    179179} 
    180180 }}} 
    181  - Note that sound device instance is now owned and managed by application, so {{{pjsua_media_config.snd_auto_close_time}}} will not work. Here is a very simple sample code to close the sound device immediately when a call get disconnected: 
    182  {{{ 
    183 /* Callback called by the pjsua-lib when call's state has changed. */ 
    184 static void on_call_state(pjsua_call_id call_id, pjsip_event *) 
     181 - Note that sound device instance is now owned and managed by application, so {{{pjsua_media_config.snd_auto_close_time}}} will not work. Here is the sample code to utilize {{{on_stream_destroyed()}}} pjsua callback as the trigger of closing the sound device: 
     182 {{{ 
     183/* Close sound device on on_stream_destroyed() pjsua callback. */ 
     184static void on_stream_destroyed(pjsua_call_id, 
     185                                pjmedia_session*,  
     186                                unsigned) 
    185187{ 
    186     pjsua_call_info ci; 
    187  
    188     pjsua_call_get_info(call_id, &ci); 
    189      
    190     if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { 
    191         if (snd_port) { 
    192             pjmedia_snd_port_destroy(snd_port); 
    193             snd_port = NULL; 
    194         } 
     188    if (g_snd_port) { 
     189        pjmedia_snd_port_destroy(g_snd_port); 
     190        g_snd_port = NULL; 
    195191    } 
    196192} 
     193 
    197194 }}} 
    198195