From dfcafbec34e0e454d9995551998af5d40a27c7ad Mon Sep 17 00:00:00 2001 From: christian mueller Date: Thu, 1 Mar 2012 19:12:55 +0100 Subject: * fix [GAM-28] problems in routingsender.cpp * [GAM-27] major refactoring: bringing everything to standardized names * Enhancement of CAmSerializer.h * improvement of documentation * adoption & regeneration of inerfaces --- AudioManagerDaemon/include/CAmCommandReceiver.h | 92 ++++++++ AudioManagerDaemon/include/CAmCommandSender.h | 85 +++++++ AudioManagerDaemon/include/CAmControlReceiver.h | 131 +++++++++++ AudioManagerDaemon/include/CAmControlSender.h | 103 +++++++++ AudioManagerDaemon/include/CAmDatabaseHandler.h | 280 +++++++++++++++++++++++ AudioManagerDaemon/include/CAmDatabaseObserver.h | 83 +++++++ AudioManagerDaemon/include/CAmRouter.h | 84 +++++++ AudioManagerDaemon/include/CAmRoutingReceiver.h | 112 +++++++++ AudioManagerDaemon/include/CAmRoutingSender.h | 202 ++++++++++++++++ AudioManagerDaemon/include/CAmTelnetMenuHelper.h | 44 ++-- AudioManagerDaemon/include/CAmTelnetServer.h | 105 +++++++++ AudioManagerDaemon/include/CommandReceiver.h | 92 -------- AudioManagerDaemon/include/CommandSender.h | 85 ------- AudioManagerDaemon/include/ControlReceiver.h | 131 ----------- AudioManagerDaemon/include/ControlSender.h | 103 --------- AudioManagerDaemon/include/DAmDoxygenMainPage.h | 115 ++++++++++ AudioManagerDaemon/include/DatabaseHandler.h | 280 ----------------------- AudioManagerDaemon/include/DatabaseObserver.h | 83 ------- AudioManagerDaemon/include/PluginTemplate.h | 92 -------- AudioManagerDaemon/include/Router.h | 84 ------- AudioManagerDaemon/include/RoutingReceiver.h | 112 --------- AudioManagerDaemon/include/RoutingSender.h | 202 ---------------- AudioManagerDaemon/include/TAmPluginTemplate.h | 92 ++++++++ AudioManagerDaemon/include/TelnetServer.h | 105 --------- AudioManagerDaemon/include/mainpage.h | 115 ---------- 25 files changed, 1506 insertions(+), 1506 deletions(-) create mode 100644 AudioManagerDaemon/include/CAmCommandReceiver.h create mode 100644 AudioManagerDaemon/include/CAmCommandSender.h create mode 100644 AudioManagerDaemon/include/CAmControlReceiver.h create mode 100644 AudioManagerDaemon/include/CAmControlSender.h create mode 100644 AudioManagerDaemon/include/CAmDatabaseHandler.h create mode 100644 AudioManagerDaemon/include/CAmDatabaseObserver.h create mode 100644 AudioManagerDaemon/include/CAmRouter.h create mode 100644 AudioManagerDaemon/include/CAmRoutingReceiver.h create mode 100644 AudioManagerDaemon/include/CAmRoutingSender.h create mode 100644 AudioManagerDaemon/include/CAmTelnetServer.h delete mode 100644 AudioManagerDaemon/include/CommandReceiver.h delete mode 100644 AudioManagerDaemon/include/CommandSender.h delete mode 100644 AudioManagerDaemon/include/ControlReceiver.h delete mode 100644 AudioManagerDaemon/include/ControlSender.h create mode 100644 AudioManagerDaemon/include/DAmDoxygenMainPage.h delete mode 100644 AudioManagerDaemon/include/DatabaseHandler.h delete mode 100644 AudioManagerDaemon/include/DatabaseObserver.h delete mode 100644 AudioManagerDaemon/include/PluginTemplate.h delete mode 100644 AudioManagerDaemon/include/Router.h delete mode 100644 AudioManagerDaemon/include/RoutingReceiver.h delete mode 100644 AudioManagerDaemon/include/RoutingSender.h create mode 100644 AudioManagerDaemon/include/TAmPluginTemplate.h delete mode 100644 AudioManagerDaemon/include/TelnetServer.h delete mode 100644 AudioManagerDaemon/include/mainpage.h (limited to 'AudioManagerDaemon/include') diff --git a/AudioManagerDaemon/include/CAmCommandReceiver.h b/AudioManagerDaemon/include/CAmCommandReceiver.h new file mode 100644 index 0000000..72f72f2 --- /dev/null +++ b/AudioManagerDaemon/include/CAmCommandReceiver.h @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CommandReveiver.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef COMMANDRECEIVER_H_ +#define COMMANDRECEIVER_H_ + +#include +#include + +namespace am +{ + +class CAmDatabaseHandler; +class CAmControlSender; +class CAmDbusWrapper; +class CAmSocketHandler; + +/** + * This class realizes the command Interface + */ +class CAmCommandReceiver: public IAmCommandReceive +{ +public: + CAmCommandReceiver(CAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iControlSender, CAmSocketHandler* iSocketHandler); + CAmCommandReceiver(CAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iControlSender, CAmSocketHandler* iSocketHandler, CAmDbusWrapper* iDBusWrapper); + ~CAmCommandReceiver(); + am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID); + am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID); + am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume); + am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep); + am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState); + am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); + am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); + am_Error_e setSystemProperty(const am_SystemProperty_s& property); + am_Error_e getListMainConnections(std::vector& listConnections) const; + am_Error_e getListMainSinks(std::vector& listMainSinks) const; + am_Error_e getListMainSources(std::vector& listMainSources) const; + am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector& listSoundProperties) const; + am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector& listSourceProperties) const; + am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; + am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; + am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; + am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const; + am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const; + am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const; + void getInterfaceVersion(std::string& version) const; + void confirmCommandReady(const uint16_t handle); + void confirmCommandRundown(const uint16_t handle); + + uint16_t getStartupHandle(); //!< returns a startup handle + uint16_t getRundownHandle(); //!< returns a rundown handle + + void waitOnStartup(bool startup); //!< tells the ComandReceiver to start waiting for all handles to be confirmed + void waitOnRundown(bool rundown); //!< tells the ComandReceiver to start waiting for all handles to be confirmed + +private: + CAmDatabaseHandler* mDatabaseHandler; //!< pointer to the databasehandler + CAmControlSender* mControlSender; //!< pointer to the control sender + CAmDbusWrapper* mDBusWrapper; //!< pointer to the dbuswrapper + CAmSocketHandler* mSocketHandler; //!< pointer to the SocketHandler + + uint16_t handleCount; //!< counts all handles + std::vector mListStartupHandles; //!< list of handles that wait for a confirm + std::vector mListRundownHandles; //!< list of handles that wait for a confirm + bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 + bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 +}; + +} + +#endif /* COMMANDRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/CAmCommandSender.h b/AudioManagerDaemon/include/CAmCommandSender.h new file mode 100644 index 0000000..d902e96 --- /dev/null +++ b/AudioManagerDaemon/include/CAmCommandSender.h @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CommandSender.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef COMMANDSENDER_H_ +#define COMMANDSENDER_H_ + +#ifdef UNIT_TEST +#include "../test/IAmCommandBackdoor.h" //we need this for the unit test +#endif + +#include "command/IAmCommandSend.h" + +namespace am +{ + +class CAmCommandReceiver; + + +/** + * This class is used to send data to the CommandInterface. + * All loaded plugins will be called when a callback is invoked. + */ +class CAmCommandSender +{ +public: + CAmCommandSender(const std::vector& listOfPluginDirectories); + ~CAmCommandSender(); + am_Error_e startupInterfaces(CAmCommandReceiver* iCommandReceiver); + void setCommandReady(); + void setCommandRundown(); + void cbNewMainConnection(const am_MainConnectionType_s mainConnection); + void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection); + void cbNewSink(am_SinkType_s sink); + void cbRemovedSink(const am_sinkID_t sink); + void cbNewSource(const am_SourceType_s source); + void cbRemovedSource(const am_sourceID_t source); + void cbNumberOfSinkClassesChanged(); + void cbNumberOfSourceClassesChanged(); + void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState); + void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty); + void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty); + void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability); + void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability); + void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume); + void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState); + void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty); + void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time); + void getInterfaceVersion(std::string& version) const; + am_Error_e getListPlugins(std::vector& interfaces) const; +#ifdef UNIT_TEST + friend class IAmCommandBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces +#endif +private: + void unloadLibraries(void); //!< unload the shared libraries + std::vector mListInterfaces; //!< list of all interfaces + std::vector mListLibraryHandles; //!< list of all library handles. This information is used to unload the plugins correctly. + std::vector mListLibraryNames; //!< list of all library names. This information is used for getListPlugins. + + CAmCommandReceiver *mCommandReceiver; +}; + +} + +#endif /* COMMANDSENDER_H_ */ diff --git a/AudioManagerDaemon/include/CAmControlReceiver.h b/AudioManagerDaemon/include/CAmControlReceiver.h new file mode 100644 index 0000000..af5a0e4 --- /dev/null +++ b/AudioManagerDaemon/include/CAmControlReceiver.h @@ -0,0 +1,131 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmControlReceiver.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef CONTRONLRECEIVER_H_ +#define CONTRONLRECEIVER_H_ + +#include +#include + +namespace am +{ + +class CAmSocketHandler; +class CAmDatabaseHandler; +class CAmRoutingSender; +class CAmCommandSender; +class CAmRouter; + +/** + * This class is used to receive all commands from the control interface + */ +class CAmControlReceiver: public IAmControlReceive +{ +public: + CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter); + ~CAmControlReceiver(); + am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList); + am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID); + am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID); + am_Error_e crossfade(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime); + am_Error_e abortAction(const am_Handle_s handle); + am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state); + am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); + am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time); + am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector& soundProperty); + am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty); + am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector& soundProperty); + am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty); + am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState); + am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID); + am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID); + am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID); + am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); + am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); + am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID); + am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID); + am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass); + am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass); + am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass); + am_Error_e enterSystemPropertiesListDB(const std::vector& listSystemProperties); + am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID); + am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState); + am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID); + am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID); + am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID); + am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID); + am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); + am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); + am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID); + am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property); + am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID); + am_Error_e removeSinkDB(const am_sinkID_t sinkID); + am_Error_e removeSourceDB(const am_sourceID_t sourceID); + am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID); + am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID); + am_Error_e removeDomainDB(const am_domainID_t domainID); + am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID); + am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID); + am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const; + am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const; + am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const; + am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const; + am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const; + am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const; + am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const; + am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector& listSinkID) const; + am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector& listSourceID) const; + am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector& listCrossfadersID) const; + am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; + am_Error_e getListMainConnections(std::vector& listMainConnections) const; + am_Error_e getListDomains(std::vector& listDomains) const; + am_Error_e getListConnections(std::vector& listConnections) const; + am_Error_e getListSinks(std::vector& listSinks) const; + am_Error_e getListSources(std::vector& listSources) const; + am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; + am_Error_e getListHandles(std::vector& listHandles) const; + am_Error_e getListCrossfaders(std::vector& listCrossfaders) const; + am_Error_e getListGateways(std::vector& listGateways) const; + am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; + am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; + void setCommandReady(); + void setCommandRundown(); + void setRoutingReady(); + void setRoutingRundown(); + void confirmControllerReady(); + void confirmControllerRundown(); + am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler); + void getInterfaceVersion(std::string& version) const; + +private: + CAmDatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler + CAmRoutingSender* mRoutingSender; //!< pointer to the routing send interface. + CAmCommandSender* mCommandSender; //!< pointer to the command send interface + CAmSocketHandler* mSocketHandler; //!< pointer to the socketHandler + CAmRouter* mRouter; //!< pointer to the Router +}; + +} + +#endif /* CONTRONLRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/CAmControlSender.h b/AudioManagerDaemon/include/CAmControlSender.h new file mode 100644 index 0000000..ddc8cf3 --- /dev/null +++ b/AudioManagerDaemon/include/CAmControlSender.h @@ -0,0 +1,103 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmControlSender.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef CONTROLSENDER_H_ +#define CONTROLSENDER_H_ + +#ifdef UNIT_TEST +#include "../test/IAmControlBackdoor.h" +#endif + +#include "control/IAmControlSend.h" + +namespace am +{ + +/** + * sends data to the commandInterface, takes the file of the library that needs to be loaded + */ +class CAmControlSender +{ +public: + CAmControlSender(std::string controlPluginFile); + ~CAmControlSender(); + am_Error_e startupController(IAmControlReceive* controlreceiveinterface) ; + void setControllerReady() ; + void setControllerRundown() ; + am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ; + am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ; + am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ; + am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ; + am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ; + am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ; + am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ; + am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ; + am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ; + am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ; + void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ; + am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ; + am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ; + am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ; + am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ; + am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ; + am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ; + am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ; + am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ; + void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ; + void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ; + void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ; + void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ; + void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ; + void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ; + void hookSystemReceiveEarlyData(const std::vector& data) ; + void hookSystemSpeedChange(const am_speed_t speed) ; + void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ; + void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ; + void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ; + void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ; + void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ; + void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ; + void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ; + am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats) ; + void getInterfaceVersion(std::string& version) const ; + void confirmCommandReady() ; + void confirmRoutingReady() ; + void confirmCommandRundown() ; + void confirmRoutingRundown() ; + +#ifdef UNIT_TEST + friend class IAmControlBackdoor; +#endif +private: + void* mlibHandle; //!< pointer to the loaded control plugin interface + IAmControlSend* mController; //!< pointer to the ControlSend interface +}; + +} + +#endif /* CONTROLSENDER_H_ */ diff --git a/AudioManagerDaemon/include/CAmDatabaseHandler.h b/AudioManagerDaemon/include/CAmDatabaseHandler.h new file mode 100644 index 0000000..ceaff88 --- /dev/null +++ b/AudioManagerDaemon/include/CAmDatabaseHandler.h @@ -0,0 +1,280 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmDatabaseHandler.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef DATABASEHANDLER_H_ +#define DATABASEHANDLER_H_ + +#include "audiomanagertypes.h" +#include +#include +#include + +namespace am +{ + +class CAmDatabaseObserver; +class CAmRoutingTree; +class CAmRoutingTreeItem; + +#define DYNAMIC_ID_BOUNDARY 100 //!< the value below is reserved for staticIDs, the value above will be assigned to dynamically registered items +//todo: check the enum values before entering & changing in the database. +//todo: change asserts for dynamic boundary checks into failure answers.# +//todo: check autoincrement boundary and set to 16bit limits +//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources +//todo: exchange last_insert_row id to be more safe +//todo: create test to ensure uniqueness of names throughout the database +//todo: enforce the uniqueness of names + +/** + * This class handles and abstracts the database + */ +class CAmDatabaseHandler +{ +public: + CAmDatabaseHandler(std::string databasePath); + ~CAmDatabaseHandler(); + am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID); + am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID); + am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID); + am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); + am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); + am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID); + am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID); + am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID); + am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass); + am_Error_e enterSystemProperties(const std::vector& listSystemProperties); + am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID); + am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState); + am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID); + am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID); + am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID); + am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID); + am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); + am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); + am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID); + am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID); + am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID); + am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property); + am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID); + am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass); + am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass); + am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay); + am_Error_e changeConnectionFinal(const am_connectionID_t connectionID); + am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState); + am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume); + am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume); + am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink); + am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID); + am_Error_e removeSinkDB(const am_sinkID_t sinkID); + am_Error_e removeSourceDB(const am_sourceID_t sourceID); + am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID); + am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID); + am_Error_e removeDomainDB(const am_domainID_t domainID); + am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID); + am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID); + am_Error_e removeConnection(const am_connectionID_t connectionID); + am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const; + am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const; + am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const; + am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const; + am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const; + am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const; + am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const; + am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const; + am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const; + am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const; + am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const; + am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector& listSinkID) const; + am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector& listSourceID) const; + am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; + am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; + am_Error_e getListMainConnections(std::vector& listMainConnections) const; + am_Error_e getListDomains(std::vector& listDomains) const; + am_Error_e getListConnections(std::vector& listConnections) const; + am_Error_e getListSinks(std::vector& listSinks) const; + am_Error_e getListSources(std::vector& lisSources) const; + am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; + am_Error_e getListCrossfaders(std::vector& listCrossfaders) const; + am_Error_e getListGateways(std::vector& listGateways) const; + am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; + am_Error_e getListVisibleMainConnections(std::vector& listConnections) const; + am_Error_e getListMainSinks(std::vector& listMainSinks) const; + am_Error_e getListMainSources(std::vector& listMainSources) const; + am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector& listSoundProperties) const; + am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector& listSourceProperties) const; + am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; + am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector & listConnectionFormats) const; + am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector & listConnectionFormats) const; + am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector & listConnectionFormat) const; + am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const; + am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const; + am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const; + am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const; + am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const; + am_Error_e getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector& flatTree); + am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID); + am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID); + am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID); + am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID); + am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID); + /** + * checks for a certain mainConnection + * @param mainConnectionID to be checked for + * @return true if it exists + */ + bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const; + + /** + * checks if a CrossFader exists + * @param crossfaderID the ID of the crossfader to be checked + * @return true if exists + */ + bool existcrossFader(const am_crossfaderID_t crossfaderID) const; + + /** + * checks if a connection already exists. + * Only takes sink, source and format information for search! + * @param connection the connection to be checked + * @return true if connections exists + */ + bool existConnection(const am_Connection_s connection); + + /** + * checks if a connection with the given ID exists + * @param connectionID + * @return true if connection exits + */ + bool existConnectionID(const am_connectionID_t connectionID); + /** + * checks for a certain Source + * @param sourceID to be checked for + * @return true if it exists + */ + bool existSource(const am_sourceID_t sourceID) const; + + /** + * checks if a source name or ID exists + * @param sourceID the sourceID + * @param name the name + * @return true if it exits + */ + bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const; + + /** + * checks if a name exits + * @param name the name + * @return true if it exits + */ + bool existSourceName(const std::string& name) const; + /** + * checks for a certain Sink + * @param sinkID to be checked for + * @return true if it exists + */ + bool existSink(const am_sinkID_t sinkID) const; + + /** + * checks if a sink with the ID or the name exists + * @param sinkID the ID + * @param name the name + * @return true if it exists. + */ + bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const; + + /** + * checks if a sink with the name exists + * @param name the name + * @return true if it exists + */ + bool existSinkName(const std::string& name) const; + + /** + * checks for a certain domain + * @param domainID to be checked for + * @return true if it exists + */ + bool existDomain(const am_domainID_t domainID) const; + + /** + * checks for certain gateway + * @param gatewayID to be checked for + * @return true if it exists + */ + bool existGateway(const am_gatewayID_t gatewayID) const; + + /** + * checks for certain SinkClass + * @param sinkClassID + * @return true if it exists + */ + bool existSinkClass(const am_sinkClass_t sinkClassID) const; + + /** + * checks for certain sourceClass + * @param sourceClassID + * @return true if it exists + */ + bool existSourceClass(const am_sourceClass_t sourceClassID) const; + + /** + * registers the Observer at the Database + * @param iObserver pointer to the observer + */ + void registerObserver(CAmDatabaseObserver *iObserver); + + /** + * gives information about the visibility of a source + * @param sourceID the sourceID + * @return true if source is visible + */ + bool sourceVisible(const am_sourceID_t sourceID) const; + + /** + * gives information about the visibility of a sink + * @param sinkID the sinkID + * @return true if source is visible + */ + bool sinkVisible(const am_sinkID_t sinkID) const; + +private: + am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const; + bool sqQuery(const std::string& query); + bool openDatabase(); //!< opens the database + void createTables(); //!< creates all tables from the static table + sqlite3 *mDatabase; //!< pointer to the database + std::string mPath; //!< path to the database + CAmDatabaseObserver *mDatabaseObserver; //!< pointer to the Observer + bool mFirstStaticSink; + bool mFirstStaticSource; + bool mFirstStaticGateway; + bool mFirstStaticSinkClass; + bool mFirstStaticSourceClass; + bool mFirstStaticCrossfader; + typedef std::map > ListConnectionFormat; //!< type for list of connection formats + ListConnectionFormat mListConnectionFormat; //!< list of connection formats +}; + +} + +#endif /* DATABASEHANDLER_H_ */ diff --git a/AudioManagerDaemon/include/CAmDatabaseObserver.h b/AudioManagerDaemon/include/CAmDatabaseObserver.h new file mode 100644 index 0000000..430f061 --- /dev/null +++ b/AudioManagerDaemon/include/CAmDatabaseObserver.h @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmDatabaseObserver.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef DATABASEOBSERVER_H_ +#define DATABASEOBSERVER_H_ + +#include +#include +#include "shared/CAmSerializer.h" + +namespace am +{ + +class CAmTelnetServer; +class CAmCommandSender; +class CAmRoutingSender; +class CAmSocketHandler; + +/** + * This class observes the Database and notifies other classes about important events, mainly the CommandSender. + */ + +class CAmDatabaseObserver +{ +public: + CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler); + CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler, CAmTelnetServer *iTelnetServer); + ~CAmDatabaseObserver(); + void numberOfSinkClassesChanged(); + void numberOfSourceClassesChanged(); + void newSink(const am_Sink_s& sink); + void newSource(const am_Source_s& source); + void newDomain(const am_Domain_s& domain); + void newGateway(const am_Gateway_s& gateway); + void newCrossfader(const am_Crossfader_s& crossfader); + void newMainConnection(const am_MainConnectionType_s& mainConnection); + void removedMainConnection(const am_mainConnectionID_t mainConnection); + void removedSink(const am_sinkID_t sinkID, const bool visible); + void removedSource(const am_sourceID_t sourceID, const bool visible); + void removeDomain(const am_domainID_t domainID); + void removeGateway(const am_gatewayID_t gatewayID); + void removeCrossfader(const am_crossfaderID_t crossfaderID); + void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState); + void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty); + void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty); + void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability); + void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability); + void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume); + void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState); + void systemPropertyChanged(const am_SystemProperty_s& SystemProperty); + void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time); + +private: + CAmCommandSender *mCommandSender; //!< pointer to the comandSender + CAmRoutingSender* mRoutingSender; //!< pointer to the routingSender + CAmTelnetServer* mTelnetServer; //!< pointer to the telnetserver + CAmSerializer mSerializer; +}; + +} + +#endif /* DATABASEOBSERVER_H_ */ diff --git a/AudioManagerDaemon/include/CAmRouter.h b/AudioManagerDaemon/include/CAmRouter.h new file mode 100644 index 0000000..ba13bf1 --- /dev/null +++ b/AudioManagerDaemon/include/CAmRouter.h @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmRouter.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef ROUTER_H_ +#define ROUTER_H_ + +#include + +namespace am +{ + +class CAmDatabaseHandler; +class CAmControlSender; + +class CAmRouter +{ +public: + CAmRouter(CAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender); + am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList); + ~CAmRouter(); + +private: + am_Error_e findBestWay(am_sinkID_t sinkID, am_sourceID_t sourceID, std::vector& listRoute, std::vector::iterator routeIterator, std::vector::iterator gatewayIterator); + void listPossibleConnectionFormats(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& listFormats) const; + void listRestrictedOutputFormatsGateways(const am_gatewayID_t gatewayID, const am_ConnectionFormat_e sinkConnectionFormat, std::vector& listFormats) const; + CAmDatabaseHandler* mDatabaseHandler; + CAmControlSender* mControlSender; +}; + +class CAmRoutingTreeItem +{ +public: + CAmRoutingTreeItem(const am_domainID_t domainID, const am_gatewayID_t gatewayID = 0, CAmRoutingTreeItem *parent = 0); + void appendChild(CAmRoutingTreeItem *newChild); + void returnChildItems(std::vector listChildItems); + am_domainID_t returnDomainID() const; + am_gatewayID_t returnGatewayID() const; + virtual ~CAmRoutingTreeItem(); + CAmRoutingTreeItem* returnParent() const; +private: + std::vector mListChildItems; //!< List of all child items + am_domainID_t mDomainID; //!< the domain ID of the item + am_gatewayID_t mGatewayID; //!< the gateway Id + CAmRoutingTreeItem *mParentItem; //!< pointer to the parent item +}; + +class CAmRoutingTree +{ +public: + CAmRoutingTree(const am_domainID_t rootDomainID); + CAmRoutingTreeItem* insertItem(const am_domainID_t domainID, const am_gatewayID_t gatewayID, CAmRoutingTreeItem *parent); + void getRoute(CAmRoutingTreeItem* targetItem, std::vector& listGateways); + am_domainID_t returnRootDomainID() const; + CAmRoutingTreeItem* returnRootItem(); + virtual ~CAmRoutingTree(); +private: + CAmRoutingTreeItem mRootItem; //!< pointer to root item + std::vector mListChild; //!< list of all childs +}; + +} /* namespace am */ +#endif /* ROUTER_H_ */ + diff --git a/AudioManagerDaemon/include/CAmRoutingReceiver.h b/AudioManagerDaemon/include/CAmRoutingReceiver.h new file mode 100644 index 0000000..dfacc3b --- /dev/null +++ b/AudioManagerDaemon/include/CAmRoutingReceiver.h @@ -0,0 +1,112 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmRoutingReceiver.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef ROUTINGRECEIVER_H_ +#define ROUTINGRECEIVER_H_ + +#include +#include + +namespace am +{ + +class CAmSocketHandler; +class CAmDbusWrapper; +class CAmDatabaseHandler; +class CAmRoutingSender; +class CAmControlSender; + +/** + * Implements the Receiving side of the RoutingPlugins. + */ +class CAmRoutingReceiver: public IAmRoutingReceive +{ +public: + CAmRoutingReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler); + CAmRoutingReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper); + ~CAmRoutingReceiver(); + void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); + void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); + void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error); + void ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error); + void ackSetSourceState(const am_Handle_s handle, const am_Error_e error); + void ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error); + void ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error); + void ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error); + void ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error); + void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error); + void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume); + void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume); + am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID); + am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID); + am_Error_e deregisterDomain(const am_domainID_t domainID); + am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); + am_Error_e deregisterGateway(const am_gatewayID_t gatewayID); + am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID); + am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID); + am_Error_e deregisterSink(const am_sinkID_t sinkID); + am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID); + am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID); + am_Error_e deregisterSource(const am_sourceID_t sourceID); + am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); + am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID); + am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID); + am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID); + void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState); + void hookDomainRegistrationComplete(const am_domainID_t domainID); + void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability); + void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability); + void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState); + void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay); + void sendChangedData(const std::vector& earlyData); + am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const; + am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const; + void getInterfaceVersion(std::string& version) const; + void confirmRoutingReady(const uint16_t handle); + void confirmRoutingRundown(const uint16_t handle); + + uint16_t getStartupHandle(); //!< returns a startup handle + uint16_t getRundownHandle(); //!< returns a rundown handle + + void waitOnStartup(bool startup); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed + void waitOnRundown(bool rundown); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed + +private: + CAmDatabaseHandler *mDatabaseHandler; //!< pointer to the databaseHandler + CAmRoutingSender *mRoutingSender; //!< pointer to the routingSender + CAmControlSender *mControlSender; //!< pointer to the controlSender + CAmSocketHandler *mSocketHandler; //!< pointer to sockethandler + CAmDbusWrapper *mDBusWrapper; //!< pointer to dbuswrapper + + uint16_t handleCount; //!< counts all handles + std::vector mListStartupHandles; //!< list of handles that wait for a confirm + std::vector mListRundownHandles; //!< list of handles that wait for a confirm + bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 + bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 + +}; + +} + +#endif /* ROUTINGRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/CAmRoutingSender.h b/AudioManagerDaemon/include/CAmRoutingSender.h new file mode 100644 index 0000000..c6a7677 --- /dev/null +++ b/AudioManagerDaemon/include/CAmRoutingSender.h @@ -0,0 +1,202 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmRoutingSender.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef ROUTINGSENDER_H_ +#define ROUTINGSENDER_H_ + +#include "routing/IAmRoutingSend.h" +#include + +#ifdef UNIT_TEST //this is needed to test RoutingSender +#include "../test/IAmRoutingBackdoor.h" +#endif + +namespace am +{ + +class CAmRoutingReceiver; + +/** + * Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins + */ +class CAmRoutingSender +{ +public: + CAmRoutingSender(const std::vector& listOfPluginDirectories); + ~CAmRoutingSender(); + + /** + * removes a handle from the list + * @param handle to be removed + * @return E_OK in case of success + */ + am_Error_e removeHandle(const am_Handle_s& handle); + + /** + * @author Christian + * this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. + * This must be done whenever a domain is registered. + */ + am_Error_e addDomainLookup(const am_Domain_s& domainData); + /** + * @author Christian + * this adds the Source to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. + * This must be done whenever a Source is registered. + */ + am_Error_e addSourceLookup(const am_Source_s& sourceData); + /** + * @author Christian + * this adds the Sink to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. + * This must be done whenever a Sink is registered. + */ + am_Error_e addSinkLookup(const am_Sink_s& sinkData); + /** + * @author Christian + * this adds the Crossfader to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. + * This must be done whenever a Crossfader is registered. + */ + am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData); + /** + * @author Christian + * this removes the Domain to the lookup table of the Router. This must be done everytime a domain is deregistered. + */ + am_Error_e removeDomainLookup(const am_domainID_t domainID); + /** + * @author Christian + * this removes the Source to the lookup table of the Router. This must be done everytime a source is deregistered. + */ + am_Error_e removeSourceLookup(const am_sourceID_t sourceID); + /** + * @author Christian + * this removes the Sink to the lookup table of the Router. This must be done everytime a sink is deregistered. + */ + am_Error_e removeSinkLookup(const am_sinkID_t sinkID); + /** + * @author Christian + * this removes the Crossfader to the lookup table of the Router. This must be done everytime a crossfader is deregistered. + */ + am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID); + am_Error_e startupInterfaces(CAmRoutingReceiver* iRoutingReceiver); + void setRoutingReady(); + void setRoutingRundown(); + am_Error_e asyncAbort(const am_Handle_s& handle); + am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat); + am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID); + am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); + am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); + am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state); + am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty); + am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector& listSoundProperties, const am_sourceID_t sourceID); + am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector& listSoundProperties, const am_sinkID_t sinkID); + am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty); + am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time); + am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState); + am_Error_e getListHandles(std::vector & listHandles) const; + am_Error_e getListPlugins(std::vector& interfaces) const; + void getInterfaceVersion(std::string& version) const; + + //!< is used to pair interfaces with busnames + struct InterfaceNamePairs + { + IAmRoutingSend* routingInterface; + std::string busName; + }; + + //!< is used to store data related to handles + class am_handleData_c + { + public: + union + { + am_sinkID_t sinkID; + am_sourceID_t sourceID; + am_crossfaderID_t crossfaderID; + am_connectionID_t connectionID; + }; + union + { + am_SoundProperty_s soundPropery; + am_SourceState_e sourceState; + am_volume_t volume; + am_HotSink_e hotSink; + std::vector* soundProperties; + }; + + }; + +#ifdef UNIT_TEST //this is needed to test RoutingSender + friend class IAmRoutingBackdoor; +#endif + + /** + * returns the data that belong to handles + * @param handle the handle + * @return a class holding the handle data + */ + am_handleData_c returnHandleData(const am_Handle_s handle) const; + +private: + + //!< is needed to sort the handles in the map + struct comparator + { + bool operator()(const am_Handle_s& a, const am_Handle_s& b) const + { + return (a.handle < b.handle); + } + }; + + /** + * creates a handle and adds it to the list of handles + * @param handleData the data that should be saves together with the handle + * @param type the type of handle to be created + * @return the handle + */ + am_Handle_s createHandle(const am_handleData_c& handleData, const am_Handle_e type); + void unloadLibraries(void); //!< unloads all loaded plugins + + typedef std::map DomainInterfaceMap; //!< maps domains to interfaces + typedef std::map SinkInterfaceMap; //!< maps sinks to interfaces + typedef std::map SourceInterfaceMap; //!< maps sources to interfaces + typedef std::map CrossfaderInterfaceMap; //!< maps crossfaders to interfaces + typedef std::map ConnectionInterfaceMap; //!< maps connections to interfaces + typedef std::map HandleInterfaceMap; //!< maps handles to interfaces + typedef std::map HandlesMap; //!< maps handleData to handles + + int16_t mHandleCount; //!< is used to create handles + HandlesMap mlistActiveHandles; //!< list of all currently "running" handles. + std::vector mListLibraryHandles; //!< list of all loaded pluginInterfaces + std::vector mListInterfaces; //!< list of busname/interface relation + ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces + CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface + DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces + SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces + SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces + HandleInterfaceMap mMapHandleInterface; //!< map of handles to interfaces + CAmRoutingReceiver *mRoutingReceiver; +}; + +} + +#endif /* ROUTINGSENDER_H_ */ diff --git a/AudioManagerDaemon/include/CAmTelnetMenuHelper.h b/AudioManagerDaemon/include/CAmTelnetMenuHelper.h index 5322526..54a0ee5 100644 --- a/AudioManagerDaemon/include/CAmTelnetMenuHelper.h +++ b/AudioManagerDaemon/include/CAmTelnetMenuHelper.h @@ -41,17 +41,17 @@ namespace am { -class TelnetServer; -class DatabaseHandler; -class CommandSender; -class RoutingSender; -class ControlSender; -class CommandReceiver; -class RoutingReceiver; -class ControlReceiver; - -class Router; -class SocketHandler; +class CAmTelnetServer; +class CAmDatabaseHandler; +class CAmCommandSender; +class CAmRoutingSender; +class CAmControlSender; +class CAmCommandReceiver; +class CAmRoutingReceiver; +class CAmControlReceiver; + +class CAmRouter; +class CAmSocketHandler; class CAmTelnetMenuHelper { @@ -62,7 +62,7 @@ public: eRootState = 0, eListState, eInfoState, eGetState, eSetState }; - CAmTelnetMenuHelper(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, Router *iRouter, TelnetServer *iTelnetServer); + CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer); ~CAmTelnetMenuHelper(); @@ -171,16 +171,16 @@ private: std::map mCurrentMainStateMap; static CAmTelnetMenuHelper* instance; - TelnetServer *mpTelenetServer; - SocketHandler *mpSocketHandler; - CommandSender *mpCommandSender; - CommandReceiver *mpCommandReceiver; - RoutingSender *mpRoutingSender; - RoutingReceiver *mpRoutingReceiver; - ControlSender *mpControlSender; - ControlReceiver *mpControlReceiver; - DatabaseHandler *mpDatabasehandler; - Router *mpRouter; + CAmTelnetServer *mpTelenetServer; + CAmSocketHandler *mpSocketHandler; + CAmCommandSender *mpCommandSender; + CAmCommandReceiver *mpCommandReceiver; + CAmRoutingSender *mpRoutingSender; + CAmRoutingReceiver *mpRoutingReceiver; + CAmControlSender *mpControlSender; + CAmControlReceiver *mpControlReceiver; + CAmDatabaseHandler *mpDatabasehandler; + CAmRouter *mpRouter; tCommandMap mRootCommands; tCommandMap mListCommands; diff --git a/AudioManagerDaemon/include/CAmTelnetServer.h b/AudioManagerDaemon/include/CAmTelnetServer.h new file mode 100644 index 0000000..f7bf274 --- /dev/null +++ b/AudioManagerDaemon/include/CAmTelnetServer.h @@ -0,0 +1,105 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file CAmTelnetServer.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef TELNETSERVER_H_ +#define TELNETSERVER_H_ + +#include "shared/CAmSocketHandler.h" +#include "CAmTelnetMenuHelper.h" +#include +#include + +namespace am +{ + +class CAmDatabaseHandler; +class CAmCommandSender; +class CAmRoutingSender; +class CAmControlSender; +class CAmCommandReceiver; +class CAmRoutingReceiver; +class CAmControlReceiver; +class CAmRouter; +class CAmTelnetMenuHelper; + +class CAmTelnetServer +{ +public: + CAmTelnetServer(CAmSocketHandler *iSocketHandler, + CAmCommandSender *iCommandSender, + CAmCommandReceiver *iCommandReceiver, + CAmRoutingSender *iRoutingSender, + CAmRoutingReceiver *iRoutingReceiver, + CAmControlSender *iControlSender, + CAmControlReceiver *iControlReceiver, + CAmDatabaseHandler *iDatabasehandler, + CAmRouter *iRouter, + unsigned int servPort, + unsigned int maxConnections); + + ~CAmTelnetServer(); + void connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void* userData); + void disconnectClient(int filedescriptor); + void receiveData(const pollfd pfd, const sh_pollHandle_t handle, void* userData); + bool dispatchData(const sh_pollHandle_t handle, void* userData); + bool check(const sh_pollHandle_t handle, void* userData); + TAmShPollFired telnetConnectFiredCB; + TAmShPollFired telnetReceiveFiredCB; + TAmShPollDispatch telnetDispatchCB; + TAmShPollCheck telnetCheckCB; +private: + + typedef void (*CommandPrototype)(std::vector& msg,int filedescriptor); + typedef std::map mMapCommand_t; + + void sliceCommand(const std::string& string,std::string& command,std::queue& msg); + mMapCommand_t createCommandMap(); + struct connection_s + { + int filedescriptor; + sh_pollHandle_t handle; + }; + + static CAmTelnetServer* instance; + CAmSocketHandler *mSocketHandler; + CAmCommandSender *mCommandSender; + CAmCommandReceiver *mCommandReceiver; + CAmRoutingSender *mRoutingSender; + CAmRoutingReceiver *mRoutingReceiver; + CAmControlSender *mControlSender; + CAmControlReceiver *mControlReceiver; + CAmDatabaseHandler *mDatabasehandler; + CAmRouter *mRouter; + sh_pollHandle_t mConnecthandle; + std::queue mMsgList; + std::vector mListConnections; + int mConnectFD; + unsigned int mServerPort; + unsigned int mMaxConnections; + CAmTelnetMenuHelper mTelnetMenuHelper; + +}; + +} /* namespace am */ +#endif /* TELNETSERVER_H_ */ diff --git a/AudioManagerDaemon/include/CommandReceiver.h b/AudioManagerDaemon/include/CommandReceiver.h deleted file mode 100644 index 5279a31..0000000 --- a/AudioManagerDaemon/include/CommandReceiver.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file CommandReveiver.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef COMMANDRECEIVER_H_ -#define COMMANDRECEIVER_H_ - -#include -#include - -namespace am -{ - -class DatabaseHandler; -class ControlSender; -class DBusWrapper; -class SocketHandler; - -/** - * This class realizes the command Interface - */ -class CommandReceiver: public CommandReceiveInterface -{ -public: - CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender, SocketHandler* iSocketHandler); - CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender, SocketHandler* iSocketHandler, DBusWrapper* iDBusWrapper); - ~CommandReceiver(); - am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID); - am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID); - am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume); - am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep); - am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState); - am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); - am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); - am_Error_e setSystemProperty(const am_SystemProperty_s& property); - am_Error_e getListMainConnections(std::vector& listConnections) const; - am_Error_e getListMainSinks(std::vector& listMainSinks) const; - am_Error_e getListMainSources(std::vector& listMainSources) const; - am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector& listSoundProperties) const; - am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector& listSourceProperties) const; - am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; - am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; - am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; - am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const; - am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const; - am_Error_e getSocketHandler(SocketHandler*& socketHandler) const; - void getInterfaceVersion(std::string& version) const; - void confirmCommandReady(const uint16_t handle); - void confirmCommandRundown(const uint16_t handle); - - uint16_t getStartupHandle(); //!< returns a startup handle - uint16_t getRundownHandle(); //!< returns a rundown handle - - void waitOnStartup(bool startup); //!< tells the ComandReceiver to start waiting for all handles to be confirmed - void waitOnRundown(bool rundown); //!< tells the ComandReceiver to start waiting for all handles to be confirmed - -private: - DatabaseHandler* mDatabaseHandler; //!< pointer to the databasehandler - ControlSender* mControlSender; //!< pointer to the control sender - DBusWrapper* mDBusWrapper; //!< pointer to the dbuswrapper - SocketHandler* mSocketHandler; //!< pointer to the SocketHandler - - uint16_t handleCount; //!< counts all handles - std::vector mListStartupHandles; //!< list of handles that wait for a confirm - std::vector mListRundownHandles; //!< list of handles that wait for a confirm - bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 - bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 -}; - -} - -#endif /* COMMANDRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/CommandSender.h b/AudioManagerDaemon/include/CommandSender.h deleted file mode 100644 index 0a8d2b2..0000000 --- a/AudioManagerDaemon/include/CommandSender.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file CommandSender.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef COMMANDSENDER_H_ -#define COMMANDSENDER_H_ - -#ifdef UNIT_TEST -#include "../test/CommandInterfaceBackdoor.h" //we need this for the unit test -#endif - -#include "command/CommandSendInterface.h" - -namespace am -{ - -class CommandReceiver; - - -/** - * This class is used to send data to the CommandInterface. - * All loaded plugins will be called when a callback is invoked. - */ -class CommandSender -{ -public: - CommandSender(const std::vector& listOfPluginDirectories); - ~CommandSender(); - am_Error_e startupInterfaces(CommandReceiver* iCommandReceiver); - void setCommandReady(); - void setCommandRundown(); - void cbNewMainConnection(const am_MainConnectionType_s mainConnection); - void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection); - void cbNewSink(am_SinkType_s sink); - void cbRemovedSink(const am_sinkID_t sink); - void cbNewSource(const am_SourceType_s source); - void cbRemovedSource(const am_sourceID_t source); - void cbNumberOfSinkClassesChanged(); - void cbNumberOfSourceClassesChanged(); - void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState); - void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty); - void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty); - void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability); - void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability); - void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume); - void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState); - void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty); - void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time); - void getInterfaceVersion(std::string& version) const; - am_Error_e getListPlugins(std::vector& interfaces) const; -#ifdef UNIT_TEST - friend class CommandInterfaceBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces -#endif -private: - void unloadLibraries(void); //!< unload the shared libraries - std::vector mListInterfaces; //!< list of all interfaces - std::vector mListLibraryHandles; //!< list of all library handles. This information is used to unload the plugins correctly. - std::vector mListLibraryNames; //!< list of all library names. This information is used for getListPlugins. - - CommandReceiver *mCommandReceiver; -}; - -} - -#endif /* COMMANDSENDER_H_ */ diff --git a/AudioManagerDaemon/include/ControlReceiver.h b/AudioManagerDaemon/include/ControlReceiver.h deleted file mode 100644 index dfb0695..0000000 --- a/AudioManagerDaemon/include/ControlReceiver.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file ControlReceiver.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef CONTRONLRECEIVER_H_ -#define CONTRONLRECEIVER_H_ - -#include -#include - -namespace am -{ - -class SocketHandler; -class DatabaseHandler; -class RoutingSender; -class CommandSender; -class Router; - -/** - * This class is used to receive all commands from the control interface - */ -class ControlReceiver: public ControlReceiveInterface -{ -public: - ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler, Router* iRouter); - ~ControlReceiver(); - am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList); - am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID); - am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID); - am_Error_e crossfade(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime); - am_Error_e abortAction(const am_Handle_s handle); - am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state); - am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); - am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time); - am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector& soundProperty); - am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty); - am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector& soundProperty); - am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty); - am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState); - am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID); - am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID); - am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID); - am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); - am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); - am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID); - am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID); - am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass); - am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass); - am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass); - am_Error_e enterSystemPropertiesListDB(const std::vector& listSystemProperties); - am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID); - am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState); - am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID); - am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID); - am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID); - am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID); - am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); - am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); - am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID); - am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property); - am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID); - am_Error_e removeSinkDB(const am_sinkID_t sinkID); - am_Error_e removeSourceDB(const am_sourceID_t sourceID); - am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID); - am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID); - am_Error_e removeDomainDB(const am_domainID_t domainID); - am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID); - am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID); - am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const; - am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const; - am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const; - am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const; - am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const; - am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const; - am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const; - am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector& listSinkID) const; - am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector& listSourceID) const; - am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector& listCrossfadersID) const; - am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; - am_Error_e getListMainConnections(std::vector& listMainConnections) const; - am_Error_e getListDomains(std::vector& listDomains) const; - am_Error_e getListConnections(std::vector& listConnections) const; - am_Error_e getListSinks(std::vector& listSinks) const; - am_Error_e getListSources(std::vector& listSources) const; - am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; - am_Error_e getListHandles(std::vector& listHandles) const; - am_Error_e getListCrossfaders(std::vector& listCrossfaders) const; - am_Error_e getListGateways(std::vector& listGateways) const; - am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; - am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; - void setCommandReady(); - void setCommandRundown(); - void setRoutingReady(); - void setRoutingRundown(); - void confirmControllerReady(); - void confirmControllerRundown(); - am_Error_e getSocketHandler(SocketHandler*& socketHandler); - void getInterfaceVersion(std::string& version) const; - -private: - DatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler - RoutingSender* mRoutingSender; //!< pointer to the routing send interface. - CommandSender* mCommandSender; //!< pointer to the command send interface - SocketHandler* mSocketHandler; //!< pointer to the socketHandler - Router* mRouter; //!< pointer to the Router -}; - -} - -#endif /* CONTRONLRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/ControlSender.h b/AudioManagerDaemon/include/ControlSender.h deleted file mode 100644 index 6e04d48..0000000 --- a/AudioManagerDaemon/include/ControlSender.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file ControlSender.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef CONTROLSENDER_H_ -#define CONTROLSENDER_H_ - -#ifdef UNIT_TEST -#include "../test/ControlInterfaceBackdoor.h" -#endif - -#include "control/ControlSendInterface.h" - -namespace am -{ - -/** - * sends data to the commandInterface, takes the file of the library that needs to be loaded - */ -class ControlSender -{ -public: - ControlSender(std::string controlPluginFile); - ~ControlSender(); - am_Error_e startupController(ControlReceiveInterface* controlreceiveinterface) ; - void setControllerReady() ; - void setControllerRundown() ; - am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ; - am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ; - am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ; - am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ; - am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ; - am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ; - am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ; - am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ; - am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ; - am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ; - void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ; - am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ; - am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ; - am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ; - am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ; - am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ; - am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ; - am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ; - am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ; - void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ; - void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ; - void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ; - void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ; - void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ; - void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ; - void hookSystemReceiveEarlyData(const std::vector& data) ; - void hookSystemSpeedChange(const am_speed_t speed) ; - void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ; - void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ; - void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ; - void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ; - void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ; - void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ; - void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ; - void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ; - void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ; - void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ; - void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ; - am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats) ; - void getInterfaceVersion(std::string& version) const ; - void confirmCommandReady() ; - void confirmRoutingReady() ; - void confirmCommandRundown() ; - void confirmRoutingRundown() ; - -#ifdef UNIT_TEST - friend class ControlInterfaceBackdoor; -#endif -private: - void* mlibHandle; //!< pointer to the loaded control plugin interface - ControlSendInterface* mController; //!< pointer to the ControlSend interface -}; - -} - -#endif /* CONTROLSENDER_H_ */ diff --git a/AudioManagerDaemon/include/DAmDoxygenMainPage.h b/AudioManagerDaemon/include/DAmDoxygenMainPage.h new file mode 100644 index 0000000..e27b233 --- /dev/null +++ b/AudioManagerDaemon/include/DAmDoxygenMainPage.h @@ -0,0 +1,115 @@ +/** + * \mainpage + * + * + * \image html genivilogo.png + * + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \par Copyright + * Copyright Copyright (C) 2011,2012 GENIVI Alliance\n + * Copyright Copyright (C) 2011,2012 BMW AG + * + * \par License + * Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements. + * This file is licensed under the terms of the Mozilla Public License 2.0.\n + * A copy of the license text has been included in the “LICENSE” file in the root directory of the source distribution. + * You can also obtain a copy of the license text at\n + * http://mozilla.org/MPL/2.0/. + * + * \par More information + * can be found at https://collab.genivi.org/wiki/display/genivi/GENIVI+Home \n + * + * \par About AudioManager + * The AudioManager is a Deamon that manages all Audio Connections in a GENIVI headunit. + * It is a managing instance that uses so called RoutingAdaptors to control AudioDomains that then do the "real" connections. + * \n\n\n + * + * + * \section architecture Architecture Overview + * + * The architecture concept bases on the partition of management (logic) and routing (action). Sinks and sources are clustered into independent parts which are capable of exchanging audio with each other (AudioDomains). Between these AudioDomains, Audio can be interchanged via Gateways. \n + * Since the routing and the management shall be independent from the actual used system, it is realized as an OwnedComponent, the AudioManager. Each AudioDomain has a Routing Adapter which implements some necessary logic and is the interface between the AudioManager and the AudioDomains. + * + * \section domains Audio Domains + * + * An Audio Domain consists of sinks and sources that can exchange audio with each other. To make the most out of the concept, AudioDomains shall be chosen in such a way that they are implemented by already existing audio routing engines. + * + * The AudioManager assumes that there are no restrictions in interconnection of sinks and sources. One or more sources can be connected to one sink and one or more sinks can be connected to one source. Since real hardware or software might end up in having restrictions, the knowledge of this must exist in the AudioManager and handled by him accordingly. This shall be accomplished via a plug-in mechanism. An AudioDomain is not tied to a hardware or software implementation. It can be software or hardware or even a combination of both. \n + * + * Examples for possible audio domains:\n + * PulseAudio, Alsa, Jack, DSP, FPGA, MOST, In-chip switching matrix\n + * + * The clustering and usage of the AudioDomains will vary from each product. Care must be taken while choosing the right AudioDomains in regards to system load (due to resampling), latency and of course flexibility.\n + * In special implementations of the AudioDomain, it is capable of operation a certain time without interaction to the AudioManager. This is needed to fulfill the requirements for Early & Late Audio, more information can be found below. + * + * \section routing_adaptor Routing Adapter + * + * Via this adapter, the interconnection from the AudioManager to the AudioDomains is accomplished. An AudioDomain shall have exactly one RoutingAdapter. In the terms of GENIVI, a RoutingAdapter is an AbstractComponent, this means that we define an API and a certain behavior in UML models but do not maintain components itself. Existing implementations from Proof of Concepts are shipped as example Adapters "as is" but cannot be seen as maintained components.\n + * The implementation of a routing adapter can and will vary from each project to another since the combination of sinks and sources, the used hardware etc has influence on the adapters. Besides interchanging and abstracting information between the AudioManager and the sinks and sources, the Adapters also need to implement some business logic in order to interact with the AudioManager. This include for example the registering of components, managing the current state, error handling etc.\n + * In the special case of an EarlyDomain, the routing adapter also has to manage start-up and rundown including persistence for his domain while the AudioManager is not started or already stopped. During this periods of time, these special adapters have to be able to fulfill basic tasks like changing volumes, for example (this implies that the Adapter is implemented on a different piece of hardware, e.g. vehicle processor). + * + * \section Gateway + * + * Gateways are used to let audio flow between two domains. They always have a direction and can only transport one stream at a time. Several gateways connecting the same domains together can exist in parallel so that more than one source can be connected to more than one sink from the same domains at the same time.\n + * The representation of a Gateway in the domain which originates the audio is a sink. In the receiving domain, the gateway appears as a source. The AudioManager knows about the Gateways, in terms of connection, it handles it as simple sources and sinks. + * + * \section AudioManagerDaemon + * + * The AudioManager is the central managing instance of the Audio architecture. It is designed as an OwnedComponent, this means that the software is maintained within GENIVI as open source component. The AudioManager consists of 4 central components.\n + * + * GOwnedComponent: AudioManager Daemon\n + * + * This component is owned and maintained by Genivi. It is the central audio framework component. There can be only one daemon in a system (singleton). + * + * \subsection controlinterface Control Interface Plugin + * + * This describes the interface towards the Controlling Instances of the AudioManagerDaemon. This is the HMI and interrupt sources that use this interface to start their interrupt and stop it again. The interface shall be asynchronous. Via this interface all user interactions are handled. + * + * \subsection routinginterface Routing Interface Plugin + * + * This interface is used by the AudioManager to control the RoutingAdapters and communicate with them. The communication is based on two interfaces, one is provided by the AudioManager for communication from the adapters towards the AudioManager and one for the opposite direction. The design of the AudioManager shall be done in such a way that several Interfaces are supported at the same time via a plug-in mechanism. The plug-ins are (either statically - due to performance reasons or dynamically) loaded at start-up. Due to this architecture, the number of buses and routing adapters that are supported are as low as possible for each system and as high as needed without the need of changing the AudioManager itself. The AudioManager expects a bus-like structure behind each plug-in, so that a plug-in can implement a bus interface and proxy the messages to the routing adapters - the AudioManager will be capable of addressing more than one adapter one each plug-in. The interface shall is asynchronous for all timely critical commands. + * + * \section interfaces Interfaces + * the calls to the interfaces of the AudioManagerDaemon are generally not threadsafe ! + * Nevertheless if such calls from a different thread-context are needed, you may use the defered-call pattern that utilizes the mainloop (Sockethandler) to get self called in the next loop of the mainloop. For more infomation please check the audiomanger wiki page. + * + * \section deferred The deferred call pattern + * Create a unix pipe or socket and add the file descriptor to the Sockethandler. Whenever a call needs to be deferred you can store the necessary information protected by a mutex in a queue and write to the socket or pipe. This will lead to a callback in the next loop of the mainloop - when getting called by the callback that was registered at the Sockethandler execute your call with the information stored away. + * + * + * \section sources_sinks Sources & Sinks + * \subsection Visibility + * Sources and sinks can either be visible or not. If they are visible, the HMI is informed about their existence and can use them. \n + * Invisible Sources and Sinks either are system only relevant (e.g. an audio processing that has a source and a sink) or belong to a gateway. + * + * \subsection Availability + * It can be the case, that sources and sinks are present in the system but cannot be used at the moment. This is indicated via the availability. A sample use-case for this feature is CD drive that shall only be available if a CD is inserted. + * + * \section Interrupts + * \subsection llinterrupts Low level interrupts + * \todo write low level Interrupts description + * + * \subsection Interrupts + * \todo write Interrupts description + * + * \section Persistency + * It is the job of the AudioManagerController to handle the persistency. It is planned to expose an interface via the ControlInterface to accomplish this but the GENIVI persistance is not ready yet. \n + * + * + * \section speed Speed dependent volume + * The adjustments for the speed are done product specific in the controller. The speed information itself is retrieved by the AudioManagerDaemon, sampled and quantified and forwarded to the controller.\n + * Turning speed controlled volume on/off and possible settings are achieved via SinkSoundProperty settings. + * + * \section Lipsync + * It is the job of the AudioManager to retrieve all latency timing information from each connection, to aggregate this information and provide a latency information on a per MainConnection Basis. It is not the task of the AudioManager to actually delay or speed up video or audio signals to achieve a lipsync. The actual correction shall be done in the videoplayer with the information provided by the AudioManager. + * The time information is always reported by the routingadaptors for each connection. Delays that are introduced in a sink or a gateway are counting for the connection that connects to this sink or gateway.\n + * After the buildup of a connection the first timing information needs to be sent within 5 seconds, the timing information from the routing adaptors need to be sent via 4 seconds. If the latency for a connection is variable and changes over lifetime of the connection, the routing adaptors shall resend the value and the audiomanger will correct the over all latency.\n + * @author Christian Mueller + * @created 25-Feb-2012 3:54:06 PM + */ + +#ifndef MAINPAGE_H_ +#define MAINPAGE_H_ + +#endif /* MAINPAGE_H_ */ diff --git a/AudioManagerDaemon/include/DatabaseHandler.h b/AudioManagerDaemon/include/DatabaseHandler.h deleted file mode 100644 index 964bbbe..0000000 --- a/AudioManagerDaemon/include/DatabaseHandler.h +++ /dev/null @@ -1,280 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file Databasehandler.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef DATABASEHANDLER_H_ -#define DATABASEHANDLER_H_ - -#include "audiomanagertypes.h" -#include -#include -#include - -namespace am -{ - -class DatabaseObserver; -class RoutingTree; -class RoutingTreeItem; - -#define DYNAMIC_ID_BOUNDARY 100 //!< the value below is reserved for staticIDs, the value above will be assigned to dynamically registered items -//todo: check the enum values before entering & changing in the database. -//todo: change asserts for dynamic boundary checks into failure answers.# -//todo: check autoincrement boundary and set to 16bit limits -//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources -//todo: exchange last_insert_row id to be more safe -//todo: create test to ensure uniqueness of names throughout the database -//todo: enforce the uniqueness of names - -/** - * This class handles and abstracts the database - */ -class DatabaseHandler -{ -public: - DatabaseHandler(std::string databasePath); - ~DatabaseHandler(); - am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID); - am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID); - am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID); - am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); - am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); - am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID); - am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID); - am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID); - am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass); - am_Error_e enterSystemProperties(const std::vector& listSystemProperties); - am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID); - am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState); - am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID); - am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID); - am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID); - am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID); - am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID); - am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID); - am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID); - am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID); - am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID); - am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property); - am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID); - am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass); - am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass); - am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay); - am_Error_e changeConnectionFinal(const am_connectionID_t connectionID); - am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState); - am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume); - am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume); - am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink); - am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID); - am_Error_e removeSinkDB(const am_sinkID_t sinkID); - am_Error_e removeSourceDB(const am_sourceID_t sourceID); - am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID); - am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID); - am_Error_e removeDomainDB(const am_domainID_t domainID); - am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID); - am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID); - am_Error_e removeConnection(const am_connectionID_t connectionID); - am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const; - am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const; - am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const; - am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const; - am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const; - am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const; - am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const; - am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const; - am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const; - am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const; - am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const; - am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector& listSinkID) const; - am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector& listSourceID) const; - am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; - am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector& listGatewaysID) const; - am_Error_e getListMainConnections(std::vector& listMainConnections) const; - am_Error_e getListDomains(std::vector& listDomains) const; - am_Error_e getListConnections(std::vector& listConnections) const; - am_Error_e getListSinks(std::vector& listSinks) const; - am_Error_e getListSources(std::vector& lisSources) const; - am_Error_e getListSourceClasses(std::vector& listSourceClasses) const; - am_Error_e getListCrossfaders(std::vector& listCrossfaders) const; - am_Error_e getListGateways(std::vector& listGateways) const; - am_Error_e getListSinkClasses(std::vector& listSinkClasses) const; - am_Error_e getListVisibleMainConnections(std::vector& listConnections) const; - am_Error_e getListMainSinks(std::vector& listMainSinks) const; - am_Error_e getListMainSources(std::vector& listMainSources) const; - am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector& listSoundProperties) const; - am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector& listSourceProperties) const; - am_Error_e getListSystemProperties(std::vector& listSystemProperties) const; - am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector & listConnectionFormats) const; - am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector & listConnectionFormats) const; - am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector & listConnectionFormat) const; - am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const; - am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const; - am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const; - am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const; - am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const; - am_Error_e getRoutingTree(bool onlyfree, RoutingTree& tree, std::vector& flatTree); - am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID); - am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID); - am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID); - am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID); - am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID); - /** - * checks for a certain mainConnection - * @param mainConnectionID to be checked for - * @return true if it exists - */ - bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const; - - /** - * checks if a CrossFader exists - * @param crossfaderID the ID of the crossfader to be checked - * @return true if exists - */ - bool existcrossFader(const am_crossfaderID_t crossfaderID) const; - - /** - * checks if a connection already exists. - * Only takes sink, source and format information for search! - * @param connection the connection to be checked - * @return true if connections exists - */ - bool existConnection(const am_Connection_s connection); - - /** - * checks if a connection with the given ID exists - * @param connectionID - * @return true if connection exits - */ - bool existConnectionID(const am_connectionID_t connectionID); - /** - * checks for a certain Source - * @param sourceID to be checked for - * @return true if it exists - */ - bool existSource(const am_sourceID_t sourceID) const; - - /** - * checks if a source name or ID exists - * @param sourceID the sourceID - * @param name the name - * @return true if it exits - */ - bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const; - - /** - * checks if a name exits - * @param name the name - * @return true if it exits - */ - bool existSourceName(const std::string& name) const; - /** - * checks for a certain Sink - * @param sinkID to be checked for - * @return true if it exists - */ - bool existSink(const am_sinkID_t sinkID) const; - - /** - * checks if a sink with the ID or the name exists - * @param sinkID the ID - * @param name the name - * @return true if it exists. - */ - bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const; - - /** - * checks if a sink with the name exists - * @param name the name - * @return true if it exists - */ - bool existSinkName(const std::string& name) const; - - /** - * checks for a certain domain - * @param domainID to be checked for - * @return true if it exists - */ - bool existDomain(const am_domainID_t domainID) const; - - /** - * checks for certain gateway - * @param gatewayID to be checked for - * @return true if it exists - */ - bool existGateway(const am_gatewayID_t gatewayID) const; - - /** - * checks for certain SinkClass - * @param sinkClassID - * @return true if it exists - */ - bool existSinkClass(const am_sinkClass_t sinkClassID) const; - - /** - * checks for certain sourceClass - * @param sourceClassID - * @return true if it exists - */ - bool existSourceClass(const am_sourceClass_t sourceClassID) const; - - /** - * registers the Observer at the Database - * @param iObserver pointer to the observer - */ - void registerObserver(DatabaseObserver *iObserver); - - /** - * gives information about the visibility of a source - * @param sourceID the sourceID - * @return true if source is visible - */ - bool sourceVisible(const am_sourceID_t sourceID) const; - - /** - * gives information about the visibility of a sink - * @param sinkID the sinkID - * @return true if source is visible - */ - bool sinkVisible(const am_sinkID_t sinkID) const; - -private: - am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const; - bool sqQuery(const std::string& query); - bool openDatabase(); //!< opens the database - void createTables(); //!< creates all tables from the static table - sqlite3 *mDatabase; //!< pointer to the database - std::string mPath; //!< path to the database - DatabaseObserver *mDatabaseObserver; //!< pointer to the Observer - bool mFirstStaticSink; - bool mFirstStaticSource; - bool mFirstStaticGateway; - bool mFirstStaticSinkClass; - bool mFirstStaticSourceClass; - bool mFirstStaticCrossfader; - typedef std::map > ListConnectionFormat; //!< type for list of connection formats - ListConnectionFormat mListConnectionFormat; //!< list of connection formats -}; - -} - -#endif /* DATABASEHANDLER_H_ */ diff --git a/AudioManagerDaemon/include/DatabaseObserver.h b/AudioManagerDaemon/include/DatabaseObserver.h deleted file mode 100644 index 3862a79..0000000 --- a/AudioManagerDaemon/include/DatabaseObserver.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file DatabaseObserver.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef DATABASEOBSERVER_H_ -#define DATABASEOBSERVER_H_ - -#include -#include -#include "CAmSerializer.h" - -namespace am -{ - -class TelnetServer; -class CommandSender; -class RoutingSender; -class SocketHandler; - -/** - * This class observes the Database and notifies other classes about important events, mainly the CommandSender. - */ - -class DatabaseObserver -{ -public: - DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, SocketHandler *iSocketHandler); - DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, SocketHandler *iSocketHandler, TelnetServer *iTelnetServer); - ~DatabaseObserver(); - void numberOfSinkClassesChanged(); - void numberOfSourceClassesChanged(); - void newSink(const am_Sink_s& sink); - void newSource(const am_Source_s& source); - void newDomain(const am_Domain_s& domain); - void newGateway(const am_Gateway_s& gateway); - void newCrossfader(const am_Crossfader_s& crossfader); - void newMainConnection(const am_MainConnectionType_s& mainConnection); - void removedMainConnection(const am_mainConnectionID_t mainConnection); - void removedSink(const am_sinkID_t sinkID, const bool visible); - void removedSource(const am_sourceID_t sourceID, const bool visible); - void removeDomain(const am_domainID_t domainID); - void removeGateway(const am_gatewayID_t gatewayID); - void removeCrossfader(const am_crossfaderID_t crossfaderID); - void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState); - void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty); - void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty); - void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability); - void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability); - void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume); - void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState); - void systemPropertyChanged(const am_SystemProperty_s& SystemProperty); - void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time); - -private: - CommandSender *mCommandSender; //!< pointer to the comandSender - RoutingSender* mRoutingSender; //!< pointer to the routingSender - TelnetServer* mTelnetServer; //!< pointer to the telnetserver - CAmSerializer mSerializer; -}; - -} - -#endif /* DATABASEOBSERVER_H_ */ diff --git a/AudioManagerDaemon/include/PluginTemplate.h b/AudioManagerDaemon/include/PluginTemplate.h deleted file mode 100644 index 2c4dc42..0000000 --- a/AudioManagerDaemon/include/PluginTemplate.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file pluginTemplate.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef PLUGINTEMPLATE_H_ -#define PLUGINTEMPLATE_H_ - -#include -#include -#include "DLTWrapper.h" - -namespace am -{ - -/** - * This template tries to load a library and cast ot to a class - * @param libname the full path to the library to be loaded - * @return returns the pointer to the class to be loaded - */ -template T* getCreateFunction(const std::string& libname, void*& libraryHandle) -{ - - logInfo("getCreateFunction : Trying to load library with name: ",libname); - - // cut off directories - char* fileWithPath = const_cast(libname.c_str()); - std::string libFileName = basename(fileWithPath); - - // cut off "lib" in front and cut off .so end" - std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory"; - - // open library - dlerror(); // Clear any existing error - libraryHandle = dlopen(libname.c_str(), RTLD_LAZY); - const char* dlopen_error = dlerror(); - if (!libraryHandle || dlopen_error) - { - logError("getCreateFunction : dlopen failed",dlopen_error); - return 0; - } - - // get entry point from shared lib - dlerror(); // Clear any existing error - - union - { - void* voidPointer; - T* typedPointer; - } functionPointer; - - // Note: direct cast is not allowed by ISO C++. e.g. - // T* createFunction = reinterpret_cast(dlsym(libraryHandle, createFunctionName.c_str())); - // compiler warning: "forbids casting between pointer-to-function and pointer-to-object" - - functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str()); - T* createFunction = functionPointer.typedPointer; - - const char* dlsym_error = dlerror(); - if (!createFunction || dlsym_error) - { - logError("getCreateFunction: Failed to load shared lib entry point",dlsym_error); - } - else - { - logInfo("getCreateFunction : loaded successfully plugin", createFunctionName); - } - return createFunction; -} - -} - -#endif /* PLUGINTEMPLATE_H_ */ diff --git a/AudioManagerDaemon/include/Router.h b/AudioManagerDaemon/include/Router.h deleted file mode 100644 index 11a5634..0000000 --- a/AudioManagerDaemon/include/Router.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file Router.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef ROUTER_H_ -#define ROUTER_H_ - -#include - -namespace am -{ - -class DatabaseHandler; -class ControlSender; - -class Router -{ -public: - Router(DatabaseHandler* iDatabaseHandler, ControlSender* iSender); - am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList); - ~Router(); - -private: - am_Error_e findBestWay(am_sinkID_t sinkID, am_sourceID_t sourceID, std::vector& listRoute, std::vector::iterator routeIterator, std::vector::iterator gatewayIterator); - void listPossibleConnectionFormats(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& listFormats) const; - void listRestrictedOutputFormatsGateways(const am_gatewayID_t gatewayID, const am_ConnectionFormat_e sinkConnectionFormat, std::vector& listFormats) const; - DatabaseHandler* mDatabaseHandler; - ControlSender* mControlSender; -}; - -class RoutingTreeItem -{ -public: - RoutingTreeItem(const am_domainID_t domainID, const am_gatewayID_t gatewayID = 0, RoutingTreeItem *parent = 0); - void appendChild(RoutingTreeItem *newChild); - void returnChildItems(std::vector listChildItems); - am_domainID_t returnDomainID() const; - am_gatewayID_t returnGatewayID() const; - virtual ~RoutingTreeItem(); - RoutingTreeItem* returnParent() const; -private: - std::vector mListChildItems; //!< List of all child items - am_domainID_t mDomainID; //!< the domain ID of the item - am_gatewayID_t mGatewayID; //!< the gateway Id - RoutingTreeItem *mParentItem; //!< pointer to the parent item -}; - -class RoutingTree -{ -public: - RoutingTree(const am_domainID_t rootDomainID); - RoutingTreeItem* insertItem(const am_domainID_t domainID, const am_gatewayID_t gatewayID, RoutingTreeItem *parent); - void getRoute(RoutingTreeItem* targetItem, std::vector& listGateways); - am_domainID_t returnRootDomainID() const; - RoutingTreeItem* returnRootItem(); - virtual ~RoutingTree(); -private: - RoutingTreeItem mRootItem; //!< pointer to root item - std::vector mListChild; //!< list of all childs -}; - -} /* namespace am */ -#endif /* ROUTER_H_ */ - diff --git a/AudioManagerDaemon/include/RoutingReceiver.h b/AudioManagerDaemon/include/RoutingReceiver.h deleted file mode 100644 index ae964ff..0000000 --- a/AudioManagerDaemon/include/RoutingReceiver.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file RoutingReceiver.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef ROUTINGRECEIVER_H_ -#define ROUTINGRECEIVER_H_ - -#include -#include - -namespace am -{ - -class SocketHandler; -class DBusWrapper; -class DatabaseHandler; -class RoutingSender; -class ControlSender; - -/** - * Implements the Receiving side of the RoutingPlugins. - */ -class RoutingReceiver: public RoutingReceiveInterface -{ -public: - RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler); - RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper); - ~RoutingReceiver(); - void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); - void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); - void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error); - void ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error); - void ackSetSourceState(const am_Handle_s handle, const am_Error_e error); - void ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error); - void ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error); - void ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error); - void ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error); - void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error); - void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume); - void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume); - am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID); - am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID); - am_Error_e deregisterDomain(const am_domainID_t domainID); - am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID); - am_Error_e deregisterGateway(const am_gatewayID_t gatewayID); - am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID); - am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID); - am_Error_e deregisterSink(const am_sinkID_t sinkID); - am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID); - am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID); - am_Error_e deregisterSource(const am_sourceID_t sourceID); - am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID); - am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID); - am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID); - am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID); - void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState); - void hookDomainRegistrationComplete(const am_domainID_t domainID); - void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability); - void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability); - void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState); - void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay); - void sendChangedData(const std::vector& earlyData); - am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const; - am_Error_e getSocketHandler(SocketHandler*& socketHandler) const; - void getInterfaceVersion(std::string& version) const; - void confirmRoutingReady(const uint16_t handle); - void confirmRoutingRundown(const uint16_t handle); - - uint16_t getStartupHandle(); //!< returns a startup handle - uint16_t getRundownHandle(); //!< returns a rundown handle - - void waitOnStartup(bool startup); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed - void waitOnRundown(bool rundown); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed - -private: - DatabaseHandler *mDatabaseHandler; //!< pointer to the databaseHandler - RoutingSender *mRoutingSender; //!< pointer to the routingSender - ControlSender *mControlSender; //!< pointer to the controlSender - SocketHandler *mSocketHandler; //!< pointer to sockethandler - DBusWrapper *mDBusWrapper; //!< pointer to dbuswrapper - - uint16_t handleCount; //!< counts all handles - std::vector mListStartupHandles; //!< list of handles that wait for a confirm - std::vector mListRundownHandles; //!< list of handles that wait for a confirm - bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 - bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 - -}; - -} - -#endif /* ROUTINGRECEIVER_H_ */ diff --git a/AudioManagerDaemon/include/RoutingSender.h b/AudioManagerDaemon/include/RoutingSender.h deleted file mode 100644 index f445313..0000000 --- a/AudioManagerDaemon/include/RoutingSender.h +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file RoutingSender.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef ROUTINGSENDER_H_ -#define ROUTINGSENDER_H_ - -#include "routing/RoutingSendInterface.h" -#include - -#ifdef UNIT_TEST //this is needed to test RoutingSender -#include "../test/RoutingInterfaceBackdoor.h" -#endif - -namespace am -{ - -class RoutingReceiver; - -/** - * Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins - */ -class RoutingSender -{ -public: - RoutingSender(const std::vector& listOfPluginDirectories); - ~RoutingSender(); - - /** - * removes a handle from the list - * @param handle to be removed - * @return E_OK in case of success - */ - am_Error_e removeHandle(const am_Handle_s& handle); - - /** - * @author Christian - * this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. - * This must be done whenever a domain is registered. - */ - am_Error_e addDomainLookup(const am_Domain_s& domainData); - /** - * @author Christian - * this adds the Source to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. - * This must be done whenever a Source is registered. - */ - am_Error_e addSourceLookup(const am_Source_s& sourceData); - /** - * @author Christian - * this adds the Sink to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. - * This must be done whenever a Sink is registered. - */ - am_Error_e addSinkLookup(const am_Sink_s& sinkData); - /** - * @author Christian - * this adds the Crossfader to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface. - * This must be done whenever a Crossfader is registered. - */ - am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData); - /** - * @author Christian - * this removes the Domain to the lookup table of the Router. This must be done everytime a domain is deregistered. - */ - am_Error_e removeDomainLookup(const am_domainID_t domainID); - /** - * @author Christian - * this removes the Source to the lookup table of the Router. This must be done everytime a source is deregistered. - */ - am_Error_e removeSourceLookup(const am_sourceID_t sourceID); - /** - * @author Christian - * this removes the Sink to the lookup table of the Router. This must be done everytime a sink is deregistered. - */ - am_Error_e removeSinkLookup(const am_sinkID_t sinkID); - /** - * @author Christian - * this removes the Crossfader to the lookup table of the Router. This must be done everytime a crossfader is deregistered. - */ - am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID); - am_Error_e startupInterfaces(RoutingReceiver* iRoutingReceiver); - void setRoutingReady(); - void setRoutingRundown(); - am_Error_e asyncAbort(const am_Handle_s& handle); - am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat); - am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID); - am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); - am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); - am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state); - am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty); - am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector& listSoundProperties, const am_sourceID_t sourceID); - am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector& listSoundProperties, const am_sinkID_t sinkID); - am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty); - am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time); - am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState); - am_Error_e getListHandles(std::vector & listHandles) const; - am_Error_e getListPlugins(std::vector& interfaces) const; - void getInterfaceVersion(std::string& version) const; - - //!< is used to pair interfaces with busnames - struct InterfaceNamePairs - { - RoutingSendInterface* routingInterface; - std::string busName; - }; - - //!< is used to store data related to handles - class am_handleData_c - { - public: - union - { - am_sinkID_t sinkID; - am_sourceID_t sourceID; - am_crossfaderID_t crossfaderID; - am_connectionID_t connectionID; - }; - union - { - am_SoundProperty_s soundPropery; - am_SourceState_e sourceState; - am_volume_t volume; - am_HotSink_e hotSink; - std::vector* soundProperties; - }; - - }; - -#ifdef UNIT_TEST //this is needed to test RoutingSender - friend class RoutingInterfaceBackdoor; -#endif - - /** - * returns the data that belong to handles - * @param handle the handle - * @return a class holding the handle data - */ - am_handleData_c returnHandleData(const am_Handle_s handle) const; - -private: - - //!< is needed to sort the handles in the map - struct comparator - { - bool operator()(const am_Handle_s& a, const am_Handle_s& b) const - { - return (a.handle < b.handle); - } - }; - - /** - * creates a handle and adds it to the list of handles - * @param handleData the data that should be saves together with the handle - * @param type the type of handle to be created - * @return the handle - */ - am_Handle_s createHandle(const am_handleData_c& handleData, const am_Handle_e type); - void unloadLibraries(void); //!< unloads all loaded plugins - - typedef std::map DomainInterfaceMap; //!< maps domains to interfaces - typedef std::map SinkInterfaceMap; //!< maps sinks to interfaces - typedef std::map SourceInterfaceMap; //!< maps sources to interfaces - typedef std::map CrossfaderInterfaceMap; //!< maps crossfaders to interfaces - typedef std::map ConnectionInterfaceMap; //!< maps connections to interfaces - typedef std::map HandleInterfaceMap; //!< maps handles to interfaces - typedef std::map HandlesMap; //!< maps handleData to handles - - int16_t mHandleCount; //!< is used to create handles - HandlesMap mlistActiveHandles; //!< list of all currently "running" handles. - std::vector mListLibraryHandles; //!< list of all loaded pluginInterfaces - std::vector mListInterfaces; //!< list of busname/interface relation - ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces - CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface - DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces - SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces - SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces - HandleInterfaceMap mMapHandleInterface; //!< map of handles to interfaces - RoutingReceiver *mRoutingReceiver; -}; - -} - -#endif /* ROUTINGSENDER_H_ */ diff --git a/AudioManagerDaemon/include/TAmPluginTemplate.h b/AudioManagerDaemon/include/TAmPluginTemplate.h new file mode 100644 index 0000000..e525ce3 --- /dev/null +++ b/AudioManagerDaemon/include/TAmPluginTemplate.h @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file TAmPluginTemplate.h + * + * \date 20-Oct-2011 3:42:04 PM + * \author Christian Mueller (christian.ei.mueller@bmw.de) + * + * \section License + * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) + * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. + * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. + * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. + * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. + * + */ + +#ifndef PLUGINTEMPLATE_H_ +#define PLUGINTEMPLATE_H_ + +#include +#include +#include "shared/CAmDltWrapper.h" + +namespace am +{ + +/** + * This template tries to load a library and cast ot to a class + * @param libname the full path to the library to be loaded + * @return returns the pointer to the class to be loaded + */ +template T* getCreateFunction(const std::string& libname, void*& libraryHandle) +{ + + logInfo("getCreateFunction : Trying to load library with name: ",libname); + + // cut off directories + char* fileWithPath = const_cast(libname.c_str()); + std::string libFileName = basename(fileWithPath); + + // cut off "lib" in front and cut off .so end" + std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory"; + + // open library + dlerror(); // Clear any existing error + libraryHandle = dlopen(libname.c_str(), RTLD_LAZY); + const char* dlopen_error = dlerror(); + if (!libraryHandle || dlopen_error) + { + logError("getCreateFunction : dlopen failed",dlopen_error); + return 0; + } + + // get entry point from shared lib + dlerror(); // Clear any existing error + + union + { + void* voidPointer; + T* typedPointer; + } functionPointer; + + // Note: direct cast is not allowed by ISO C++. e.g. + // T* createFunction = reinterpret_cast(dlsym(libraryHandle, createFunctionName.c_str())); + // compiler warning: "forbids casting between pointer-to-function and pointer-to-object" + + functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str()); + T* createFunction = functionPointer.typedPointer; + + const char* dlsym_error = dlerror(); + if (!createFunction || dlsym_error) + { + logError("getCreateFunction: Failed to load shared lib entry point",dlsym_error); + } + else + { + logInfo("getCreateFunction : loaded successfully plugin", createFunctionName); + } + return createFunction; +} + +} + +#endif /* PLUGINTEMPLATE_H_ */ diff --git a/AudioManagerDaemon/include/TelnetServer.h b/AudioManagerDaemon/include/TelnetServer.h deleted file mode 100644 index f95bd84..0000000 --- a/AudioManagerDaemon/include/TelnetServer.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file TelnetServer.h - * - * \date 20-Oct-2011 3:42:04 PM - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \section License - * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause) - * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details. - * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see . - * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense. - * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception. - * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned. - * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. - * - */ - -#ifndef TELNETSERVER_H_ -#define TELNETSERVER_H_ - -#include "SocketHandler.h" -#include "CAmTelnetMenuHelper.h" -#include -#include - -namespace am -{ - -class DatabaseHandler; -class CommandSender; -class RoutingSender; -class ControlSender; -class CommandReceiver; -class RoutingReceiver; -class ControlReceiver; -class Router; -class CAmTelnetMenuHelper; - -class TelnetServer -{ -public: - TelnetServer(SocketHandler *iSocketHandler, - CommandSender *iCommandSender, - CommandReceiver *iCommandReceiver, - RoutingSender *iRoutingSender, - RoutingReceiver *iRoutingReceiver, - ControlSender *iControlSender, - ControlReceiver *iControlReceiver, - DatabaseHandler *iDatabasehandler, - Router *iRouter, - unsigned int servPort, - unsigned int maxConnections); - - ~TelnetServer(); - void connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void* userData); - void disconnectClient(int filedescriptor); - void receiveData(const pollfd pfd, const sh_pollHandle_t handle, void* userData); - bool dispatchData(const sh_pollHandle_t handle, void* userData); - bool check(const sh_pollHandle_t handle, void* userData); - shPollFired_T telnetConnectFiredCB; - shPollFired_T telnetReceiveFiredCB; - shPollDispatch_T telnetDispatchCB; - shPollCheck_T telnetCheckCB; -private: - - typedef void (*CommandPrototype)(std::vector& msg,int filedescriptor); - typedef std::map mMapCommand_t; - - void sliceCommand(const std::string& string,std::string& command,std::queue& msg); - mMapCommand_t createCommandMap(); - struct connection_s - { - int filedescriptor; - sh_pollHandle_t handle; - }; - - static TelnetServer* instance; - SocketHandler *mSocketHandler; - CommandSender *mCommandSender; - CommandReceiver *mCommandReceiver; - RoutingSender *mRoutingSender; - RoutingReceiver *mRoutingReceiver; - ControlSender *mControlSender; - ControlReceiver *mControlReceiver; - DatabaseHandler *mDatabasehandler; - Router *mRouter; - sh_pollHandle_t mConnecthandle; - std::queue mMsgList; - std::vector mListConnections; - int mConnectFD; - unsigned int mServerPort; - unsigned int mMaxConnections; - CAmTelnetMenuHelper mTelnetMenuHelper; - -}; - -} /* namespace am */ -#endif /* TELNETSERVER_H_ */ diff --git a/AudioManagerDaemon/include/mainpage.h b/AudioManagerDaemon/include/mainpage.h deleted file mode 100644 index 8d8fdab..0000000 --- a/AudioManagerDaemon/include/mainpage.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * \mainpage - * - * - * \image html genivilogo.png - * - * \author Christian Mueller (christian.ei.mueller@bmw.de) - * - * \par Copyright - * Copyright Copyright (C) 2011,2012 GENIVI Alliance\n - * Copyright Copyright (C) 2011,2012 BMW AG - * - * \par License - * Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements. - * This file is licensed under the terms of the Mozilla Public License 2.0.\n - * A copy of the license text has been included in the “LICENSE” file in the root directory of the source distribution. - * You can also obtain a copy of the license text at\n - * http://mozilla.org/MPL/2.0/. - * - * \par More information - * can be found at https://collab.genivi.org/wiki/display/genivi/GENIVI+Home \n - * - * \par About AudioManager - * The AudioManager is a Deamon that manages all Audio Connections in a GENIVI headunit. - * It is a managing instance that uses so called RoutingAdaptors to control AudioDomains that then do the "real" connections. - * \n\n\n - * - * - * \section architecture Architecture Overview - * - * The architecture concept bases on the partition of management (logic) and routing (action). Sinks and sources are clustered into independent parts which are capable of exchanging audio with each other (AudioDomains). Between these AudioDomains, Audio can be interchanged via Gateways. \n - * Since the routing and the management shall be independent from the actual used system, it is realized as an OwnedComponent, the AudioManager. Each AudioDomain has a Routing Adapter which implements some necessary logic and is the interface between the AudioManager and the AudioDomains. - * - * \section domains Audio Domains - * - * An Audio Domain consists of sinks and sources that can exchange audio with each other. To make the most out of the concept, AudioDomains shall be chosen in such a way that they are implemented by already existing audio routing engines. - * - * The AudioManager assumes that there are no restrictions in interconnection of sinks and sources. One or more sources can be connected to one sink and one or more sinks can be connected to one source. Since real hardware or software might end up in having restrictions, the knowledge of this must exist in the AudioManager and handled by him accordingly. This shall be accomplished via a plug-in mechanism. An AudioDomain is not tied to a hardware or software implementation. It can be software or hardware or even a combination of both. \n - * - * Examples for possible audio domains:\n - * PulseAudio, Alsa, Jack, DSP, FPGA, MOST, In-chip switching matrix\n - * - * The clustering and usage of the AudioDomains will vary from each product. Care must be taken while choosing the right AudioDomains in regards to system load (due to resampling), latency and of course flexibility.\n - * In special implementations of the AudioDomain, it is capable of operation a certain time without interaction to the AudioManager. This is needed to fulfill the requirements for Early & Late Audio, more information can be found below. - * - * \section routing_adaptor Routing Adapter - * - * Via this adapter, the interconnection from the AudioManager to the AudioDomains is accomplished. An AudioDomain shall have exactly one RoutingAdapter. In the terms of GENIVI, a RoutingAdapter is an AbstractComponent, this means that we define an API and a certain behavior in UML models but do not maintain components itself. Existing implementations from Proof of Concepts are shipped as example Adapters "as is" but cannot be seen as maintained components.\n - * The implementation of a routing adapter can and will vary from each project to another since the combination of sinks and sources, the used hardware etc has influence on the adapters. Besides interchanging and abstracting information between the AudioManager and the sinks and sources, the Adapters also need to implement some business logic in order to interact with the AudioManager. This includes for example the registering of components, managing the current state, error handling etc.\n - * In the special case of an EarlyDomain, the routing adapter also has to manage start-up and rundown including persistence for his domain while the AudioManager is not started or already stopped. During this periods of time, these special adapters have to be able to fulfill basic tasks like changing volumes, for example (this implies that the Adapter is implemented on a different piece of hardware, e.g. vehicle processor). - * - * \section Gateway - * - * Gateways are used to let audio flow between two domains. They always have a direction and can only transport one stream at a time. Several gateways connecting the same domains together can exist in parallel so that more than one source can be connected to more than one sink from the same domains at the same time.\n - * The representation of a Gateway in the domain which originates the audio is a sink. In the receiving domain, the gateway appears as a source. The AudioManager knows about the Gateways, in terms of connection, it handles it as simple sources and sinks. - * - * \section AudioManagerDaemon - * - * The AudioManager is the central managing instance of the Audio architecture. It is designed as an OwnedComponent, this means that the software is maintained within GENIVI as open source component. The AudioManager consists of 4 central components.\n - * - * GOwnedComponent: AudioManager Daemon\n - * - * This component is owned and maintained by Genivi. It is the central audio framework component. There can be only one daemon in a system (singleton). - * - * \subsection controlinterface Control Interface Plugin - * - * This describes the interface towards the Controlling Instances of the AudioManagerDaemon. This is the HMI and interrupt sources that use this interface to start their interrupt and stop it again. The interface shall be asynchronous. Via this interface all user interactions are handled. - * - * \subsection routinginterface Routing Interface Plugin - * - * This interface is used by the AudioManager to control the RoutingAdapters and communicate with them. The communication is based on two interfaces, one is provided by the AudioManager for communication from the adapters towards the AudioManager and one for the opposite direction. The design of the AudioManager shall be done in such a way that several Interfaces are supported at the same time via a plug-in mechanism. The plug-ins are (either statically - due to performance reasons or dynamically) loaded at start-up. Due to this architecture, the number of buses and routing adapters that are supported are as low as possible for each system and as high as needed without the need of changing the AudioManager itself. The AudioManager expects a bus-like structure behind each plug-in, so that a plug-in can implement a bus interface and proxy the messages to the routing adapters - the AudioManager will be capable of addressing more than one adapter one each plug-in. The interface shall is asynchronous for all timely critical commands. - * - * \section interfaces Interfaces - * the calls to the interfaces of the AudioManagerDaemon are generally not threadsafe ! - * Nevertheless if such calls from a different thread-context are needed, you may use the defered-call pattern that utilizes the mainloop (Sockethandler) to get self called in the next loop of the mainloop. For more infomation please check the audiomanger wiki page. - * - * \section deferred The deferred call pattern - * Create a unix pipe or socket and add the file descriptor to the Sockethandler. Whenever a call needs to be deferred you can store the necessary information protected by a mutex in a queue and write to the socket or pipe. This will lead to a callback in the next loop of the mainloop - when getting called by the callback that was registered at the Sockethandler execute your call with the information stored away. - * - * - * \section sources_sinks Sources & Sinks - * \subsection Visibility - * Sources and sinks can either be visible or not. If they are visible, the HMI is informed about their existence and can use them. \n - * Invisible Sources and Sinks either are system only relevant (e.g. an audio processing that has a source and a sink) or belong to a gateway. - * - * \subsection Availability - * It can be the case, that sources and sinks are present in the system but cannot be used at the moment. This is indicated via the availability. A sample use-case for this feature is CD drive that shall only be available if a CD is inserted. - * - * \section Interrupts - * \subsection llinterrupts Low level interrupts - * \todo write low level Interrupts description - * - * \subsection Interrupts - * \todo write Interrupts description - * - * \section Persistency - * It is the job of the AudioManagerController to handle the persistency. It is planned to expose an interface via the ControlInterface to accomplish this but the GENIVI persistance is not ready yet. \n - * - * - * \section speed Speed dependent volume - * The adjustments for the speed are done product specific in the controller. The speed information itself is retrieved by the AudioManagerDaemon, sampled and quantified and forwarded to the controller.\n - * Turning speed controlled volume on/off and possible settings are achieved via SinkSoundProperty settings. - * - * \section Lipsync - * It is the job of the AudioManager to retrieve all latency timing information from each connection, to aggregate this information and provide a latency information on a per MainConnection Basis. It is not the task of the AudioManager to actually delay or speed up video or audio signals to achieve a lipsync. The actual correction shall be done in the videoplayer with the information provided by the AudioManager. - * The time information is always reported by the routingadaptors for each connection. Delays that are introduced in a sink or a gateway are counting for the connection that connects to this sink or gateway.\n - * After the buildup of a connection the first timing information needs to be sent within 5 seconds, the timing information from the routing adaptors need to be sent via 4 seconds. If the latency for a connection is variable and changes over lifetime of the connection, the routing adaptors shall resend the value and the audiomanger will correct the over all latency.\n - * @author Christian Mueller - * @created 25-Feb-2012 3:54:06 PM - */ - -#ifndef MAINPAGE_H_ -#define MAINPAGE_H_ - -#endif /* MAINPAGE_H_ */ -- cgit v1.2.1