Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
sender.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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_peer/sender.h
10//! @brief Sender peer.
11
12#ifndef ROC_PEER_SENDER_H_
13#define ROC_PEER_SENDER_H_
14
18#include "roc_core/mutex.h"
19#include "roc_core/scoped_ptr.h"
20#include "roc_packet/iwriter.h"
21#include "roc_peer/basic_peer.h"
22#include "roc_peer/context.h"
25#include "roc_rtp/format_map.h"
26
27namespace roc {
28namespace peer {
29
30//! Sender peer.
32public:
33 //! Initialize.
34 Sender(Context& context, const pipeline::SenderConfig& pipeline_config);
35
36 //! Deinitialize.
38
39 //! Check if successfully constructed.
40 bool valid() const;
41
42 //! Set outgoing interface address.
43 bool
44 set_outgoing_address(size_t slot_index, address::Interface iface, const char* ip);
45
46 //! Connect peer to remote endpoint.
47 bool
48 connect(size_t slot_index, address::Interface iface, const address::EndpointUri& uri);
49
50 //! Check if all necessary bind and connect calls were made.
51 bool is_ready();
52
53 //! Get sender sink.y
55
56private:
57 struct Port {
59 netio::UdpSenderConfig orig_config;
61 packet::IWriter* writer;
62
63 Port()
64 : handle(NULL)
65 , writer(NULL) {
66 }
67 };
68
69 struct Slot {
71 Port ports[address::Iface_Max];
72
73 Slot()
74 : slot(NULL) {
75 }
76 };
77
78 bool check_compatibility_(address::Interface iface, const address::EndpointUri& uri);
79 void update_compatibility_(address::Interface iface, const address::EndpointUri& uri);
80
81 Slot* get_slot_(size_t slot_index);
82 Port&
83 select_outgoing_port_(Slot& slot, address::Interface, address::AddrFamily family);
84 bool setup_outgoing_port_(Port& port,
86 address::AddrFamily family);
87
88 virtual void schedule_task_processing(pipeline::PipelineLoop&,
90 virtual void cancel_task_processing(pipeline::PipelineLoop&);
91
92 core::Mutex mutex_;
93
94 rtp::FormatMap format_map_;
95
96 pipeline::SenderLoop pipeline_;
97 ctl::ControlLoop::Tasks::PipelineProcessing processing_task_;
98
99 core::Array<Slot, 8> slots_;
100
101 bool used_interfaces_[address::Iface_Max];
102 address::Protocol used_protocols_[address::Iface_Max];
103
104 bool valid_;
105};
106
107} // namespace peer
108} // namespace roc
109
110#endif // ROC_PEER_SENDER_H_
Base class for peers.
Network endpoint URI.
Definition: endpoint_uri.h:26
struct PortHandle * PortHandle
Opaque port handle.
Definition: network_loop.h:55
Packet writer interface.
Definition: iwriter.h:21
Base class for peers.
Definition: basic_peer.h:22
Context & context()
Peer's context.
Peer context.
Definition: context.h:45
Sender peer.
Definition: sender.h:31
bool connect(size_t slot_index, address::Interface iface, const address::EndpointUri &uri)
Connect peer to remote endpoint.
bool valid() const
Check if successfully constructed.
bool set_outgoing_address(size_t slot_index, address::Interface iface, const char *ip)
Set outgoing interface address.
Sender(Context &context, const pipeline::SenderConfig &pipeline_config)
Initialize.
sndio::ISink & sink()
Get sender sink.y.
bool is_ready()
Check if all necessary bind and connect calls were made.
~Sender()
Deinitialize.
Pipeline task scheduler interface. PipelineLoop uses this interface to schedule asynchronous work....
struct SlotHandle * SlotHandle
Opaque slot handle.
Definition: sender_loop.h:46
Sink interface.
Definition: isink.h:22
Peer context.
Network endpoint URI.
RTP payload format map.
Interface ID.
Pipeline task scheduler interface.
Packet writer interface.
Mutex.
Interface
Interface ID.
Definition: interface.h:19
@ Iface_Max
Number of interfaces.
Definition: interface.h:36
Protocol
Protocol ID.
Definition: protocol.h:19
AddrFamily
Address family.
Definition: addr_family.h:19
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Protocol ID.
Unique ownrship pointer.
Sender pipeline loop.
UDP sender parameters.
Sender parameters.
Definition: config.h:101