summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfaceCAPI/src
diff options
context:
space:
mode:
Diffstat (limited to 'PluginRoutingInterfaceCAPI/src')
-rw-r--r--PluginRoutingInterfaceCAPI/src/CAmLookupData.cpp669
-rw-r--r--PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp266
-rw-r--r--PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCommon.cpp282
-rw-r--r--PluginRoutingInterfaceCAPI/src/CAmRoutingService.cpp435
4 files changed, 1652 insertions, 0 deletions
diff --git a/PluginRoutingInterfaceCAPI/src/CAmLookupData.cpp b/PluginRoutingInterfaceCAPI/src/CAmLookupData.cpp
new file mode 100644
index 0000000..6788618
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/src/CAmLookupData.cpp
@@ -0,0 +1,669 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include <algorithm>
+#include "CAmLookupData.h"
+#include "CAmRoutingSenderCommon.h"
+#include "shared/CAmDltWrapper.h"
+
+
+namespace am {
+
+const char * CAmLookupData::BUS_NAME = "CAPIRoutingPlugin";
+
+/**
+ * rs_lookupData_s
+ */
+
+rs_lookupData_s::rs_lookupData_s(const std::shared_ptr<RoutingSenderProxy<> > & aProxy):mSenderProxy(aProxy)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ mSubscription = mSenderProxy->getProxyStatusEvent().subscribe(std::bind(&rs_lookupData_s::onServiceStatusEvent,this,std::placeholders::_1));
+}
+
+rs_lookupData_s::~rs_lookupData_s()
+{
+ mSenderProxy->getProxyStatusEvent().unsubscribe(mSubscription);
+ mSenderProxy.reset();
+}
+
+std::shared_ptr<RoutingSenderProxy<>> & rs_lookupData_s::getProxy()
+{
+ return mSenderProxy;
+}
+
+bool rs_lookupData_s::isConnected()
+{
+ return mIsConnected;
+}
+
+am_Error_e rs_lookupData_s::asyncAbort(const uint16_t handle, RoutingSenderProxyBase::AsyncAbortAsyncCallback callback)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncAbortAsync(static_cast<am_gen::am_handle_t>(handle), callback);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncConnect(const uint16_t handle,
+ const am_connectionID_t connectionID,
+ const am_sourceID_t sourceID,
+ const am_sinkID_t sinkID,
+ const am_ConnectionFormat_e connectionFormat,
+ RoutingSenderProxyBase::AsyncConnectAsyncCallback callback)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncConnectAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_connectionID_t>(connectionID),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ static_cast<am_gen::am_sinkID_t>(sinkID),
+ static_cast<am_gen::am_ConnectionFormat_e>(connectionFormat),
+ callback);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncDisconnect(const uint16_t handle,
+ const am_connectionID_t connectionID,
+ RoutingSenderProxyBase::AsyncDisconnectAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncDisconnectAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_connectionID_t>(connectionID),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSinkVolume( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_volume_t volume,
+ const am_RampType_e ramp,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncSetSinkVolumeAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncSetSinkVolumeAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sinkID_t>(sinkID),
+ static_cast<am_gen::am_volume_t>(volume),
+ static_cast<am_gen::am_RampType_e>(ramp),
+ static_cast<am_gen::am_time_t>(time),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSourceVolume(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_volume_t volume,
+ const am_RampType_e ramp,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncSetSourceVolumeAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncSetSourceVolumeAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ static_cast<am_gen::am_volume_t>(volume),
+ static_cast<am_gen::am_RampType_e>(ramp),
+ static_cast<am_gen::am_time_t>(time),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSourceState( const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_SourceState_e state,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertiesAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncSetSourceStateAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ static_cast<am_gen::am_SourceState_e>(state),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSinkSoundProperties( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const std::vector<am_SoundProperty_s>& listSoundProperties,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertiesAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_SoundProperty_L lsp;
+ CAmConvertAMVector2CAPI(listSoundProperties, lsp);
+ mSenderProxy->asyncSetSinkSoundPropertiesAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sinkID_t>(sinkID),
+ lsp,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSinkSoundProperty( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_SoundProperty_s& soundProperty,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertyAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_SoundProperty_s converted;
+ CAmConvertAM2CAPI(soundProperty, converted);
+ mSenderProxy->asyncSetSinkSoundPropertyAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sinkID_t>(sinkID),
+ converted,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSourceSoundProperties(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const std::vector<am_SoundProperty_s>& listSoundProperties,
+ RoutingSenderProxyBase::AsyncSetSourceSoundPropertiesAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_SoundProperty_L lsp;
+ CAmConvertAMVector2CAPI(listSoundProperties, lsp);
+ mSenderProxy->asyncSetSourceSoundPropertiesAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ lsp,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSourceSoundProperty(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_SoundProperty_s& soundProperty,
+ RoutingSenderProxyBase::AsyncSetSourceSoundPropertyAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_SoundProperty_s converted;
+ CAmConvertAM2CAPI(soundProperty, converted);
+ mSenderProxy->asyncSetSourceSoundPropertyAsync( static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ converted,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+
+am_Error_e rs_lookupData_s::asyncCrossFade(const uint16_t handle,
+ const am_crossfaderID_t crossfaderID,
+ const am_HotSink_e hotSink,
+ const am_RampType_e rampType,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncCrossFadeAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->asyncCrossFadeAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_crossfaderID_t>(crossfaderID),
+ static_cast<am_gen::am_HotSink_e>(hotSink),
+ static_cast<am_gen::am_RampType_e>(rampType),
+ static_cast<am_gen::am_time_t>(time),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState, RoutingSenderProxyBase::SetDomainStateAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ mSenderProxy->setDomainStateAsync(static_cast<am_gen::am_domainID_t>(domainID),
+ static_cast<am_gen::am_DomainState_e>(domainState),
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetVolumes(const uint16_t handle,
+ const std::vector<am_Volumes_s>& volumes ,
+ RoutingSenderProxyBase::AsyncSetVolumesAsyncCallback cb )
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_Volumes_l list;
+ CAmConvertAMVector2CAPI(volumes, list);
+ mSenderProxy->asyncSetVolumesAsync(static_cast<am_gen::am_handle_t>(handle),
+ list,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSinkNotificationConfiguration(const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_NotificationConfiguration_s& notificationConfiguration,
+ RoutingSenderProxyBase::AsyncSetSinkNotificationConfigurationAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_NotificationConfiguration_s converted;
+ CAmConvertAM2CAPI(notificationConfiguration, converted);
+ mSenderProxy->asyncSetSinkNotificationConfigurationAsync(static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sinkID_t>(sinkID),
+ converted,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e rs_lookupData_s::asyncSetSourceNotificationConfiguration(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_NotificationConfiguration_s& notificationConfiguration,
+ RoutingSenderProxyBase::AsyncSetSourceNotificationConfigurationAsyncCallback cb)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ isConnected : ", isConnected(), " ]");
+ if(isConnected())
+ {
+ am_gen::am_NotificationConfiguration_s converted;
+ CAmConvertAM2CAPI(notificationConfiguration, converted);
+ mSenderProxy->asyncSetSourceNotificationConfigurationAsync( static_cast<am_gen::am_handle_t>(handle),
+ static_cast<am_gen::am_sourceID_t>(sourceID),
+ converted,
+ cb);
+ return (E_OK);
+ }
+ return (E_UNKNOWN);
+}
+
+void rs_lookupData_s::onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus)
+{
+ std::string serviceID;
+ logInfo(__PRETTY_FUNCTION__, serviceID, " status : ", (int)serviceStatus );
+ mIsConnected = (serviceStatus==CommonAPI::AvailabilityStatus::AVAILABLE);
+}
+
+/**
+ * CAmLookupData
+ */
+
+CAmLookupData::CAmLookupData():mMapDomains(), mMapSinks(), mMapSources(),mMapConnections(),mMapHandles(), mMapCrossfaders() {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmLookupData::~CAmLookupData() {
+ // TODO Auto-generated destructor stub
+}
+
+void CAmLookupData::addDomainLookup(am_domainID_t & domainID,
+ std::shared_ptr<RoutingSenderProxy<>> & aProxy)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ domainID : ", domainID, " ]");
+ RSLookupDataPtr lookupData = std::make_shared<rs_lookupData_s>(aProxy);
+ mMapDomains.insert(std::make_pair(domainID, lookupData));
+}
+
+void CAmLookupData::removeHandle(uint16_t handle)
+{
+ mMapHandles.erase(handle);
+}
+
+void CAmLookupData::addSourceLookup(am_sourceID_t sourceID, am_domainID_t domainID)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ domainID : ", domainID, " ]", " [ sourceID : ", sourceID, " ]");
+ mapDomain_t::iterator iter(mMapDomains.begin());
+ iter = mMapDomains.find(domainID);
+ if (iter != mMapDomains.end())
+ {
+ mMapSources.insert(std::make_pair(sourceID, iter->second));
+ }
+}
+
+void CAmLookupData::addSinkLookup(am_sinkID_t sinkID, am_domainID_t domainID)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ domainID : ", domainID, " ]", " [ sinkID : ", sinkID, " ]");
+ mapDomain_t::iterator iter(mMapDomains.begin());
+ iter = mMapDomains.find(domainID);
+ if (iter != mMapDomains.end())
+ {
+ mMapSinks.insert(std::make_pair(sinkID, iter->second));
+ }
+}
+
+void CAmLookupData::addCrossfaderLookup(am_crossfaderID_t crossfaderID, am_sourceID_t soucreID)
+{
+ logInfo(__PRETTY_FUNCTION__, " [ crossfaderID : ", crossfaderID, " ]", " [ soucreID : ", soucreID, " ]");
+ mapSources_t::iterator iter(mMapSources.begin());
+ iter = mMapSources.find(soucreID);
+ if (iter != mMapSources.end())
+ {
+ mMapCrossfaders.insert(std::make_pair(crossfaderID, iter->second));
+ }
+}
+
+void CAmLookupData::removeDomainLookup(am_domainID_t domainID)
+{
+ mapDomain_t::iterator iter(mMapDomains.begin());
+ iter = mMapDomains.find(domainID);
+ if (iter != mMapDomains.end())
+ {
+ CAmLookupData::removeEntriesForValue(iter->second, mMapSources);
+ CAmLookupData::removeEntriesForValue(iter->second, mMapSinks);
+ CAmLookupData::removeEntriesForValue(iter->second, mMapCrossfaders);
+ CAmLookupData::removeEntriesForValue(iter->second, mMapHandles);
+ CAmLookupData::removeEntriesForValue(iter->second, mMapConnections);
+ mMapDomains.erase(domainID);
+ }
+}
+
+void CAmLookupData::removeSourceLookup(am_sourceID_t sourceID)
+{
+ mMapSources.erase(sourceID);
+}
+
+void CAmLookupData::removeSinkLookup(am_sinkID_t sinkID)
+{
+ mMapSinks.erase(sinkID);
+}
+
+void CAmLookupData::removeCrossfaderLookup(am_crossfaderID_t crossfaderID)
+{
+ mMapCrossfaders.erase(crossfaderID);
+}
+
+void CAmLookupData::removeConnectionLookup(am_connectionID_t connectionID)
+{
+ mMapConnections.erase(connectionID);
+}
+
+template <typename TKey> void CAmLookupData::removeEntriesForValue(const RSLookupDataPtr & value, std::map<TKey,RSLookupDataPtr> & map)
+{
+ typename std::map<TKey,RSLookupDataPtr>::iterator it = map.begin();
+ while ( it != map.end() )
+ {
+ if (it->second == value)
+ {
+ typename std::map<TKey,RSLookupDataPtr>::iterator it_tmp = it;
+ it++;
+ map.erase(it_tmp);
+ }
+ else
+ ++it;
+ }
+}
+
+template <typename TKey> const CAmLookupData::RSLookupDataPtr CAmLookupData::getValueForKey(const TKey & key, const std::map<TKey,CAmLookupData::RSLookupDataPtr> & map)
+{
+ mapHandles_t::const_iterator iter = map.find(key);
+ if (iter != map.end() )
+ {
+ return iter->second;
+ }
+ return NULL;
+}
+
+am_Error_e CAmLookupData::asyncAbort(const uint16_t handle, RoutingSenderProxyBase::AsyncAbortAsyncCallback callback)
+{
+ RSLookupDataPtr result = getValueForKey(handle, mMapHandles);
+ if(result)
+ return result->asyncAbort(handle, callback);
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncConnect(const uint16_t handle,
+ const am_connectionID_t connectionID,
+ const am_sourceID_t sourceID,
+ const am_sinkID_t sinkID,
+ const am_ConnectionFormat_e connectionFormat,
+ RoutingSenderProxyBase::AsyncConnectAsyncCallback callback)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapConnections.insert(std::make_pair(connectionID, result));
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncConnect(handle, connectionID, sourceID, sinkID, connectionFormat, callback);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncDisconnect(const uint16_t handle,
+ const am_connectionID_t connectionID,
+ RoutingSenderProxyBase::AsyncDisconnectAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(connectionID, mMapConnections);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncDisconnect(handle, connectionID, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSinkVolume( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_volume_t volume,
+ const am_RampType_e ramp,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncSetSinkVolumeAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sinkID, mMapSinks);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSinkVolume(handle, sinkID, volume, ramp, time, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSourceVolume(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_volume_t volume,
+ const am_RampType_e ramp,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncSetSourceVolumeAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSourceVolume(handle, sourceID, volume, ramp, time, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSourceState(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_SourceState_e state,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertiesAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSourceState(handle, sourceID, state, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSinkSoundProperties( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const std::vector<am_SoundProperty_s>& listSoundProperties,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertiesAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sinkID, mMapSinks);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSinkSoundProperties(handle, sinkID, listSoundProperties, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSinkSoundProperty( const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_SoundProperty_s& soundProperty,
+ RoutingSenderProxyBase::AsyncSetSinkSoundPropertyAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sinkID, mMapSinks);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSinkSoundProperty(handle, sinkID, soundProperty, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSourceSoundProperties(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const std::vector<am_SoundProperty_s>& listSoundProperties,
+ RoutingSenderProxyBase::AsyncSetSourceSoundPropertiesAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSourceSoundProperties(handle, sourceID, listSoundProperties, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSourceSoundProperty(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_SoundProperty_s& soundProperty,
+ RoutingSenderProxyBase::AsyncSetSourceSoundPropertyAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSourceSoundProperty(handle, sourceID, soundProperty, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+
+am_Error_e CAmLookupData::asyncCrossFade(const uint16_t handle,
+ const am_crossfaderID_t crossfaderID,
+ const am_HotSink_e hotSink,
+ const am_RampType_e rampType,
+ const am_time_t time,
+ RoutingSenderProxyBase::AsyncCrossFadeAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(crossfaderID, mMapCrossfaders);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncCrossFade(handle, crossfaderID, hotSink, rampType, time, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState, RoutingSenderProxyBase::SetDomainStateAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(domainID, mMapDomains);
+ if(result)
+ return result->setDomainState(domainID, domainState, cb);
+ return (E_UNKNOWN);
+}
+
+
+am_Error_e CAmLookupData::asyncSetVolumes(const uint16_t handle,
+ const std::vector<am_Volumes_s>& volumes ,
+ RoutingSenderProxyBase::AsyncSetVolumesAsyncCallback cb )
+{
+
+ if(volumes.size())
+ {
+ am_Volumes_s volumeItem = volumes.at(0);
+ RSLookupDataPtr result = NULL;
+ if(volumeItem.volumeType == VT_SINK)
+ result = CAmLookupData::getValueForKey(volumeItem.volumeID.sink, mMapSinks);
+ else if(volumeItem.volumeType == VT_SOURCE)
+ result = CAmLookupData::getValueForKey(volumeItem.volumeID.source, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetVolumes(handle, volumes, cb);
+ }
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSinkNotificationConfiguration(const uint16_t handle,
+ const am_sinkID_t sinkID,
+ const am_NotificationConfiguration_s& notificationConfiguration,
+ RoutingSenderProxyBase::AsyncSetSinkNotificationConfigurationAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sinkID, mMapSinks);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSinkNotificationConfiguration(handle, sinkID, notificationConfiguration, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+am_Error_e CAmLookupData::asyncSetSourceNotificationConfiguration(const uint16_t handle,
+ const am_sourceID_t sourceID,
+ const am_NotificationConfiguration_s& notificationConfiguration,
+ RoutingSenderProxyBase::AsyncSetSourceNotificationConfigurationAsyncCallback cb)
+{
+ RSLookupDataPtr result = CAmLookupData::getValueForKey(sourceID, mMapSources);
+ if(result)
+ {
+ mMapHandles.insert(std::make_pair(+handle, result));
+ return result->asyncSetSourceNotificationConfiguration(handle, sourceID, notificationConfiguration, cb);
+ }
+ return (E_UNKNOWN);
+}
+
+} /* namespace am */
diff --git a/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp
new file mode 100644
index 0000000..55d2792
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp
@@ -0,0 +1,266 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include <cassert>
+#include <map>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "shared/CAmDltWrapper.h"
+#include "CAmRoutingSenderCAPI.h"
+
+
+namespace am
+{
+DLT_DECLARE_CONTEXT(ctxCommandCAPI)
+
+extern "C" IAmRoutingSend* PluginRoutingInterfaceCAPIFactory()
+{
+ CAmDltWrapper::instance()->registerContext(ctxCommandCAPI, "DRS", "Common-API Plugin");
+ return (new CAmRoutingSenderCAPI(Am_CAPI));
+}
+
+extern "C" void destroyPluginRoutingInterfaceCAPI(IAmRoutingSend* routingSendInterface)
+{
+ delete routingSendInterface;
+}
+
+const char * CAmRoutingSenderCAPI::ROUTING_INTERFACE_SERVICE = "local:org.genivi.audiomanger.routinginterface:org.genivi.audiomanger";
+
+CAmRoutingSenderCAPI::CAmRoutingSenderCAPI() :
+ mIsServiceStarted(false),
+ mReady(false),
+ mLookupData(),
+ mpCAmCAPIWrapper(NULL), //
+ mpIAmRoutingReceive(NULL),
+ mService()
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "RoutingSender constructed");
+}
+
+CAmRoutingSenderCAPI::CAmRoutingSenderCAPI(CAmCommonAPIWrapper *aWrapper) :
+ mIsServiceStarted(false),
+ mReady(false),
+ mLookupData(),
+ mpCAmCAPIWrapper(aWrapper), //
+ mpIAmRoutingReceive(NULL),
+ mService()
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CommandSenderCAPI constructor called");
+ assert(mpCAmCAPIWrapper!=NULL);
+}
+
+CAmRoutingSenderCAPI::~CAmRoutingSenderCAPI()
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "RoutingSender deallocate");
+ CAmDltWrapper::instance()->unregisterContext(ctxCommandCAPI);
+ tearDownInterface(mpIAmRoutingReceive);
+}
+
+am_Error_e CAmRoutingSenderCAPI::startService(IAmRoutingReceive* pIAmRoutingReceive)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__);
+ if(!mIsServiceStarted)
+ {
+ assert(pIAmRoutingReceive);
+ mService = std::make_shared<CAmRoutingService>(pIAmRoutingReceive, &mLookupData, mpCAmCAPIWrapper);
+ //Registers the service
+ if( false == mpCAmCAPIWrapper->registerStub(mService, CAmRoutingSenderCAPI::ROUTING_INTERFACE_SERVICE) )
+ {
+ return (E_NOT_POSSIBLE);
+ }
+ mIsServiceStarted = true;
+ }
+ return (E_OK);
+}
+
+am_Error_e CAmRoutingSenderCAPI::startupInterface(IAmRoutingReceive* pIAmRoutingReceive)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__);
+ mpIAmRoutingReceive = pIAmRoutingReceive;
+ return startService(mpIAmRoutingReceive);
+}
+
+am_Error_e CAmRoutingSenderCAPI::tearDownInterface(IAmRoutingReceive*)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__);
+ if(mpCAmCAPIWrapper)
+ {
+ if(mIsServiceStarted)
+ {
+ mIsServiceStarted = false;
+ mpCAmCAPIWrapper->unregisterStub(CAmRoutingSenderCAPI::ROUTING_INTERFACE_SERVICE);
+ mService.reset();
+ }
+ return (E_OK);
+ }
+ return (E_NOT_POSSIBLE);
+}
+
+void CAmRoutingSenderCAPI::getInterfaceVersion(std::string & version) const
+{
+ version = RoutingSendVersion;
+}
+
+void CAmRoutingSenderCAPI::setRoutingReady(const uint16_t handle)
+{
+ assert(mpIAmRoutingReceive);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "sending routingReady signal");
+ mReady = true;
+ mpIAmRoutingReceive->confirmRoutingReady(handle,E_OK);
+ mService->fireSetRoutingReadyEvent();
+ mService->gotReady(mLookupData.numberOfDomains(),handle);
+}
+
+void CAmRoutingSenderCAPI::setRoutingRundown(const uint16_t handle)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__);
+ assert(mpIAmRoutingReceive);
+ mReady = false;
+ mpIAmRoutingReceive->confirmRoutingRundown(handle,E_OK);
+ mService->fireSetRoutingRundownEvent();
+ mService->gotRundown(mLookupData.numberOfDomains(),handle);
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncAbort(const am_Handle_s handle)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncAbort called");
+ return mLookupData.asyncAbort(handle.handle,[&](const CommonAPI::CallStatus& callStatus, const am_gen::am_Error_e& error){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncConnect called");
+ return mLookupData.asyncConnect(handle.handle,connectionID, sourceID, sinkID, connectionFormat, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncDisconnect called");
+ return mLookupData.asyncDisconnect(handle.handle,connectionID, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSinkVolume called");
+ return mLookupData.asyncSetSinkVolume(handle.handle,sinkID, volume, ramp, time, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSourceVolume called");
+ return mLookupData.asyncSetSourceVolume(handle.handle,sourceID, volume, ramp, time, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSourceState called");
+ return mLookupData.asyncSetSourceState(handle.handle,sourceID, state,[&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSinkSoundProperties called");
+ return mLookupData.asyncSetSinkSoundProperties(handle.handle,sinkID, listSoundProperties, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSinkSoundProperty called");
+ return mLookupData.asyncSetSinkSoundProperty(handle.handle, sinkID, soundProperty, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSourceSoundProperties called");
+ return mLookupData.asyncSetSourceSoundProperties(handle.handle, sourceID, listSoundProperties, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSourceSoundProperty called");
+ return mLookupData.asyncSetSourceSoundProperty(handle.handle, sourceID, soundProperty, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)
+{
+ return mLookupData.asyncCrossFade(handle.handle, crossfaderID, hotSink, rampType, time, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::setDomainState called");
+ return mLookupData.setDomainState(domainID, domainState, [&](const CommonAPI::CallStatus& callStatus, const am_gen::am_Error_e& error){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::returnBusName(std::string& BusName) const
+{
+ BusName = CAmLookupData::BUS_NAME;
+ return (E_OK);
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& volumes)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetVolumes called");
+ return mLookupData.asyncSetVolumes(handle.handle, volumes, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& nc)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSinkNotificationConfiguration called");
+ return mLookupData.asyncSetSinkNotificationConfiguration(handle.handle, sinkID, nc, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+am_Error_e CAmRoutingSenderCAPI::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& nc)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderDbus::asyncSetSourceNotificationConfiguration called");
+ return mLookupData.asyncSetSourceNotificationConfiguration(handle.handle, sourceID, nc, [&](const CommonAPI::CallStatus& callStatus){
+ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast<int16_t>(callStatus));
+ });
+}
+
+}
+
diff --git a/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCommon.cpp b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCommon.cpp
new file mode 100644
index 0000000..c9f5876
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCommon.cpp
@@ -0,0 +1,282 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+
+#include "CAmRoutingSenderCommon.h"
+
+/**
+ * Utility functions
+ */
+
+void CAmConvertCAPI2AM(const am_gen::am_Domain_s & source, am::am_Domain_s & destination)
+{
+ destination.domainID = source.domainID;
+ destination.name = source.name;
+ destination.busname = source.busname;
+ destination.nodename = source.nodename;
+ destination.early = source.early;
+ destination.complete = source.complete;
+ destination.state = static_cast<am::am_DomainState_e>(source.state);
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_SoundProperty_s & source, am::am_SoundProperty_s & destination)
+{
+ destination.type = static_cast<am::am_SoundPropertyType_e>(source.type);
+ destination.value = source.value;
+}
+
+void CAmConvertCAPIVector2AM(const std::vector<am_gen::am_SoundProperty_s> & source, std::vector<am::am_SoundProperty_s> & destination)
+{
+ am::am_SoundProperty_s soundProp;
+ destination.clear();
+ for(std::vector<am_gen::am_SoundProperty_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ CAmConvertCAPI2AM(*iter, soundProp);
+ destination.push_back(soundProp);
+ }
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_MainSoundProperty_s & source, am::am_MainSoundProperty_s & destination)
+{
+ destination.type = static_cast<am::am_MainSoundPropertyType_e>(source.type);
+ destination.value = source.value;
+}
+
+
+void CAmConvertCAPI2AM(const am_gen::notificationPayload_s & source, am::am_NotificationPayload_s & destination)
+{
+ destination.type = static_cast<am::am_NotificationType_e>(source.type);
+ destination.value = source.payload;
+}
+
+void CAmConvertCAPIVector2AM(const std::vector<am_gen::am_Volumes_s> & source, std::vector<am::am_Volumes_s> & destination)
+{
+ destination.clear();
+ for(std::vector<am_gen::am_Volumes_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ am::am_Volumes_s volume;
+ CAmConvertCAPI2AM(*iter, volume);
+ destination.push_back(volume);
+ }
+}
+
+void CAmConvertCAPIVector2AM(const std::vector<am_gen::am_MainSoundProperty_s> & source, std::vector<am::am_MainSoundProperty_s> & destination)
+{
+ am::am_MainSoundProperty_s soundProp;
+ destination.clear();
+ for(std::vector<am_gen::am_MainSoundProperty_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ CAmConvertCAPI2AM(*iter, soundProp);
+ destination.push_back(soundProp);
+ }
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_NotificationConfiguration_s & source, am::am_NotificationConfiguration_s & destination)
+{
+ destination.type = static_cast<am::am_NotificationType_e>(source.type);
+ destination.status = static_cast<am::am_NotificationStatus_e>(source.status);
+ destination.parameter = source.parameter;
+}
+
+void CAmConvertCAPIVector2AM(const std::vector<am_gen::am_NotificationConfiguration_s> & source, std::vector<am::am_NotificationConfiguration_s> & destination)
+{
+ am::am_NotificationConfiguration_s soundProp;
+ destination.clear();
+ for(std::vector<am_gen::am_NotificationConfiguration_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ CAmConvertCAPI2AM(*iter, soundProp);
+ destination.push_back(soundProp);
+ }
+}
+
+void CAmConvertCAPIVector2AM(const std::vector<am_gen::am_ConnectionFormat_e> & source, std::vector<am::am_ConnectionFormat_e> & destination)
+{
+ destination.clear();
+ for(std::vector<am_gen::am_ConnectionFormat_e>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ destination.push_back(static_cast<am::am_ConnectionFormat_e>(*iter));
+}
+
+
+
+void CAmConvertCAPI2AM(const am_gen::sourceData_s & source, am::am_Source_s & destination)
+{
+ destination.sourceID = source.sourceID;
+ destination.domainID = source.domainID;
+ destination.name = source.name;
+ destination.sourceClassID = source.sourceClassID;
+ destination.sourceState = static_cast<am::am_SourceState_e>(source.sourceState);
+ destination.volume = source.volume;
+ destination.visible = source.visible;
+ CAmConvertCAPI2AM(source.available, destination.available);
+ destination.interruptState = static_cast<am::am_InterruptState_e>(source.interruptState);
+ CAmConvertCAPIVector2AM(source.listSoundProperties, destination.listSoundProperties);
+ CAmConvertCAPIVector2AM(source.listConnectionFormats, destination.listConnectionFormats);
+ CAmConvertCAPIVector2AM(source.listMainSoundProperties, destination.listMainSoundProperties);
+ CAmConvertCAPIVector2AM(source.listNotificationConfigurations, destination.listNotificationConfigurations);
+ CAmConvertCAPIVector2AM(source.listMainNotificationConfigurations, destination.listMainNotificationConfigurations);
+}
+
+void CAmConvertCAPI2AM(const am_gen::sinkData_s & source, am::am_Sink_s & destination)
+{
+ destination.sinkID = source.sinkID;
+ destination.domainID = source.domainID;
+ destination.name = source.name;
+ destination.sinkClassID = source.sinkClassID;
+ destination.muteState = static_cast<am::am_MuteState_e>(source.muteState);
+ destination.volume = source.volume;
+ destination.visible = source.visible;
+ destination.mainVolume = source.mainVolume;
+ CAmConvertCAPI2AM(source.available, destination.available);
+ CAmConvertCAPIVector2AM(source.listSoundProperties, destination.listSoundProperties);
+ CAmConvertCAPIVector2AM(source.listConnectionFormats, destination.listConnectionFormats);
+ CAmConvertCAPIVector2AM(source.listMainSoundProperties, destination.listMainSoundProperties);
+ CAmConvertCAPIVector2AM(source.listNotificationConfigurations, destination.listNotificationConfigurations);
+ CAmConvertCAPIVector2AM(source.listMainNotificationConfigurations, destination.listMainNotificationConfigurations);
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_Volumes_s & source, am::am_Volumes_s & destination)
+{
+ CAmConvertCAPI2AM(source.volumeID, destination.volumeID);
+ destination.volume = source.volume;
+ destination.time = source.time;
+ destination.volumeType = static_cast<am::am_VolumeType_e>(source.volumeType);
+ destination.ramp = static_cast<am::am_RampType_e>(source.ramp);
+}
+
+
+void CAmConvertCAPI2AM(const am_gen::crossfaderData_s & source, am::am_Crossfader_s & destination)
+{
+ destination.crossfaderID = source.crossfaderID;
+ destination.sinkID_A = source.sinkID_A;
+ destination.sinkID_B = source.sinkID_B;
+ destination.name = source.name;
+ destination.sourceID = source.sourceID;
+ destination.hotSink = static_cast<am::am_HotSink_e>(source.hotSink);
+}
+
+
+void CAmConvertCAPI2AM(const am_gen::am_Gateway_s & source, am::am_Gateway_s & destination)
+{
+ destination.sinkID = source.sinkID;
+ destination.gatewayID = source.gatewayID;
+ destination.name = source.name;
+ destination.sourceID = source.sourceID;
+ destination.domainSinkID = source.domainSinkID;
+ destination.domainSourceID = source.domainSourceID;
+ destination.controlDomainID = source.controlDomainID;
+ CAmConvertCAPIVector2AM(source.listSourceFormats, destination.listSourceFormats);
+ CAmConvertCAPIVector2AM(source.listSinkFormats, destination.listSinkFormats);
+ destination.convertionMatrix = source.convertionMatrix;
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_EarlyData_u & source, am::am_EarlyData_u & destination)
+{
+ if(source.isType<am_gen::am_volume_t>())
+ {
+ am_volume_t value = static_cast<am_volume_t>(source.get<am_gen::am_volume_t>());
+ destination.volume = value;
+ }
+ else if(source.isType<am_gen::am_SoundProperty_s>())
+ {
+ am_gen::am_SoundProperty_s value = source.get<am_gen::am_SoundProperty_s>();
+ am_SoundProperty_s converted;
+ CAmConvertCAPI2AM(value, converted);
+ destination.soundProperty = converted;
+ }
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_DataType_u & source, am::am_DataType_u & destination)
+{
+ if(source.isType<am_gen::am_sinkID_t>())
+ {
+ am_sinkID_t value = static_cast<am_sinkID_t>(source.get<am_gen::am_sinkID_t>());
+ destination.sink = value;
+ }
+ else if(source.isType<am_gen::am_sourceID_t>())
+ {
+ am_sourceID_t value = static_cast<am_sourceID_t>(source.get<am_gen::am_sourceID_t>());
+ destination.source = value;
+ }
+}
+
+void CAmConvertCAPI2AM(const am_gen::am_EarlyData_s & source, am::am_EarlyData_s & destination)
+{
+ CAmConvertCAPI2AM(source.data, destination.data);
+ CAmConvertCAPI2AM(source.sinksource, destination.sinksource);
+ destination.type = static_cast<am_EarlyDataType_e>(source.type);
+}
+
+
+void CAmConvertCAPI2AM(const am_gen::am_Availability_s & source, am_Availability_s & destination)
+{
+ destination.availability = static_cast<am_Availability_e>(source.availability);
+ destination.availabilityReason = static_cast<am_AvailabilityReason_e>(source.availabilityReason);
+}
+
+void CAmConvertAM2CAPI(const am_Availability_s & source, am_gen::am_Availability_s & destination)
+{
+ destination.availability = static_cast<am_gen::am_Availability_e>(source.availability);
+ destination.availabilityReason = static_cast<am_gen::am_AvailabilityReason_e>(source.availabilityReason);
+}
+
+void CAmConvertAM2CAPI(const am::am_SoundProperty_s & source, am_gen::am_SoundProperty_s & destination)
+{
+ destination.type = static_cast<am_gen::am_SoundPropertyType_e>(source.type);
+ destination.value = source.value;
+}
+
+void CAmConvertAM2CAPI(const am::am_NotificationConfiguration_s & source, am_gen::am_NotificationConfiguration_s & destination)
+{
+ destination.type = static_cast<am_gen::am_NotificationType_e>(source.type);
+ destination.status = static_cast<am_gen::am_NotificationStatus_e>(source.status);
+ destination.parameter = source.parameter;
+}
+
+void CAmConvertAM2CAPI(const am::am_Volumes_s & source, am_gen::am_Volumes_s & destination)
+{
+ if(source.volumeType == VT_SINK)
+ destination.volumeID = am_gen::am_DataType_u(static_cast<am_gen::am_sinkID_t>(source.volumeID.sink));
+ else if(source.volumeType == VT_SOURCE)
+ destination.volumeID = am_gen::am_DataType_u(static_cast<am_gen::am_sourceID_t>(source.volumeID.source));
+ destination.volumeType = static_cast<am_gen::am_VolumeType_e>(source.volumeType);
+ destination.volume = static_cast<am_gen::am_volume_t>(source.volume);
+ destination.ramp = static_cast<am_gen::am_RampType_e>(source.ramp);
+ destination.time = static_cast<am_gen::am_time_t>(source.time);
+}
+
+
+void CAmConvertAMVector2CAPI(const std::vector<am::am_Volumes_s> & source, std::vector<am_gen::am_Volumes_s> & destination)
+{
+ destination.clear();
+ for(std::vector<am::am_Volumes_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ am_gen::am_Volumes_s volume;
+ CAmConvertAM2CAPI(*iter, volume);
+ destination.push_back(volume);
+ }
+}
+
+void CAmConvertAMVector2CAPI(const std::vector<am::am_SoundProperty_s> & source, std::vector<am_gen::am_SoundProperty_s> & destination)
+{
+ am_gen::am_SoundProperty_s soundProp;
+ destination.clear();
+ for(std::vector<am::am_SoundProperty_s>::const_iterator iter = source.begin(); iter!=source.end(); iter++)
+ {
+ CAmConvertAM2CAPI(*iter, soundProp);
+ destination.push_back(soundProp);
+ }
+}
diff --git a/PluginRoutingInterfaceCAPI/src/CAmRoutingService.cpp b/PluginRoutingInterfaceCAPI/src/CAmRoutingService.cpp
new file mode 100644
index 0000000..c50cfed
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/src/CAmRoutingService.cpp
@@ -0,0 +1,435 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+#include <memory>
+#include <assert.h>
+#include <algorithm>
+#include "CAmRoutingSenderCommon.h"
+#include "shared/CAmCommonAPIWrapper.h"
+#include "CAmRoutingService.h"
+
+
+namespace am {
+
+CAmRoutingService::CAmRoutingService():mpCAmCAPIWrapper(NULL), mpIAmRoutingReceive(NULL), mpLookpData(NULL), mNumberDomains(0), mHandle(0), mReady(false) {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmRoutingService::CAmRoutingService(IAmRoutingReceive *aReceiver, CAmLookupData* aLookpData, CAmCommonAPIWrapper *aCAPIWrapper):
+ mpCAmCAPIWrapper(aCAPIWrapper), mpIAmRoutingReceive(aReceiver), mpLookpData(aLookpData), mNumberDomains(0), mHandle(0), mReady(false) {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmRoutingService::~CAmRoutingService() {
+ // TODO Auto-generated destructor stub
+}
+
+void CAmRoutingService::ackConnect(uint16_t handle, am_gen::am_connectionID_t connectionID, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_CONNECT;
+ mpIAmRoutingReceive->ackConnect(handle_s, static_cast<am_connectionID_t>(connectionID), static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackDisconnect(uint16_t handle, am_gen::am_connectionID_t connectionID, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_DISCONNECT;
+ mpIAmRoutingReceive->ackDisconnect(handle_s, static_cast<am_connectionID_t>(connectionID), static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+ //todo: Check whether the connection should be removed here!
+ mpLookpData->removeConnectionLookup(connectionID);
+}
+
+void CAmRoutingService::ackSetSinkVolume(uint16_t handle, am_gen::am_volume_t volume, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSINKVOLUME;
+ mpIAmRoutingReceive->ackSetSinkVolumeChange(handle_s, volume, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSourceVolume(uint16_t handle, am_gen::am_volume_t volume, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSOURCEVOLUME;
+ mpIAmRoutingReceive->ackSetSourceVolumeChange(handle_s, volume, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSourceState(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSOURCESTATE;
+ mpIAmRoutingReceive->ackSetSourceState(handle_s,static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSinkSoundProperties(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSINKSOUNDPROPERTIES;
+ mpIAmRoutingReceive->ackSetSinkSoundProperties(handle_s, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSinkSoundProperty(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSINKSOUNDPROPERTY;
+ mpIAmRoutingReceive->ackSetSinkSoundProperty(handle_s, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSourceSoundProperties(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSOURCESOUNDPROPERTIES;
+ mpIAmRoutingReceive->ackSetSourceSoundProperties(handle_s, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSetSourceSoundProperty(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSOURCESOUNDPROPERTY;
+ mpIAmRoutingReceive->ackSetSourceSoundProperty(handle_s, static_cast<am_Error_e>(error));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackCrossFading(uint16_t handle, am_gen::am_HotSink_e hotSink, am_gen::am_Error_e returnError) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_CROSSFADE;
+ mpIAmRoutingReceive->ackCrossFading(handle_s, static_cast<am_HotSink_e>(hotSink), static_cast<am_Error_e>(returnError));
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSourceVolumeTick(uint16_t handle, am_gen::am_sourceID_t source, am_gen::am_volume_t volume) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSOURCEVOLUME;
+ mpIAmRoutingReceive->ackSourceVolumeTick(handle_s, source, volume);
+}
+
+void CAmRoutingService::ackSinkVolumeTick(uint16_t handle, am_gen::am_sinkID_t sink, am_gen::am_volume_t volume) {
+ assert(mpIAmRoutingReceive);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETSINKVOLUME;
+ mpIAmRoutingReceive->ackSinkVolumeTick(handle_s, sink, volume);
+}
+
+void CAmRoutingService::peekDomain(std::string name, am_gen::am_domainID_t& domainID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->peekDomain(name, domainID));
+}
+
+void CAmRoutingService::registerDomain(am_gen::am_Domain_s domainData, std::string returnBusname, std::string, std::string returnInterface, am_gen::am_domainID_t& domainID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ assert(mpCAmCAPIWrapper);
+ am_Domain_s converted;
+ CAmConvertCAPI2AM(domainData, converted);
+ converted.busname = CAmLookupData::BUS_NAME;
+ am_Error_e resultCode = mpIAmRoutingReceive->registerDomain(converted, domainID);
+ error = static_cast<am_gen::am_Error_e>(resultCode);
+ if(E_OK==resultCode)
+ {
+ std::shared_ptr<CommonAPI::Factory> factory = mpCAmCAPIWrapper->factory();
+ std::shared_ptr<RoutingSenderProxy<>> shpSenderProxy = factory->buildProxy<RoutingSenderProxy>(returnBusname, returnInterface , "local");
+ mpLookpData->addDomainLookup(domainID, shpSenderProxy);
+ }
+}
+
+void CAmRoutingService::deregisterDomain(am_gen::am_domainID_t domainID, am_gen::am_Error_e& returnError) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ returnError = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->deregisterDomain(domainID));
+ if(am_gen::am_Error_e::E_OK==returnError)
+ mpLookpData->removeDomainLookup(domainID);
+}
+
+void CAmRoutingService::registerGateway(am_gen::am_Gateway_s gatewayData, am_gen::am_gatewayID_t& gatewayID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ am_Gateway_s converted;
+ CAmConvertCAPI2AM(gatewayData, converted);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->registerGateway(converted, gatewayID));
+}
+
+void CAmRoutingService::deregisterGateway(am_gen::am_gatewayID_t gatewayID, am_gen::am_Error_e& returnError) {
+ returnError = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->deregisterGateway(gatewayID));
+}
+
+void CAmRoutingService::peekSink(std::string name, am_gen::am_sinkID_t& sinkID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->peekSink(name, sinkID));
+}
+
+void CAmRoutingService::registerSink(am_gen::sinkData_s sinkData, am_gen::am_sinkID_t& sinkID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Sink_s converted;
+ CAmConvertCAPI2AM(sinkData, converted);
+ am_Error_e result = mpIAmRoutingReceive->registerSink(converted, sinkID);
+ error = static_cast<am_gen::am_Error_e>(result);
+ if(E_OK==result)
+ mpLookpData->addSinkLookup(sinkID, converted.domainID);
+}
+
+void CAmRoutingService::deregisterSink(am_gen::am_sinkID_t sinkID, am_gen::am_Error_e& returnError) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ returnError = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->deregisterSink(sinkID));
+ if(returnError==am_gen::am_Error_e::E_OK)
+ mpLookpData->removeSinkLookup(sinkID);
+}
+
+void CAmRoutingService::peekSource(std::string name, am_gen::am_sourceID_t& sourceID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->peekSource(name, sourceID));
+}
+
+void CAmRoutingService::registerSource(am_gen::sourceData_s sourceData, am_gen::am_sourceID_t& sourceID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Source_s converted;
+ CAmConvertCAPI2AM(sourceData, converted);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->registerSource(converted, sourceID));
+ if(error==am_gen::am_Error_e::E_OK)
+ mpLookpData->addSourceLookup(sourceID, sourceData.domainID);
+}
+
+void CAmRoutingService::deregisterSource(am_gen::am_sourceID_t sourceID, am_gen::am_Error_e& returnError) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ returnError = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->deregisterSource(sourceID));
+ if(returnError==am_gen::am_Error_e::E_OK)
+ mpLookpData->removeSourceLookup(sourceID);
+}
+
+void CAmRoutingService::registerCrossfader(am_gen::crossfaderData_s crossfaderData, am_gen::am_crossfaderID_t& crossfaderID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ am_Crossfader_s converted;
+ CAmConvertCAPI2AM(crossfaderData, converted);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->registerCrossfader(converted, crossfaderID));
+ if(error==am_gen::am_Error_e::E_OK)
+ mpLookpData->addCrossfaderLookup(crossfaderID, crossfaderData.sourceID);
+}
+
+void CAmRoutingService::deregisterCrossfader(am_gen::am_crossfaderID_t crossfaderID, am_gen::am_Error_e& returnError) {
+ assert(mpIAmRoutingReceive);
+ returnError = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->deregisterCrossfader(crossfaderID));
+ if(returnError==am_gen::am_Error_e::E_OK)
+ mpLookpData->removeCrossfaderLookup(crossfaderID);
+}
+
+void CAmRoutingService::peekSourceClassID(std::string name, am_gen::am_sourceClass_t& sourceClassID, am_gen::am_Error_e& error) {
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->peekSourceClassID(name, sourceClassID));
+}
+
+void CAmRoutingService::peekSinkClassID(std::string name, am_gen::am_sinkClass_t& sinkClassID, am_gen::am_Error_e& error) {
+ assert(mpIAmRoutingReceive);
+ error = static_cast<am_gen::am_Error_e>(mpIAmRoutingReceive->peekSinkClassID(name, sinkClassID));
+}
+
+void CAmRoutingService::hookInterruptStatusChange(am_gen::am_sourceID_t sourceID, uint16_t interruptState) {
+ assert(mpIAmRoutingReceive);
+ mpIAmRoutingReceive->hookInterruptStatusChange(sourceID, static_cast<am_InterruptState_e>(interruptState));
+}
+
+void CAmRoutingService::hookDomainRegistrationComplete(am_gen::am_domainID_t domainID) {
+ assert(mpIAmRoutingReceive != NULL);
+ mpIAmRoutingReceive->hookDomainRegistrationComplete(domainID);
+}
+
+void CAmRoutingService::hookSinkAvailablityStatusChange(am_gen::am_sinkID_t sinkID, am_gen::am_Availability_s availability) {
+ assert(mpIAmRoutingReceive);
+ am_Availability_s am_avialabilty;
+ CAmConvertCAPI2AM(availability, am_avialabilty);
+ mpIAmRoutingReceive->hookSinkAvailablityStatusChange(sinkID, am_avialabilty);
+}
+
+void CAmRoutingService::hookSourceAvailablityStatusChange(am_gen::am_sourceID_t sourceID, am_gen::am_Availability_s availability) {
+ assert(mpIAmRoutingReceive);
+ am_Availability_s am_availabilty;
+ CAmConvertCAPI2AM(availability, am_availabilty);
+ mpIAmRoutingReceive->hookSourceAvailablityStatusChange(sourceID, am_availabilty);
+}
+
+void CAmRoutingService::hookDomainStateChange(am_gen::am_domainID_t domainID, am_gen::am_DomainState_e domainState) {
+ assert(mpIAmRoutingReceive);
+ am_DomainState_e am_domainState = static_cast<am_DomainState_e>(domainState);
+ mpIAmRoutingReceive->hookDomainStateChange(domainID, am_domainState);
+}
+
+void CAmRoutingService::hookTimingInformationChanged(am_gen::am_connectionID_t connectionID, int16_t delay) {
+ assert(mpIAmRoutingReceive);
+ mpIAmRoutingReceive->hookTimingInformationChanged(connectionID, delay);
+}
+
+void CAmRoutingService::sendChangedData(am_gen::am_EarlyData_l earlyData_volumes, am_gen::am_EarlyData_l earlyData_soundproperties) {
+
+ assert(mpIAmRoutingReceive);
+ std::vector<am_EarlyData_s> earlyData;
+ auto func = [&](const am_gen::am_EarlyData_s &refObject)
+ {
+ am_EarlyData_s object;
+ CAmConvertCAPI2AM(refObject, object);
+ earlyData.push_back(object);
+ };
+ std::for_each(earlyData_volumes.begin(), earlyData_volumes.end(), func);
+ std::for_each(earlyData_soundproperties.begin(), earlyData_soundproperties.end(), func);
+ mpIAmRoutingReceive->sendChangedData(earlyData);
+}
+
+void CAmRoutingService::gotReady(int16_t numberDomains, uint16_t handle)
+{
+ mReady=true;
+ mNumberDomains=numberDomains;
+ mHandle=handle;
+}
+
+void CAmRoutingService::gotRundown(int16_t numberDomains, uint16_t handle)
+{
+ mReady=false;
+ mNumberDomains=numberDomains;
+ mHandle=handle;
+}
+
+void CAmRoutingService::confirmRoutingReady(am_gen::am_domainID_t) {
+ mpIAmRoutingReceive->confirmRoutingReady(mHandle, E_OK);
+ mNumberDomains++;
+}
+
+void CAmRoutingService::confirmRoutingRundown(am_gen::am_domainID_t) {
+ assert(mpIAmRoutingReceive);
+ mpIAmRoutingReceive->confirmRoutingRundown(mHandle, E_OK);
+ mNumberDomains--;
+}
+
+void CAmRoutingService::updateGateway(am_gen::am_gatewayID_t gatewayID, am_gen::am_ConnectionFormat_L listSourceFormats, am_gen::am_ConnectionFormat_L listSinkFormats, am_gen::bool_L convertionMatrix) {
+
+ assert(mpIAmRoutingReceive);
+ std::vector<am_ConnectionFormat_e> destinationSourceConnectionFormats;
+ CAmConvertCAPIVector2AM(listSourceFormats, destinationSourceConnectionFormats);
+
+ std::vector<am_ConnectionFormat_e> destinationSinkConnectionFormats;
+ CAmConvertCAPIVector2AM(listSinkFormats, destinationSinkConnectionFormats);
+
+ mpIAmRoutingReceive->updateGateway(gatewayID, destinationSourceConnectionFormats, destinationSinkConnectionFormats, convertionMatrix);
+}
+
+void CAmRoutingService::updateSink(am_gen::am_sinkID_t sinkID, am_gen::am_sinkClass_t sinkClassID, am_gen::am_SoundProperty_L listSoundProperties, am_gen::am_ConnectionFormat_L listConnectionFormats, am_gen::am_MainSoundProperty_L listMainSoundProperties) {
+ assert(mpIAmRoutingReceive);
+ std::vector<am_SoundProperty_s> dstListSoundProperties;
+ CAmConvertCAPIVector2AM(listSoundProperties, dstListSoundProperties);
+ std::vector<am_ConnectionFormat_e> dstListSinkConnectionFormats;
+ CAmConvertCAPIVector2AM(listConnectionFormats, dstListSinkConnectionFormats);
+ std::vector<am_MainSoundProperty_s> dstListMainSoundProperties;
+ CAmConvertCAPIVector2AM(listMainSoundProperties, dstListMainSoundProperties);
+ mpIAmRoutingReceive->updateSink( sinkID, sinkClassID, dstListSoundProperties,dstListSinkConnectionFormats,dstListMainSoundProperties);
+}
+
+void CAmRoutingService::updateSource(am_gen::am_sourceID_t sourceID, am_gen::am_sourceClass_t sourceClassID, am_gen::am_SoundProperty_L listSoundProperties, am_gen::am_ConnectionFormat_L listConnectionFormats, am_gen::am_MainSoundProperty_L listMainSoundProperties) {
+ assert(mpIAmRoutingReceive);
+ std::vector<am_SoundProperty_s> dstListSoundProperties;
+ CAmConvertCAPIVector2AM(listSoundProperties, dstListSoundProperties);
+ std::vector<am_ConnectionFormat_e> dstListSinkConnectionFormats;
+ CAmConvertCAPIVector2AM(listConnectionFormats, dstListSinkConnectionFormats);
+ std::vector<am_MainSoundProperty_s> dstListMainSoundProperties;
+ CAmConvertCAPIVector2AM(listMainSoundProperties, dstListMainSoundProperties);
+ mpIAmRoutingReceive->updateSource( sourceID, sourceClassID, dstListSoundProperties,dstListSinkConnectionFormats,dstListMainSoundProperties);
+}
+
+void CAmRoutingService::ackSetVolumes(uint16_t handle, am_gen::am_Volumes_l listVolumes, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ am_Handle_s handle_s;
+ handle_s.handle = handle;
+ handle_s.handleType = H_SETVOLUMES;
+ std::vector<am_Volumes_s> list;
+ CAmConvertCAPIVector2AM(listVolumes, list);
+ am_Error_e amError = static_cast<am_Error_e>(error);
+ mpIAmRoutingReceive->ackSetVolumes(handle_s, list, amError);
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSinkNotificationConfiguration(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s myhandle;
+ myhandle.handleType = H_CONNECT;
+ myhandle.handle = handle;
+ am_Error_e amError = static_cast<am_Error_e>(error);
+ mpIAmRoutingReceive->ackSinkNotificationConfiguration(myhandle, amError);
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::ackSourceNotificationConfiguration(uint16_t handle, uint16_t error) {
+ assert(mpIAmRoutingReceive);
+ assert(mpLookpData);
+ am_Handle_s myhandle;
+ myhandle.handleType = H_CONNECT;
+ myhandle.handle = handle;
+ am_Error_e amError = static_cast<am_Error_e>(error);
+ mpIAmRoutingReceive->ackSourceNotificationConfiguration(myhandle, amError);
+ mpLookpData->removeHandle(handle);
+}
+
+void CAmRoutingService::hookSinkNotificationDataChange(am_gen::am_sinkID_t sinkID, am_gen::notificationPayload_s payload) {
+ assert(mpIAmRoutingReceive);
+ am_NotificationPayload_s converted;
+ CAmConvertCAPI2AM(payload, converted);
+ mpIAmRoutingReceive->hookSinkNotificationDataChange(sinkID, converted);
+}
+
+void CAmRoutingService::hookSourceNotificationDataChange(am_gen::am_sourceID_t sourceID, am_gen::notificationPayload_s payload) {
+ assert(mpIAmRoutingReceive);
+ am_NotificationPayload_s converted;
+ CAmConvertCAPI2AM(payload, converted);
+ mpIAmRoutingReceive->hookSourceNotificationDataChange(sourceID, converted);
+}
+
+void CAmRoutingService::getRoutingReadyState(bool& readyState) {
+ readyState = mReady;
+}
+
+} /* namespace am */