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"
27 #include "RoutingSender.h"
28 #include "DatabaseHandler.h"
29 #include "ControlSender.h"
34 RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender)
35 :mDatabaseHandler(iDatabaseHandler),
36 mRoutingSender(iRoutingSender),
37 mControlSender(iControlSender)
39 assert(mDatabaseHandler!=0);
40 assert(mRoutingSender!=0);
41 assert(mControlSender!=0);
46 RoutingReceiver::~RoutingReceiver()
52 void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
54 mRoutingSender->removeHandle(handle);
57 mDatabaseHandler->changeConnectionFinal(connectionID);
61 mDatabaseHandler->removeConnection(connectionID);
63 mControlSender->cbAckConnect(handle,error);
68 void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
70 mRoutingSender->removeHandle(handle);
73 mDatabaseHandler->removeConnection(connectionID);
75 mControlSender->cbAckDisconnect(handle,error);
80 void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
82 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
83 if(error==E_OK && handleData.sinkID!=0)
85 //todo: check if volume in handleData is same than volume. React to it.
86 mDatabaseHandler->changeSinkVolume(handleData.sinkID,volume);
88 mRoutingSender->removeHandle(handle);
89 mControlSender->cbAckSetSinkVolumeChange(handle,volume,error);
94 void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
96 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
97 if(error==E_OK && handleData.sourceID!=0)
99 //todo: check if volume in handleData is same than volume. React to it.
100 mDatabaseHandler->changeSourceVolume(handleData.sourceID,volume);
102 mRoutingSender->removeHandle(handle);
103 mControlSender->cbAckSetSourceVolumeChange(handle,volume,error);
108 void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
110 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
111 if(error==E_OK && handleData.sourceID!=0)
113 //todo: check if volume in handleData is same than volume. React to it.
114 mDatabaseHandler->changeSourceState(handleData.sourceID,handleData.sourceState);
116 mRoutingSender->removeHandle(handle);
117 mControlSender->cbAckSetSourceState(handle,error);
122 void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
124 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
125 if(error==E_OK && handleData.sinkID!=0)
127 //todo: check if volume in handleData is same than volume. React to it.
128 mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID);
130 mRoutingSender->removeHandle(handle);
131 mControlSender->cbAckSetSinkSoundProperty(handle,error);
137 void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
139 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
140 if(error==E_OK && handleData.sourceID!=0)
142 //todo: check if volume in handleData is same than volume. React to it.
143 mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID);
145 mRoutingSender->removeHandle(handle);
146 mControlSender->cbAckSetSourceSoundProperty(handle,error);
151 void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
153 RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
154 if(error==E_OK && handleData.crossfaderID!=0)
156 //todo: check if volume in handleData is same than volume. React to it.
157 mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID,hotSink);
159 mRoutingSender->removeHandle(handle);
160 mControlSender->cbAckCrossFade(handle,hotSink,error);
165 void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
167 mControlSender->hookSystemSourceVolumeTick(handle,sourceID,volume);
172 void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
174 mControlSender->hookSystemSinkVolumeTick(handle,sinkID,volume);
179 am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
181 return mDatabaseHandler->peekDomain(name,domainID);
186 am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
188 return mControlSender->hookSystemRegisterDomain(domainData,domainID);
193 am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
195 return mControlSender->hookSystemDeregisterDomain(domainID);
200 am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
202 return mControlSender->hookSystemRegisterGateway(gatewayData,gatewayID);
207 am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
209 return mControlSender->hookSystemDeregisterGateway(gatewayID);
214 am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
216 return mDatabaseHandler->peekSink(name,sinkID);
221 am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
223 return mControlSender->hookSystemRegisterSink(sinkData,sinkID);
228 am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
230 return mControlSender->hookSystemDeregisterSink(sinkID);
235 am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
237 return mDatabaseHandler->peekSource(name,sourceID);
242 am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
244 return mControlSender->hookSystemRegisterSource(sourceData,sourceID);
249 am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
251 return mControlSender->hookSystemDeregisterSource(sourceID);
256 am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
258 return mControlSender->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
263 am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
265 return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
270 void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
272 return mControlSender->hookSystemInterruptStateChange(sourceID,interruptState);
277 void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
279 mControlSender->hookSystemDomainRegistrationComplete(domainID);
284 void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
286 mControlSender->hookSystemSinkAvailablityStateChange(sinkID,availability);
291 void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
293 mControlSender->hookSystemSourceAvailablityStateChange(sourceID,availability);
298 void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
300 mControlSender->hookSystemDomainStateChange(domainID,domainState);
305 void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
307 mDatabaseHandler->changeConnectionTimingInformation(connectionID,delay);
312 am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
314 mControlSender->hookSystemReceiveEarlyData(earlyData);
316 //todo: change return type to void in EA model
321 am_Error_e RoutingReceiver::peekSinkClassID(const std::string & name, am_sourceClass_t & sourceClassID)
327 am_Error_e RoutingReceiver::peekSourceClassID(const std::string & name, am_sinkClass_t & sinkClassID)
333 am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *dbusConnectionWrapper) const
335 //todo: return DbusWrapper