Ignore:
Timestamp:
Mar 19, 2006 12:47:02 AM (18 years ago)
Author:
bennylp
Message:

Fixed no audio bug in new conference, and add level adjustment in port info

File:
1 edited

Legend:

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

    r323 r333  
    4343#define BYTES_PER_SAMPLE    2 
    4444 
    45 /* 
    46  * DON'T GET CONFUSED!! 
     45#define NORMAL_LEVEL        128 
     46 
     47 
     48/* 
     49 * DON'T GET CONFUSED WITH TX/RX!! 
    4750 * 
    4851 * TX and RX directions are always viewed from the conference bridge's point 
     
    7679 
    7780    /* The normalized signal level adjustment. 
    78      * A value of 128 means there's no adjustment. 
     81     * A value of 128 (NORMAL_LEVEL) means there's no adjustment. 
    7982     */ 
    8083    unsigned             tx_adj_level;  /**< Adjustment for TX.             */ 
     
    203206 
    204207    /* Default level adjustment is 128 (which means no adjustment) */ 
    205     conf_port->tx_adj_level = 128; 
    206     conf_port->rx_adj_level = 128; 
     208    conf_port->tx_adj_level = NORMAL_LEVEL; 
     209    conf_port->rx_adj_level = NORMAL_LEVEL; 
    207210 
    208211    /* Create transmit flag array */ 
     
    561564    pj_status_t status; 
    562565 
    563     PJ_ASSERT_RETURN(conf && pool && strm_port && port_name, PJ_EINVAL); 
     566    PJ_ASSERT_RETURN(conf && pool && strm_port, PJ_EINVAL); 
     567 
     568    /* If port_name is not specified, use the port's name */ 
     569    if (!port_name) 
     570        port_name = &strm_port->info.name; 
    564571 
    565572    /* For this version of PJMEDIA, port MUST have the same number of 
     
    825832    info->clock_rate = conf_port->clock_rate; 
    826833    info->samples_per_frame = conf_port->samples_per_frame; 
     834    info->tx_adj_level = conf_port->tx_adj_level - NORMAL_LEVEL; 
     835    info->rx_adj_level = conf_port->rx_adj_level - NORMAL_LEVEL; 
    827836 
    828837    return PJ_SUCCESS; 
     
    902911 
    903912    /* Set normalized adjustment level. */ 
    904     conf_port->rx_adj_level = adj_level + 128; 
     913    conf_port->rx_adj_level = adj_level + NORMAL_LEVEL; 
    905914 
    906915    return PJ_SUCCESS; 
     
    929938 
    930939    /* Set normalized adjustment level. */ 
    931     conf_port->tx_adj_level = adj_level + 128; 
     940    conf_port->tx_adj_level = adj_level + NORMAL_LEVEL; 
    932941 
    933942    return PJ_SUCCESS; 
     
    10771086        frame.size = 0; 
    10781087 
    1079         if (cport->port) 
     1088        if (cport->port && cport->port->put_frame) 
    10801089            pjmedia_port_put_frame(cport->port, &frame); 
    10811090 
     
    10971106    buf = (pj_int16_t*)cport->mix_buf; 
    10981107 
    1099     if (cport->tx_adj_level != 128) { 
     1108    if (cport->tx_adj_level != NORMAL_LEVEL) { 
    11001109 
    11011110        unsigned adj_level = cport->tx_adj_level; 
     
    11111120 
    11121121            /* Adjust the level */ 
    1113             itemp = itemp * adj_level / 128; 
     1122            itemp = itemp * adj_level / NORMAL_LEVEL; 
    11141123 
    11151124            /* Clip the signal if it's too loud */ 
     
    11561165        cport->samples_per_frame == conf->samples_per_frame) 
    11571166    { 
    1158         pjmedia_frame frame; 
    1159  
    1160         frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
    1161         frame.buf = (pj_int16_t*)cport->mix_buf; 
    1162         frame.size = conf->samples_per_frame * BYTES_PER_SAMPLE; 
    1163         frame.timestamp.u64 = timestamp; 
    1164  
    1165         if (cport->port != NULL) 
     1167        if (cport->port != NULL) { 
     1168            pjmedia_frame frame; 
     1169 
     1170            frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
     1171            frame.buf = (pj_int16_t*)cport->mix_buf; 
     1172            frame.size = conf->samples_per_frame * BYTES_PER_SAMPLE; 
     1173            frame.timestamp.u64 = timestamp; 
     1174 
    11661175            return pjmedia_port_put_frame(cport->port, &frame); 
    1167         else 
     1176        } else 
    11681177            return PJ_SUCCESS; 
    11691178    } 
     
    11931202    if (cport->tx_buf_count >= cport->samples_per_frame) { 
    11941203         
    1195         pjmedia_frame frame; 
    11961204        pj_status_t status; 
    11971205 
    1198         frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
    1199         frame.buf = cport->tx_buf; 
    1200         frame.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 
    1201         frame.timestamp.u64 = timestamp; 
    1202  
    1203         if (cport->port) 
     1206        if (cport->port) { 
     1207            pjmedia_frame frame; 
     1208 
     1209            frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
     1210            frame.buf = cport->tx_buf; 
     1211            frame.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 
     1212            frame.timestamp.u64 = timestamp; 
     1213 
    12041214            status = pjmedia_port_put_frame(cport->port, &frame); 
    1205         else 
     1215 
     1216        } else 
    12061217            status = PJ_SUCCESS; 
    12071218 
     
    13301341         * Otherwise just calculate the averate level. 
    13311342         */ 
    1332         if (conf_port->rx_adj_level != 128) { 
     1343        if (conf_port->rx_adj_level != NORMAL_LEVEL) { 
    13331344            pj_int16_t *input = frame->buf; 
    13341345            pj_int32_t adj = conf_port->rx_adj_level; 
     
    13431354                 */ 
    13441355                itemp = input[j]; 
    1345                 itemp = itemp * adj / 128; 
     1356                itemp = itemp * adj / NORMAL_LEVEL; 
    13461357 
    13471358                /* Clip the signal if it's too loud */ 
     
    14351446    } 
    14361447 
     1448    /* MUST set frame type */ 
     1449    frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 
     1450 
    14371451    pj_mutex_unlock(conf->mutex); 
    14381452 
Note: See TracChangeset for help on using the changeset viewer.