Changeset 333
- Timestamp:
- Mar 19, 2006 12:47:02 AM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/conference.h
r323 r333 48 48 unsigned clock_rate; /**< Clock rate of the port. */ 49 49 unsigned samples_per_frame; /**< Samples per frame */ 50 int tx_adj_level; /**< Tx level adjustment. */ 51 int rx_adj_level; /**< Rx level adjustment. */ 50 52 } pjmedia_conf_port_info; 51 53 … … 169 171 * @param pool Pool to allocate buffers for this port. 170 172 * @param strm_port Stream port interface. 171 * @param name Port name. 173 * @param name Optional name for the port. If this value is NULL, 174 * the name will be taken from the name in the port 175 * info. 172 176 * @param p_slot Pointer to receive the slot index of the port in 173 177 * the conference bridge. -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r323 r333 43 43 #define BYTES_PER_SAMPLE 2 44 44 45 /* 46 * DON'T GET CONFUSED!! 45 #define NORMAL_LEVEL 128 46 47 48 /* 49 * DON'T GET CONFUSED WITH TX/RX!! 47 50 * 48 51 * TX and RX directions are always viewed from the conference bridge's point … … 76 79 77 80 /* 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. 79 82 */ 80 83 unsigned tx_adj_level; /**< Adjustment for TX. */ … … 203 206 204 207 /* 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; 207 210 208 211 /* Create transmit flag array */ … … 561 564 pj_status_t status; 562 565 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; 564 571 565 572 /* For this version of PJMEDIA, port MUST have the same number of … … 825 832 info->clock_rate = conf_port->clock_rate; 826 833 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; 827 836 828 837 return PJ_SUCCESS; … … 902 911 903 912 /* Set normalized adjustment level. */ 904 conf_port->rx_adj_level = adj_level + 128;913 conf_port->rx_adj_level = adj_level + NORMAL_LEVEL; 905 914 906 915 return PJ_SUCCESS; … … 929 938 930 939 /* Set normalized adjustment level. */ 931 conf_port->tx_adj_level = adj_level + 128;940 conf_port->tx_adj_level = adj_level + NORMAL_LEVEL; 932 941 933 942 return PJ_SUCCESS; … … 1077 1086 frame.size = 0; 1078 1087 1079 if (cport->port )1088 if (cport->port && cport->port->put_frame) 1080 1089 pjmedia_port_put_frame(cport->port, &frame); 1081 1090 … … 1097 1106 buf = (pj_int16_t*)cport->mix_buf; 1098 1107 1099 if (cport->tx_adj_level != 128) {1108 if (cport->tx_adj_level != NORMAL_LEVEL) { 1100 1109 1101 1110 unsigned adj_level = cport->tx_adj_level; … … 1111 1120 1112 1121 /* Adjust the level */ 1113 itemp = itemp * adj_level / 128;1122 itemp = itemp * adj_level / NORMAL_LEVEL; 1114 1123 1115 1124 /* Clip the signal if it's too loud */ … … 1156 1165 cport->samples_per_frame == conf->samples_per_frame) 1157 1166 { 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 1166 1175 return pjmedia_port_put_frame(cport->port, &frame); 1167 else1176 } else 1168 1177 return PJ_SUCCESS; 1169 1178 } … … 1193 1202 if (cport->tx_buf_count >= cport->samples_per_frame) { 1194 1203 1195 pjmedia_frame frame;1196 1204 pj_status_t status; 1197 1205 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 1204 1214 status = pjmedia_port_put_frame(cport->port, &frame); 1205 else 1215 1216 } else 1206 1217 status = PJ_SUCCESS; 1207 1218 … … 1330 1341 * Otherwise just calculate the averate level. 1331 1342 */ 1332 if (conf_port->rx_adj_level != 128) {1343 if (conf_port->rx_adj_level != NORMAL_LEVEL) { 1333 1344 pj_int16_t *input = frame->buf; 1334 1345 pj_int32_t adj = conf_port->rx_adj_level; … … 1343 1354 */ 1344 1355 itemp = input[j]; 1345 itemp = itemp * adj / 128;1356 itemp = itemp * adj / NORMAL_LEVEL; 1346 1357 1347 1358 /* Clip the signal if it's too loud */ … … 1435 1446 } 1436 1447 1448 /* MUST set frame type */ 1449 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 1450 1437 1451 pj_mutex_unlock(conf->mutex); 1438 1452
Note: See TracChangeset
for help on using the changeset viewer.