2 * Copyright (C) 2012, BMW AG
4 * This file is part of GENIVI Project AudioManager.
6 * Contributions are licensed to the GENIVI Alliance under one or more
7 * Contribution License Agreements.
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
17 * \file CAmControlSender.cpp
18 * For further information see http://www.genivi.org/.
22 #include "CAmControlSender.h"
28 #include "TAmPluginTemplate.h"
29 #include "shared/CAmDltWrapper.h"
34 #define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
35 #define REQUIRED_INTERFACE_VERSION_MINOR 0 //!< minor interface version. All versions smaller than this will be rejected
37 CAmControlSender::CAmControlSender(std::string controlPluginFile) :
41 std::ifstream isfile(controlPluginFile.c_str());
44 logError("ControlSender::ControlSender: Controller plugin not found:", controlPluginFile);
46 else if (!controlPluginFile.empty())
48 IAmControlSend* (*createFunc)();
49 createFunc = getCreateFunction<IAmControlSend*()>(controlPluginFile, mlibHandle);
50 assert(createFunc!=NULL);
51 mController = createFunc();
55 mController->getInterfaceVersion(version);
56 uint16_t minorVersion, majorVersion;
57 std::istringstream(version.substr(0, 1)) >> majorVersion;
58 std::istringstream(version.substr(2, 1)) >> minorVersion;
60 if (majorVersion < REQUIRED_INTERFACE_VERSION_MAJOR || ((majorVersion == REQUIRED_INTERFACE_VERSION_MAJOR) && (minorVersion > REQUIRED_INTERFACE_VERSION_MINOR)))
62 logError("ControlSender::ControlSender: Interface Version of Controller too old, exiting now");
63 throw std::runtime_error("Interface Version of Controller too old");
68 logError("ControlSender::ControlSender: No controller loaded !");
72 CAmControlSender::~CAmControlSender()
78 am_Error_e CAmControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
81 return (mController->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID));
84 am_Error_e CAmControlSender::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
87 return (mController->hookUserDisconnectionRequest(connectionID));
90 am_Error_e CAmControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
93 return (mController->hookUserSetMainSinkSoundProperty(sinkID, soundProperty));
96 am_Error_e CAmControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
99 return (mController->hookUserSetMainSourceSoundProperty(sourceID, soundProperty));
102 am_Error_e CAmControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
105 return (mController->hookUserSetSystemProperty(property));
108 am_Error_e CAmControlSender::hookUserVolumeChange(const am_sinkID_t sinkID, const am_mainVolume_t newVolume)
111 return (mController->hookUserVolumeChange(sinkID, newVolume));
114 am_Error_e CAmControlSender::hookUserVolumeStep(const am_sinkID_t sinkID, const int16_t increment)
117 return (mController->hookUserVolumeStep(sinkID, increment));
120 am_Error_e CAmControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
123 return (mController->hookUserSetSinkMuteState(sinkID, muteState));
126 am_Error_e CAmControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
129 return (mController->hookSystemRegisterDomain(domainData, domainID));
132 am_Error_e CAmControlSender::hookSystemDeregisterDomain(const am_domainID_t domainID)
135 return (mController->hookSystemDeregisterDomain(domainID));
138 void CAmControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
141 return (mController->hookSystemDomainRegistrationComplete(domainID));
144 am_Error_e CAmControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
147 return (mController->hookSystemRegisterSink(sinkData, sinkID));
150 am_Error_e CAmControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
153 return (mController->hookSystemDeregisterSink(sinkID));
156 am_Error_e CAmControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
159 return (mController->hookSystemRegisterSource(sourceData, sourceID));
162 am_Error_e CAmControlSender::hookSystemDeregisterSource(const am_sourceID_t sourceID)
165 return (mController->hookSystemDeregisterSource(sourceID));
168 am_Error_e CAmControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
171 return (mController->hookSystemRegisterGateway(gatewayData, gatewayID));
174 am_Error_e CAmControlSender::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
177 return (mController->hookSystemDeregisterGateway(gatewayID));
180 am_Error_e CAmControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
183 return (mController->hookSystemRegisterCrossfader(crossfaderData, crossfaderID));
186 am_Error_e CAmControlSender::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
189 return (mController->hookSystemDeregisterCrossfader(crossfaderID));
192 void CAmControlSender::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
195 mController->hookSystemSinkVolumeTick(handle, sinkID, volume);
198 void CAmControlSender::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
201 mController->hookSystemSourceVolumeTick(handle, sourceID, volume);
204 void CAmControlSender::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
207 mController->hookSystemInterruptStateChange(sourceID, interruptState);
210 void CAmControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
213 mController->hookSystemSinkAvailablityStateChange(sinkID, availability);
216 void CAmControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
219 mController->hookSystemSourceAvailablityStateChange(sourceID, availability);
222 void CAmControlSender::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
225 mController->hookSystemDomainStateChange(domainID, state);
228 void CAmControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
231 mController->hookSystemReceiveEarlyData(data);
234 void CAmControlSender::hookSystemSpeedChange(const am_speed_t speed)
237 mController->hookSystemSpeedChange(speed);
240 void CAmControlSender::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
243 mController->hookSystemTimingInformationChanged(mainConnectionID, time);
246 void CAmControlSender::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
249 mController->cbAckConnect(handle, errorID);
252 void CAmControlSender::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
255 mController->cbAckDisconnect(handle, errorID);
258 void CAmControlSender::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
261 mController->cbAckCrossFade(handle, hostsink, error);
264 void CAmControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
267 mController->cbAckSetSinkVolumeChange(handle, volume, error);
270 void CAmControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
273 mController->cbAckSetSourceVolumeChange(handle, volume, error);
276 void CAmControlSender::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
279 mController->cbAckSetSourceState(handle, error);
282 void CAmControlSender::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
285 mController->cbAckSetSourceSoundProperty(handle, error);
288 am_Error_e CAmControlSender::startupController(IAmControlReceive *controlreceiveinterface)
292 logError("ControlSender::startupController: no Controller to startup!");
293 throw std::runtime_error("ControlSender::startupController: no Controller to startup! Exiting now ...");
294 return (E_NON_EXISTENT);
296 return (mController->startupController(controlreceiveinterface));
299 void CAmControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
302 mController->cbAckSetSinkSoundProperty(handle, error);
305 void CAmControlSender::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
308 mController->cbAckSetSinkSoundProperties(handle, error);
311 void CAmControlSender::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
314 mController->cbAckSetSourceSoundProperties(handle, error);
317 void CAmControlSender::setControllerReady()
320 mController->setControllerReady();
323 void CAmControlSender::setControllerRundown()
326 mController->setControllerRundown();
329 am_Error_e am::CAmControlSender::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)
332 return (mController->getConnectionFormatChoice(sourceID, sinkID, listRoute, listPossibleConnectionFormats, listPrioConnectionFormats));
335 void CAmControlSender::getInterfaceVersion(std::string & version) const
337 version = ControlSendVersion;
340 void CAmControlSender::confirmCommandReady()
343 mController->confirmCommandReady();
346 void CAmControlSender::confirmRoutingReady()
349 mController->confirmRoutingReady();
352 void CAmControlSender::confirmCommandRundown()
355 mController->confirmCommandRundown();
358 void CAmControlSender::confirmRoutingRundown()
361 mController->confirmRoutingRundown();