2 * Copyright (C) 2012, BMW AG
4 * This file is part of GENIVI Project AudioManager.
6 * Contributions are licensed to the GENIVI Alliance under one or more
7 * Contribution License Agreements.
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
17 * \file CAmRoutingSender.h
18 * For further information see http://www.genivi.org/.
22 #ifndef ROUTINGSENDER_H_
23 #define ROUTINGSENDER_H_
25 #include "routing/IAmRoutingSend.h"
28 #ifdef UNIT_TEST //this is needed to test RoutingSender
29 #include "../test/IAmRoutingBackdoor.h"
35 class CAmRoutingReceiver;
38 * Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins
40 class CAmRoutingSender
43 CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories);
46 am_Error_e removeHandle(const am_Handle_s& handle);
47 am_Error_e addDomainLookup(const am_Domain_s& domainData);
48 am_Error_e addSourceLookup(const am_Source_s& sourceData);
49 am_Error_e addSinkLookup(const am_Sink_s& sinkData);
50 am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
51 am_Error_e removeDomainLookup(const am_domainID_t domainID);
52 am_Error_e removeSourceLookup(const am_sourceID_t sourceID);
53 am_Error_e removeSinkLookup(const am_sinkID_t sinkID);
54 am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID);
56 am_Error_e startupInterfaces(CAmRoutingReceiver* iRoutingReceiver);
57 void setRoutingReady();
58 void setRoutingRundown();
59 am_Error_e asyncAbort(const am_Handle_s& handle);
60 am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat);
61 am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
62 am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time);
63 am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time);
64 am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
65 am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
66 am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID);
67 am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID);
68 am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
69 am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time);
70 am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
71 am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const;
72 am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
73 void getInterfaceVersion(std::string& version) const;
75 struct InterfaceNamePairs //!< is used to pair interfaces with busnames
77 IAmRoutingSend* routingInterface; //!< pointer to the routingInterface
78 std::string busName; //!< the busname
81 class am_handleData_c //!< is used to store data related to handles
87 am_sourceID_t sourceID;
88 am_crossfaderID_t crossfaderID;
89 am_connectionID_t connectionID;
94 am_SoundProperty_s soundPropery;
95 am_SourceState_e sourceState;
98 std::vector<am_SoundProperty_s>* soundProperties;
103 am_handleData_c returnHandleData(const am_Handle_s handle) const; //!< returns the handle data associated with a handle
105 #ifdef UNIT_TEST //this is needed to test RoutingSender
106 friend class IAmRoutingBackdoor;
110 struct comparator //!< is needed to sort the handles in the map
112 bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
114 return (a.handle < b.handle);
118 am_Handle_s createHandle(const am_handleData_c& handleData, const am_Handle_e type); //!< creates a handle
119 void unloadLibraries(void); //!< unloads all loaded plugins
121 typedef std::map<am_domainID_t, IAmRoutingSend*> DomainInterfaceMap; //!< maps domains to interfaces
122 typedef std::map<am_sinkID_t, IAmRoutingSend*> SinkInterfaceMap; //!< maps sinks to interfaces
123 typedef std::map<am_sourceID_t, IAmRoutingSend*> SourceInterfaceMap; //!< maps sources to interfaces
124 typedef std::map<am_crossfaderID_t, IAmRoutingSend*> CrossfaderInterfaceMap; //!< maps crossfaders to interfaces
125 typedef std::map<am_connectionID_t, IAmRoutingSend*> ConnectionInterfaceMap; //!< maps connections to interfaces
126 typedef std::map<uint16_t, IAmRoutingSend*> HandleInterfaceMap; //!< maps handles to interfaces
127 typedef std::map<am_Handle_s, am_handleData_c, comparator> HandlesMap; //!< maps handleData to handles
129 int16_t mHandleCount; //!< is used to create handles
130 HandlesMap mlistActiveHandles; //!< list of all currently "running" handles.
131 std::vector<void*> mListLibraryHandles; //!< list of all loaded pluginInterfaces
132 std::vector<InterfaceNamePairs> mListInterfaces; //!< list of busname/interface relation
133 ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces
134 CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface
135 DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces
136 SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces
137 SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces
138 HandleInterfaceMap mMapHandleInterface; //!< map of handles to interfaces
139 CAmRoutingReceiver *mpRoutingReceiver; //!< pointer to routing receiver
144 #endif /* ROUTINGSENDER_H_ */