2019-06-28 06:38:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
|
2021-02-19 01:13:43 +00:00
|
|
|
namespace uvgrtp {
|
2019-06-28 06:38:41 +00:00
|
|
|
namespace clock {
|
|
|
|
|
|
2019-07-25 05:34:45 +00:00
|
|
|
/* network time protocol */
|
|
|
|
|
namespace ntp {
|
|
|
|
|
uint64_t now();
|
2019-06-28 06:38:41 +00:00
|
|
|
|
2019-07-25 05:34:45 +00:00
|
|
|
/* return the difference of ntp timestamps in milliseconds */
|
|
|
|
|
uint64_t diff(uint64_t ntp1, uint64_t ntp2);
|
2019-06-28 06:38:41 +00:00
|
|
|
|
2019-07-25 05:34:45 +00:00
|
|
|
/* Calculate the difference between now
|
|
|
|
|
* (a wall clock reading when the function is called) and "then"
|
|
|
|
|
*
|
|
|
|
|
* The result is in milliseconds */
|
|
|
|
|
uint64_t diff_now(uint64_t then);
|
|
|
|
|
};
|
2019-06-28 06:38:41 +00:00
|
|
|
|
2019-07-25 05:34:45 +00:00
|
|
|
/* high-resolution clock */
|
|
|
|
|
namespace hrc {
|
|
|
|
|
typedef std::chrono::high_resolution_clock::time_point hrc_t;
|
|
|
|
|
|
|
|
|
|
hrc_t now();
|
|
|
|
|
|
|
|
|
|
/* the result is in milliseconds */
|
|
|
|
|
uint64_t diff(hrc_t hrc1, hrc_t hrc2);
|
|
|
|
|
|
|
|
|
|
/* the result is in milliseconds */
|
|
|
|
|
uint64_t diff_now(hrc_t then);
|
2019-08-31 05:06:43 +00:00
|
|
|
|
|
|
|
|
uint64_t diff_now_us(hrc_t& then);
|
2019-07-25 05:34:45 +00:00
|
|
|
};
|
2019-06-28 06:38:41 +00:00
|
|
|
|
|
|
|
|
uint64_t ms_to_jiffies(uint64_t ms);
|
|
|
|
|
uint64_t jiffies_to_ms(uint64_t jiffies);
|
2019-07-15 08:49:24 +00:00
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2019-07-25 05:34:45 +00:00
|
|
|
int gettimeofday(struct timeval *tp, struct timezone *tzp);
|
2019-07-15 08:49:24 +00:00
|
|
|
#endif
|
2019-06-28 06:38:41 +00:00
|
|
|
};
|
|
|
|
|
};
|
2021-02-19 01:13:43 +00:00
|
|
|
|
|
|
|
|
namespace uvg_rtp = uvgrtp;
|