Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
15
#include "
roc_audio/sample_spec.h
"
16
#include "
roc_core/attributes.h
"
17
#include "
roc_core/noncopyable.h
"
18
#include "
roc_core/rate_limiter.h
"
19
#include "
roc_core/stddefs.h
"
20
#include "
roc_packet/iwriter.h
"
21
#include "
roc_packet/packet.h
"
22
23
namespace
roc
{
24
namespace
rtp {
25
26
//! Remembers a recent pair of capture timestamp and rtp ts.
27
class
TimestampExtractor
:
public
packet::IWriter
,
public
core::NonCopyable
<> {
28
public
:
29
//! Initialize.
30
TimestampExtractor
(
packet::IWriter
& writer,
const
audio::SampleSpec
& sample_spec);
31
32
//! Destroy.
33
virtual
~TimestampExtractor
();
34
35
//! Passes pkt downstream and remembers its capture and rtp timestamps.
36
virtual
ROC_ATTR_NODISCARD
status::StatusCode
write
(
const
packet::PacketPtr
& pkt);
37
38
//! Check if mapping already available.
39
bool
has_mapping
();
40
41
//! Get rtp timestamp mapped to given capture timestamp.
42
//! @pre
43
//! has_mapping() should return true, otherwise it will panic.
44
packet::stream_timestamp_t
get_mapping
(
core::nanoseconds_t
capture_ts);
45
46
private
:
47
packet::IWriter
& writer_;
48
49
bool
has_ts_;
50
core::nanoseconds_t
capt_ts_;
51
packet::stream_timestamp_t
rtp_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_
attributes.h
Compiler attributes.
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition:
attributes.h:31
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition:
sample_spec.h:30
roc::core::NonCopyable
Base class for non-copyable objects.
Definition:
noncopyable.h:23
roc::core::RateLimiter
Rate limiter.
Definition:
rate_limiter.h:22
roc::core::SharedPtr< Packet >
roc::packet::IWriter
Packet writer interface.
Definition:
iwriter.h:23
roc::rtp::TimestampExtractor
Remembers a recent pair of capture timestamp and rtp ts.
Definition:
timestamp_extractor.h:27
roc::rtp::TimestampExtractor::TimestampExtractor
TimestampExtractor(packet::IWriter &writer, const audio::SampleSpec &sample_spec)
Initialize.
roc::rtp::TimestampExtractor::write
virtual ROC_ATTR_NODISCARD status::StatusCode write(const packet::PacketPtr &pkt)
Passes pkt downstream and remembers its capture and rtp timestamps.
roc::rtp::TimestampExtractor::has_mapping
bool has_mapping()
Check if mapping already available.
roc::rtp::TimestampExtractor::get_mapping
packet::stream_timestamp_t get_mapping(core::nanoseconds_t capture_ts)
Get rtp timestamp mapped to given capture timestamp.
roc::rtp::TimestampExtractor::~TimestampExtractor
virtual ~TimestampExtractor()
Destroy.
iwriter.h
Packet writer interface.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition:
time.h:58
roc::packet::stream_timestamp_t
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition:
units.h:36
roc
Root namespace.
noncopyable.h
Non-copyable object.
packet.h
Packet.
rate_limiter.h
Rate limiter.
sample_spec.h
Sample specifications.
roc::status::StatusCode
StatusCode
Status code.
Definition:
status_code.h:19
stddefs.h
Commonly used types and functions.
roc_rtp
timestamp_extractor.h
Generated by
1.9.1