Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
ntp.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_packet/ntp.h
10
//! @brief Utitilies for NTP timestamp.
11
12
#ifndef ROC_PACKET_NTP_H_
13
#define ROC_PACKET_NTP_H_
14
15
#include "
roc_core/time.h
"
16
17
namespace
roc
{
18
namespace
packet
{
19
20
//! NTP timestamp.
21
//!
22
//! Format:
23
//! - highest 32 bits - seconds since NTP epoch
24
//! - lowest 32 bits - fractions of a second
25
//!
26
//! Epoch:
27
//! - for dates in years 1968-2036, epoch starts from 1 Jan 1900 00:00:00
28
//! - for dates in years 2036-2104, epoch starts from 7 Feb 2036 06:28:16
29
//!
30
//! See RFC 5905 and RFC 2030.
31
//!
32
//! See also:
33
//! - https://tickelton.gitlab.io/articles/ntp-timestamps/
34
//! - https://www.eecis.udel.edu/~mills/y2k.html
35
typedef
uint64_t
ntp_timestamp_t
;
36
37
//! Convert Unix absolute time to NTP absolute time.
38
//! @remarks
39
//! @p unix_time defines nanoseconds since Unix epoch (should belong to years 1968-2104).
40
ntp_timestamp_t
unix_2_ntp
(
core::nanoseconds_t
unix_time);
41
42
//! Convert NTP absolute time to Unix absolute time.
43
core::nanoseconds_t
ntp_2_unix
(
ntp_timestamp_t
ntp_time);
44
45
//! Convert nanoseconds delta to NTP delta.
46
//! @remarks
47
//! @p ns_delta defines nanoseconds delta (should be positive)
48
ntp_timestamp_t
nanoseconds_2_ntp
(
core::nanoseconds_t
ns_delta);
49
50
//! Converts NTP delta to nanoseconds delta.
51
core::nanoseconds_t
ntp_2_nanoseconds
(
ntp_timestamp_t
ntp_delta);
52
53
}
// namespace packet
54
}
// namespace roc
55
56
#endif
// ROC_PACKET_NTP_H_
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::packet
Network packets and packet processing.
roc::packet::unix_2_ntp
ntp_timestamp_t unix_2_ntp(core::nanoseconds_t unix_time)
Convert Unix absolute time to NTP absolute time.
roc::packet::nanoseconds_2_ntp
ntp_timestamp_t nanoseconds_2_ntp(core::nanoseconds_t ns_delta)
Convert nanoseconds delta to NTP delta.
roc::packet::ntp_timestamp_t
uint64_t ntp_timestamp_t
NTP timestamp.
Definition
ntp.h:35
roc::packet::ntp_2_nanoseconds
core::nanoseconds_t ntp_2_nanoseconds(ntp_timestamp_t ntp_delta)
Converts NTP delta to nanoseconds delta.
roc::packet::ntp_2_unix
core::nanoseconds_t ntp_2_unix(ntp_timestamp_t ntp_time)
Convert NTP absolute time to Unix absolute time.
roc
Root namespace.
time.h
Time definitions.
roc_packet
ntp.h
Generated by
1.17.0