Changeset 864


Ignore:
Timestamp:
Dec 26, 2006 2:27:14 AM (17 years ago)
Author:
bennylp
Message:

Ticket #51: Added audio level adjustment to PJSUA-API

Location:
pjproject/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/conference.c

    r838 r864  
    6262#define SIGNATURE           PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'F') 
    6363#define SIGNATURE_PORT      PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'P') 
     64/* Normal level is hardcodec to 128 in all over places */ 
    6465#define NORMAL_LEVEL        128 
    6566#define SLOT_TYPE           unsigned 
     
    11381139 
    11391140    /* Value must be from -128 to +127 */ 
    1140     PJ_ASSERT_RETURN(adj_level >= -128 && adj_level <= 127, PJ_EINVAL); 
     1141    /* Disabled, you can put more than +127, at your own risk:  
     1142     PJ_ASSERT_RETURN(adj_level >= -128 && adj_level <= 127, PJ_EINVAL); 
     1143     */ 
     1144    PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 
    11411145 
    11421146    conf_port = conf->ports[slot]; 
     
    11651169 
    11661170    /* Value must be from -128 to +127 */ 
    1167     PJ_ASSERT_RETURN(adj_level >= -128 && adj_level <= 127, PJ_EINVAL); 
     1171    /* Disabled, you can put more than +127,, at your own risk: 
     1172     PJ_ASSERT_RETURN(adj_level >= -128 && adj_level <= 127, PJ_EINVAL); 
     1173     */ 
     1174    PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 
    11681175 
    11691176    conf_port = conf->ports[slot]; 
     
    13651372                 */ 
    13661373                itemp = input[j]; 
    1367                 itemp = itemp * adj / NORMAL_LEVEL; 
     1374                /*itemp = itemp * adj / NORMAL_LEVEL; */ 
     1375                itemp = (itemp * adj) >> 7; 
    13681376 
    13691377                /* Clip the signal if it's too loud */ 
     
    13971405 
    13981406            /* Adjust the level */ 
    1399             itemp = itemp * adj_level / NORMAL_LEVEL; 
     1407            /*itemp = itemp * adj_level / NORMAL_LEVEL;*/ 
     1408            itemp = (itemp * adj_level) >> 7; 
    14001409 
    14011410            /* Clip the signal if it's too loud */ 
     
    16511660                 */ 
    16521661                itemp = input[j]; 
    1653                 itemp = itemp * adj / NORMAL_LEVEL; 
     1662                /*itemp = itemp * adj / NORMAL_LEVEL;*/ 
     1663                itemp = (itemp * adj) >> 7; 
    16541664 
    16551665                /* Clip the signal if it's too loud */ 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r863 r864  
    7676    pjmedia_snd_port       *snd; 
    7777#endif 
     78 
     79    float                   mic_level, 
     80                            speaker_level; 
    7881 
    7982} app_config; 
     
    210213    cfg->wav_port = PJSUA_INVALID_ID; 
    211214    cfg->rec_port = PJSUA_INVALID_ID; 
     215    cfg->mic_level = cfg->speaker_level = 1.0; 
    212216} 
    213217 
     
    849853            PJ_LOG(1,(THIS_FILE,  
    850854                      "Argument \"%s\" is not valid. Use --help to see help", 
    851                       argv[pj_optind-1])); 
     855                      argv[pj_optind])); 
    852856            return -1; 
    853857        } 
     
    18381842    puts("| dq  Dump curr. call quality  | cc  Connect port         | dd  Dump detailed |"); 
    18391843    puts("|                              | cd  Disconnect port      | dc  Dump config   |"); 
    1840     puts("|  S  Send arbitrary REQUEST   |                          |  f  Save config   |"); 
     1844    puts("|  S  Send arbitrary REQUEST   |  V  Adjust audio Volume  |  f  Save config   |"); 
    18411845    puts("+------------------------------+--------------------------+-------------------+"); 
    18421846    puts("|  q  QUIT                                                                    |"); 
     
    27142718            break; 
    27152719 
     2720        case 'V': 
     2721            /* Adjust audio volume */ 
     2722            sprintf(buf, "Adjust mic level: [%4.1fx] ", app_config.mic_level); 
     2723            if (simple_input(buf,text,sizeof(text))) { 
     2724                char *err; 
     2725                app_config.mic_level = (float)strtod(text, &err); 
     2726                pjsua_conf_adjust_rx_level(0, app_config.mic_level); 
     2727            } 
     2728            sprintf(buf, "Adjust speaker level: [%4.1fx] ",  
     2729                    app_config.speaker_level); 
     2730            if (simple_input(buf,text,sizeof(text))) { 
     2731                char *err; 
     2732                app_config.speaker_level = (float)strtod(text, &err); 
     2733                pjsua_conf_adjust_tx_level(0, app_config.speaker_level); 
     2734            } 
     2735 
     2736            break; 
     2737 
    27162738        case 'd': 
    27172739            if (menuin[1] == 'c') { 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r863 r864  
    26242624PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, 
    26252625                                           pjsua_conf_port_id sink); 
     2626 
     2627 
     2628/** 
     2629 * Adjust the signal level to be transmitted from the bridge to the  
     2630 * specified port by making it louder or quieter. 
     2631 * 
     2632 * @param slot          The conference bridge slot number. 
     2633 * @param level         Signal level adjustment. Value 1.0 means no level 
     2634 *                      adjustment, while value 0 means to mute the port. 
     2635 * 
     2636 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     2637 */ 
     2638PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, 
     2639                                                float level); 
     2640 
     2641/** 
     2642 * Adjust the signal level to be received from the specified port (to 
     2643 * the bridge) by making it louder or quieter. 
     2644 * 
     2645 * @param slot          The conference bridge slot number. 
     2646 * @param level         Signal level adjustment. Value 1.0 means no level 
     2647 *                      adjustment, while value 0 means to mute the port. 
     2648 * 
     2649 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     2650 */ 
     2651PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, 
     2652                                                float level); 
     2653 
     2654/** 
     2655 * Get last signal level transmitted to or received from the specified port. 
     2656 * The signal level is an integer value in zero to 255, with zero indicates 
     2657 * no signal, and 255 indicates the loudest signal level. 
     2658 * 
     2659 * @param slot          The conference bridge slot number. 
     2660 * @param tx_level      Optional argument to receive the level of signal 
     2661 *                      transmitted to the specified port (i.e. the direction 
     2662 *                      is from the bridge to the port). 
     2663 * @param rx_level      Optional argument to receive the level of signal 
     2664 *                      received from the port (i.e. the direction is from the 
     2665 *                      port to the bridge). 
     2666 * 
     2667 * @return              PJ_SUCCESS on success. 
     2668 */ 
     2669PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, 
     2670                                                 unsigned *tx_level, 
     2671                                                 unsigned *rx_level); 
     2672 
     2673/** 
     2674 *  
     2675 */ 
     2676 
    26262677 
    26272678 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r863 r864  
    674674 
    675675 
     676/* 
     677 * Adjust the signal level to be transmitted from the bridge to the  
     678 * specified port by making it louder or quieter. 
     679 */ 
     680PJ_DEF(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, 
     681                                               float level) 
     682{ 
     683    return pjmedia_conf_adjust_tx_level(pjsua_var.mconf, slot, 
     684                                        (int)((level-1) * 128)); 
     685} 
     686 
     687/* 
     688 * Adjust the signal level to be received from the specified port (to 
     689 * the bridge) by making it louder or quieter. 
     690 */ 
     691PJ_DEF(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, 
     692                                               float level) 
     693{ 
     694    return pjmedia_conf_adjust_rx_level(pjsua_var.mconf, slot, 
     695                                        (int)((level-1) * 128)); 
     696} 
     697 
     698 
     699/* 
     700 * Get last signal level transmitted to or received from the specified port. 
     701 */ 
     702PJ_DEF(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, 
     703                                                unsigned *tx_level, 
     704                                                unsigned *rx_level) 
     705{ 
     706    return pjmedia_conf_get_signal_level(pjsua_var.mconf, slot,  
     707                                         tx_level, rx_level); 
     708} 
     709 
    676710/***************************************************************************** 
    677711 * File player. 
     
    10091043{ 
    10101044    pjmedia_port *conf_port; 
    1011     const pjmedia_snd_dev_info *cap_info, *play_info; 
     1045    const pjmedia_snd_dev_info *play_info; 
    10121046    unsigned clock_rates[] = { 0, 22050, 44100, 48000, 11025, 32000, 8000}; 
    10131047    unsigned selected_clock_rate = 0; 
Note: See TracChangeset for help on using the changeset viewer.