Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
validator.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/validator.h
10//! @brief RTP validator.
11
12#ifndef ROC_RTP_VALIDATOR_H_
13#define ROC_RTP_VALIDATOR_H_
14
17#include "roc_core/time.h"
18#include "roc_packet/ireader.h"
19
20namespace roc {
21namespace rtp {
22
23//! Validator parameters.
25 //! Maximum allowed delta between two consecutive packet seqnums.
27
28 //! Maximum allowed delta between two consecutive packet timestamps, in nanoseconds.
30
32 : max_sn_jump(100)
33 , max_ts_jump(core::Second) {
34 }
35};
36
37//! RTP validator.
39public:
40 //! Initialize.
41 //!
42 //! @b Parameters
43 //! - @p reader is input packet reader
44 //! - @p config defines validator parameters
45 //! - @p sample_spec defines session sample spec
47 const ValidatorConfig& config,
48 const audio::SampleSpec& sample_spec);
49
50 //! Read next packet.
51 //! @remarks
52 //! Reads packet from the underlying reader and validates it. If the packet
53 //! is valid, return it. Otherwise, returns NULL.
55
56private:
57 bool check_(const packet::RTP& prev, const packet::RTP& next) const;
58
59 packet::IReader& reader_;
60 packet::PacketPtr prev_packet_;
61
62 const ValidatorConfig config_;
63 const audio::SampleSpec sample_spec_;
64};
65
66} // namespace rtp
67} // namespace roc
68
69#endif // ROC_RTP_VALIDATOR_H_
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
Base class for non-copyable objects.
Definition: noncopyable.h:23
Packet reader interface.
Definition: ireader.h:21
RTP validator.
Definition: validator.h:38
virtual packet::PacketPtr read()
Read next packet.
Validator(packet::IReader &reader, const ValidatorConfig &config, const audio::SampleSpec &sample_spec)
Initialize.
Packet reader interface.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Sample specifications.
RTP packet.
Definition: rtp.h:23
Validator parameters.
Definition: validator.h:24
core::nanoseconds_t max_ts_jump
Maximum allowed delta between two consecutive packet timestamps, in nanoseconds.
Definition: validator.h:29
size_t max_sn_jump
Maximum allowed delta between two consecutive packet seqnums.
Definition: validator.h:26
Time definitions.