Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
timestamp_injector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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_rtp/timestamp_injector.h
10//! @brief Fills capture timestamp field in packets.
11
12#ifndef ROC_RTP_TIMESTAMP_INJECTOR_H_
13#define ROC_RTP_TIMESTAMP_INJECTOR_H_
14
18#include "roc_core/stddefs.h"
19#include "roc_packet/ireader.h"
20
21namespace roc {
22namespace rtp {
23
24//! Fills capture timestamps in rtp packets.
25//! @remarks
26//! Gets a pair of a reference unix-time stamp (in ns) and correspondent rtp timestamp,
27//! and approximates this dependency to a passing packet.
29public:
30 //! Initialize.
32
33 //! Virtual destructor.
35
36 //! Get packet with filled capture ts field.
37 //! @remarks
38 //! If update_mapping has not been called yet, capture timestamp will be 0.
40
41 //! Get a pair of a reference timestamps.
44
45private:
46 bool has_ts_;
47 core::nanoseconds_t capt_ts_;
49
50 packet::IReader& reader_;
51 const audio::SampleSpec sample_spec_;
52
53 size_t n_drops_;
54
55 core::RateLimiter rate_limiter_;
56};
57
58} // namespace rtp
59} // namespace roc
60
61#endif // ROC_RTP_TIMESTAMP_INJECTOR_H_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:30
Base class for non-copyable objects.
Definition noncopyable.h:23
Packet reader interface.
Definition ireader.h:23
Fills capture timestamps in rtp packets.
virtual ~TimestampInjector()
Virtual destructor.
TimestampInjector(packet::IReader &reader, const audio::SampleSpec &sample_spec)
Initialize.
void update_mapping(core::nanoseconds_t capture_ts, packet::stream_timestamp_t rtp_ts)
Get a pair of a reference timestamps.
virtual status::StatusCode read(packet::PacketPtr &)
Get packet with filled capture ts field.
Packet reader interface.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition units.h:36
StatusCode
Status code.
Definition status_code.h:19
Root namespace.
Non-copyable object.
Rate limiter.
Sample specifications.
Commonly used types and functions.