Changeset 384 for pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
- Timestamp:
- Apr 5, 2006 4:56:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
r383 r384 20 20 #include <pjmedia/errno.h> 21 21 #include <pj/assert.h> 22 #include <pj/log.h> 22 23 #include <pj/os.h> 23 24 #include <pj/sock.h> 24 25 #include <pj/string.h> 25 26 27 #define THIS_FILE "rtcp.c" 26 28 27 29 #define RTCP_SR 200 … … 33 35 #endif 34 36 37 #if 0 38 # define TRACE_(x) PJ_LOG(3,x) 39 #else 40 # define TRACE_(x) 41 #endif 35 42 36 43 /* … … 183 190 pj_get_timestamp(&session->rtcp_lsr_time); 184 191 185 /* Calculate ee_delayif it has RR */192 /* Calculate RTT if it has RR */ 186 193 if (size >= sizeof(pjmedia_rtcp_pkt)) { 187 194 188 195 /* Can only calculate if LSR and DLSR is present in RR */ 189 196 if (rtcp->rr.lsr && rtcp->rr.dlsr) { 190 pj_uint32_t lsr, now, dlsr, eedelay; 197 pj_uint32_t lsr, now, dlsr; 198 pj_uint64_t eedelay; 191 199 pjmedia_rtcp_ntp_rec ntp; 192 200 … … 207 215 eedelay = now - lsr - dlsr; 208 216 209 /* Convert end to end delay to msec: 217 /* Convert end to end delay to usec (keeping the calculation in 218 * 64bit space):: 210 219 * session->ee_delay = (eedelay * 1000) / 65536; 211 220 */ 212 session->ee_delay = (eedelay * 1000) >> 16; 221 eedelay = (eedelay * 1000000) >> 16; 222 223 TRACE_((THIS_FILE, "Rx RTCP: lsr=%p, dlsr=%p (%d:%03dms), " 224 "now=%p, rtt=%p", 225 lsr, dlsr, dlsr/65536, (dlsr%65536)*1000/65536, 226 now, (pj_uint32_t)eedelay)); 227 228 /* Only save calculation if "now" is greater than lsr, or 229 * otherwise rtt will be invalid 230 */ 231 if (now-dlsr >= lsr) { 232 session->rtt_us = (pj_uint32_t)eedelay; 233 } else { 234 TRACE_((THIS_FILE, "NTP clock running backwards?")); 235 } 213 236 } 214 237 } … … 272 295 rtcp_pkt->sr.ntp_frac = pj_htonl(ntp.lo); 273 296 274 if (session->rtcp_lsr_time.u64 == 0 || session->rtcp_lsr.lo == 0) {297 if (session->rtcp_lsr_time.u64 == 0) { 275 298 rtcp_pkt->rr.lsr = 0; 276 299 rtcp_pkt->rr.dlsr = 0; … … 290 313 pj_get_timestamp(&ts); 291 314 315 /* Calculate DLSR */ 316 ts.u64 -= session->rtcp_lsr_time.u64; 317 292 318 /* Convert interval to 1/65536 seconds value */ 293 319 ts.u64 = ((ts.u64 - session->rtcp_lsr_time.u64) << 16) /
Note: See TracChangeset
for help on using the changeset viewer.