AudioManager  7.6.6
Native Application Runtime Environment
CAmRoutingSender.h
Go to the documentation of this file.
1 
24 #ifndef ROUTINGSENDER_H_
25 #define ROUTINGSENDER_H_
26 
27 #include "IAmRouting.h"
28 #include <map>
29 #include <memory>
30 
31 #ifdef UNIT_TEST //this is needed to test RoutingSender
32 #include "../test/IAmRoutingBackdoor.h"
33 #endif
34 
35 #include "CAmDatabaseHandlerMap.h"
36 
37 namespace am
38 {
39 
40 class CAmRoutingReceiver;
41 
46 {
47 public:
48  CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler);
50 
51  am_Error_e removeHandle(const am_Handle_s& handle);
52  am_Error_e addDomainLookup(const am_Domain_s& domainData);
53  am_Error_e addSourceLookup(const am_Source_s& sourceData);
54  am_Error_e addSinkLookup(const am_Sink_s& sinkData);
55  am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
61 
63  void setRoutingReady();
64  void setRoutingRundown();
65  am_Error_e asyncAbort(const am_Handle_s& handle);
66  am_Error_e asyncConnect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat);
67  am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
68  am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
69  am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
70  am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
71  am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
72  am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID);
73  am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID);
74  am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
75  am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time);
76  am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
77  am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const;
78  am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
79  void getInterfaceVersion(std::string& version) const;
80  am_Error_e asyncSetVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes);
81  am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration);
82  am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration);
83  am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s>& listOfExistingConnections);
84 
86  {
88  std::string busName;
89  };
90 
92  {
93  public:
94  handleDataBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler) : mInterface(interface), mpDatabaseHandler(databaseHandler) {}
95  virtual ~handleDataBase() {}
96  virtual am_Error_e writeDataToDatabase()=0;
97  IAmRoutingSend* returnInterface() {return mInterface;}
98  private:
99  IAmRoutingSend* mInterface;
100  protected:
102  };
103 
105  {
106  public:
107  handleVolumeBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler,am_volume_t volume) :
108  handleDataBase(interface,databaseHandler)
109  ,mVolume(volume) {}
110  virtual ~handleVolumeBase(){}
111  am_volume_t returnVolume() { return mVolume; }
112  private:
113  am_volume_t mVolume;
114  };
115 
117  {
118  public:
119  handleSinkSoundProperty(IAmRoutingSend* interface,const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
120  handleDataBase(interface,databaseHandler)
121  ,mSinkID(sinkID)
122  ,mSoundProperty(soundProperty) {}
124  am_Error_e writeDataToDatabase();
125  private:
126  am_sinkID_t mSinkID;
127  am_SoundProperty_s mSoundProperty;
128  };
129 
131  {
132  public:
133  handleSinkSoundProperties(IAmRoutingSend* interface,const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
134  handleDataBase(interface,databaseHandler)
135  ,mSinkID(sinkID)
136  ,mlistSoundProperties(listSoundProperties) {}
138  am_Error_e writeDataToDatabase();
139  private:
140  am_sinkID_t mSinkID;
141  std::vector<am_SoundProperty_s> mlistSoundProperties;
142  };
143 
145  {
146  public:
147  handleSourceSoundProperty(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
148  handleDataBase(interface,databaseHandler)
149  ,mSourceID(sourceID)
150  ,mSoundProperty(soundProperty) {}
152  am_Error_e writeDataToDatabase();
153  private:
154  am_sourceID_t mSourceID;
155  am_SoundProperty_s mSoundProperty;
156  };
157 
159  {
160  public:
161  handleSourceSoundProperties(IAmRoutingSend* interface,const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
162  handleDataBase(interface,databaseHandler)
163  ,mSourceID(sourceID)
164  ,mlistSoundProperties(listSoundProperties) {}
166  am_Error_e writeDataToDatabase();
167  private:
168  am_sourceID_t mSourceID;
169  std::vector<am_SoundProperty_s> mlistSoundProperties;
170  };
171 
173  {
174  public:
175  handleSourceState(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SourceState_e& state, IAmDatabaseHandler* databaseHandler) :
176  handleDataBase(interface,databaseHandler)
177  ,mSourceID(sourceID)
178  ,mSourceState(state) {}
180  am_Error_e writeDataToDatabase();
181  private:
182  am_sourceID_t mSourceID;
183  am_SourceState_e mSourceState;
184  };
185 
187  {
188  public:
189  handleSourceVolume(IAmRoutingSend* interface, const am_sourceID_t sourceID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
190  handleVolumeBase(interface,databaseHandler,volume)
191  ,mSourceID(sourceID) {}
193  am_Error_e writeDataToDatabase();
194  private:
195  am_sourceID_t mSourceID;
196  };
197 
199  {
200  public:
201  handleSinkVolume(IAmRoutingSend* interface, const am_sinkID_t sinkID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
202  handleVolumeBase(interface,databaseHandler,volume)
203  ,mSinkID(sinkID) {}
205  am_Error_e writeDataToDatabase();
206  private:
207  am_sinkID_t mSinkID;
208  };
209 
211  {
212  public:
213  handleCrossFader(IAmRoutingSend* interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e& hotSink, IAmDatabaseHandler* databaseHandler) :
214  handleDataBase(interface,databaseHandler)
215  ,mCrossfaderID(crossfaderID)
216  ,mHotSink(hotSink) {}
218  am_Error_e writeDataToDatabase();
219  private:
220  am_crossfaderID_t mCrossfaderID;
221  am_HotSink_e mHotSink;
222  };
223 
225  {
226  public:
227  handleConnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler) :
228  handleDataBase(interface,databaseHandler)
229  ,mConnectionID(connectionID)
230  ,mConnectionPending(true) {}
231  ~handleConnect();
232  am_Error_e writeDataToDatabase();
233  private:
234  am_connectionID_t mConnectionID;
235  bool mConnectionPending;
236  };
237 
239  {
240  public:
241  handleDisconnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler,CAmRoutingSender* routingSender) :
242  handleDataBase(interface,databaseHandler)
243  ,mConnectionID(connectionID)
244  ,mRoutingSender(routingSender){}
245  ~handleDisconnect();
246  am_Error_e writeDataToDatabase();
247  private:
248  am_connectionID_t mConnectionID;
249  CAmRoutingSender* mRoutingSender;
250  };
251 
253  {
254  public:
255  handleSetVolumes(IAmRoutingSend* interface, const std::vector<am_Volumes_s> listVolumes, IAmDatabaseHandler* databaseHandler) :
256  handleDataBase(interface,databaseHandler)
257  ,mlistVolumes(listVolumes) {}
259  am_Error_e writeDataToDatabase();
260  private:
261  std::vector<am_Volumes_s> mlistVolumes;
262  };
263 
265  {
266  public:
267  handleSetSinkNotificationConfiguration(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
268  handleDataBase(interface,databaseHandler)
269  ,mSinkID(sinkID)
270  ,mNotificationConfiguration(notificationConfiguration){}
272  am_Error_e writeDataToDatabase();
273  private:
274  am_sinkID_t mSinkID;
275  am_NotificationConfiguration_s mNotificationConfiguration;
276  };
277 
279  {
280  public:
281  handleSetSourceNotificationConfiguration(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
282  handleDataBase(interface,databaseHandler)
283  ,mSourceID(sourceID)
284  ,mNotificationConfiguration(notificationConfiguration) {}
286  am_Error_e writeDataToDatabase();
287  private:
288  am_sourceID_t mSourceID;
289  am_NotificationConfiguration_s mNotificationConfiguration;
290  };
291 
293  void checkVolume(const am_Handle_s handle, const am_volume_t volume);
294  bool handleExists(const am_Handle_s handle);
295 
296 #ifdef UNIT_TEST //this is needed to test RoutingSender
297  friend class IAmRoutingBackdoor;
298 #endif
299 
300 private:
301  struct comparator
302  {
303  bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
304  {
305  return (a.handle<b.handle || (a.handle==b.handle && a.handleType<b.handleType));
306  }
307  };
308 
309  void loadPlugins(const std::vector<std::string>& listOfPluginDirectories);
310  am_Handle_s createHandle(std::shared_ptr<handleDataBase> handleData, const am_Handle_e type);
311  void unloadLibraries(void);
312 
313  typedef std::map<am_domainID_t, IAmRoutingSend*> DomainInterfaceMap;
314  typedef std::map<am_sinkID_t, IAmRoutingSend*> SinkInterfaceMap;
315  typedef std::map<am_sourceID_t, IAmRoutingSend*> SourceInterfaceMap;
316  typedef std::map<am_crossfaderID_t, IAmRoutingSend*> CrossfaderInterfaceMap;
317  typedef std::map<am_connectionID_t, IAmRoutingSend*> ConnectionInterfaceMap;
318  typedef std::map<am_Handle_s, std::shared_ptr<handleDataBase>, comparator> HandlesMap;
319 
320  int16_t mHandleCount;
321  HandlesMap mlistActiveHandles;
322  std::vector<void*> mListLibraryHandles;
323  std::vector<InterfaceNamePairs> mListInterfaces;
324  CrossfaderInterfaceMap mMapCrossfaderInterface;
325  ConnectionInterfaceMap mMapConnectionInterface;
326  DomainInterfaceMap mMapDomainInterface;
327  SinkInterfaceMap mMapSinkInterface;
328  SourceInterfaceMap mMapSourceInterface;
329  CAmRoutingReceiver *mpRoutingReceiver;
330  IAmDatabaseHandler* mpDatabaseHandler;
331 };
332 
333 }
334 
335 #endif /* ROUTINGSENDER_H_ */
Implements the RoutingSendInterface.
am_Error_e asyncAbort(const am_Handle_s &handle)
uint16_t am_connectionID_t
a connection ID
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
handleCrossFader(IAmRoutingSend *interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e &hotSink, IAmDatabaseHandler *databaseHandler)
Copyright (C) 2012 - 2014, BMW AG.
handleSourceVolume(IAmRoutingSend *interface, const am_sourceID_t sourceID, IAmDatabaseHandler *databaseHandler, const am_volume_t &volume)
am_Error_e
the errors of the audiomanager.
handleSourceSoundProperty(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty, IAmDatabaseHandler *databaseHandler)
This struct holds information about the configuration for notifications.
am_Error_e getListHandles(std::vector< am_Handle_s > &listHandles) const
This struct describes the attribiutes of a sink.
This class implements everything from Audiomanager -> RoutingAdapter There are two rules that have to...
Definition: IAmRouting.h:357
void getInterfaceVersion(std::string &version) const
am_Error_e asyncCrossFade(am_Handle_s &handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time)
handleSinkSoundProperty(IAmRoutingSend *interface, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty, IAmDatabaseHandler *databaseHandler)
void checkVolume(const am_Handle_s handle, const am_volume_t volume)
This struct describes the attribiutes of a domain.
handleSetSinkNotificationConfiguration(IAmRoutingSend *interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler *databaseHandler)
am_Error_e addSinkLookup(const am_Sink_s &sinkData)
uint16_t am_crossfaderID_t
a crossfader ID
uint16_t am_CustomConnectionFormat_t
This type classifies the format in which data is exchanged within a connection.
am_Error_e asyncSetSinkSoundProperty(am_Handle_s &handle, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty)
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
am_Error_e addCrossfaderLookup(const am_Crossfader_s &crossfaderData)
am_Error_e asyncDisconnect(am_Handle_s &handle, const am_connectionID_t connectionID)
am_Error_e addDomainLookup(const am_Domain_s &domainData)
Implements the Receiving side of the RoutingPlugins.
handleSourceSoundProperties(IAmRoutingSend *interface, const am_sourceID_t sourceID, const std::vector< am_SoundProperty_s > &listSoundProperties, IAmDatabaseHandler *databaseHandler)
am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID)
am_Error_e asyncSetSourceVolume(am_Handle_s &handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
SPDX license identifier: MPL-2.0.
am_Error_e asyncSetSourceSoundProperty(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty)
handleSinkSoundProperties(IAmRoutingSend *interface, const am_sinkID_t sinkID, const std::vector< am_SoundProperty_s > &listSoundProperties, IAmDatabaseHandler *databaseHandler)
am_Error_e addSourceLookup(const am_Source_s &sourceData)
am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector< am_Connection_s > &listOfExistingConnections)
am_Error_e asyncSetSourceSoundProperties(am_Handle_s &handle, const std::vector< am_SoundProperty_s > &listSoundProperties, const am_sourceID_t sourceID)
a handle is used for asynchronous operations and is uniquely assigned for each of this operations ...
IAmRoutingSend * routingInterface
pointer to the routingInterface
uint16_t am_sourceID_t
a source ID
handleVolumeBase(IAmRoutingSend *interface, IAmDatabaseHandler *databaseHandler, am_volume_t volume)
am_Error_e asyncSetSinkSoundProperties(am_Handle_s &handle, const std::vector< am_SoundProperty_s > &listSoundProperties, const am_sinkID_t sinkID)
struct describing the sound property
am_Error_e asyncSetSourceState(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SourceState_e state)
handleSetSourceNotificationConfiguration(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler *databaseHandler)
This class handles and abstracts the database.
handleDataBase(IAmRoutingSend *interface, IAmDatabaseHandler *databaseHandler)
handleDisconnect(IAmRoutingSend *interface, const am_connectionID_t connectionID, IAmDatabaseHandler *databaseHandler, CAmRoutingSender *routingSender)
am_HotSink_e
describes the active sink of a crossfader.
int16_t am_volume_t
The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE).
This struct describes the attribiutes of a crossfader.
am_Error_e asyncSetSinkVolume(am_Handle_s &handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
handleSetVolumes(IAmRoutingSend *interface, const std::vector< am_Volumes_s > listVolumes, IAmDatabaseHandler *databaseHandler)
bool handleExists(const am_Handle_s handle)
returns true if the handle exists
am_Handle_e handleType
the handletype
am_Error_e getListPlugins(std::vector< std::string > &interfaces) const
am_Error_e writeToDatabaseAndRemove(const am_Handle_s handle)
write data to Database and remove handle
am_Error_e startupInterfaces(CAmRoutingReceiver *iRoutingReceiver)
uint16_t handle
the handle as value
am_Error_e removeHandle(const am_Handle_s &handle)
removes a handle from the list
uint16_t am_time_t
time in ms!
am_Handle_e
This enumeration is used to define the type of the action that is correlated to a handle...
am_Error_e removeSinkLookup(const am_sinkID_t sinkID)
uint16_t am_domainID_t
a domain ID
am_Error_e removeSourceLookup(const am_sourceID_t sourceID)
CAmRoutingSender(const std::vector< std::string > &listOfPluginDirectories, IAmDatabaseHandler *databaseHandler)
am_Error_e asyncSetVolumes(am_Handle_s &handle, const std::vector< am_Volumes_s > &listVolumes)
This struct describes the attribiutes of a source.
uint16_t am_CustomRampType_t
The given ramp types here are just examples.
uint16_t am_sinkID_t
a sink ID
am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s &handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration)
handleSinkVolume(IAmRoutingSend *interface, const am_sinkID_t sinkID, IAmDatabaseHandler *databaseHandler, const am_volume_t &volume)
am_SourceState_e
The source state reflects the state of the source.
am_Error_e removeConnectionLookup(const am_connectionID_t connectionID)
handleSourceState(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_SourceState_e &state, IAmDatabaseHandler *databaseHandler)
handleConnect(IAmRoutingSend *interface, const am_connectionID_t connectionID, IAmDatabaseHandler *databaseHandler)
am_Error_e asyncConnect(am_Handle_s &handle, am_connectionID_t &connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat)
am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s &handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration)
< is used to pair interfaces with busnames
am_Error_e removeDomainLookup(const am_domainID_t domainID)