Ignore:
Timestamp:
Jan 20, 2007 5:14:24 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #70: Frame timestamp not propagated correctly in PJMEDIA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/os.h

    r746 r887  
    922922 
    923923/** 
     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 */ 
     929PJ_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/** 
    924937 * Add timestamp t2 to t1. 
    925938 * @param t1        t1. 
     
    934947    t1->u32.hi += t2->u32.hi; 
    935948    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 */ 
     959PJ_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; 
    936966    if (t1->u32.lo < old) 
    937967        ++t1->u32.hi; 
     
    960990 
    961991/** 
     992 * Substract timestamp t2 from t1. 
     993 * @param t1        t1. 
     994 * @param t2        t2. 
     995 */ 
     996PJ_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 */ 
     1014PJ_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/** 
    9621029 * Calculate the elapsed time, and store it in pj_time_val. 
    9631030 * This function calculates the elapsed time using highest precision 
Note: See TracChangeset for help on using the changeset viewer.