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"
29 RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender)
30 :mDatabaseHandler(iDatabaseHandler),
31 mRoutingSender(iRoutingSender),
32 mControlSender(iControlSender)
34 assert(mDatabaseHandler!=0);
35 assert(mRoutingSender!=0);
36 assert(mControlSender!=0);
41 RoutingReceiver::~RoutingReceiver()
47 void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
49 mRoutingSender->removeHandle(handle);
52 mDatabaseHandler->changeConnectionFinal(connectionID);
56 mDatabaseHandler->removeConnection(connectionID);
58 mControlSender->cbAckConnect(handle,error);
63 void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
65 mRoutingSender->removeHandle(handle);
68 mDatabaseHandler->removeConnection(connectionID);
70 mControlSender->cbAckDisconnect(handle,error);
75 void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
77 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
78 if(error==E_OK && handleData.sinkID!=0)
80 //todo: check if volume in handleData is same than volume. React to it.
81 mDatabaseHandler->changeSinkVolume(handleData.sinkID,volume);
83 mRoutingSender->removeHandle(handle);
84 mControlSender->cbAckSetSinkVolumeChange(handle,volume,error);
89 void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
91 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
92 if(error==E_OK && handleData.sourceID!=0)
94 //todo: check if volume in handleData is same than volume. React to it.
95 mDatabaseHandler->changeSourceVolume(handleData.sourceID,volume);
97 mRoutingSender->removeHandle(handle);
98 mControlSender->cbAckSetSourceVolumeChange(handle,volume,error);
103 void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
105 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
106 if(error==E_OK && handleData.sourceID!=0)
108 //todo: check if volume in handleData is same than volume. React to it.
109 mDatabaseHandler->changeSourceState(handleData.sourceID,handleData.sourceState);
111 mRoutingSender->removeHandle(handle);
112 mControlSender->cbAckSetSourceState(handle,error);
117 void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
119 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
120 if(error==E_OK && handleData.sinkID!=0)
122 //todo: check if volume in handleData is same than volume. React to it.
123 mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID);
125 mRoutingSender->removeHandle(handle);
126 mControlSender->cbAckSetSinkSoundProperty(handle,error);
132 void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
134 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
135 if(error==E_OK && handleData.sourceID!=0)
137 //todo: check if volume in handleData is same than volume. React to it.
138 mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID);
140 mRoutingSender->removeHandle(handle);
141 mControlSender->cbAckSetSourceSoundProperty(handle,error);
146 void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
148 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
149 if(error==E_OK && handleData.crossfaderID!=0)
151 //todo: check if volume in handleData is same than volume. React to it.
152 mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID,hotSink);
154 mRoutingSender->removeHandle(handle);
155 mControlSender->cbAckCrossFade(handle,hotSink,error);
160 void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
162 mControlSender->hookSystemSourceVolumeTick(handle,sourceID,volume);
167 void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
169 mControlSender->hookSystemSinkVolumeTick(handle,sinkID,volume);
174 am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
176 return mDatabaseHandler->peekDomain(name,domainID);
181 am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
183 return mControlSender->hookSystemRegisterDomain(domainData,domainID);
188 am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
190 return mControlSender->hookSystemDeregisterDomain(domainID);
195 am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
197 return mControlSender->hookSystemRegisterGateway(gatewayData,gatewayID);
202 am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
204 return mControlSender->hookSystemDeregisterGateway(gatewayID);
209 am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
211 return mDatabaseHandler->peekSink(name,sinkID);
216 am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
218 return mControlSender->hookSystemRegisterSink(sinkData,sinkID);
223 am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
225 return mControlSender->hookSystemDeregisterSink(sinkID);
230 am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
232 return mDatabaseHandler->peekSource(name,sourceID);
237 am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
239 return mControlSender->hookSystemRegisterSource(sourceData,sourceID);
244 am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
246 return mControlSender->hookSystemDeregisterSource(sourceID);
251 am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
253 return mControlSender->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
258 am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
260 return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
265 void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
267 return mControlSender->hookSystemInterruptStateChange(sourceID,interruptState);
272 void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
274 mControlSender->hookSystemDomainRegistrationComplete(domainID);
280 void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
282 mControlSender->hookSystemSinkAvailablityStateChange(sinkID,availability);
287 void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
289 mControlSender->hookSystemSourceAvailablityStateChange(sourceID,availability);
294 void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
296 mControlSender->hookSystemDomainStateChange(domainID,domainState);
301 void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
303 mDatabaseHandler->changeConnectionTimingInformation(connectionID,delay);
308 am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
310 mControlSender->hookSystemReceiveEarlyData(earlyData);
312 //todo: change return type to void in EA model
317 am_Error_e RoutingReceiver::peekSinkClassID(const std::string & name, am_sourceClass_t & sourceClassID)
322 am_Error_e RoutingReceiver::peekSourceClassID(const std::string & name, am_sinkClass_t & sinkClassID)
327 am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *dbusConnectionWrapper) const
329 //todo: return DbusWrapper