Changeset 358 for pjproject/trunk/pjmedia/src/pjmedia/conference.c
- Timestamp:
- Mar 24, 2006 8:41:20 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r352 r358 29 29 #include <pj/string.h> 30 30 31 /* CONF_DEBUG enables detailed operation of the conference bridge. 32 * Beware that it prints large amounts of logs (several lines per frame). 33 */ 31 34 //#define CONF_DEBUG 32 35 #ifdef CONF_DEBUG 33 36 # include <stdio.h> 34 # define TRACE_(x) {printf x; fflush(stdout); }37 # define TRACE_(x) PJ_LOG(5,x) 35 38 #else 36 39 # define TRACE_(x) 40 #endif 41 42 43 /* REC_FILE macro enables recording of the samples written to the sound 44 * device. The file contains RAW PCM data with no header, and has the 45 * same settings (clock rate etc) as the conference bridge. 46 * This should only be enabled when debugging audio quality *only*. 47 */ 48 //#define REC_FILE "confrec.pcm" 49 #ifdef REC_FILE 50 static FILE *fhnd_rec; 37 51 #endif 38 52 … … 967 981 pj_assert(count == conf->samples_per_frame); 968 982 983 TRACE_((THIS_FILE, "read_port %.*s: count=%d", 984 (int)cport->name.slen, cport->name.ptr, 985 count)); 986 969 987 /* If port's samples per frame and sampling rate matches conference 970 988 * bridge's settings, get the frame directly from the port. … … 976 994 f.buf = frame; 977 995 f.size = count * BYTES_PER_SAMPLE; 996 997 TRACE_((THIS_FILE, " get_frame %.*s: count=%d", 998 (int)cport->name.slen, cport->name.ptr, 999 count)); 978 1000 979 1001 status = (cport->port->get_frame)(cport->port, &f); … … 998 1020 f.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 999 1021 1022 TRACE_((THIS_FILE, " get_frame, count=%d", 1023 cport->samples_per_frame)); 1024 1000 1025 status = pjmedia_port_get_frame(cport->port, &f); 1001 1026 … … 1006 1031 1007 1032 if (f.type != PJMEDIA_FRAME_TYPE_AUDIO) { 1033 TRACE_((THIS_FILE, " get_frame returned non-audio")); 1008 1034 zero_samples( cport->rx_buf + cport->rx_buf_count, 1009 1035 cport->samples_per_frame); … … 1011 1037 1012 1038 cport->rx_buf_count += cport->samples_per_frame; 1039 1040 TRACE_((THIS_FILE, " rx buffer size is now %d", 1041 cport->rx_buf_count)); 1013 1042 1014 1043 pj_assert(cport->rx_buf_count <= cport->rx_buf_cap); … … 1023 1052 unsigned src_count; 1024 1053 1054 TRACE_((THIS_FILE, " resample, input count=%d", 1055 pjmedia_resample_get_input_size(cport->rx_resample))); 1056 1025 1057 pjmedia_resample_run( cport->rx_resample,cport->rx_buf, frame); 1026 1058 … … 1033 1065 } 1034 1066 1067 TRACE_((THIS_FILE, " rx buffer size is now %d", 1068 cport->rx_buf_count)); 1069 1035 1070 } else { 1036 1071 … … 1068 1103 frame.size = 0; 1069 1104 1070 if (cport->port && cport->port->put_frame) 1105 if (cport->port && cport->port->put_frame) { 1071 1106 pjmedia_port_put_frame(cport->port, &frame); 1107 } 1072 1108 1073 1109 cport->tx_level = 0; … … 1112 1148 } 1113 1149 1114 } else {1150 } else if (cport->sources) { 1115 1151 /* No need to adjust signal level. */ 1116 1152 for (j=0; j<conf->samples_per_frame; ++j) { 1117 1153 buf[j] = unsigned2pcm(cport->mix_buf[j] / cport->sources); 1118 1154 } 1155 } else { 1156 // Not necessarry. Buffer has been zeroed before. 1157 // zero_samples(buf, conf->samples_per_frame); 1158 pj_assert(buf[0] == 0); 1119 1159 } 1120 1160 … … 1155 1195 frame.timestamp.u64 = timestamp; 1156 1196 1197 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", 1198 (int)cport->name.slen, cport->name.ptr, 1199 frame.size / BYTES_PER_SAMPLE)); 1200 1157 1201 return pjmedia_port_put_frame(cport->port, &frame); 1158 1202 } else … … 1186 1230 pj_status_t status; 1187 1231 1232 TRACE_((THIS_FILE, "write_port %.*s: count=%d", 1233 (int)cport->name.slen, cport->name.ptr, 1234 cport->samples_per_frame)); 1235 1188 1236 if (cport->port) { 1189 1237 pjmedia_frame frame; … … 1193 1241 frame.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 1194 1242 frame.timestamp.u64 = timestamp; 1243 1244 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", 1245 (int)cport->name.slen, cport->name.ptr, 1246 frame.size / BYTES_PER_SAMPLE)); 1195 1247 1196 1248 status = pjmedia_port_put_frame(cport->port, &frame); … … 1206 1258 } 1207 1259 1260 TRACE_((THIS_FILE, " tx_buf count now is %d", 1261 cport->tx_buf_count)); 1262 1208 1263 return status; 1209 1264 } … … 1222 1277 unsigned ci, cj, i, j; 1223 1278 1279 TRACE_((THIS_FILE, "- clock -")); 1280 1224 1281 /* Check that correct size is specified. */ 1225 1282 pj_assert(frame->size == conf->samples_per_frame * … … 1228 1285 /* Must lock mutex (must we??) */ 1229 1286 pj_mutex_lock(conf->mutex); 1230 1231 TRACE_(("p"));1232 1287 1233 1288 /* Zero all port's temporary buffers. */ … … 1245 1300 mix_buf = conf_port->mix_buf; 1246 1301 1247 for (j=0; j<conf->samples_per_frame; ++j) 1248 mix_buf[j] = 0; 1302 for (j=0; j<conf->samples_per_frame; ++j) mix_buf[j] = 0; 1249 1303 } 1250 1304 … … 1422 1476 /* Return sound playback frame. */ 1423 1477 if (conf->ports[0]->sources) { 1478 TRACE_((THIS_FILE, "write to audio, count=%d", 1479 conf->samples_per_frame)); 1480 1424 1481 copy_samples( frame->buf, (pj_int16_t*)conf->ports[0]->mix_buf, 1425 1482 conf->samples_per_frame); … … 1432 1489 1433 1490 pj_mutex_unlock(conf->mutex); 1491 1492 #ifdef REC_FILE 1493 if (fhnd_rec == NULL) 1494 fhnd_rec = fopen(REC_FILE, "wb"); 1495 if (fhnd_rec) 1496 fwrite(frame->buf, frame->size, 1, fhnd_rec); 1497 #endif 1434 1498 1435 1499 return PJ_SUCCESS; … … 1448 1512 pj_int16_t *target_snd_buf; 1449 1513 unsigned i; 1450 1451 TRACE_(("r"));1452 1514 1453 1515 /* Check for correct size. */
Note: See TracChangeset
for help on using the changeset viewer.