AudioManager  7.5.11
Native Application Runtime Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 namespace am
36 {
37 
38 class CAmRoutingReceiver;
39 class IAmDatabaseHandler;
40 
45 {
46 public:
47  CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler);
49 
50  am_Error_e removeHandle(const am_Handle_s& handle);
51  am_Error_e addDomainLookup(const am_Domain_s& domainData);
52  am_Error_e addSourceLookup(const am_Source_s& sourceData);
53  am_Error_e addSinkLookup(const am_Sink_s& sinkData);
54  am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
60 
62  void setRoutingReady();
63  void setRoutingRundown();
64  am_Error_e asyncAbort(const am_Handle_s& handle);
65  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);
66  am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
67  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);
68  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);
69  am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
70  am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
71  am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID);
72  am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID);
73  am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
74  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);
75  am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
76  am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const;
77  am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
78  void getInterfaceVersion(std::string& version) const;
79  am_Error_e asyncSetVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes);
80  am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration);
81  am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration);
82  am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s>& listOfExistingConnections);
83 
85  {
87  std::string busName;
88  };
89 
91  {
92  public:
93  handleDataBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler) : mInterface(interface), mpDatabaseHandler(databaseHandler) {}
94  virtual ~handleDataBase() {}
95  virtual am_Error_e writeDataToDatabase()=0;
96  IAmRoutingSend* returnInterface() {return mInterface;}
97  private:
98  IAmRoutingSend* mInterface;
99  protected:
101  };
102 
104  {
105  public:
106  handleVolumeBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler,am_volume_t volume) :
107  handleDataBase(interface,databaseHandler)
108  ,mVolume(volume) {}
109  virtual ~handleVolumeBase(){}
110  am_volume_t returnVolume() { return mVolume; }
111  private:
112  am_volume_t mVolume;
113  };
114 
116  {
117  public:
118  handleSinkSoundProperty(IAmRoutingSend* interface,const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
119  handleDataBase(interface,databaseHandler)
120  ,mSinkID(sinkID)
121  ,mSoundProperty(soundProperty) {}
124  private:
125  am_sinkID_t mSinkID;
126  am_SoundProperty_s mSoundProperty;
127  };
128 
130  {
131  public:
132  handleSinkSoundProperties(IAmRoutingSend* interface,const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
133  handleDataBase(interface,databaseHandler)
134  ,mSinkID(sinkID)
135  ,mlistSoundProperties(listSoundProperties) {}
138  private:
139  am_sinkID_t mSinkID;
140  std::vector<am_SoundProperty_s> mlistSoundProperties;
141  };
142 
144  {
145  public:
146  handleSourceSoundProperty(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
147  handleDataBase(interface,databaseHandler)
148  ,mSourceID(sourceID)
149  ,mSoundProperty(soundProperty) {}
152  private:
153  am_sourceID_t mSourceID;
154  am_SoundProperty_s mSoundProperty;
155  };
156 
158  {
159  public:
160  handleSourceSoundProperties(IAmRoutingSend* interface,const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
161  handleDataBase(interface,databaseHandler)
162  ,mSourceID(sourceID)
163  ,mlistSoundProperties(listSoundProperties) {}
166  private:
167  am_sourceID_t mSourceID;
168  std::vector<am_SoundProperty_s> mlistSoundProperties;
169  };
170 
172  {
173  public:
174  handleSourceState(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SourceState_e& state, IAmDatabaseHandler* databaseHandler) :
175  handleDataBase(interface,databaseHandler)
176  ,mSourceID(sourceID)
177  ,mSourceState(state) {}
180  private:
181  am_sourceID_t mSourceID;
182  am_SourceState_e mSourceState;
183  };
184 
186  {
187  public:
188  handleSourceVolume(IAmRoutingSend* interface, const am_sourceID_t sourceID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
189  handleVolumeBase(interface,databaseHandler,volume)
190  ,mSourceID(sourceID) {}
193  private:
194  am_sourceID_t mSourceID;
195  };
196 
198  {
199  public:
200  handleSinkVolume(IAmRoutingSend* interface, const am_sinkID_t sinkID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
201  handleVolumeBase(interface,databaseHandler,volume)
202  ,mSinkID(sinkID) {}
205  private:
206  am_sinkID_t mSinkID;
207  };
208 
210  {
211  public:
212  handleCrossFader(IAmRoutingSend* interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e& hotSink, IAmDatabaseHandler* databaseHandler) :
213  handleDataBase(interface,databaseHandler)
214  ,mCrossfaderID(crossfaderID)
215  ,mHotSink(hotSink) {}
218  private:
219  am_crossfaderID_t mCrossfaderID;
220  am_HotSink_e mHotSink;
221  };
222 
224  {
225  public:
226  handleConnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler) :
227  handleDataBase(interface,databaseHandler)
228  ,mConnectionID(connectionID)
229  ,mConnectionPending(true) {}
230  ~handleConnect();
232  private:
233  am_connectionID_t mConnectionID;
234  bool mConnectionPending;
235  };
236 
238  {
239  public:
240  handleDisconnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler,CAmRoutingSender* routingSender) :
241  handleDataBase(interface,databaseHandler)
242  ,mConnectionID(connectionID)
243  ,mRoutingSender(routingSender){}
246  private:
247  am_connectionID_t mConnectionID;
248  CAmRoutingSender* mRoutingSender;
249  };
250 
252  {
253  public:
254  handleSetVolumes(IAmRoutingSend* interface, const std::vector<am_Volumes_s> listVolumes, IAmDatabaseHandler* databaseHandler) :
255  handleDataBase(interface,databaseHandler)
256  ,mlistVolumes(listVolumes) {}
259  private:
260  std::vector<am_Volumes_s> mlistVolumes;
261  };
262 
264  {
265  public:
266  handleSetSinkNotificationConfiguration(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
267  handleDataBase(interface,databaseHandler)
268  ,mSinkID(sinkID)
269  ,mNotificationConfiguration(notificationConfiguration){}
272  private:
273  am_sinkID_t mSinkID;
274  am_NotificationConfiguration_s mNotificationConfiguration;
275  };
276 
278  {
279  public:
280  handleSetSourceNotificationConfiguration(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
281  handleDataBase(interface,databaseHandler)
282  ,mSourceID(sourceID)
283  ,mNotificationConfiguration(notificationConfiguration) {}
286  private:
287  am_sourceID_t mSourceID;
288  am_NotificationConfiguration_s mNotificationConfiguration;
289  };
290 
292  void checkVolume(const am_Handle_s handle, const am_volume_t volume);
293  bool handleExists(const am_Handle_s handle);
294 
295 #ifdef UNIT_TEST //this is needed to test RoutingSender
296  friend class IAmRoutingBackdoor;
297 #endif
298 
299 private:
300  struct comparator
301  {
302  bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
303  {
304  return (a.handle<b.handle || (a.handle==b.handle && a.handleType<b.handleType));
305  }
306  };
307 
308  am_Handle_s createHandle(std::shared_ptr<handleDataBase> handleData, const am_Handle_e type);
309  void unloadLibraries(void);
310 
311  typedef std::map<am_domainID_t, IAmRoutingSend*> DomainInterfaceMap;
312  typedef std::map<am_sinkID_t, IAmRoutingSend*> SinkInterfaceMap;
313  typedef std::map<am_sourceID_t, IAmRoutingSend*> SourceInterfaceMap;
314  typedef std::map<am_crossfaderID_t, IAmRoutingSend*> CrossfaderInterfaceMap;
315  typedef std::map<am_connectionID_t, IAmRoutingSend*> ConnectionInterfaceMap;
316  typedef std::map<am_Handle_s, std::shared_ptr<handleDataBase>, comparator> HandlesMap;
317 
318  int16_t mHandleCount;
319  HandlesMap mlistActiveHandles;
320  std::vector<void*> mListLibraryHandles;
321  std::vector<InterfaceNamePairs> mListInterfaces;
322  CrossfaderInterfaceMap mMapCrossfaderInterface;
323  ConnectionInterfaceMap mMapConnectionInterface;
324  DomainInterfaceMap mMapDomainInterface;
325  SinkInterfaceMap mMapSinkInterface;
326  SourceInterfaceMap mMapSourceInterface;
327  CAmRoutingReceiver *mpRoutingReceiver;
328  IAmDatabaseHandler* mpDatabaseHandler;
329 };
330 
331 }
332 
333 #endif /* ROUTINGSENDER_H_ */
am_Error_e writeDataToDatabase()
function to write the handle data to the database
Implements the RoutingSendInterface.
am_Error_e asyncAbort(const am_Handle_s &handle)
uint16_t am_connectionID_t
a connection ID
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 writeDataToDatabase()
function to write the handle data to the database
am_Error_e getListHandles(std::vector< am_Handle_s > &listHandles) const
This struct describes the attribiutes of a sink.
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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)
virtual am_Error_e writeDataToDatabase()=0
function to write the handle data to the database
am_Error_e addSinkLookup(const am_Sink_s &sinkData)
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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 writeDataToDatabase()
function to write the handle data to the database
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 writeDataToDatabase()
function to write the handle data to the database
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)
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 ...
am_Error_e writeDataToDatabase()
function to write the handle data to the database
am_Error_e writeDataToDatabase()
function to write the handle data to the database
IAmRoutingSend * routingInterface
pointer to the routingInterface
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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)
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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 writeDataToDatabase()
function to write the handle data to the database
am_Error_e removeSinkLookup(const am_sinkID_t sinkID)
uint16_t am_domainID_t
a domain ID
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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.
am_Error_e writeDataToDatabase()
function to write the handle data to the database
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)