Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
session.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/session.h
10//! @brief RTCP session.
11
12#ifndef ROC_RTCP_SESSION_H_
13#define ROC_RTCP_SESSION_H_
14
16#include "roc_core/stddefs.h"
17#include "roc_core/time.h"
19#include "roc_packet/iwriter.h"
20#include "roc_packet/packet.h"
22#include "roc_rtcp/builder.h"
25#include "roc_rtcp/traverser.h"
26
27namespace roc {
28namespace rtcp {
29
30//! RTCP session.
31//! Processes incoming RTCP packets and generates outgoing RTCP packets.
32class Session {
33public:
34 //! Initialize.
36 ISenderHooks* send_hooks,
37 packet::IWriter* packet_writer,
38 packet::IComposer& packet_composer,
39 packet::PacketFactory& packet_factory,
40 core::BufferFactory<uint8_t>& buffer_factory);
41
42 //! Check if initialization succeeded.
43 bool is_valid() const;
44
45 //! Parse and process incoming packet.
46 //! Invokes session hooks methods during processing.
48
49 //! When we should generate packets next time.
50 //! Returns absolute time.
51 //! @p current_time is current time in nanoseconds since Unix epoch.
53
54 //! Generate and send packet(s).
55 //! Should be called accroding to generation_deadline().
56 //! @p current_time is current time in nanoseconds since Unix epoch.
59
60private:
61 void parse_events_(const Traverser& traverser);
62 void parse_reports_(const Traverser& traverser);
63
64 void parse_session_description_(const SdesTraverser& sdes);
65 void parse_goodbye_(const ByeTraverser& bye);
66 void parse_sender_report_(const header::SenderReportPacket& sr);
67 void parse_receiver_report_(const header::ReceiverReportPacket& rr);
68 void parse_reception_block_(const header::ReceptionReportBlock& blk);
69
70 status::StatusCode generate_packet_(core::nanoseconds_t current_time,
71 packet::PacketPtr& packet);
72
73 void build_packet_(core::Slice<uint8_t>& data, core::nanoseconds_t report_time);
74 void build_sender_report_(Builder& bld, core::nanoseconds_t report_time);
75 void build_receiver_report_(Builder& bld, core::nanoseconds_t report_time);
76 header::ReceptionReportBlock build_reception_block_(const ReceptionMetrics& metrics);
77 void build_session_description_(Builder& bld);
78 void build_source_description_(Builder& bld, packet::stream_source_t ssrc);
79
80 packet::PacketFactory& packet_factory_;
81 core::BufferFactory<uint8_t>& buffer_factory_;
82
83 packet::IWriter* packet_writer_;
84 packet::IComposer& packet_composer_;
85
86 IReceiverHooks* recv_hooks_;
87 ISenderHooks* send_hooks_;
88
89 core::nanoseconds_t next_deadline_;
90
93
94 bool valid_;
95};
96
97} // namespace rtcp
98} // namespace roc
99
100#endif // ROC_RTCP_SESSION_H_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Buffer factory.
RTCP packet builder.
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Packet composer interface.
Definition icomposer.h:22
Packet writer interface.
Definition iwriter.h:23
RTCP compound packet builder.
Definition builder.h:26
BYE packet traverer.
Receiver hooks interface.
Sender hooks interface.
SDES packet traverer.
RTCP session. Processes incoming RTCP packets and generates outgoing RTCP packets.
Definition session.h:32
ROC_ATTR_NODISCARD status::StatusCode process_packet(const packet::PacketPtr &packet)
Parse and process incoming packet. Invokes session hooks methods during processing.
status::StatusCode ROC_ATTR_NODISCARD generate_packets(core::nanoseconds_t current_time)
Generate and send packet(s). Should be called accroding to generation_deadline(). current_time is cur...
Session(IReceiverHooks *recv_hooks, ISenderHooks *send_hooks, packet::IWriter *packet_writer, packet::IComposer &packet_composer, packet::PacketFactory &packet_factory, core::BufferFactory< uint8_t > &buffer_factory)
Initialize.
bool is_valid() const
Check if initialization succeeded.
core::nanoseconds_t generation_deadline(core::nanoseconds_t current_time)
When we should generate packets next time. Returns absolute time. current_time is current time in nan...
RTCP compound packet traverser.
Definition traverser.h:24
Receiver Report RTCP packet (RR).
Definition headers.h:474
static const size_t MaxTextLen
Get maximum allowed item text length.
Definition headers.h:741
Sender Report RTCP packet (SR).
Definition headers.h:571
Packet composer interface.
Receiver hooks interface.
Sender hooks interface.
Packet writer interface.
uint32_t stream_source_t
Packet stream identifier.
Definition units.h:27
Root namespace.
Packet.
Packet factory.
StatusCode
Status code.
Definition status_code.h:19
Commonly used types and functions.
Metrics sent from receiver to sender per source.
Definition metrics.h:38
Time definitions.
RTCP packet traverser.