summaryrefslogtreecommitdiff
path: root/PluginCommandInterfaceCAPI/src
diff options
context:
space:
mode:
Diffstat (limited to 'PluginCommandInterfaceCAPI/src')
-rw-r--r--PluginCommandInterfaceCAPI/src/CAmCommandSenderCAPI.cpp364
-rw-r--r--PluginCommandInterfaceCAPI/src/CAmCommandSenderCommon.cpp159
-rw-r--r--PluginCommandInterfaceCAPI/src/CAmCommandSenderService.cpp236
3 files changed, 759 insertions, 0 deletions
diff --git a/PluginCommandInterfaceCAPI/src/CAmCommandSenderCAPI.cpp b/PluginCommandInterfaceCAPI/src/CAmCommandSenderCAPI.cpp
new file mode 100644
index 0000000..75414c2
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/src/CAmCommandSenderCAPI.cpp
@@ -0,0 +1,364 @@
+/**
+ * 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 "CAmCommandSenderCAPI.h"
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <cassert>
+#include <set>
+#include "shared/CAmDltWrapper.h"
+#include "CAmCommandSenderCommon.h"
+
+
+DLT_DECLARE_CONTEXT(ctxCommandCAPI)
+
+/**
+ * factory for plugin loading
+ */
+extern "C" IAmCommandSend* PluginCommandInterfaceCAPIFactory()
+{
+ CAmDltWrapper::instance()->registerContext(ctxCommandCAPI, "CAPIP", "Common-API Plugin");
+ return (new CAmCommandSenderCAPI(Am_CAPI));
+}
+
+/**
+ * destroy instance of commandSendInterface
+ */
+extern "C" void destroyPluginCommandInterfaceCAPIFactory(IAmCommandSend* commandSendInterface)
+{
+ delete commandSendInterface;
+}
+
+
+const char * CAmCommandSenderCAPI::COMMAND_SENDER_SERVICE = "local:org.genivi.audiomanger.commandinterface:org.genivi.audiomanger";
+
+#define RETURN_IF_NOT_READY() if(!mReady) return;
+
+CAmCommandSenderCAPI::CAmCommandSenderCAPI() :
+ mService(), //
+ mpCAmCAPIWrapper(NULL), //
+ mpIAmCommandReceive(NULL), //
+ mReady(false),
+ mIsServiceStarted(false)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CommandSenderCAPI constructor called");
+}
+
+CAmCommandSenderCAPI::CAmCommandSenderCAPI(CAmCommonAPIWrapper *aWrapper) :
+ mService(), //
+ mpCAmCAPIWrapper(aWrapper), //
+ mpIAmCommandReceive(NULL), //
+ mReady(false),
+ mIsServiceStarted(false)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CommandSenderCAPI constructor called");
+ assert(mpCAmCAPIWrapper!=NULL);
+}
+
+CAmCommandSenderCAPI::~CAmCommandSenderCAPI()
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "CAPICommandSender destructed");
+ CAmDltWrapper::instance()->unregisterContext(ctxCommandCAPI);
+ tearDownInterface(mpIAmCommandReceive);
+}
+
+/**
+ * registers a service
+ */
+am_Error_e CAmCommandSenderCAPI::startService(IAmCommandReceive* commandreceiveinterface)
+{
+ if(!mIsServiceStarted)
+ {
+ assert(commandreceiveinterface);
+ mService = std::make_shared<CAmCommandSenderService>(commandreceiveinterface);
+ //Registers the service
+ if( false == mpCAmCAPIWrapper->registerStub(mService, CAmCommandSenderCAPI::COMMAND_SENDER_SERVICE) )
+ {
+ return (E_NOT_POSSIBLE);
+ }
+ mIsServiceStarted = true;
+ }
+ return (E_OK);
+}
+
+/**
+ * sets a command receiver object and registers a service
+ */
+am_Error_e CAmCommandSenderCAPI::startupInterface(IAmCommandReceive* commandreceiveinterface)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "startupInterface called");
+ mpIAmCommandReceive = commandreceiveinterface;
+ return startService(commandreceiveinterface);
+}
+
+/**
+ * stops the service
+ */
+am_Error_e CAmCommandSenderCAPI::tearDownInterface(IAmCommandReceive*)
+{
+ if(mpCAmCAPIWrapper)
+ {
+ if(mIsServiceStarted)
+ {
+ mIsServiceStarted = false;
+ mpCAmCAPIWrapper->unregisterStub(CAmCommandSenderCAPI::COMMAND_SENDER_SERVICE);
+ mService.reset();
+ }
+ return (E_OK);
+ }
+ return (E_NOT_POSSIBLE);
+}
+
+void CAmCommandSenderCAPI::setCommandReady(const uint16_t handle)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbCommunicationReady called");
+ mReady = true;
+ mpIAmCommandReceive->confirmCommandReady(handle,E_OK);
+}
+
+void CAmCommandSenderCAPI::setCommandRundown(const uint16_t handle)
+{
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbCommunicationRundown called");
+ mReady = false;
+ mpIAmCommandReceive->confirmCommandRundown(handle,E_OK);
+}
+
+void CAmCommandSenderCAPI::cbNewMainConnection(const am_MainConnectionType_s& )
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
+ mService->fireNumberOfMainConnectionsChangedEvent();
+}
+
+void CAmCommandSenderCAPI::cbRemovedMainConnection(const am_mainConnectionID_t mainConnection)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
+ mService->fireNumberOfMainConnectionsChangedEvent();
+}
+
+void CAmCommandSenderCAPI::cbNewSink(const am_SinkType_s& sink)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNewSink called");
+ CommandInterface::am_Availability_s convAvailability;
+ CAmConvertAvailablility(sink.availability, convAvailability);
+ CommandInterface::am_SinkType_s ciSink(sink.sinkID, sink.name, convAvailability, sink.volume, CAmConvert2CAPIType(sink.muteState), sink.sinkClassID);
+ mService->fireSinkAddedEvent(ciSink);
+}
+
+void CAmCommandSenderCAPI::cbRemovedSink(const am_sinkID_t sinkID)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbRemovedSink called");
+ mService->fireSinkRemovedEvent(sinkID);
+}
+
+void CAmCommandSenderCAPI::cbNewSource(const am_SourceType_s& source)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNewSource called");
+ CommandInterface::am_Availability_s convAvailability;
+ CAmConvertAvailablility(source.availability, convAvailability);
+ CommandInterface::am_SourceType_s ciSource(source.sourceID, source.name, convAvailability, source.sourceClassID);
+ mService->fireSourceAddedEvent(ciSource);
+}
+
+void CAmCommandSenderCAPI::cbRemovedSource(const am_sourceID_t source)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbRemovedSource called");
+ mService->fireSourceRemovedEvent(source);
+}
+
+void CAmCommandSenderCAPI::cbNumberOfSinkClassesChanged()
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNumberOfSinkClassesChanged called");
+ mService->fireNumberOfSinkClassesChangedEvent();
+}
+
+void CAmCommandSenderCAPI::cbNumberOfSourceClassesChanged()
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbNumberOfSourceClassesChanged called");
+ mService->fireNumberOfSourceClassesChangedEvent();
+}
+
+void CAmCommandSenderCAPI::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbMainConnectionStateChanged called, connectionID=", connectionID, "connectionState=", connectionState);
+ CommandInterface::am_mainConnectionID_t cID = connectionID;
+ mService->fireMainConnectionStateChangedEvent(cID, CAmConvert2CAPIType(connectionState));
+}
+
+void CAmCommandSenderCAPI::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbMainSinkSoundPropertyChanged called, sinkID", sinkID, "SoundProperty.type", soundProperty.type, "SoundProperty.value", soundProperty.value);
+ CommandInterface::am_MainSoundProperty_s mainSoundProp(CAmConvert2CAPIType(soundProperty.type), soundProperty.value);
+ mService->fireMainSinkSoundPropertyChangedEvent(sinkID, mainSoundProp);
+}
+
+void CAmCommandSenderCAPI::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbMainSourceSoundPropertyChanged called, sourceID", sourceID, "SoundProperty.type", SoundProperty.type, "SoundProperty.value", SoundProperty.value);
+ CommandInterface::am_MainSoundProperty_s convValue;
+ CAmConvertMainSoundProperty(SoundProperty, convValue);
+ mService->fireMainSourceSoundPropertyChangedEvent(sourceID, convValue);
+}
+
+void CAmCommandSenderCAPI::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSinkAvailabilityChanged called, sinkID", sinkID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
+ CommandInterface::am_Availability_s convAvailability;
+ CAmConvertAvailablility(availability, convAvailability);
+ mService->fireSinkAvailabilityChangedEvent(sinkID, convAvailability);
+}
+
+void CAmCommandSenderCAPI::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSourceAvailabilityChanged called, sourceID", sourceID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
+ CommandInterface::am_Availability_s convAvailability;
+ CAmConvertAvailablility(availability, convAvailability);
+ mService->fireSourceAvailabilityChangedEvent(sourceID, convAvailability);
+}
+
+void CAmCommandSenderCAPI::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbVolumeChanged called, sinkID", sinkID, "volume", volume);
+ mService->fireVolumeChangedEvent(sinkID, volume);
+}
+
+void CAmCommandSenderCAPI::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSinkMuteStateChanged called, sinkID", sinkID, "muteState", muteState);
+ CommandInterface::am_MuteState_e ciMuteState = CAmConvert2CAPIType(muteState);
+ mService->fireSinkMuteStateChangedEvent(sinkID, ciMuteState);
+}
+
+void CAmCommandSenderCAPI::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSystemPropertyChanged called, SystemProperty.type", SystemProperty.type, "SystemProperty.value", SystemProperty.value);
+ CommandInterface::am_SystemProperty_s convValue;
+ CAmConvertSystemProperty(SystemProperty, convValue);
+ mService->fireSystemPropertyChangedEvent(convValue);
+}
+
+void CAmCommandSenderCAPI::cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbTimingInformationChanged called, mainConnectionID=", mainConnectionID, "time=", time);
+ CommandInterface::am_mainConnectionID_t ciMainConnection = mainConnectionID;
+ mService->fireTimingInformationChangedEvent(ciMainConnection, time);
+}
+
+void CAmCommandSenderCAPI::getInterfaceVersion(std::string & version) const
+{
+ version = CommandSendVersion;
+}
+
+void CAmCommandSenderCAPI::cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSinkUpdated called, sinkID", sinkID);
+ CommandInterface::am_MainSoundProperty_l list;
+ std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
+ CommandInterface::am_MainSoundProperty_s prop(CAmConvert2CAPIType(ref.type), ref.value);
+ list.push_back(prop);
+ });
+ mService->fireSinkUpdatedEvent(sinkID, sinkClassID, list);
+}
+
+void CAmCommandSenderCAPI::cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSourceUpdated called, sourceID", sourceID);
+ CommandInterface::am_MainSoundProperty_l list;
+ std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
+ CommandInterface::am_MainSoundProperty_s prop(CAmConvert2CAPIType(ref.type), ref.value);
+ list.push_back(prop);
+ });
+ mService->fireSourceUpdatedEvent(sourceID, sourceClassID, list);
+}
+
+void CAmCommandSenderCAPI::cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s& notification)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSinkNotification called, sinkID", sinkID);
+ CommandInterface::am_NotificationPayload_s ciNnotif(CAmConvert2CAPIType(notification.type), notification.value);
+ mService->fireSinkNotificationEvent(sinkID, ciNnotif);
+}
+
+void CAmCommandSenderCAPI::cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s& notification)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSourceNotification called, sourceID", sourceID);
+ CommandInterface::am_NotificationPayload_s ciNnotif(CAmConvert2CAPIType(notification.type), notification.value);
+ mService->fireSourceNotificationEvent(sourceID, ciNnotif);
+}
+
+void CAmCommandSenderCAPI::cbMainSinkNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSinkMainNotificationConfigurationChanged called, sinkID", sinkID);
+ org::genivi::audiomanager::am::am_NotificationConfiguration_s ciNotifConfig(CAmConvert2CAPIType(mainNotificationConfiguration.type),
+ CAmConvert2CAPIType(mainNotificationConfiguration.status),
+ mainNotificationConfiguration.parameter);
+ mService->fireMainSinkNotificationConfigurationChangedEvent(sinkID, ciNotifConfig);
+}
+
+void CAmCommandSenderCAPI::cbMainSourceNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+{
+ RETURN_IF_NOT_READY()
+ assert((bool)mService);
+ log(&ctxCommandCAPI, DLT_LOG_INFO, "cbSourceMainNotificationConfigurationChanged called, sourceID", sourceID);
+ org::genivi::audiomanager::am::am_NotificationConfiguration_s ciNotifConfig(CAmConvert2CAPIType(mainNotificationConfiguration.type),
+ CAmConvert2CAPIType(mainNotificationConfiguration.status),
+ mainNotificationConfiguration.parameter);
+ mService->fireMainSourceNotificationConfigurationChangedEvent(sourceID, ciNotifConfig);
+}
diff --git a/PluginCommandInterfaceCAPI/src/CAmCommandSenderCommon.cpp b/PluginCommandInterfaceCAPI/src/CAmCommandSenderCommon.cpp
new file mode 100644
index 0000000..dca4f50
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/src/CAmCommandSenderCommon.cpp
@@ -0,0 +1,159 @@
+/**
+ * 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 "CAmCommandSenderCommon.h"
+
+/**
+ * Utility functions
+ */
+void CAmConvertAvailablility(const am_Availability_s & amAavailability, CommandInterface::am_Availability_s & result)
+{
+ result.availability = CAmConvert2CAPIType(amAavailability.availability);
+ result.availabilityReason = CAmConvert2CAPIType(amAavailability.availabilityReason);
+}
+
+void CAmConvertMainSoundProperty(const am_MainSoundProperty_s & amMainSoundProperty, CommandInterface::am_MainSoundProperty_s & result)
+{
+ result.type = CAmConvert2CAPIType(amMainSoundProperty.type);
+ result.value = amMainSoundProperty.value;
+}
+
+void CAmConvertSystemProperty(const am_SystemProperty_s & amSystemProperty, CommandInterface::am_SystemProperty_s & result)
+{
+ result.type = CAmConvert2CAPIType(amSystemProperty.type);
+ result.value = amSystemProperty.value;
+}
+
+CommandInterface::am_ClassProperty_e CAmConvert2CAPIType(const am_ClassProperty_e & property)
+{
+ return CP_MAX==property?
+ CommandInterface::am_ClassProperty_e::CP_MAX
+ :
+ static_cast<CommandInterface::am_ClassProperty_e>(property);
+}
+
+CommandInterface::am_SystemPropertyType_e CAmConvert2CAPIType(const am_SystemPropertyType_e & property)
+{
+ return SYP_MAX==property?
+ CommandInterface::am_SystemPropertyType_e::SYP_MAX
+ :
+ static_cast<CommandInterface::am_SystemPropertyType_e>(property);
+}
+
+CommandInterface::am_Availablility_e CAmConvert2CAPIType(const am_Availability_e & availability)
+{
+ return (A_MAX==availability)?CommandInterface::am_Availablility_e::A_MAX
+ :
+ static_cast<CommandInterface::am_Availablility_e>(availability);
+}
+
+CommandInterface::am_AvailabilityReason_e CAmConvert2CAPIType(const am_AvailabilityReason_e & availabilityReason)
+{
+ return (AR_MAX==availabilityReason)?CommandInterface::am_AvailabilityReason_e::AR_MAX
+ :
+ static_cast<CommandInterface::am_AvailabilityReason_e>(availabilityReason);
+}
+
+CommandInterface::am_MuteState_e CAmConvert2CAPIType(const am_MuteState_e & muteState)
+{
+ return MS_MAX==muteState?
+ CommandInterface::am_MuteState_e::MS_MAX
+ :
+ static_cast<CommandInterface::am_MuteState_e>(muteState);
+}
+
+am_MuteState_e CAmConvertFromCAPIType(const CommandInterface::am_MuteState_e & muteState)
+{
+ return CommandInterface::am_MuteState_e::MS_MAX==muteState?
+ MS_MAX:static_cast<am_MuteState_e>(muteState);
+}
+
+CommandInterface::am_MainSoundPropertyType_e CAmConvert2CAPIType(const am_MainSoundPropertyType_e & type)
+{
+ return MSP_MAX==type?
+ CommandInterface::am_MainSoundPropertyType_e::MSP_MAX
+ :
+ static_cast<CommandInterface::am_MainSoundPropertyType_e>(type);
+}
+am_MainSoundPropertyType_e CAmConvertFromCAPIType(const CommandInterface::am_MainSoundPropertyType_e & type)
+{
+ return CommandInterface::am_MainSoundPropertyType_e::MSP_MAX==type?
+ MSP_MAX:static_cast<am_MainSoundPropertyType_e>(type);
+}
+
+
+
+CommandInterface::am_ConnectionState_e CAmConvert2CAPIType(const am_ConnectionState_e & connectionState)
+{
+ return CS_MAX==connectionState?
+ CommandInterface::am_ConnectionState_e::CS_MAX
+ :
+ static_cast<CommandInterface::am_ConnectionState_e>(connectionState);
+}
+am_ConnectionState_e CAmConvertFromCAPIType(const CommandInterface::am_ConnectionState_e & connectionState)
+{
+ return CommandInterface::am_ConnectionState_e::CS_MAX==connectionState?
+ CS_MAX:static_cast<am_ConnectionState_e>(connectionState);
+}
+
+org::genivi::audiomanager::am::am_NotificationType_e CAmConvert2CAPIType(const am_NotificationType_e & notificationType)
+{
+ return NT_MAX==notificationType?
+ org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX
+ :
+ static_cast<org::genivi::audiomanager::am::am_NotificationType_e>(notificationType);
+}
+am_NotificationType_e CAmConvertFromCAPIType(const org::genivi::audiomanager::am::am_NotificationType_e & notificationType)
+{
+ return org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX==notificationType?
+ NT_MAX:static_cast<am_NotificationType_e>(notificationType);
+}
+
+org::genivi::audiomanager::am::am_NotificationStatus_e CAmConvert2CAPIType(const am_NotificationStatus_e & notificationStatus)
+{
+ return NS_MAX==notificationStatus?
+ org::genivi::audiomanager::am::am_NotificationStatus_e::NS_MAX
+ :
+ static_cast<org::genivi::audiomanager::am::am_NotificationStatus_e>(notificationStatus);
+}
+am_NotificationStatus_e CAmConvertFromCAPIType(const org::genivi::audiomanager::am::am_NotificationStatus_e & notificationStatus)
+{
+ return org::genivi::audiomanager::am::am_NotificationStatus_e::NS_MAX==notificationStatus?
+ NS_MAX:static_cast<am_NotificationStatus_e>(notificationStatus);
+}
+
+CommandInterface::am_Error_e CAmConvert2CAPIType(const am_Error_e & error)
+{
+ return E_MAX==error?
+ CommandInterface::am_Error_e::E_MAX
+ :
+ static_cast<CommandInterface::am_Error_e>(error);
+}
+am_Error_e CAmConvertFromCAPIType(const CommandInterface::am_Error_e & error)
+{
+ return CommandInterface::am_Error_e::E_MAX==error?
+ E_MAX:static_cast<am_Error_e>(error);
+}
+
+
+am_SystemPropertyType_e CAmConvertFromCAPIType(const CommandInterface::am_SystemPropertyType_e & propType)
+{
+ return CommandInterface::am_SystemPropertyType_e::SYP_MAX==propType?
+ SYP_MAX:static_cast<am_SystemPropertyType_e>(propType);
+}
+
diff --git a/PluginCommandInterfaceCAPI/src/CAmCommandSenderService.cpp b/PluginCommandInterfaceCAPI/src/CAmCommandSenderService.cpp
new file mode 100644
index 0000000..4d463d2
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/src/CAmCommandSenderService.cpp
@@ -0,0 +1,236 @@
+/**
+ * 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 "CAmCommandSenderService.h"
+#include <assert.h>
+#include <algorithm>
+#include "CAmCommandSenderCommon.h"
+
+
+namespace am {
+
+CAmCommandSenderService::CAmCommandSenderService():mpIAmCommandReceive(NULL) {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmCommandSenderService::CAmCommandSenderService(IAmCommandReceive *aReceiver):mpIAmCommandReceive(aReceiver) {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmCommandSenderService::~CAmCommandSenderService() {
+ // TODO Auto-generated destructor stub
+}
+
+void CAmCommandSenderService::Connect(CommandInterface::am_sourceID_t sourceID, CommandInterface::am_sinkID_t sinkID, CommandInterface::am_Error_e& result, CommandInterface::am_mainConnectionID_t& mainConnectionID) {
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->connect(sourceID, sinkID, mainConnectionID));
+}
+
+void CAmCommandSenderService::Disconnect(CommandInterface::am_mainConnectionID_t mainConnectionID, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->disconnect(mainConnectionID));
+}
+
+void CAmCommandSenderService::SetVolume(CommandInterface::am_sinkID_t sinkID, CommandInterface::am_mainVolume_t volume, CommandInterface::am_Error_e& result) {
+
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->setVolume(sinkID, volume));
+}
+
+void CAmCommandSenderService::VolumeStep(CommandInterface::am_sinkID_t sinkID, CommandInterface::am_mainVolume_t volumeStep, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->volumeStep(sinkID, volumeStep));
+}
+
+void CAmCommandSenderService::SetSinkMuteState(CommandInterface::am_sinkID_t sinkID, CommandInterface::am_MuteState_e muteState, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->setSinkMuteState(sinkID, CAmConvertFromCAPIType(muteState)));
+}
+
+void CAmCommandSenderService::SetMainSinkSoundProperty(CommandInterface::am_sinkID_t sinkID, CommandInterface::am_MainSoundProperty_s soundProperty, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ am_MainSoundProperty_s property = {CAmConvertFromCAPIType(soundProperty.type), soundProperty.value};
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->setMainSinkSoundProperty(property, sinkID));
+}
+
+void CAmCommandSenderService::SetMainSourceSoundProperty(CommandInterface::am_sourceID_t sourceID, CommandInterface::am_MainSoundProperty_s soundProperty, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ am_MainSoundProperty_s property = {CAmConvertFromCAPIType(soundProperty.type), soundProperty.value};
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->setMainSourceSoundProperty(property, sourceID));
+}
+
+void CAmCommandSenderService::SetSystemProperty(CommandInterface::am_SystemProperty_s soundProperty, CommandInterface::am_Error_e& result) {
+ assert(mpIAmCommandReceive);
+ am_SystemProperty_s property = {CAmConvertFromCAPIType(soundProperty.type), soundProperty.value};
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->setSystemProperty(property));
+}
+
+void CAmCommandSenderService::GetListMainConnections(CommandInterface::am_Error_e& result, CommandInterface::am_MainConnectionType_l& listConnections) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_MainConnectionType_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListMainConnections(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_MainConnectionType_s item;
+ for(std::vector<am_MainConnectionType_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.mainConnectionID = iter->mainConnectionID;
+ item.sourceID = iter->sourceID;
+ item.sinkID = iter->sinkID;
+ item.delay = iter->delay;
+ item.connectionState = CAmConvert2CAPIType(iter->connectionState);
+ listConnections.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListMainSinks(CommandInterface::am_Error_e& result, CommandInterface::am_SinkType_l& listMainSinks) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_SinkType_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListMainSinks(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_SinkType_s item;
+ for(std::vector<am_SinkType_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.sinkID = iter->sinkID;
+ item.name = iter->name;
+ item.sinkClassID = iter->sinkClassID;
+ item.volume = iter->volume;
+ item.muteState = CAmConvert2CAPIType(iter->muteState);
+ CAmConvertAvailablility(iter->availability, item.availability);
+ listMainSinks.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListMainSources(CommandInterface::am_Error_e& result, CommandInterface::am_SourceType_l& listMainSources) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_SourceType_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListMainSources(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_SourceType_s item;
+ for(std::vector<am_SourceType_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.sourceID = iter->sourceID;
+ item.name = iter->name;
+ item.sourceClassID = iter->sourceClassID;
+ CAmConvertAvailablility(iter->availability, item.availability);
+ listMainSources.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListMainSinkSoundProperties(CommandInterface::am_sinkID_t sinkID, CommandInterface::am_Error_e& result, CommandInterface::am_MainSoundProperty_l& listSoundProperties) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_MainSoundProperty_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListMainSinkSoundProperties(sinkID, list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_MainSoundProperty_s item;
+ for(std::vector<am_MainSoundProperty_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.type = CAmConvert2CAPIType(iter->type);
+ item.value = iter->value;
+ listSoundProperties.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListMainSourceSoundProperties(CommandInterface::am_sourceID_t sourceID, CommandInterface::am_Error_e& result, CommandInterface::am_MainSoundProperty_l& listSourceProperties) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_MainSoundProperty_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListMainSourceSoundProperties(sourceID, list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_MainSoundProperty_s item;
+ for(std::vector<am_MainSoundProperty_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.type = CAmConvert2CAPIType(iter->type);
+ item.value = iter->value;
+ listSourceProperties.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListSourceClasses(CommandInterface::am_Error_e& result, CommandInterface::am_SourceClass_l& listSourceClasses) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_SourceClass_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListSourceClasses(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_SourceClass_s item;
+ for(std::vector<am_SourceClass_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.sourceClassID = iter->sourceClassID;
+ item.name = iter->name;
+ item.listClassProperties.clear();
+ std::for_each(iter->listClassProperties.begin(), iter->listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
+ CommandInterface::am_ClassProperty_s classProp(CAmConvert2CAPIType(ref.classProperty), ref.value);
+ item.listClassProperties.push_back(classProp);
+ });
+ listSourceClasses.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListSinkClasses(CommandInterface::am_Error_e& result, CommandInterface::am_SinkClass_l& listSinkClasses) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_SinkClass_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListSinkClasses(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_SinkClass_s item;
+ for(std::vector<am_SinkClass_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.sinkClassID = iter->sinkClassID;
+ item.name = iter->name;
+ item.listClassProperties.clear();
+ std::for_each(iter->listClassProperties.begin(), iter->listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
+ CommandInterface::am_ClassProperty_s classProp(CAmConvert2CAPIType(ref.classProperty), ref.value);
+ item.listClassProperties.push_back(classProp);
+ });
+ listSinkClasses.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetListSystemProperties(CommandInterface::am_Error_e& result, CommandInterface::am_SystemProperty_l& listSystemProperties) {
+ assert(mpIAmCommandReceive);
+ std::vector<am_SystemProperty_s> list;
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getListSystemProperties(list));
+ if(result==CommandInterface::am_Error_e::E_OK)
+ {
+ CommandInterface::am_SystemProperty_s item;
+ for(std::vector<am_SystemProperty_s>::const_iterator iter = list.begin(); iter!=list.end(); iter++)
+ {
+ item.type = CAmConvert2CAPIType(iter->type);
+ item.value = iter->value;
+ listSystemProperties.push_back (item);
+ }
+ }
+}
+
+void CAmCommandSenderService::GetTimingInformation(CommandInterface::am_mainConnectionID_t mainConnectionID, CommandInterface::am_Error_e& result, CommandInterface::am_timeSync_t& delay) {
+ assert(mpIAmCommandReceive);
+ result = CAmConvert2CAPIType(mpIAmCommandReceive->getTimingInformation(mainConnectionID, delay));
+}
+
+} /* namespace am */