Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
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
15
#include "
roc_audio/sample_spec.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/rate_limiter.h
"
18
#include "
roc_core/stddefs.h
"
19
#include "
roc_packet/ireader.h
"
20
21
namespace
roc
{
22
namespace
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.
28
class
TimestampInjector
:
public
packet::IReader
,
public
core::NonCopyable
<> {
29
public
:
30
//! Initialize.
31
TimestampInjector
(
packet::IReader
& reader,
const
audio::SampleSpec
& sample_spec);
32
33
//! Virtual destructor.
34
virtual
~TimestampInjector
();
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.
39
virtual
ROC_ATTR_NODISCARD
status::StatusCode
read
(
packet::PacketPtr
&);
40
41
//! Get a pair of a reference timestamps.
42
void
update_mapping
(
core::nanoseconds_t
capture_ts,
43
packet::stream_timestamp_t
rtp_ts);
44
45
private
:
46
bool
has_ts_;
47
core::nanoseconds_t
capt_ts_;
48
packet::stream_timestamp_t
rtp_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_
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::packet::IReader
Packet reader interface.
Definition
ireader.h:23
roc::rtp::TimestampInjector::~TimestampInjector
virtual ~TimestampInjector()
Virtual destructor.
roc::rtp::TimestampInjector::TimestampInjector
TimestampInjector(packet::IReader &reader, const audio::SampleSpec &sample_spec)
Initialize.
roc::rtp::TimestampInjector::update_mapping
void update_mapping(core::nanoseconds_t capture_ts, packet::stream_timestamp_t rtp_ts)
Get a pair of a reference timestamps.
roc::rtp::TimestampInjector::read
virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr &)
Get packet with filled capture ts field.
ireader.h
Packet reader interface.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::packet::PacketPtr
core::SharedPtr< Packet > PacketPtr
Packet smart pointer.
Definition
packet.h:34
roc::packet::stream_timestamp_t
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition
units.h:36
roc::rtp
RTP protocol support.
roc
Root namespace.
noncopyable.h
Non-copyable object.
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_injector.h
Generated by
1.17.0