Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
builder.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/builder.h
10//! @brief RTCP packet builder.
11
12#ifndef ROC_RTCP_BUILDER_H_
13#define ROC_RTCP_BUILDER_H_
14
16#include "roc_core/stddefs.h"
17#include "roc_packet/units.h"
19#include "roc_rtcp/headers.h"
20#include "roc_rtcp/sdes.h"
21
22namespace roc {
23namespace rtcp {
24
25//! RTCP compound packet builder.
26class Builder : public core::NonCopyable<> {
27public:
28 //! Initialize builder.
29 //! It will write data to the given slice.
31
32 //! @name Sender Report (SR)
33 //! @{
34
35 //! Start SR packet inside compound RTCP packet.
37
38 //! Add reception report to current SR packet.
40
41 //! Finish SR packet.
42 void end_sr();
43
44 //! @}
45
46 //! @name Receiver Report (RR)
47 //! @{
48
49 //! Start RR packet inside compound RTCP packet.
51
52 //! Add reception report to current RR packet.
54
55 //! Finish RR packet.
56 void end_rr();
57
58 //! @}
59
60 //! @name Extended Report (XR)
61 //! @{
62
63 //! Start XR packet inside compound RTCP packet.
64 void begin_xr(const header::XrPacket& xr);
65
66 //! Add RRTR block to current XR packet.
68
69 //! Start DLRR block inside current XR packet.
71
72 //! Add DLRR report to current DLRR block.
74
75 //! Finish current DLRR block.
77
78 //! Finish current XR packet.
79 void end_xr();
80
81 //! @}
82
83 //! @name Session Description (SDES)
84 //! @{
85
86 //! Start SDES packet inside compound RTCP packet.
87 void begin_sdes();
88
89 //! Start new SDES chunk in current SDES packet.
90 void begin_sdes_chunk(const SdesChunk& chunk);
91
92 //! Add SDES item to current SDES chunk.
93 void add_sdes_item(const SdesItem& item);
94
95 //! Finish current SDES chunk.
97
98 //! Finish current SDES packet.
99 void end_sdes();
100
101 //! @}
102
103 //! @name Goodbye message (BYE)
104 //! @{
105
106 //! Start BYE packet inside compound RTCP packet.
107 void begin_bye();
108
109 //! Add SSRC to current BYE packet.
111
112 //! Add REASON to current BYE packet.
113 void add_bye_reason(const char* reason);
114
115 //! Finish current BYE packet.
116 void end_bye();
117
118 //! @}
119
120private:
121 void add_report_(const header::ReceptionReportBlock& report);
122 void end_packet_();
123
124 enum State {
125 NONE,
126 SR_HEAD,
127 SR_REPORT,
128 RR_HEAD,
129 RR_REPORT,
130 XR_HEAD,
131 XR_DLRR_HEAD,
132 XR_DLRR_REPORT,
133 SDES_HEAD,
134 SDES_CHUNK,
135 BYE_HEAD,
136 BYE_SSRC,
137 BYE_REASON
138 };
139
140 State state_;
142 header::PacketHeader* header_;
143 header::XrBlockHeader* xr_header_;
144 core::Slice<uint8_t> cur_slice_;
145 bool report_written_;
146 bool cname_written_;
147};
148
149} // namespace rtcp
150} // namespace roc
151
152#endif // ROC_RTCP_BUILDER_H_
RTCP interface structures.
Base class for non-copyable objects.
Definition noncopyable.h:23
RTCP compound packet builder.
Definition builder.h:26
void end_sr()
Finish SR packet.
void begin_rr(const header::ReceiverReportPacket &rr)
Start RR packet inside compound RTCP packet.
void end_sdes()
Finish current SDES packet.
void add_xr_dlrr_report(const header::XrDlrrSubblock &report)
Add DLRR report to current DLRR block.
void end_rr()
Finish RR packet.
void end_sdes_chunk()
Finish current SDES chunk.
void end_xr_dlrr()
Finish current DLRR block.
void begin_bye()
Start BYE packet inside compound RTCP packet.
void add_bye_ssrc(const packet::source_t ssrc)
Add SSRC to current BYE packet.
void end_bye()
Finish current BYE packet.
void add_rr_report(const header::ReceptionReportBlock &report)
Add reception report to current RR packet.
void begin_xr_dlrr(const header::XrDlrrBlock &dlrr)
Start DLRR block inside current XR packet.
void begin_sr(const header::SenderReportPacket &sr)
Start SR packet inside compound RTCP packet.
Builder(core::Slice< uint8_t > &data)
Initialize builder. It will write data to the given slice.
void begin_sdes()
Start SDES packet inside compound RTCP packet.
void add_xr_rrtr(const header::XrRrtrBlock &rrtr)
Add RRTR block to current XR packet.
void add_sdes_item(const SdesItem &item)
Add SDES item to current SDES chunk.
void end_xr()
Finish current XR packet.
void begin_sdes_chunk(const SdesChunk &chunk)
Start new SDES chunk in current SDES packet.
void add_bye_reason(const char *reason)
Add REASON to current BYE packet.
void begin_xr(const header::XrPacket &xr)
Start XR packet inside compound RTCP packet.
void add_sr_report(const header::ReceptionReportBlock &report)
Add reception report to current SR packet.
RTCP packet header, common for all RTCP packet types.
Definition headers.h:149
Receiver Report RTCP packet (RR).
Definition headers.h:471
Sender Report RTCP packet (SR).
Definition headers.h:568
XR DLRR Report block.
Definition headers.h:1234
XR DLRR Report sub-block.
Definition headers.h:1166
RTCP Extended Report Packet.
Definition headers.h:980
XR Receiver Reference Time Report block.
Definition headers.h:1114
uint32_t source_t
Packet source ID identifying packet stream.
Definition units.h:22
Root namespace.
Non-copyable object.
RTCP headers.
SDES elements.
Commonly used types and functions.
Parsed SDES chunk.
Definition sdes.h:23
Parsed SDES item.
Definition sdes.h:33
Various units used in packets.