Dante Application Library API
Loading...
Searching...
No Matches
Connections.hpp
1#pragma once
2
3#include "audinate/dal/Common.hpp"
4#include "audinate/dal/ConnectionsConfig.hpp"
5#include "audinate/dal/DAL.hpp"
6
7#include <vector>
8#include <functional>
9
10
11namespace Audinate { namespace DAL {
12
13//------------------------------------------------------
14// Connection API
15//------------------------------------------------------
16
20class LocalDevice
21{
22public:
23 LocalDevice() : mNumTxChannels(), mNumRxChannels() {}
24
25 bool operator==(const LocalDevice & other) const { return mNumTxChannels == other.mNumTxChannels && mNumRxChannels == other.mNumRxChannels; }
26 bool operator!=(const LocalDevice & other) const { return !(operator==(other)); }
27
28 unsigned int mNumTxChannels;
29 unsigned int mNumRxChannels;
30};
31
35class DeviceChannels
36{
37public:
38 DeviceChannels() : mDeviceName(), mChannelNames(), mIpv4Address(), mIdentifiable(), mSending() {}
39 bool operator==(const DeviceChannels & other) const { return mDeviceName == other.mDeviceName && mChannelNames == other.mChannelNames && mIpv4Address == other.mIpv4Address && mIdentifiable == other.mIdentifiable && mSending == other.mSending; }
40 bool operator!=(const DeviceChannels & other) const { return !(operator==(other)); }
41
42 std::string mDeviceName;
43 std::vector<std::string> mChannelNames;
44 Ipv4Address mIpv4Address;
45 bool mIdentifiable;
46
47 // Is the device sending any audio at the moment?
48 bool mSending;
49};
50
54class AvailableChannels
55{
56public:
57 AvailableChannels() : mDevices() {}
58 bool operator==(const AvailableChannels & other) const { return mDevices == other.mDevices; }
59 bool operator!=(const AvailableChannels & other) const { return !(operator==(other)); }
60
61 std::vector<DeviceChannels> mDevices;
62};
63
64enum class ConnectionStatus
65{
66 // There is no connection set for the given local channel.
67 None,
68
69 // The connection API has not yet begun processing the connection
70 Pending,
71
72 // The requested source device was not found. Only applicable for receive channels
73 Unresolved,
74
75 // The requested destination device was not found. Only applicable for transmit channels
76 DestinationDeviceNotFound,
77
78 // The requested destination channel was not found on the destination device. Only applicable for transmit channels
79 DestinationChannelNotFound,
80
81 // The connection is being made. See the subscription status for more detailed information
82 InProgress,
83
84 // The connection has been made but no audio packets have been received
85 Inactive,
86
87 // The connection has been made and audio packets are being received
88 Active,
89
90 // The connection failed for some reason. See the subscription status for more detailed information
91 Error
92};
93
94std::string toString(ConnectionStatus status);
95
96typedef Uint8 SubscriptionStatus;
97
98std::string subscriptionStatusToString(uint8_t subscriptionStatus);
99
104{
105public:
106 unsigned int mLocalChannelId;
107 std::string mRemoteChannelName;
108 std::string mRemoteDeviceName;
109
110 ConnectionStatus mConnectionStatus;
111 SubscriptionStatus mSubscriptionStatus;
112};
113
117typedef std::function<void()> LocalDeviceChangedFn;
118
124typedef std::function<void(std::vector<unsigned int> txChannelIds, std::vector<unsigned int> rxChannelIds)> AvailableChannelsChangedFn;
125
131typedef std::function<void(ChannelDirection dir, std::vector<unsigned int> channelIds)> ConnectionChangedFn;
132
133class Connections
134{
135protected:
136 Connections() {}
137
138public:
139 virtual ~Connections() {}
140
145
150 virtual AvailableChannels getAvailableSources(unsigned int rxChannelId) = 0;
151
156 virtual AvailableChannels getAvailableDestinations(unsigned int txChannelId) = 0;
157
161 virtual void identify(const std::string & deviceName) = 0;
162
168 virtual void setReceiveChannelSource(unsigned int rxChannelId, const std::string & remoteChannelName, const std::string & remoteDeviceName) = 0;
169
174 virtual Connection getReceiveChannelState(unsigned int rxChannelId) = 0;
175
181 virtual void setTransmitChannelDestination(unsigned int txChannelId, const std::string & remoteChannelName, const std::string & remoteDeviceName) = 0;
182
187 virtual Connection getTransmitChannelState(unsigned int txChannelId) = 0;
188
206
210 virtual void setLocalDeviceChangedFn(LocalDeviceChangedFn fn) = 0;
211
215 virtual void setAvailableChannelsChangedFn(AvailableChannelsChangedFn fn) = 0;
216
220 virtual void setConnectionChangedFn(ConnectionChangedFn fn) = 0;
221
222};
223
231std::shared_ptr<Connections> createConnections(std::shared_ptr<DAL> dal, const ConnectionsConfig & config);
232
233}; };
A list of channels on the network, grouped by device.
Definition Connections.hpp:55
Connection class for managing connections between other Dante devices and the DAL device.
Definition Connections.hpp:104
ConnectionStatus mConnectionStatus
Current status of the connection.
Definition Connections.hpp:110
std::string mRemoteChannelName
Channel name for the remote channel of the subscribed device.
Definition Connections.hpp:107
SubscriptionStatus mSubscriptionStatus
Current subscription status of the connection.
Definition Connections.hpp:111
unsigned int mLocalChannelId
Channel ID for the local channel of the DAL device.
Definition Connections.hpp:106
std::string mRemoteDeviceName
Device name for the remote device the channel is subscribed to.
Definition Connections.hpp:108
Definition ConnectionsConfig.hpp:8
virtual AvailableChannels getAvailableSources(unsigned int rxChannelId)=0
Get the list of available sources for the given receive channel.
virtual Connection getReceiveChannelState(unsigned int rxChannelId)=0
Get the connection state for the given receive channel.
virtual void setAvailableChannelsChangedFn(AvailableChannelsChangedFn fn)=0
Add a handler to be notified when the set of available channels changes.
virtual void identify(const std::string &deviceName)=0
Attempt to identify a given device.
virtual void clearRemoteSubscriptionsToLocalDevice()=0
Remove all remote rx channels subscriptions to the local device that are not part of a currently conf...
virtual void setLocalDeviceChangedFn(LocalDeviceChangedFn fn)=0
Add a handler to be notified when the set of local device changes.
virtual void setConnectionChangedFn(ConnectionChangedFn fn)=0
Add a handler to be notified when connection state changes for one or more channels.
virtual AvailableChannels getAvailableDestinations(unsigned int txChannelId)=0
Get the list of available destinations for the given transmit channel.
virtual void setReceiveChannelSource(unsigned int rxChannelId, const std::string &remoteChannelName, const std::string &remoteDeviceName)=0
Specify the remote channel from which the local receive channel will receive audio To clear the confi...
virtual void setTransmitChannelDestination(unsigned int txChannelId, const std::string &remoteChannelName, const std::string &remoteDeviceName)=0
Specify a remote channel that will receive audio from the given local transmit channel.
virtual LocalDevice getLocalDevice()=0
Get information about the local device.
virtual Connection getTransmitChannelState(unsigned int txChannelId)=0
Get the connection state for the given transmit channel.
Definition Common.hpp:28
The local device's current settings.
Definition Connections.hpp:21