Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
timestamp_extractor.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_extractor.h
10//! @brief Extracts capture timestamp field from packets.
11
12#ifndef ROC_RTP_TIMESTAMP_EXTRACTOR_H_
13#define ROC_RTP_TIMESTAMP_EXTRACTOR_H_
14
16#include "roc_core/attributes.h"
19#include "roc_core/stddefs.h"
20#include "roc_packet/iwriter.h"
21#include "roc_packet/packet.h"
22
23namespace roc {
24namespace rtp {
25
26//! Remembers a recent pair of capture timestamp and rtp ts.
28public:
29 //! Initialize.
31
32 //! Destroy.
34
35 //! Passes pkt downstream and remembers its capture and rtp timestamps.
37
38 //! Check if mapping already available.
40
41 //! Get rtp timestamp mapped to given capture timestamp.
42 //! @pre
43 //! has_mapping() should return true, otherwise it will panic.
45
46private:
47 packet::IWriter& writer_;
48
49 bool has_ts_;
50 core::nanoseconds_t capt_ts_;
52
53 const audio::SampleSpec sample_spec_;
54
55 core::RateLimiter rate_limiter_;
56};
57
58} // namespace rtp
59} // namespace roc
60
61#endif // ROC_RTP_TIMESTAMP_EXTRACTOR_H_
Compiler attributes.
#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 writer interface.
Definition iwriter.h:23
Remembers a recent pair of capture timestamp and rtp ts.
TimestampExtractor(packet::IWriter &writer, const audio::SampleSpec &sample_spec)
Initialize.
bool has_mapping()
Check if mapping already available.
virtual status::StatusCode write(const packet::PacketPtr &pkt)
Passes pkt downstream and remembers its capture and rtp timestamps.
packet::stream_timestamp_t get_mapping(core::nanoseconds_t capture_ts)
Get rtp timestamp mapped to given capture timestamp.
virtual ~TimestampExtractor()
Destroy.
Packet writer 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.
Packet.
Rate limiter.
Sample specifications.
Commonly used types and functions.