37 #ifndef RTPTIMEUTILITIES_H 39 #define RTPTIMEUTILITIES_H 43 #ifndef RTP_HAVE_QUERYPERFORMANCECOUNTER 49 #endif // RTP_HAVE_QUERYPERFORMANCECOUNTER 53 #define RTP_NTPTIMEOFFSET 2208988800UL 55 #ifdef RTP_HAVE_VSUINT64SUFFIX 56 #define C1000000 1000000ui64 57 #define CEPOCH 11644473600000000ui64 59 #define C1000000 1000000ULL 60 #define CEPOCH 11644473600000000ULL 61 #endif // RTP_HAVE_VSUINT64SUFFIX 64 #include "../custom/apple/apple_compat.h" 113 static void Wait(
const RTPTime &delay);
155 #ifdef RTP_HAVE_QUERYPERFORMANCECOUNTER 157 #endif // RTP_HAVE_QUERYPERFORMANCECOUNTER 171 m_t = (double) seconds + 1e-6 * (
double) microseconds;
177 m_t = (double) possec + 1e-6 * (
double) microseconds;
192 double x = (double) ntptime.
GetLSW();
193 x /= (65536.0 * 65536.0);
197 m_t = (double) sec + 1e-6 * (
double) microsec;
213 microsec = (
uint32_t) (1e6 * (m_t - (
double) sec) + 0.5);
218 microsec = (
uint32_t) (1e6 * ((-m_t) - (double) sec) + 0.5);
221 if (microsec >= 1000000)
229 #ifdef RTP_HAVE_QUERYPERFORMANCECOUNTER 243 static int inited = 0;
244 static uint64_t microseconds, initmicroseconds;
245 static LARGE_INTEGER performancefrequency;
247 uint64_t emulate_microseconds, microdiff;
248 SYSTEMTIME systemtime;
251 LARGE_INTEGER performancecount;
253 QueryPerformanceCounter(&performancecount);
258 QueryPerformanceFrequency(&performancefrequency);
259 GetSystemTime(&systemtime);
260 SystemTimeToFileTime(&systemtime,&filetime);
263 initmicroseconds = CalculateMicroseconds(performancecount.QuadPart, performancefrequency.QuadPart);
266 emulate_microseconds = CalculateMicroseconds(performancecount.QuadPart, performancefrequency.QuadPart);
268 microdiff = emulate_microseconds - initmicroseconds;
270 double t = 1e-6*(double)(microseconds + microdiff);
281 DWORD t = ((DWORD)sec)*1000+(((DWORD)microsec)/1000);
287 #ifdef RTP_HAVE_CLOCK_GETTIME 290 return (
double) ts.tv_sec + 1e-9 * (double) ts.tv_nsec;
295 static bool s_initialized =
false;
296 static double s_startOffet = 0;
300 s_initialized =
true;
303 struct timespec tpSys, tpMono;
305 clock_gettime(CLOCK_REALTIME, &tpSys);
306 clock_gettime(CLOCK_MONOTONIC, &tpMono);
311 s_startOffet = tSys - tMono;
315 struct timespec tpMono;
316 clock_gettime(CLOCK_MONOTONIC, &tpMono);
319 return tMono0 + s_startOffet;
322 #else // gettimeofday fallback 331 #endif // RTP_HAVE_CLOCK_GETTIME 341 struct timespec req, rem;
344 req.tv_sec = (time_t) sec;
345 req.tv_nsec = ((long) nanosec);
348 ret = nanosleep(&req, &rem);
350 }
while (ret == -1 && errno == EINTR);
353 #endif // RTP_HAVE_QUERYPERFORMANCECOUNTER 376 x = microsec / 1000000.0;
377 x *= (65536.0 * 65536.0);
419 #endif // RTPTIMEUTILITIES_H
bool operator<=(const RTPTime &t) const
RTPNTPTime(uint32_t m, uint32_t l)
RTPTimeInitializerObject timeinit
uint32_t GetMicroSeconds() const
RTPTime & operator+=(const RTPTime &t)
bool operator<=(double a, Fixed< IntType, IntBits > const &b)
bool operator>(const RTPTime &t) const
bool operator>=(double a, Fixed< IntType, IntBits > const &b)
double RTPTime_timespecToDouble(struct timespec &ts)
#define RTP_NTPTIMEOFFSET
RTPTime & operator-=(const RTPTime &t)
bool operator>=(const RTPTime &t) const
bool operator<(double a, Fixed< IntType, IntBits > const &b)
static void Wait(const RTPTime &delay)
RTPNTPTime GetNTPTime() const
static RTPTime CurrentTime()
bool operator>(double a, Fixed< IntType, IntBits > const &b)
bool operator<(const RTPTime &t) const
int64_t GetSeconds() const
unsigned __int64 uint64_t