Dante Application Library API
Common.hpp
1 #pragma once
2 
3 #include "audinate/dal/Types.hpp"
4 
5 #include <functional>
6 #include <memory>
7 #include <string>
8 #include <vector>
9 
10 //Windows: Add inline specifier to the member functions to make it accessible outside the dal library
11 //Refer https://stackoverflow.com/questions/24511376/how-to-dllexport-a-class-derived-from-stdruntime-error
12 #ifdef _WIN32
13  #define INLINE_STD_EXCEPTION inline
14 #else
15  #define INLINE_STD_EXCEPTION
16 #endif
17 
18 namespace Audinate { namespace DAL {
19 
20 enum class ChannelDirection
21 {
22  Tx,
23  Rx
24 };
25 
26 
28 {
29 public:
30  Ipv4Address() : _() {}
31  ~Ipv4Address() {}
32 
33  union
34  {
35  uint32_t addr32;
36  uint8_t addr8[4];
37  } _;
38 
39  bool operator==(const Ipv4Address & other) const { return _.addr32 == other._.addr32; }
40  bool operator!=(const Ipv4Address & other) const { return !operator==(other); }
41 
42  std::string toString() const
43  {
44  return std::to_string(_.addr8[0]) + "." + std::to_string(_.addr8[1]) + "." + std::to_string(_.addr8[2]) + "." + std::to_string(_.addr8[3]);
45  }
46 };
47 
48 #ifdef _WIN32
49 class DalException : public std::exception
50 #else
51 class __attribute__((visibility("default"))) DalException : public std::exception
52 #endif
53 {
54 public:
55  static DalException create(Error err, const std::string & description);
56  static DalException create(const std::string & name, const std::string & description);
57  ~DalException() {}
58 
59  INLINE_STD_EXCEPTION Error getError() { return mError; }
60  INLINE_STD_EXCEPTION std::string getErrorName() const { return mErrorName; }
61  INLINE_STD_EXCEPTION std::string getErrorDescription() const { return mErrorDescription; }
62 
63 private:
64  Error mError;
65  std::string mErrorName;
66  std::string mErrorDescription;
67 
68  DalException(Error error, const std::string & errorName, const std::string & errorDescription);
69 };
70 
72 {
73 public:
74  enum class Type
75  {
76  None,
77  Port,
78  Path
79  };
80  SocketDescriptor() : mType(Type::None), mPortNum(), mSocketPath() {}
81  SocketDescriptor(uint16_t portNum) : mType(Type::Port), mPortNum(portNum), mSocketPath() {}
82  SocketDescriptor(std::string socketPath) : mType(Type::Path), mPortNum(), mSocketPath(socketPath) {}
83 
84  Type getType() const { return mType; }
85  uint16_t getPortNumber() const { return mPortNum; }
86  std::string getSocketPath() const { return mSocketPath; }
87 
88 private:
89  Type mType;
90  uint16_t mPortNum;
91  std::string mSocketPath;
92 };
93 
98 std::string toString(SocketDescriptor socketDescriptor);
99 
100 
108 enum class Protocol
109 {
110  // The protocol used for managing audio routing configuration from external controllers. Externally visible. Application specifies the port number for the local server.
111  Arcp,
112 
113  // The protocol used for managing audio routing configuration from embedded controllers. Not externally visible. Application specifies the port number for the local server.
114  ArcpLocal,
115 
116  // A protocol used within Dante networks for creating and maintaining audio connections. Externally visible. Application specifies the port number for the local server.
117  Dbcp,
118 
119  // The protocol used within Dante networks for creating and maintaining conmon channels connections. Externally visible. Application specifies the port number for the local server.
120  Cmcp,
121 
122  // The protocol for sending conmon messages on the various channels. Externally visible. Application specifies a base port number for the local instance's channel ports. DAL instances uses a range of up to 10 port numbers starting from the base number.
123  ConmonChannels,
124 
125  // The protocol for conmon clients (Including Embedded DAPI instances) to communicate with their local server. Not externally visible. Application specifies the port number for the local server.
126  ConmonClient,
127 
128  // The protocol for dante components (including Embedded DAPI instances) to communicate with the device's domain proxy. Not externally visible. Application can specify the port number for the local server.
129  DomainClientProxy,
130 
131  // Protocol for audio transport. Externally visible. Application specifies the port number for the local instance's server ports. DAL instances uses a range of up to 256 port numbers starting from the base number. This range may eventually be programatically configurable / queryable.
132  AudioBase,
133 
134  // Protocol for websocket API server. Externally visible. Setting this to zero will result in the websocket API server using an ephemeral port. Setting this
135  // to a non-zero value will result in the websocket API server using the given fixed port. In both cases the Instance::getProtocolSocketDescriptor API can be
136  // used to retrieve the runtime value that the server ends up using.
137  WebSocket
138 
139 #ifdef _WIN32
140  // The protocol used by mdns-enabled applications to communicate with the mdns server
141  , MdnsClient
142 #endif
143 };
144 
149 std::string toString(Protocol protocol);
150 
154 enum class Component
155 {
156  None,
157 
158  // Multicast-based DNS discovery engine. Not required if a globally installed Dante Discovery instance is assumed
159  Mdns,
160 
161  // The Dante Control & Monitoring Engine.
162  ConmonServer,
163 
164  // The Dante Audio Routing Configuration Engine.
165  Apec,
166 
167  // A Precision Time Protocol instance. Only used when DAL uses PTP as its time source.
168  Ptp
169 };
170 
171 std::string toString(Component component);
172 
173 enum class ComponentStatus
174 {
175  // The instance is stopped and the component is stopped.
176  Stopped,
177 
178  // The instance is running, the component is not required
179  Unused,
180 
181  // The instance is running. The component is required but is not currently running
182  Pending,
183 
184  // The instance is running and the component is running
185  Running
186 };
187 
192 std::string toString(ComponentStatus status);
193 
194 
195 enum class TimeSource
196 {
197  // DAL will track time from the network via Ptp. Incoming audio streams are not required in order to track time.
198  Ptp,
199 
200  // DAL will track time from incoming Audio Packets. The DAL instance will not run a ptp child process.
201  RxAudio
202 };
203 
204 enum class LogLevel
205 {
206  None,
207  Error,
208  Warning,
209  Notice,
210  Info,
211  Debug
212 };
213 
214 }; };
Audinate::DAL::SocketDescriptor
Definition: Common.hpp:71
Audinate::DAL::Ipv4Address
Definition: Common.hpp:27
Audinate::DAL::DalException
Definition: Common.hpp:49