- Timestamp:
- Jan 20, 2007 5:14:24 AM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/os.h
r746 r887 922 922 923 923 /** 924 * Set timestamp from 32bit values. 925 * @param t The timestamp to be set. 926 * @param hi The high 32bit part. 927 * @param lo The low 32bit part. 928 */ 929 PJ_INLINE(void) pj_set_timestamp32(pj_timestamp *t, pj_uint32_t hi, 930 pj_uint32_t lo) 931 { 932 t->u32.hi = hi; 933 t->u32.lo = lo; 934 } 935 936 /** 924 937 * Add timestamp t2 to t1. 925 938 * @param t1 t1. … … 934 947 t1->u32.hi += t2->u32.hi; 935 948 t1->u32.lo += t2->u32.lo; 949 if (t1->u32.lo < old) 950 ++t1->u32.hi; 951 #endif 952 } 953 954 /** 955 * Add timestamp t2 to t1. 956 * @param t1 t1. 957 * @param t2 t2. 958 */ 959 PJ_INLINE(void) pj_add_timestamp32(pj_timestamp *t1, pj_uint32_t t2) 960 { 961 #if PJ_HAS_INT64 962 t1->u64 += t2; 963 #else 964 pj_uint32_t old = t1->u32.lo; 965 t1->u32.lo += t2; 936 966 if (t1->u32.lo < old) 937 967 ++t1->u32.hi; … … 960 990 961 991 /** 992 * Substract timestamp t2 from t1. 993 * @param t1 t1. 994 * @param t2 t2. 995 */ 996 PJ_INLINE(void) pj_sub_timestamp32(pj_timestamp *t1, pj_uint32_t t2) 997 { 998 #if PJ_HAS_INT64 999 t1->u64 -= t2; 1000 #else 1001 if (t1->u32.lo >= t2) 1002 t1->u32.lo -= t2; 1003 else { 1004 t1->u32.lo -= t2; 1005 --t1->u32.hi; 1006 } 1007 #endif 1008 } 1009 1010 /** 1011 * Get the timestamp difference between t2 and t1 (that is t2 minus t1), 1012 * and return a 32bit signed integer difference. 1013 */ 1014 PJ_INLINE(pj_int32_t) pj_timestamp_diff32(const pj_timestamp *t1, 1015 const pj_timestamp *t2) 1016 { 1017 /* Be careful with the signess (I think!) */ 1018 #if PJ_HAS_INT64 1019 pj_int64_t diff = t2->u64 - t1->u64; 1020 return (pj_int32_t) diff; 1021 #else 1022 pj_int32 diff = t2->u32.lo - t1->u32.lo; 1023 return diff; 1024 #endif 1025 } 1026 1027 1028 /** 962 1029 * Calculate the elapsed time, and store it in pj_time_val. 963 1030 * This function calculates the elapsed time using highest precision -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r864 r887 1312 1312 */ 1313 1313 static pj_status_t write_port(pjmedia_conf *conf, struct conf_port *cport, 1314 pj_uint32_ttimestamp,1314 const pj_timestamp *timestamp, 1315 1315 pjmedia_frame_type *frm_type) 1316 1316 { 1317 1317 pj_int16_t *buf; 1318 unsigned j ;1318 unsigned j, ts; 1319 1319 pj_status_t status; 1320 1320 … … 1332 1332 pjmedia_frame frame; 1333 1333 1334 /* Adjust the timestamp */ 1335 frame.timestamp.u64 = timestamp->u64 * cport->clock_rate / 1336 conf->clock_rate; 1334 1337 frame.type = PJMEDIA_FRAME_TYPE_NONE; 1335 1338 frame.buf = NULL; … … 1458 1461 frame.buf = (pj_int16_t*)cport->mix_buf; 1459 1462 frame.size = conf->samples_per_frame * BYTES_PER_SAMPLE; 1460 frame.timestamp.u64 = timestamp; 1463 /* No need to adjust timestamp, port has the same 1464 * clock rate as conference bridge 1465 */ 1466 frame.timestamp = *timestamp; 1461 1467 1462 1468 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", … … 1492 1498 /* Transmit while we have enough frame in the tx_buf. */ 1493 1499 status = PJ_SUCCESS; 1500 ts = 0; 1494 1501 while (cport->tx_buf_count >= cport->samples_per_frame && 1495 1502 status == PJ_SUCCESS) … … 1506 1513 frame.buf = cport->tx_buf; 1507 1514 frame.size = cport->samples_per_frame * BYTES_PER_SAMPLE; 1508 frame.timestamp.u64 = timestamp; 1515 /* Adjust timestamp as port may have different clock rate 1516 * than the bridge. 1517 */ 1518 frame.timestamp.u64 = timestamp->u64 * cport->clock_rate / 1519 conf->clock_rate; 1520 1521 /* Add timestamp for individual frame */ 1522 frame.timestamp.u64 += ts; 1523 ts += cport->samples_per_frame; 1509 1524 1510 1525 TRACE_((THIS_FILE, "put_frame %.*s, count=%d", … … 1747 1762 ++ci; 1748 1763 1749 status = write_port( conf, conf_port, frame->timestamp.u32.lo,1764 status = write_port( conf, conf_port, &frame->timestamp, 1750 1765 &frm_type); 1751 1766 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.