Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
filter.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 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/filter.h
10
//! @brief RTP filter.
11
12
#ifndef ROC_RTP_FILTER_H_
13
#define ROC_RTP_FILTER_H_
14
15
#include "
roc_audio/iframe_decoder.h
"
16
#include "
roc_audio/sample_spec.h
"
17
#include "
roc_core/noncopyable.h
"
18
#include "
roc_core/time.h
"
19
#include "
roc_packet/ireader.h
"
20
21
namespace
roc
{
22
namespace
rtp
{
23
24
//! RTP filter parameters.
25
struct
FilterConfig {
26
//! Maximum allowed delta between two consecutive packet seqnums.
27
//! If exceeded, packet is dropped.
28
size_t
max_sn_jump
;
29
30
//! Maximum allowed delta between two consecutive packet timestamps, in nanoseconds.
31
//! If exceeded, packet is dropped.
32
core::nanoseconds_t
max_ts_jump
;
33
34
FilterConfig()
35
:
max_sn_jump
(100)
36
,
max_ts_jump
(
core
::Second) {
37
}
38
};
39
40
//! RTP filter.
41
//!
42
//! Performs initial validation and initialization of incoming sequence
43
//! of RTP packets.
44
//!
45
//! - Validates sequence of incoming RTP packets and detects disturbances,
46
//! like seqnum jumps, timestamp jumps, SSRC changes, etc.
47
//!
48
//! - Populates local fields (that are not carried over network),
49
//! currently packet duration (based on provided payload decoder).
50
class
Filter
:
public
packet::IReader
,
public
core::NonCopyable
<> {
51
public
:
52
//! Initialize.
53
//!
54
//! @b Parameters
55
//! - @p reader is used to read input packets
56
//! - @p decoder is used to query parameters of packets
57
//! - @p config defines filtering parameters
58
//! - @p sample_spec defines stream sample spec
59
Filter
(
packet::IReader
& reader,
60
audio::IFrameDecoder
& decoder,
61
const
FilterConfig
& config,
62
const
audio::SampleSpec
& sample_spec);
63
64
//! Read next packet.
65
virtual
ROC_ATTR_NODISCARD
status::StatusCode
read
(
packet::PacketPtr
& pp);
66
67
private
:
68
bool
validate_(
const
packet::PacketPtr
&
packet
);
69
void
populate_(
const
packet::PacketPtr
&
packet
);
70
71
bool
validate_sequence_(
const
packet::RTP
& prev,
const
packet::RTP
& next)
const
;
72
73
packet::IReader
& reader_;
74
audio::IFrameDecoder
& decoder_;
75
76
bool
has_prev_packet_;
77
packet::RTP
prev_packet_rtp_;
78
79
const
FilterConfig
config_;
80
const
audio::SampleSpec
sample_spec_;
81
};
82
83
}
// namespace rtp
84
}
// namespace roc
85
86
#endif
// ROC_RTP_FILTER_H_
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::audio::IFrameDecoder
Audio frame decoder interface.
Definition
iframe_decoder.h:24
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::packet::IReader
Packet reader interface.
Definition
ireader.h:23
roc::rtp::Filter::Filter
Filter(packet::IReader &reader, audio::IFrameDecoder &decoder, const FilterConfig &config, const audio::SampleSpec &sample_spec)
Initialize.
roc::rtp::Filter::read
virtual ROC_ATTR_NODISCARD status::StatusCode read(packet::PacketPtr &pp)
Read next packet.
iframe_decoder.h
Audio frame decoder interface.
ireader.h
Packet reader interface.
roc::core
General-purpose building blocks and platform abstraction layer.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::packet
Network packets and packet processing.
roc::packet::PacketPtr
core::SharedPtr< Packet > PacketPtr
Packet smart pointer.
Definition
packet.h:34
roc::rtp
RTP protocol support.
roc
Root namespace.
noncopyable.h
Non-copyable object.
sample_spec.h
Sample specifications.
roc::status::StatusCode
StatusCode
Status code.
Definition
status_code.h:19
roc::packet::RTP
RTP packet.
Definition
rtp.h:24
roc::rtp::FilterConfig
RTP filter parameters.
Definition
filter.h:25
roc::rtp::FilterConfig::max_sn_jump
size_t max_sn_jump
Maximum allowed delta between two consecutive packet seqnums. If exceeded, packet is dropped.
Definition
filter.h:28
roc::rtp::FilterConfig::max_ts_jump
core::nanoseconds_t max_ts_jump
Maximum allowed delta between two consecutive packet timestamps, in nanoseconds. If exceeded,...
Definition
filter.h:32
time.h
Time definitions.
roc_rtp
filter.h
Generated by
1.17.0