uvgRTP
clock.hh
1 #pragma once
2 
3 #include <chrono>
4 
5 namespace uvgrtp {
6  namespace clock {
7 
8  /* network time protocol */
9  namespace ntp {
10  uint64_t now();
11 
12  /* return the difference of ntp timestamps in milliseconds */
13  uint64_t diff(uint64_t ntp1, uint64_t ntp2);
14 
15  /* Calculate the difference between now
16  * (a wall clock reading when the function is called) and "then"
17  *
18  * The result is in milliseconds */
19  uint64_t diff_now(uint64_t then);
20  };
21 
22  /* high-resolution clock */
23  namespace hrc {
24  typedef std::chrono::high_resolution_clock::time_point hrc_t;
25 
26  hrc_t now();
27 
28  /* the result is in milliseconds */
29  uint64_t diff(hrc_t hrc1, hrc_t hrc2);
30 
31  /* the result is in milliseconds */
32  uint64_t diff_now(hrc_t then);
33 
34  uint64_t diff_now_us(hrc_t& then);
35  };
36 
37  uint64_t ms_to_jiffies(uint64_t ms);
38  uint64_t jiffies_to_ms(uint64_t jiffies);
39 
40 #ifdef _WIN32
41  int gettimeofday(struct timeval *tp, struct timezone *tzp);
42 #endif
43  };
44 };
45 
46 namespace uvg_rtp = uvgrtp;