Changeset 3632


Ignore:
Timestamp:
Jul 13, 2011 3:05:22 AM (13 years ago)
Author:
bennylp
Message:

Fixed #1299: New callback to notify that sound device needs to be opened or closed

Location:
pjproject/branches/projects/2.0-dev
Files:
4 edited

Legend:

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

    r3629 r3632  
    31353135 
    31363136/* 
     3137 * Notification on sound device operation. 
     3138 */ 
     3139static pj_status_t on_snd_dev_operation(int operation) 
     3140{ 
     3141    PJ_LOG(3,(THIS_FILE, "Turning sound device %s", (operation? "ON":"OFF"))); 
     3142    return PJ_SUCCESS; 
     3143} 
     3144 
     3145/* 
    31373146 * Print buddy list. 
    31383147 */ 
     
    50525061    app_config.cfg.cb.on_transport_state = &on_transport_state; 
    50535062    app_config.cfg.cb.on_ice_transport_error = &on_ice_transport_error; 
     5063    app_config.cfg.cb.on_snd_dev_operation = &on_snd_dev_operation; 
    50545064    app_config.log_cfg.cb = log_cb; 
    50555065 
  • pjproject/branches/projects/2.0-dev/pjsip/include/pjsua-lib/pjsua.h

    r3609 r3632  
    962962                                   pj_status_t status, void *param); 
    963963 
     964    /** 
     965     * Callback when the sound device is about to be opened or closed. 
     966     * This callback will be called even when null sound device or no 
     967     * sound device is configured by the application (i.e. the 
     968     * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs). 
     969     * This API is mostly useful when the application wants to manage 
     970     * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()), 
     971     * to get notified when it should open or close the sound device. 
     972     * 
     973     * @param operation The value will be set to 0 to signal that sound 
     974     *                  device is about to be closed, and 1 to be opened. 
     975     * 
     976     * @return          The callback must return PJ_SUCCESS at the moment. 
     977     */ 
     978    pj_status_t (*on_snd_dev_operation)(int operation); 
     979 
     980 
    964981} pjsua_callback; 
    965982 
  • pjproject/branches/projects/2.0-dev/pjsip/include/pjsua-lib/pjsua_internal.h

    r3629 r3632  
    401401    pjmedia_master_port *null_snd;  /**< Master port for null sound.    */ 
    402402    pjmedia_port        *null_port; /**< Null port.                     */ 
    403  
     403    pj_bool_t            snd_is_on; /**< Media flow is currently active */ 
    404404 
    405405    /* Video device */ 
  • pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c

    r3629 r3632  
    377377     * It is idle when there is no port connection in the bridge and 
    378378     * there is no active call. 
     379     * 
     380     * Note: this block is now valid if no snd dev is used because of #1299 
    379381     */ 
    380     if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL) && 
     382    if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL || 
     383            pjsua_var.no_snd) && 
    381384        pjsua_var.snd_idle_timer.id == PJ_FALSE && 
    382385        pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 && 
     
    24222425                } 
    24232426            } 
     2427        } else if (pjsua_var.no_snd) { 
     2428            if (!pjsua_var.snd_is_on) { 
     2429                pjsua_var.snd_is_on = PJ_TRUE; 
     2430                /* Notify app */ 
     2431                if (pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     2432                    (*pjsua_var.ua_cfg.cb.on_snd_dev_operation)(1); 
     2433                } 
     2434            } 
    24242435        } 
    24252436 
     
    24382449                return status; 
    24392450            } 
    2440         } 
    2441  
     2451        } else if (pjsua_var.no_snd && !pjsua_var.snd_is_on) { 
     2452            pjsua_var.snd_is_on = PJ_TRUE; 
     2453            /* Notify app */ 
     2454            if (pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     2455                (*pjsua_var.ua_cfg.cb.on_snd_dev_operation)(1); 
     2456            } 
     2457        } 
    24422458    } 
    24432459 
     
    30933109    /* Close existing sound port */ 
    30943110    close_snd_dev(); 
     3111 
     3112    /* Notify app */ 
     3113    if (pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     3114        (*pjsua_var.ua_cfg.cb.on_snd_dev_operation)(1); 
     3115    } 
    30953116 
    30963117    /* Create memory pool for sound device. */ 
     
    32303251static void close_snd_dev(void) 
    32313252{ 
     3253    /* Notify app */ 
     3254    if (pjsua_var.snd_is_on && pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     3255        (*pjsua_var.ua_cfg.cb.on_snd_dev_operation)(0); 
     3256    } 
     3257 
    32323258    /* Close sound device */ 
    32333259    if (pjsua_var.snd_port) { 
     
    32633289        pj_pool_release(pjsua_var.snd_pool); 
    32643290    pjsua_var.snd_pool = NULL; 
     3291    pjsua_var.snd_is_on = PJ_FALSE; 
    32653292} 
    32663293 
     
    33253352 
    33263353    pjsua_var.no_snd = PJ_FALSE; 
     3354    pjsua_var.snd_is_on = PJ_TRUE; 
    33273355 
    33283356    return PJ_SUCCESS; 
     
    33593387    /* Close existing sound device */ 
    33603388    close_snd_dev(); 
     3389 
     3390    /* Notify app */ 
     3391    if (pjsua_var.ua_cfg.cb.on_snd_dev_operation) { 
     3392        (*pjsua_var.ua_cfg.cb.on_snd_dev_operation)(1); 
     3393    } 
    33613394 
    33623395    /* Create memory pool for sound device. */ 
     
    33893422 
    33903423    pjsua_var.no_snd = PJ_FALSE; 
     3424    pjsua_var.snd_is_on = PJ_TRUE; 
    33913425 
    33923426    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.