Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
receiver_endpoint.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_pipeline/receiver_endpoint.h
10
//! @brief Receiver endpoint pipeline.
11
12
#ifndef ROC_PIPELINE_RECEIVER_ENDPOINT_H_
13
#define ROC_PIPELINE_RECEIVER_ENDPOINT_H_
14
15
#include "
roc_address/interface.h
"
16
#include "
roc_address/protocol.h
"
17
#include "
roc_core/iarena.h
"
18
#include "
roc_core/mpsc_queue.h
"
19
#include "
roc_core/optional.h
"
20
#include "
roc_core/ref_counted.h
"
21
#include "
roc_core/scoped_ptr.h
"
22
#include "
roc_packet/iparser.h
"
23
#include "
roc_packet/iwriter.h
"
24
#include "
roc_packet/shipper.h
"
25
#include "
roc_pipeline/config.h
"
26
#include "
roc_pipeline/state_tracker.h
"
27
#include "
roc_rtcp/composer.h
"
28
#include "
roc_rtcp/parser.h
"
29
#include "
roc_rtp/encoding_map.h
"
30
#include "
roc_rtp/parser.h
"
31
32
namespace
roc
{
33
namespace
pipeline
{
34
35
class
ReceiverSessionGroup
;
36
37
//! Receiver endpoint sub-pipeline.
38
//!
39
//! Contains:
40
//! - a pipeline for processing packets from single network endpoint
41
//! - a reference to session group to which packets are routed
42
class
ReceiverEndpoint
:
public
core::RefCounted
<ReceiverEndpoint, core::ArenaAllocation>,
43
public
core::ListNode
<>,
44
private
packet::IWriter
{
45
public
:
46
//! Initialize.
47
ReceiverEndpoint
(
address::Protocol
proto
,
48
StateTracker
& state_tracker,
49
ReceiverSessionGroup
& session_group,
50
const
rtp::EncodingMap
& encoding_map,
51
const
address::SocketAddr
&
inbound_address
,
52
packet::IWriter
*
outbound_writer
,
53
core::IArena
&
arena
);
54
55
//! Check if the port pipeline was succefully constructed.
56
bool
is_valid
()
const
;
57
58
//! Get protocol.
59
address::Protocol
proto
()
const
;
60
61
//! Get composer for outbound packets.
62
//! @remarks
63
//! This composer will create packets according to endpoint protocol.
64
//! @note
65
//! Not all protocols support outbound packets on receiver. If it's
66
//! not supported, the method returns NULL.
67
packet::IComposer
*
outbound_composer
();
68
69
//! Get writer for outbound packets.
70
//! This way feedback packets for sender generated by receiver reach network.
71
//! @remarks
72
//! Packets passed to this writer will be enqueued for sending.
73
//! When frame is requested to ReceiverSession, it generates packets
74
//! and writes them to outbound writers of endpoints.
75
//! @note
76
//! Not all protocols support outbound packets on receiver. If it's
77
//! not supported, the method returns NULL.
78
packet::IWriter
*
outbound_writer
();
79
80
//! Get bind address for inbound packets.
81
const
address::SocketAddr
&
inbound_address
()
const
;
82
83
//! Get writer for inbound packets.
84
//! This way packets from network reach receiver pipeline.
85
//! @remarks
86
//! Packets passed to this writer will be pulled into pipeline.
87
//! This writer is thread-safe and lock-free, packets can be written
88
//! to it from netio thread.
89
packet::IWriter
&
inbound_writer
();
90
91
//! Pull packets written to inbound writer into pipeline.
92
//! @remarks
93
//! Packets are written to inbound_writer() from network thread.
94
//! They don't appear in pipeline immediately. Instead, pipeline thread
95
//! should periodically call pull_packets() to make them available.
96
ROC_ATTR_NODISCARD
status::StatusCode
pull_packets
(
core::nanoseconds_t
current_time);
97
98
private
:
99
virtual
ROC_ATTR_NODISCARD
status::StatusCode
write(
const
packet::PacketPtr
&
packet
);
100
101
const
address::Protocol
proto_;
102
103
StateTracker
& state_tracker_;
104
ReceiverSessionGroup
& session_group_;
105
106
// Outbound packets sub-pipeline.
107
// On receiver, typically present only in control endpoints.
108
packet::IComposer
* composer_;
109
core::Optional<rtcp::Composer>
rtcp_composer_;
110
core::Optional<packet::Shipper>
shipper_;
111
112
// Inbound packets sub-pipeline.
113
// On receiver, always present.
114
packet::IParser
* parser_;
115
core::Optional<rtp::Parser>
rtp_parser_;
116
core::ScopedPtr<packet::IParser>
fec_parser_;
117
core::Optional<rtcp::Parser>
rtcp_parser_;
118
address::SocketAddr
inbound_address_;
119
core::MpscQueue<packet::Packet>
inbound_queue_;
120
121
bool
valid_;
122
};
123
124
}
// namespace pipeline
125
}
// namespace roc
126
127
#endif
// ROC_PIPELINE_RECEIVER_ENDPOINT_H_
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::address::SocketAddr
Socket address.
Definition
socket_addr.h:26
roc::core::ArenaAllocation::arena
IArena & arena() const
Get arena.
Definition
allocation_policy.h:37
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::ListNode
Base class for List element.
Definition
list_node.h:48
roc::core::MpscQueue
Thread-safe lock-free node-based intrusive multi-producer single-consumer queue.
Definition
mpsc_queue.h:45
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::core::RefCounted
Base class for object with reference counter.
Definition
ref_counted.h:40
roc::core::ScopedPtr
Unique ownrship pointer.
Definition
scoped_ptr.h:33
roc::packet::IComposer
Packet composer interface.
Definition
icomposer.h:22
roc::packet::IParser
Packet parser interface.
Definition
iparser.h:22
roc::packet::IWriter
Packet writer interface.
Definition
iwriter.h:23
roc::pipeline::ReceiverEndpoint::inbound_writer
packet::IWriter & inbound_writer()
Get writer for inbound packets. This way packets from network reach receiver pipeline.
roc::pipeline::ReceiverEndpoint::ReceiverEndpoint
ReceiverEndpoint(address::Protocol proto, StateTracker &state_tracker, ReceiverSessionGroup &session_group, const rtp::EncodingMap &encoding_map, const address::SocketAddr &inbound_address, packet::IWriter *outbound_writer, core::IArena &arena)
Initialize.
roc::pipeline::ReceiverEndpoint::outbound_composer
packet::IComposer * outbound_composer()
Get composer for outbound packets.
roc::pipeline::ReceiverEndpoint::pull_packets
ROC_ATTR_NODISCARD status::StatusCode pull_packets(core::nanoseconds_t current_time)
Pull packets written to inbound writer into pipeline.
roc::pipeline::ReceiverEndpoint::outbound_writer
packet::IWriter * outbound_writer()
Get writer for outbound packets. This way feedback packets for sender generated by receiver reach net...
roc::pipeline::ReceiverEndpoint::proto
address::Protocol proto() const
Get protocol.
roc::pipeline::ReceiverEndpoint::is_valid
bool is_valid() const
Check if the port pipeline was succefully constructed.
roc::pipeline::ReceiverEndpoint::inbound_address
const address::SocketAddr & inbound_address() const
Get bind address for inbound packets.
roc::pipeline::ReceiverSessionGroup
Receiver session group.
Definition
receiver_session_group.h:48
roc::pipeline::StateTracker
Pipeline state tracker.
Definition
state_tracker.h:30
roc::rtp::EncodingMap
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Definition
encoding_map.h:33
encoding_map.h
RTP encoding map.
iarena.h
Memory arena interface.
interface.h
Interface ID.
iparser.h
Packet parser interface.
iwriter.h
Packet writer interface.
mpsc_queue.h
Multi-producer single-consumer queue.
roc::address::Protocol
Protocol
Protocol ID.
Definition
protocol.h:19
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::pipeline
Sender and receiver processing pipelines.
roc
Root namespace.
optional.h
Optionally constructed object.
protocol.h
Protocol ID.
ref_counted.h
Base class for object with reference counter.
config.h
Pipeline config.
composer.h
RTCP packet composer.
parser.h
RTCP packet parser.
parser.h
RTP packet parser.
scoped_ptr.h
Unique ownrship pointer.
shipper.h
Prepare and ship outgoing packets.
state_tracker.h
Pipeline state tracker.
roc::status::StatusCode
StatusCode
Status code.
Definition
status_code.h:19
roc_pipeline
receiver_endpoint.h
Generated by
1.17.0