Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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 <errno.h>
16#include <sys/time.h>
17#include <time.h>
18
20#include "roc_core/panic.h"
21#include "roc_core/time.h"
22#include "roc_packet/units.h"
23
24namespace roc {
25namespace packet {
26
27//! Get current NTP time.
29
30//! Compares a and b if they close enough.
32
33//! Converts nanoseconds to ntp timestamp.
34//! @param ns must be non-negative.
35//! @remark
36//! Warning: for deltas only, since NTP epoch represnted in nanoseconds could not fit
37//! into 64 bits.
39
40//! Converts ntp timestamp to nanoseconds.
41//! @remark
42//! Warning: for deltas only, since NTP epoch represented in nanoseconds could not fit
43//! into 64 bits.
45
46} // namespace packet
47} // namespace roc
48
49#endif // ROC_PACKET_NTP_H_
Convert errno to string.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
bool ntp_equal_delta(ntp_timestamp_t a, ntp_timestamp_t b, ntp_timestamp_t delta)
Compares a and b if they close enough.
core::nanoseconds_t ntp_2_nanoseconds(ntp_timestamp_t ts)
Converts ntp timestamp to nanoseconds.
packet::ntp_timestamp_t ntp_timestamp()
Get current NTP time.
ntp_timestamp_t nanoseconds_2_ntp(core::nanoseconds_t ns)
Converts nanoseconds to ntp timestamp.
uint64_t ntp_timestamp_t
NTP timestamp.
Definition units.h:91
Root namespace.
Panic.
Time definitions.
Various units used in packets.