summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-01-20 05:14:24 +0000
committerBenny Prijono <bennylp@teluu.com>2007-01-20 05:14:24 +0000
commit9a8ba64767cb954e092b5aa7577871462ec3d595 (patch)
treeb76f01b56242b11ff74ee2909ceabcd1cdc2ceee /pjlib
parent7031c4d6b8b973b364abe6a236feb77ed40db307 (diff)
Fixed ticket #70: Frame timestamp not propagated correctly in PJMEDIA
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@887 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/os.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h
index 98a94c37..d57d13b6 100644
--- a/pjlib/include/pj/os.h
+++ b/pjlib/include/pj/os.h
@@ -921,6 +921,19 @@ PJ_DECL(pj_status_t) pj_get_timestamp(pj_timestamp *ts);
PJ_DECL(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq);
/**
+ * Set timestamp from 32bit values.
+ * @param t The timestamp to be set.
+ * @param hi The high 32bit part.
+ * @param lo The low 32bit part.
+ */
+PJ_INLINE(void) pj_set_timestamp32(pj_timestamp *t, pj_uint32_t hi,
+ pj_uint32_t lo)
+{
+ t->u32.hi = hi;
+ t->u32.lo = lo;
+}
+
+/**
* Add timestamp t2 to t1.
* @param t1 t1.
* @param t2 t2.
@@ -939,6 +952,23 @@ PJ_INLINE(void) pj_add_timestamp(pj_timestamp *t1, const pj_timestamp *t2)
}
/**
+ * Add timestamp t2 to t1.
+ * @param t1 t1.
+ * @param t2 t2.
+ */
+PJ_INLINE(void) pj_add_timestamp32(pj_timestamp *t1, pj_uint32_t t2)
+{
+#if PJ_HAS_INT64
+ t1->u64 += t2;
+#else
+ pj_uint32_t old = t1->u32.lo;
+ t1->u32.lo += t2;
+ if (t1->u32.lo < old)
+ ++t1->u32.hi;
+#endif
+}
+
+/**
* Substract timestamp t2 from t1.
* @param t1 t1.
* @param t2 t2.
@@ -959,6 +989,43 @@ PJ_INLINE(void) pj_sub_timestamp(pj_timestamp *t1, const pj_timestamp *t2)
}
/**
+ * Substract timestamp t2 from t1.
+ * @param t1 t1.
+ * @param t2 t2.
+ */
+PJ_INLINE(void) pj_sub_timestamp32(pj_timestamp *t1, pj_uint32_t t2)
+{
+#if PJ_HAS_INT64
+ t1->u64 -= t2;
+#else
+ if (t1->u32.lo >= t2)
+ t1->u32.lo -= t2;
+ else {
+ t1->u32.lo -= t2;
+ --t1->u32.hi;
+ }
+#endif
+}
+
+/**
+ * Get the timestamp difference between t2 and t1 (that is t2 minus t1),
+ * and return a 32bit signed integer difference.
+ */
+PJ_INLINE(pj_int32_t) pj_timestamp_diff32(const pj_timestamp *t1,
+ const pj_timestamp *t2)
+{
+ /* Be careful with the signess (I think!) */
+#if PJ_HAS_INT64
+ pj_int64_t diff = t2->u64 - t1->u64;
+ return (pj_int32_t) diff;
+#else
+ pj_int32 diff = t2->u32.lo - t1->u32.lo;
+ return diff;
+#endif
+}
+
+
+/**
* Calculate the elapsed time, and store it in pj_time_val.
* This function calculates the elapsed time using highest precision
* calculation that is available for current platform, considering