- Timestamp:
- Feb 5, 2009 10:59:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c
r2437 r2438 997 997 (pjmedia_frame*)f_dst); 998 998 999 /* Update TX timestamp. */1000 pj_add_timestamp32(&cport_dst->ts_tx,1001 cport_dst->samples_per_frame);1002 1003 999 /* Reset TX buffer. */ 1004 1000 f_dst->subframe_cnt = 0; 1005 1001 f_dst->samples_cnt = 0; 1006 1002 } 1003 1004 /* Update TX timestamp. */ 1005 pj_add_timestamp32(&cport_dst->ts_tx, 1006 cport_dst->samples_per_frame); 1007 1007 1008 } 1008 1009 } … … 1037 1038 pjmedia_port_put_frame(cport_dst->port, frm_dst); 1038 1039 1039 /* Update TX timestamp. */1040 pj_add_timestamp32(&cport_dst->ts_tx,1041 cport_dst->samples_per_frame);1042 1043 1040 /* Reset TX buffer. */ 1044 1041 frm_dst->size = 0; 1045 1042 } 1043 1044 /* Update TX timestamp. */ 1045 pj_add_timestamp32(&cport_dst->ts_tx, 1046 cport_dst->samples_per_frame); 1046 1047 } 1047 1048 } … … 1063 1064 frm_dst->type = PJMEDIA_FRAME_TYPE_AUDIO; 1064 1065 frm_dst->size = cport_dst->samples_per_frame << 1; 1065 if (cport_dst->port) 1066 if (cport_dst->port) { 1066 1067 pjmedia_port_put_frame(cport_dst->port, frm_dst); 1068 1069 /* Reset TX buffer. */ 1070 frm_dst->size = 0; 1071 } 1067 1072 1068 1073 /* Update TX timestamp. */ 1069 1074 pj_add_timestamp32(&cport_dst->ts_tx, 1070 1075 cport_dst->samples_per_frame); 1071 1072 /* Reset TX buffer. */1073 frm_dst->size = 0;1074 1076 } 1075 1077 } else { … … 1080 1082 pjmedia_frame_ext_append_subframe(f_dst, NULL, 0, (pj_uint16_t) 1081 1083 (cport_dst->samples_per_frame- 1082 f_dst->samples_cnt));1083 if (cport_dst->port) 1084 f_dst->samples_cnt)); 1085 if (cport_dst->port) { 1084 1086 pjmedia_port_put_frame(cport_dst->port, frm_dst); 1087 1088 /* Reset TX buffer. */ 1089 f_dst->subframe_cnt = 0; 1090 f_dst->samples_cnt = 0; 1091 } 1085 1092 1086 1093 /* Update TX timestamp. */ 1087 1094 pj_add_timestamp32(&cport_dst->ts_tx, 1088 1095 cport_dst->samples_per_frame); 1089 1090 /* Reset TX buffer. */1091 f_dst->subframe_cnt = 0;1092 f_dst->samples_cnt = 0;1093 1096 } 1094 1097 } … … 1096 1099 /* Synchronize clock. */ 1097 1100 while (pj_cmp_timestamp(&cport_dst->ts_clock, 1098 &cport_dst->ts_tx) > =0)1101 &cport_dst->ts_tx) > 0) 1099 1102 { 1100 if (cport_dst->port) {1101 frm_dst->type = PJMEDIA_FRAME_TYPE_NONE;1102 frm_dst->timestamp = cport_dst->ts_tx;1103 frm_dst->type = PJMEDIA_FRAME_TYPE_NONE; 1104 frm_dst->timestamp = cport_dst->ts_tx; 1105 if (cport_dst->port) 1103 1106 pjmedia_port_put_frame(cport_dst->port, frm_dst); 1104 } 1107 1108 /* Update TX timestamp. */ 1105 1109 pj_add_timestamp32(&cport_dst->ts_tx, cport_dst->samples_per_frame); 1106 1110 } … … 1235 1239 cport->tx_level = 0; 1236 1240 1237 while (pj_cmp_timestamp(&cport->ts_clock, &cport->ts_tx) > =0)1241 while (pj_cmp_timestamp(&cport->ts_clock, &cport->ts_tx) > 0) 1238 1242 { 1239 1243 if (cport->tx_setting == PJMEDIA_PORT_ENABLE) { … … 1265 1269 pj_uint16_t samples_per_subframe; 1266 1270 1271 if (f_src_->samples_cnt < this_cport->samples_per_frame) { 1272 pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 1273 frame->type = PJMEDIA_FRAME_TYPE_NONE; 1274 break; 1275 } 1276 1267 1277 f_dst->samples_cnt = 0; 1268 1278 f_dst->subframe_cnt = 0; … … 1270 1280 samples_per_subframe = f_src_->samples_cnt / f_src_->subframe_cnt; 1271 1281 1282 1272 1283 while (f_dst->samples_cnt < this_cport->samples_per_frame) { 1273 1284 sf = pjmedia_frame_ext_get_subframe(f_src_, i++); 1285 pj_assert(sf); 1274 1286 pjmedia_frame_ext_append_subframe(f_dst, sf->data, sf->bitlen, 1275 1287 samples_per_subframe); … … 1277 1289 1278 1290 /* Shift left TX buffer. */ 1279 sf = pjmedia_frame_ext_get_subframe(f_src_, i); 1280 if (sf) { 1281 pjmedia_frame_ext_subframe *sf_end; 1282 unsigned len; 1283 1284 sf_end = pjmedia_frame_ext_get_subframe(f_src_, 1285 f_src_->subframe_cnt -1); 1286 len = (pj_uint8_t*)sf_end - (pj_uint8_t*)sf + sf_end->bitlen/8; 1287 if (sf_end->bitlen % 8 != 0) 1288 ++len; 1289 pj_memmove(this_cport->tx_buf + sizeof(pjmedia_frame_ext), sf, 1290 len); 1291 pjmedia_frame_ext_pop_subframes(f_src_, i); 1292 1293 } else if (f_src->type == PJMEDIA_FRAME_TYPE_AUDIO) { 1294 if ((f_src->size>>1) < this_cport->samples_per_frame) { 1295 pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 1296 frame->type = PJMEDIA_FRAME_TYPE_NONE; 1297 break; 1291 1298 } 1292 f_src_->samples_cnt = f_src_->samples_cnt - 1293 (pj_uint16_t)(i * samples_per_subframe); 1294 f_src_->subframe_cnt = f_src_->subframe_cnt - (pj_uint16_t)i; 1295 1296 } else if (f_src->type == PJMEDIA_FRAME_TYPE_AUDIO) { 1299 1297 1300 pjmedia_copy_samples((pj_int16_t*)frame->buf, 1298 1301 (pj_int16_t*)f_src->buf, … … 1307 1310 this_cport->samples_per_frame, 1308 1311 f_src->size >> 1); 1312 } else { /* PJMEDIA_FRAME_TYPE_NONE */ 1313 /* Reset TX buffer */ 1314 pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 1315 frame->type = PJMEDIA_FRAME_TYPE_NONE; 1309 1316 } 1310 1317 } while (0); … … 1326 1333 unsigned j; 1327 1334 pj_int32_t level; 1328 1329 /* Check for correct size. */1330 PJ_ASSERT_RETURN( f->size == conf->samples_per_frame *1331 conf->bits_per_sample / 8,1332 PJMEDIA_ENCSAMPLESPFRAME);1333 1335 1334 1336 pj_add_timestamp32(&cport->ts_rx, cport->samples_per_frame);
Note: See TracChangeset
for help on using the changeset viewer.