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