Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
17#include "roc_core/iarena.h"
18#include "roc_core/mpsc_queue.h"
20#include "roc_core/optional.h"
21#include "roc_core/scoped_ptr.h"
23#include "roc_packet/iparser.h"
24#include "roc_packet/iwriter.h"
25#include "roc_packet/shipper.h"
27#include "roc_rtcp/composer.h"
28#include "roc_rtcp/parser.h"
29#include "roc_rtp/composer.h"
30
31namespace roc {
32namespace pipeline {
33
34class SenderSession;
35
36//! Sender endpoint sub-pipeline.
37//!
38//! Contains:
39//! - a pipeline for processing packets for single network endpoint
41public:
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
48 StateTracker& state_tracker,
49 SenderSession& sender_session,
52 core::IArena& arena);
53
54 //! Check if pipeline was succefully constructed.
55 bool is_valid() const;
56
57 //! Get protocol.
59
60 //! Get destination address for outbound packets.
62
63 //! Get composer for outbound packets.
64 //! @remarks
65 //! This composer will create packets according to endpoint protocol.
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.
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.
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.
95
96private:
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_;
109 core::Optional<rtcp::Composer> rtcp_composer_;
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_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Memory arena interface.
Definition iarena.h:23
Thread-safe lock-free node-based intrusive multi-producer single-consumer queue.
Definition mpsc_queue.h:45
Base class for non-copyable objects.
Definition noncopyable.h:23
Optionally constructed object.
Definition optional.h:25
Unique ownrship pointer.
Definition scoped_ptr.h:33
Packet composer interface.
Definition icomposer.h:22
Packet parser interface.
Definition iparser.h:22
Packet writer interface.
Definition iwriter.h:23
Sender endpoint sub-pipeline.
address::Protocol proto() const
Get protocol.
packet::IComposer & outbound_composer()
Get composer for outbound packets.
const address::SocketAddr & outbound_address() const
Get destination address for outbound packets.
bool is_valid() const
Check if pipeline was succefully constructed.
packet::IWriter & outbound_writer()
Get writer for outbound packets. This way packets generated by sender reach network.
ROC_ATTR_NODISCARD status::StatusCode pull_packets(core::nanoseconds_t current_time)
Pull packets written to inbound writer into pipeline.
packet::IWriter * inbound_writer()
Get writer for inbound packets. This way feedback packets from receiver reach sender pipeline.
SenderEndpoint(address::Protocol proto, StateTracker &state_tracker, SenderSession &sender_session, const address::SocketAddr &outbound_address, packet::IWriter &outbound_writer, core::IArena &arena)
Initialize.
Sender session sub-pipeline.
Pipeline state tracker.
Memory arena interface.
Packet composer interface.
Packet parser interface.
Packet writer interface.
Multi-producer single-consumer queue.
Protocol
Protocol ID.
Definition protocol.h:19
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
Root namespace.
Non-copyable object.
Optionally constructed object.
Protocol ID.
RTCP packet composer.
RTCP packet parser.
RTP packet composer.
Unique ownrship pointer.
Prepare and ship outgoing packets.
Socket address.
Pipeline state tracker.
StatusCode
Status code.
Definition status_code.h:19