Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
bye_traverser.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 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_rtcp/bye_traverser.h
10
//! @brief RTCP interface structures.
11
12
#ifndef ROC_RTCP_BYE_TRAVERSER_H_
13
#define ROC_RTCP_BYE_TRAVERSER_H_
14
15
#include "
roc_core/slice.h
"
16
#include "
roc_core/stddefs.h
"
17
#include "
roc_core/time.h
"
18
#include "
roc_packet/units.h
"
19
#include "
roc_rtcp/headers.h
"
20
21
namespace
roc
{
22
namespace
rtcp
{
23
24
//! BYE packet traverer.
25
class
ByeTraverser
{
26
public
:
27
//! Packet iterator.
28
class
Iterator {
29
public
:
30
//! Iterator state.
31
enum
State
{
32
BEGIN
,
//!< Iterator created.
33
SSRC
,
//!< SSRC element.
34
REASON
,
//!< REASON element.
35
END
//!< Parsed whole packet.
36
};
37
38
//! Advance iterator.
39
State
next
();
40
41
//! Check if there were any parsing errors.
42
bool
error
()
const
;
43
44
//! Get SSRC element.
45
//! @pre Can be used if next() returned SSRC.
46
packet::stream_source_t
get_ssrc
()
const
;
47
48
//! Get REASON element.
49
//! Zero-terminated UTF-8 string.
50
//! Pointer is valid only until next() call.
51
//! @pre Can be used if next() returned REASON.
52
const
char
*
get_reason
()
const
;
53
54
private
:
55
friend
class
ByeTraverser;
56
57
explicit
Iterator(
const
ByeTraverser& traverser);
58
void
next_element_();
59
void
parse_ssrc_();
60
void
parse_reason_();
61
62
const
ByeTraverser& traverser_;
63
64
State
state_;
65
const
core::Slice<uint8_t>
buf_;
66
size_t
cur_pos_;
67
size_t
cur_ssrc_;
68
bool
error_;
69
70
packet::stream_source_t
parsed_ssrc_;
71
char
parsed_reason_[header::MaxTextLen + 1];
72
};
73
74
//! Initialize traverser.
75
//! It will parse and iterate provided buffer.
76
explicit
ByeTraverser
(
const
core::Slice<uint8_t>
& buf);
77
78
//! Parse packet from buffer.
79
bool
parse
();
80
81
//! Construct iterator.
82
//! @pre Can be used if parse() returned true.
83
Iterator
iter
()
const
;
84
85
//! Get number of SSRC elements in packet.
86
size_t
ssrc_count
()
const
;
87
88
private
:
89
core::Slice<uint8_t>
buf_;
90
bool
parsed_;
91
size_t
ssrc_count_;
92
};
93
94
}
// namespace rtcp
95
}
// namespace roc
96
97
#endif
// ROC_RTCP_BYE_TRAVERSER_H_
roc::core::Slice
Slice.
Definition
slice.h:55
roc::rtcp::ByeTraverser::Iterator
Packet iterator.
Definition
bye_traverser.h:28
roc::rtcp::ByeTraverser::Iterator::get_ssrc
packet::stream_source_t get_ssrc() const
Get SSRC element.
roc::rtcp::ByeTraverser::Iterator::get_reason
const char * get_reason() const
Get REASON element. Zero-terminated UTF-8 string. Pointer is valid only until next() call.
roc::rtcp::ByeTraverser::Iterator::State
State
Iterator state.
Definition
bye_traverser.h:31
roc::rtcp::ByeTraverser::Iterator::END
@ END
Parsed whole packet.
Definition
bye_traverser.h:35
roc::rtcp::ByeTraverser::Iterator::BEGIN
@ BEGIN
Iterator created.
Definition
bye_traverser.h:32
roc::rtcp::ByeTraverser::Iterator::SSRC
@ SSRC
SSRC element.
Definition
bye_traverser.h:33
roc::rtcp::ByeTraverser::Iterator::REASON
@ REASON
REASON element.
Definition
bye_traverser.h:34
roc::rtcp::ByeTraverser::Iterator::error
bool error() const
Check if there were any parsing errors.
roc::rtcp::ByeTraverser::Iterator::next
State next()
Advance iterator.
roc::rtcp::ByeTraverser::iter
Iterator iter() const
Construct iterator.
roc::rtcp::ByeTraverser::ssrc_count
size_t ssrc_count() const
Get number of SSRC elements in packet.
roc::rtcp::ByeTraverser::ByeTraverser
ByeTraverser(const core::Slice< uint8_t > &buf)
Initialize traverser. It will parse and iterate provided buffer.
roc::rtcp::ByeTraverser::parse
bool parse()
Parse packet from buffer.
roc::packet::stream_source_t
uint32_t stream_source_t
Packet stream identifier.
Definition
units.h:27
roc::rtcp
RTCP protocol support.
roc
Root namespace.
headers.h
RTCP headers.
slice.h
Slice.
stddefs.h
Commonly used types and functions.
time.h
Time definitions.
units.h
Various units used in packets.
roc_rtcp
bye_traverser.h
Generated by
1.17.0