2 * Copyright (C) 2011, BMW AG
4 * GeniviAudioMananger AudioManagerDaemon
6 * \file RoutingReceiver.cpp
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (christian.ei.mueller@bmw.de)
11 * \section LicenseRoutingReceiver.h
13 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
14 * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
16 * 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.
17 * 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.
18 * 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>.
19 * 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.
20 * 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.
21 * 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.
22 * 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.
26 #include "RoutingReceiver.h"
31 am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler)
32 :mDatabaseHandler(iDatabaseHandler),
33 mRoutingSender(iRoutingSender),
34 mControlSender(iControlSender),
35 mSocketHandler(iSocketHandler)
37 assert(mDatabaseHandler!=NULL);
38 assert(mRoutingSender!=NULL);
39 assert(mControlSender!=NULL);
40 assert(mSocketHandler!=NULL);
43 am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, DBusWrapper *iDBusWrapper)
44 :mDatabaseHandler(iDatabaseHandler),
45 mRoutingSender(iRoutingSender),
46 mControlSender(iControlSender),
47 mDBusWrapper(iDBusWrapper)
49 assert(mDatabaseHandler!=NULL);
50 assert(mRoutingSender!=NULL);
51 assert(mControlSender!=NULL);
52 assert(mDBusWrapper!=NULL);
55 am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper)
56 :mDatabaseHandler(iDatabaseHandler),
57 mRoutingSender(iRoutingSender),
58 mControlSender(iControlSender),
59 mSocketHandler(iSocketHandler),
60 mDBusWrapper(iDBusWrapper)
62 assert(mDatabaseHandler!=NULL);
63 assert(mRoutingSender!=NULL);
64 assert(mControlSender!=NULL);
65 assert(mSocketHandler!=NULL);
66 assert(mDBusWrapper!=NULL);
71 RoutingReceiver::~RoutingReceiver()
77 void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
79 mRoutingSender->removeHandle(handle);
82 mDatabaseHandler->changeConnectionFinal(connectionID);
86 mDatabaseHandler->removeConnection(connectionID);
88 mControlSender->cbAckConnect(handle,error);
93 void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
95 mRoutingSender->removeHandle(handle);
98 mDatabaseHandler->removeConnection(connectionID);
100 mControlSender->cbAckDisconnect(handle,error);
105 void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
107 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
108 if(error==E_OK && handleData.sinkID!=0)
110 //todo: check if volume in handleData is same than volume. React to it.
111 mDatabaseHandler->changeSinkVolume(handleData.sinkID,volume);
113 mRoutingSender->removeHandle(handle);
114 mControlSender->cbAckSetSinkVolumeChange(handle,volume,error);
119 void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
121 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
122 if(error==E_OK && handleData.sourceID!=0)
124 //todo: check if volume in handleData is same than volume. React to it.
125 mDatabaseHandler->changeSourceVolume(handleData.sourceID,volume);
127 mRoutingSender->removeHandle(handle);
128 mControlSender->cbAckSetSourceVolumeChange(handle,volume,error);
133 void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
135 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
136 if(error==E_OK && handleData.sourceID!=0)
138 //todo: check if volume in handleData is same than volume. React to it.
139 mDatabaseHandler->changeSourceState(handleData.sourceID,handleData.sourceState);
141 mRoutingSender->removeHandle(handle);
142 mControlSender->cbAckSetSourceState(handle,error);
147 void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
149 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
150 if(error==E_OK && handleData.sinkID!=0)
152 //todo: check if volume in handleData is same than volume. React to it.
153 mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID);
155 mRoutingSender->removeHandle(handle);
156 mControlSender->cbAckSetSinkSoundProperty(handle,error);
162 void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
164 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
165 if(error==E_OK && handleData.sourceID!=0)
167 //todo: check if volume in handleData is same than volume. React to it.
168 mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID);
170 mRoutingSender->removeHandle(handle);
171 mControlSender->cbAckSetSourceSoundProperty(handle,error);
176 void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
178 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
179 if(error==E_OK && handleData.crossfaderID!=0)
181 //todo: check if volume in handleData is same than volume. React to it.
182 mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID,hotSink);
184 mRoutingSender->removeHandle(handle);
185 mControlSender->cbAckCrossFade(handle,hotSink,error);
190 void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
192 mControlSender->hookSystemSourceVolumeTick(handle,sourceID,volume);
197 void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
199 mControlSender->hookSystemSinkVolumeTick(handle,sinkID,volume);
204 am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
206 return mDatabaseHandler->peekDomain(name,domainID);
211 am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
213 return mControlSender->hookSystemRegisterDomain(domainData,domainID);
218 am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
220 return mControlSender->hookSystemDeregisterDomain(domainID);
225 am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
227 return mControlSender->hookSystemRegisterGateway(gatewayData,gatewayID);
232 am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
234 return mControlSender->hookSystemDeregisterGateway(gatewayID);
239 am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
241 return mDatabaseHandler->peekSink(name,sinkID);
246 am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
248 return mControlSender->hookSystemRegisterSink(sinkData,sinkID);
253 am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
255 return mControlSender->hookSystemDeregisterSink(sinkID);
260 am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
262 return mDatabaseHandler->peekSource(name,sourceID);
267 am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
269 return mControlSender->hookSystemRegisterSource(sourceData,sourceID);
274 am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
276 return mControlSender->hookSystemDeregisterSource(sourceID);
281 am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
283 return mControlSender->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
288 am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
290 return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
295 void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
297 return mControlSender->hookSystemInterruptStateChange(sourceID,interruptState);
302 void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
304 mControlSender->hookSystemDomainRegistrationComplete(domainID);
309 void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
311 mControlSender->hookSystemSinkAvailablityStateChange(sinkID,availability);
316 void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
318 mControlSender->hookSystemSourceAvailablityStateChange(sourceID,availability);
323 void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
325 mControlSender->hookSystemDomainStateChange(domainID,domainState);
330 void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
332 mDatabaseHandler->changeConnectionTimingInformation(connectionID,delay);
337 am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
339 mControlSender->hookSystemReceiveEarlyData(earlyData);
341 //todo: change return type to void in EA model
346 am_Error_e RoutingReceiver::peekSinkClassID(const std::string name, const am_sinkClass_t& sinkClassID)
352 am_Error_e RoutingReceiver::peekSourceClassID(const std::string name, const am_sourceClass_t& sourceClassID)
358 am_Error_e am::RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *& dbusConnectionWrapper) const
360 #ifdef WITH_DBUS_WRAPPER
361 dbusConnectionWrapper=mDBusWrapper;
369 am_Error_e am::RoutingReceiver::getSocketHandler(SocketHandler *& socketHandler) const
371 #ifdef WITH_SOCKETHANDLER_LOOP
372 socketHandler=mSocketHandler;