* [ GAM-6 ] enhace routing algorithm: changed the way the routing algorithm gets...
[profile/ivi/audiomanager.git] / AudioManagerDaemon / src / ControlSender.cpp
1 /**
2  * Copyright (C) 2011, BMW AG
3  *
4  * GeniviAudioMananger AudioManagerDaemon
5  *
6  * \file ControlSender.cpp
7  *
8  * \date 20-Oct-2011 3:42:04 PM
9  * \author Christian Mueller (christian.ei.mueller@bmw.de)
10  *
11  * \section License
12  * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13  * Copyright (C) 2011, BMW AG Christian Mueller  Christian.ei.mueller@bmw.de
14  *
15  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17  * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18  * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19  * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20  * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21  * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
22  *
23  */
24
25 #include "ControlSender.h"
26 #include "PluginTemplate.h"
27 #include "DLTWrapper.h"
28 #include <cassert>
29 #include <fstream>
30
31 using namespace am;
32
33 #define REQUIRED_MIN_INTERFACE_VERSION 1
34
35 ControlSender::ControlSender(std::string controlPluginFile) :
36         mlibHandle(NULL), //
37         mController(NULL)
38 {
39     std::ifstream isfile(controlPluginFile.c_str());
40     if (!isfile)
41     {
42         logError("ControlSender::ControlSender: Controller plugin not found:", controlPluginFile);
43     }
44     else if (!controlPluginFile.empty())
45     {
46         ControlSendInterface* (*createFunc)();
47         createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile, mlibHandle);
48         assert(createFunc!=NULL);
49         mController = createFunc();
50
51         //check libversion
52         assert(REQUIRED_MIN_INTERFACE_VERSION<=mController->getInterfaceVersion());
53     }
54     else
55     {
56         logError("ControlSender::ControlSender: No controller loaded !");
57     }
58 }
59
60 ControlSender::~ControlSender()
61 {
62     if (mlibHandle)
63         dlclose(mlibHandle);
64 }
65
66 void ControlSender::hookAllPluginsLoaded()
67 {
68     mController->hookAllPluginsLoaded();
69 }
70
71 am_Error_e ControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
72 {
73     return mController->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID);
74 }
75
76 am_Error_e ControlSender::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
77 {
78     return mController->hookUserDisconnectionRequest(connectionID);
79 }
80
81 am_Error_e ControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
82 {
83     return mController->hookUserSetMainSinkSoundProperty(sinkID, soundProperty);
84 }
85
86 am_Error_e ControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
87 {
88     return mController->hookUserSetMainSourceSoundProperty(sourceID, soundProperty);
89 }
90
91 am_Error_e ControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
92 {
93     return mController->hookUserSetSystemProperty(property);
94 }
95
96 am_Error_e ControlSender::hookUserVolumeChange(const am_sinkID_t sinkID, const am_mainVolume_t newVolume)
97 {
98     return mController->hookUserVolumeChange(sinkID, newVolume);
99 }
100
101 am_Error_e ControlSender::hookUserVolumeStep(const am_sinkID_t sinkID, const int16_t increment)
102 {
103     return mController->hookUserVolumeStep(sinkID, increment);
104 }
105
106 am_Error_e ControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
107 {
108     return mController->hookUserSetSinkMuteState(sinkID, muteState);
109 }
110
111 am_Error_e ControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
112 {
113     return mController->hookSystemRegisterDomain(domainData, domainID);
114 }
115
116 am_Error_e ControlSender::hookSystemDeregisterDomain(const am_domainID_t domainID)
117 {
118     return mController->hookSystemDeregisterDomain(domainID);
119 }
120
121 void ControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
122 {
123     return mController->hookSystemDomainRegistrationComplete(domainID);
124 }
125
126 am_Error_e ControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
127 {
128     return mController->hookSystemRegisterSink(sinkData, sinkID);
129 }
130
131 am_Error_e ControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
132 {
133     return mController->hookSystemDeregisterSink(sinkID);
134 }
135
136 am_Error_e ControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
137 {
138     return mController->hookSystemRegisterSource(sourceData, sourceID);
139 }
140
141 am_Error_e ControlSender::hookSystemDeregisterSource(const am_sourceID_t sourceID)
142 {
143     return mController->hookSystemDeregisterSource(sourceID);
144 }
145
146 am_Error_e ControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
147 {
148     return mController->hookSystemRegisterGateway(gatewayData, gatewayID);
149 }
150
151 am_Error_e ControlSender::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
152 {
153     return mController->hookSystemDeregisterGateway(gatewayID);
154 }
155
156 am_Error_e ControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
157 {
158     return mController->hookSystemRegisterCrossfader(crossfaderData, crossfaderID);
159 }
160
161 am_Error_e ControlSender::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
162 {
163     return mController->hookSystemDeregisterCrossfader(crossfaderID);
164 }
165
166 void ControlSender::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
167 {
168     mController->hookSystemSinkVolumeTick(handle, sinkID, volume);
169 }
170
171 void ControlSender::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
172 {
173     mController->hookSystemSourceVolumeTick(handle, sourceID, volume);
174 }
175
176 void ControlSender::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
177 {
178     mController->hookSystemInterruptStateChange(sourceID, interruptState);
179 }
180
181 void ControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
182 {
183     mController->hookSystemSinkAvailablityStateChange(sinkID, availability);
184 }
185
186 void ControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
187 {
188     mController->hookSystemSourceAvailablityStateChange(sourceID, availability);
189 }
190
191 void ControlSender::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
192 {
193     mController->hookSystemDomainStateChange(domainID, state);
194 }
195
196 void ControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
197 {
198     mController->hookSystemReceiveEarlyData(data);
199 }
200
201 void ControlSender::hookSystemSpeedChange(const am_speed_t speed)
202 {
203     mController->hookSystemSpeedChange(speed);
204 }
205
206 void ControlSender::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
207 {
208     mController->hookSystemTimingInformationChanged(mainConnectionID, time);
209 }
210
211 void ControlSender::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
212 {
213     mController->cbAckConnect(handle, errorID);
214 }
215
216 void ControlSender::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
217 {
218     mController->cbAckDisconnect(handle, errorID);
219 }
220
221 void ControlSender::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
222 {
223     mController->cbAckCrossFade(handle, hostsink, error);
224 }
225
226 void ControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
227 {
228     mController->cbAckSetSinkVolumeChange(handle, volume, error);
229 }
230
231 void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
232 {
233     mController->cbAckSetSourceVolumeChange(handle, volume, error);
234 }
235
236 void ControlSender::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
237 {
238     mController->cbAckSetSourceState(handle, error);
239 }
240
241 void ControlSender::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
242 {
243     mController->cbAckSetSourceSoundProperty(handle, error);
244 }
245
246 am_Error_e ControlSender::startupController(ControlReceiveInterface *controlreceiveinterface)
247 {
248     return mController->startupController(controlreceiveinterface);
249 }
250
251 am_Error_e ControlSender::stopController()
252 {
253     return mController->stopController();
254 }
255
256 void ControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
257 {
258     mController->cbAckSetSinkSoundProperty(handle, error);
259 }
260
261 void ControlSender::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
262 {
263     mController->cbAckSetSinkSoundProperties(handle, error);
264 }
265
266 void ControlSender::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
267 {
268     mController->cbAckSetSourceSoundProperties(handle, error);
269 }
270
271 am_Error_e am::ControlSender::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e> & listPrioConnectionFormats)
272 {
273     return mController->getConnectionFormatChoice(sourceID, sinkID, listRoute, listPossibleConnectionFormats, listPrioConnectionFormats);
274 }
275
276 uint16_t ControlSender::getInterfaceVersion() const
277 {
278     return ControlSendVersion;
279 }
280