4 * Created on: Oct 24, 2011
8 #include "ControlReceiver.h"
11 DLT_IMPORT_CONTEXT(AudioManager)
13 ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender)
14 : mDatabaseHandler(iDatabaseHandler),
15 mRoutingSender(iRoutingSender)
19 ControlReceiver::~ControlReceiver()
23 am_Error_e ControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
25 //todo: implement routing algorithm
30 am_Error_e ControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
32 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::connect got called, connectionFormat"),DLT_INT(format),DLT_STRING("sourceID"),DLT_INT(sourceID),DLT_STRING("sinkID"),DLT_INT(sinkID));
34 am_Connection_s tempConnection;
35 tempConnection.sinkID=sinkID;
36 tempConnection.sourceID=sourceID;
37 tempConnection.connectionFormat=format;
38 tempConnection.connectionID=0;
40 if (mDatabaseHandler->existConnection(tempConnection)) return E_ALREADY_EXISTS; //todo:enter the correct connectionID here?
42 mDatabaseHandler->enterConnectionDB(tempConnection,connectionID);
43 return mRoutingSender->asyncConnect(handle,connectionID,sourceID,sinkID,format);
48 am_Error_e ControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
50 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::disconnect got called, connectionID="),DLT_INT(connectionID));
52 if (!mDatabaseHandler->existConnectionID(connectionID)) return E_NON_EXISTENT; //todo: check with EA model and correct
53 return mRoutingSender->asyncDisconnect(handle,connectionID);
58 am_Error_e ControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)
60 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::crossfade got called, hotSource="),DLT_INT(hotSource),DLT_STRING("crossfaderID="),DLT_INT(crossfaderID),DLT_STRING("rampType="),DLT_INT(rampType),DLT_STRING("rampTime="),DLT_INT(rampTime));
62 if (!mDatabaseHandler->existcrossFader(crossfaderID)) return E_NON_EXISTENT;
63 return mRoutingSender->asyncCrossFade(handle,crossfaderID,hotSource,rampType,rampTime);
68 am_Error_e ControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
70 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceState got called, sourceID="),DLT_INT(sourceID),DLT_STRING("state="),DLT_INT(state));
72 am_SourceState_e sourceState;
73 if(mDatabaseHandler->getSoureState(sourceID,sourceState)!=E_OK) return E_UNKNOWN;
74 if(sourceState==state) return E_NO_CHANGE;
75 return mRoutingSender->asyncSetSourceState(handle,sourceID,state);
80 am_Error_e ControlReceiver::setSinkVolume(am_Handle_s & handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
82 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkVolume got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(ramp),DLT_STRING("time="),DLT_INT(time));
84 am_volume_t tempVolume;
85 if(mDatabaseHandler->getSinkVolume(sinkID,tempVolume)!=E_OK) return E_UNKNOWN;
86 if(tempVolume==volume) return E_NO_CHANGE;
87 return mRoutingSender->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
92 am_Error_e ControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)
94 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceVolume got called, sourceID="),DLT_INT(sourceID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(rampType),DLT_STRING("time="),DLT_INT(time));
96 am_volume_t tempVolume;
97 if(mDatabaseHandler->getSourceVolume(sourceID,tempVolume)!=E_OK) return E_UNKNOWN;
98 if(tempVolume==volume) return E_NO_CHANGE;
99 return mRoutingSender->asyncSetSourceVolume(handle,sourceID,volume,rampType,time);
104 am_Error_e ControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
106 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperty got called, sinkID="),DLT_INT(sinkID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
109 if(mDatabaseHandler->getSinkSoundPropertyValue(sinkID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
110 if(value==soundProperty.value) return E_NO_CHANGE;
111 return mRoutingSender->asyncSetSinkSoundProperty(handle,sinkID,soundProperty);
116 am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
118 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperty got called, sourceID="),DLT_INT(sourceID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
121 if(mDatabaseHandler->getSourceSoundPropertyValue(sourceID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
122 if(value==soundProperty.value) return E_NO_CHANGE;
123 return mRoutingSender->asyncSetSourceSoundProperty(handle,sourceID,soundProperty);
128 am_Error_e ControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
130 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setDomainState got called, domainID="),DLT_INT(domainID),DLT_STRING("domainState="),DLT_INT(domainState));
132 am_DomainState_e tempState=DS_MIN;
133 if(mDatabaseHandler->getDomainState(domainID,tempState)!=E_OK) return E_UNKNOWN;
134 if(tempState==domainState) return E_NO_CHANGE;
135 return mRoutingSender->setDomainState(domainID,domainState);
140 am_Error_e ControlReceiver::abortAction(const am_Handle_s handle)
142 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::abortAction got called, handle.type="),DLT_INT(handle.handle),DLT_STRING("handle.handleType="),DLT_INT(handle.handleType));
144 return mRoutingSender->asyncAbort(handle);
149 am_Error_e ControlReceiver::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
151 return mDatabaseHandler->enterDomainDB(domainData,domainID);
156 am_Error_e ControlReceiver::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
158 return mDatabaseHandler->enterMainConnectionDB(mainConnectionData,connectionID);
163 am_Error_e ControlReceiver::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
165 return mDatabaseHandler->enterSinkDB(sinkData,sinkID);
170 am_Error_e ControlReceiver::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
172 return mDatabaseHandler->enterCrossfaderDB(crossfaderData,crossfaderID);
177 am_Error_e ControlReceiver::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
179 return mDatabaseHandler->enterGatewayDB(gatewayData,gatewayID);
184 am_Error_e ControlReceiver::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
186 return mDatabaseHandler->enterSourceDB(sourceData,sourceID);
189 am_Error_e ControlReceiver::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
191 return mDatabaseHandler->enterSinkClassDB(sinkClass,sinkClassID);
194 am_Error_e ControlReceiver::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
196 return mDatabaseHandler->enterSourceClassDB(sourceClassID,sourceClass);
200 am_Error_e ControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> & listSystemProperties)
202 return mDatabaseHandler->enterSystemProperties(listSystemProperties);
206 am_Error_e ControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s & route)
208 return mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID,route);
213 am_Error_e ControlReceiver::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
215 return mDatabaseHandler->changeMainConnectionStateDB(mainconnectionID,connectionState);
220 am_Error_e ControlReceiver::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
222 return mDatabaseHandler->changeSinkMainVolumeDB(mainVolume,sinkID);
227 am_Error_e ControlReceiver::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
229 return mDatabaseHandler->changeSinkAvailabilityDB(availability,sinkID);
234 am_Error_e ControlReceiver::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
236 return mDatabaseHandler->changDomainStateDB(domainState,domainID);
241 am_Error_e ControlReceiver::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
243 return mDatabaseHandler->changeSinkMuteStateDB(muteState,sinkID);
248 am_Error_e ControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
250 return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sinkID);
255 am_Error_e ControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
257 return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sourceID);
262 am_Error_e ControlReceiver::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
264 return mDatabaseHandler->changeSourceAvailabilityDB(availability,sourceID);
269 am_Error_e ControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s & property)
271 return mDatabaseHandler->changeSystemPropertyDB(property);
276 am_Error_e ControlReceiver::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
278 return mDatabaseHandler->removeMainConnectionDB(mainConnectionID);
283 am_Error_e ControlReceiver::removeSinkDB(const am_sinkID_t sinkID)
285 return mDatabaseHandler->removeSinkDB(sinkID);
290 am_Error_e ControlReceiver::removeSourceDB(const am_sourceID_t sourceID)
292 return mDatabaseHandler->removeSourceDB(sourceID);
297 am_Error_e ControlReceiver::removeGatewayDB(const am_gatewayID_t gatewayID)
299 return mDatabaseHandler->removeGatewayDB(gatewayID);
304 am_Error_e ControlReceiver::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
306 return mDatabaseHandler->removeCrossfaderDB(crossfaderID);
311 am_Error_e ControlReceiver::removeDomainDB(const am_domainID_t domainID)
313 return mDatabaseHandler->removeDomainDB(domainID);
318 am_Error_e ControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
320 return mDatabaseHandler->getSourceClassInfoDB(sourceID,classInfo);
324 am_Error_e ControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
326 return mDatabaseHandler->getSinkClassInfoDB(sinkID,sinkClass);
331 am_Error_e ControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
333 return mDatabaseHandler->getGatewayInfoDB(gatewayID,gatewayData);
338 am_Error_e ControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
340 return mDatabaseHandler->getCrossfaderInfoDB(crossfaderID,crossfaderData);
345 am_Error_e ControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
347 return mDatabaseHandler->getListSinksOfDomain(domainID,listSinkID);
352 am_Error_e ControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
354 return mDatabaseHandler->getListSourcesOfDomain(domainID,listSourceID);
359 am_Error_e ControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
361 return mDatabaseHandler->getListCrossfadersOfDomain(domainID,listGatewaysID);
366 am_Error_e ControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
368 return mDatabaseHandler->getListGatewaysOfDomain(domainID,listGatewaysID);
373 am_Error_e ControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
375 return mDatabaseHandler->getListMainConnections(listMainConnections);
380 am_Error_e ControlReceiver::getListDomains(std::vector<am_Domain_s> & listDomains) const
382 return mDatabaseHandler->getListDomains(listDomains);
387 am_Error_e ControlReceiver::getListConnections(std::vector<am_Connection_s> & listConnections) const
389 return mDatabaseHandler->getListConnections(listConnections);
394 am_Error_e ControlReceiver::getListSinks(std::vector<am_Sink_s> & listSinks) const
396 return mDatabaseHandler->getListSinks(listSinks);
401 am_Error_e ControlReceiver::getListSources(std::vector<am_Source_s> & listSources) const
403 return mDatabaseHandler->getListSources(listSources);
408 am_Error_e ControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
410 return mDatabaseHandler->getListSourceClasses(listSourceClasses);
415 am_Error_e ControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
417 return mRoutingSender->getListHandles(listHandles);
422 am_Error_e ControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
424 return mDatabaseHandler->getListCrossfaders(listCrossfaders);
429 am_Error_e ControlReceiver::getListGateways(std::vector<am_Gateway_s> & listGateways) const
431 return mDatabaseHandler->getListGateways(listGateways);
436 am_Error_e ControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
438 return mDatabaseHandler->getListSinkClasses(listSinkClasses);
442 am_Error_e ControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
444 return mDatabaseHandler->getListSystemProperties(listSystemProperties);
448 am_Error_e ControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
450 mDatabaseHandler->changeSinkClassInfoDB(classInfo);
453 am_Error_e ControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
455 mDatabaseHandler->changeSourceClassInfoDB(classInfo);
458 am_Error_e ControlReceiver::removeSinkClassDB(const am_sinkClass_t sinkClassID)
460 mDatabaseHandler->removeSinkClassDB(sinkClassID);
463 am_Error_e ControlReceiver::removeSourceClassDB(const am_sourceClass_t sourceClassID)
465 mDatabaseHandler->removeSourceClassDB(sourceClassID);
468 void ControlReceiver::setCommandReady()
472 void ControlReceiver::setRoutingReady()