summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/src
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-01-10 15:58:38 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-01-12 00:09:34 +0100
commit472d0762b68ce0f2a755b4215515a3e031831495 (patch)
tree276e811f00dfe17cba15c56092b33d67ba2793f6 /AudioManagerDaemon/src
parent6ebae8c4d3a340c135ed2f5f611a0e1c31994164 (diff)
downloadaudiomanager-472d0762b68ce0f2a755b4215515a3e031831495.tar.gz
* recreated the header files out of the model. Added versioning support in the headerfiles generated
* ensured compatibility with 64 bit systems while compiling dbus [ changed FindDBUS.cmake] * updated the README to better support building * updated typo in introspectable string of DBusWrapper * reworked including strategie * added getInterfafeVersion method on all interfaces * added Interface Versioning support * added version as part of .so ending * it is no possible to set a vector of source and sink sound properties at a time * added interface to ask for all loaded plugins on RoutingSender * added first version of telnet server (not yet productive) - set to not active in CMakeLists.txt * added changelog (created out of git commit log) * added default values for all enum types to be save even on other if communication is on other domain
Diffstat (limited to 'AudioManagerDaemon/src')
-rw-r--r--AudioManagerDaemon/src/CommandReceiver.cpp11
-rw-r--r--AudioManagerDaemon/src/CommandSender.cpp19
-rw-r--r--AudioManagerDaemon/src/ControlReceiver.cpp41
-rw-r--r--AudioManagerDaemon/src/ControlSender.cpp51
-rw-r--r--AudioManagerDaemon/src/DBusWrapper.cpp2
-rw-r--r--AudioManagerDaemon/src/DatabaseHandler.cpp1
-rw-r--r--AudioManagerDaemon/src/DatabaseObserver.cpp16
-rw-r--r--AudioManagerDaemon/src/RoutingReceiver.cpp50
-rw-r--r--AudioManagerDaemon/src/RoutingSender.cpp83
-rw-r--r--AudioManagerDaemon/src/TelnetServer.cpp270
-rw-r--r--AudioManagerDaemon/src/main.cpp67
11 files changed, 573 insertions, 38 deletions
diff --git a/AudioManagerDaemon/src/CommandReceiver.cpp b/AudioManagerDaemon/src/CommandReceiver.cpp
index 6cee4ad..15d2430 100644
--- a/AudioManagerDaemon/src/CommandReceiver.cpp
+++ b/AudioManagerDaemon/src/CommandReceiver.cpp
@@ -23,6 +23,8 @@
*/
#include "CommandReceiver.h"
+#include "DatabaseHandler.h"
+#include "ControlSender.h"
#include <SocketHandler.h>
#include <config.h>
#include <assert.h>
@@ -204,7 +206,7 @@ am_Error_e CommandReceiver::getDBusConnectionWrapper(DBusWrapper*& dbusConnectio
#endif /*WITH_DBUS_WRAPPER*/
}
-am_Error_e am::CommandReceiver::getSocketHandler(SocketHandler *& socketHandler) const
+am_Error_e CommandReceiver::getSocketHandler(SocketHandler *& socketHandler) const
{
#ifdef WITH_SOCKETHANDLER_LOOP
socketHandler=mSocketHandler;
@@ -214,6 +216,13 @@ am_Error_e am::CommandReceiver::getSocketHandler(SocketHandler *& socketHandler)
#endif /*WITH_SOCKETHANDLER_LOOP*/
}
+uint16_t CommandReceiver::getInterfaceVersion() const
+{
+ return CommandReceiveVersion;
+}
+
+
+
diff --git a/AudioManagerDaemon/src/CommandSender.cpp b/AudioManagerDaemon/src/CommandSender.cpp
index 7ea9ee8..92734c4 100644
--- a/AudioManagerDaemon/src/CommandSender.cpp
+++ b/AudioManagerDaemon/src/CommandSender.cpp
@@ -24,11 +24,14 @@
#include "CommandSender.h"
+#include "command/CommandReceiveInterface.h"
#include <dirent.h>
#include <dlt/dlt.h>
#include "PluginTemplate.h"
using namespace am;
+#define REQUIRED_INTERFACE_VERSION 1
+
DLT_IMPORT_CONTEXT(AudioManager)
//!< macro to call all interfaces
@@ -67,7 +70,7 @@ CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirecto
unsigned char entryType = itemInDirectory->d_type;
std::string entryName = itemInDirectory->d_name;
- bool regularFile = (entryType == DT_REG);
+ bool regularFile = (entryType == DT_REG || entryType== DT_LNK);
bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
if (regularFile && sharedLibExtension)
@@ -104,6 +107,13 @@ CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirecto
continue;
}
+ //check libversion
+ if (commander->getInterfaceVersion()<REQUIRED_INTERFACE_VERSION)
+ {
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Version of Interface to old"));
+ continue;
+ }
+
mListInterfaces.push_back(commander);
mListLibraryHandles.push_back(tempLibHandle);
}
@@ -258,6 +268,13 @@ void CommandSender::unloadLibraries(void)
mListLibraryHandles.clear();
}
+uint16_t CommandSender::getInterfaceVersion() const
+{
+ return CommandSendVersion;
+}
+
+
+
diff --git a/AudioManagerDaemon/src/ControlReceiver.cpp b/AudioManagerDaemon/src/ControlReceiver.cpp
index 3a88c84..763bf2c 100644
--- a/AudioManagerDaemon/src/ControlReceiver.cpp
+++ b/AudioManagerDaemon/src/ControlReceiver.cpp
@@ -23,7 +23,11 @@
*/
#include <config.h>
+#include <SocketHandler.h>
#include "ControlReceiver.h"
+#include "DatabaseHandler.h"
+#include "RoutingSender.h"
+#include "CommandSender.h"
#include <assert.h>
#include <dlt/dlt.h>
@@ -151,7 +155,21 @@ am_Error_e ControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_
return mRoutingSender->asyncSetSinkSoundProperty(handle,sinkID,soundProperty);
}
+am_Error_e am::ControlReceiver::setSinkSoundProperties(am_Handle_s & handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperties got called, sinkID="),DLT_INT(sinkID));
+ uint16_t value;
+ bool noChange=true;
+ std::vector<am_SoundProperty_s>::const_iterator it=listSoundProperties.begin();
+ for(;it!=listSoundProperties.end();++it)
+ {
+ if(mDatabaseHandler->getSinkSoundPropertyValue(sinkID,it->type,value)!=E_OK) return (E_UNKNOWN);
+ if(value!=it->value) noChange=false;
+ }
+ if (noChange) return (E_NO_CHANGE);
+ return (mRoutingSender->asyncSetSinkSoundProperties(handle,listSoundProperties,sinkID));
+}
am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
@@ -163,6 +181,21 @@ am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const a
return mRoutingSender->asyncSetSourceSoundProperty(handle,sourceID,soundProperty);
}
+am_Error_e am::ControlReceiver::setSourceSoundProperties(am_Handle_s & handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperties got called, sourceID="),DLT_INT(sourceID));
+
+ uint16_t value;
+ bool noChange=true;
+ std::vector<am_SoundProperty_s>::const_iterator it=listSoundProperties.begin();
+ for(;it!=listSoundProperties.end();++it)
+ {
+ if(mDatabaseHandler->getSourceSoundPropertyValue(sourceID,it->type,value)!=E_OK) return (E_UNKNOWN);
+ if(value!=it->value) noChange=false;
+ }
+ if (noChange) return (E_NO_CHANGE);
+ return (mRoutingSender->asyncSetSourceSoundProperties(handle,listSoundProperties,sourceID));
+}
am_Error_e ControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
@@ -528,6 +561,14 @@ am_Error_e am::ControlReceiver::getSocketHandler(SocketHandler *& socketHandler)
}
+uint16_t ControlReceiver::getInterfaceVersion() const
+{
+ return ControlReceiveVersion;
+}
+
+
+
+
diff --git a/AudioManagerDaemon/src/ControlSender.cpp b/AudioManagerDaemon/src/ControlSender.cpp
index cc0c6bb..a9e9220 100644
--- a/AudioManagerDaemon/src/ControlSender.cpp
+++ b/AudioManagerDaemon/src/ControlSender.cpp
@@ -1,9 +1,26 @@
-/*
- * ControlSender.cpp
- *
- * Created on: Dec 9, 2011
- * Author: christian
- */
+/**
+* Copyright (C) 2011, BMW AG
+*
+* GeniviAudioMananger AudioManagerDaemon
+*
+* \file ControlSender.cpp
+*
+* \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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
+* 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.
+*
+*/
#include "ControlSender.h"
#include <assert.h>
@@ -14,6 +31,8 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
+#define REQUIRED_MIN_INTERFACE_VERSION 1
+
ControlSender::ControlSender(std::string controlPluginFile)
:mlibHandle(NULL),
mController(NULL)
@@ -24,6 +43,9 @@ ControlSender::ControlSender(std::string controlPluginFile)
createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile,mlibHandle);
assert(createFunc!=NULL);
mController = createFunc();
+
+ //check libversion
+ assert(REQUIRED_MIN_INTERFACE_VERSION<=mController->getInterfaceVersion());
}
else
{
@@ -303,5 +325,22 @@ void ControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am
return mController->cbAckSetSinkSoundProperty(handle,error);
}
+void ControlSender::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+ return mController->cbAckSetSinkSoundProperties(handle,error);
+}
+
+void ControlSender::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+ return mController->cbAckSetSourceSoundProperties(handle,error);
+}
+
+uint16_t ControlSender::getInterfaceVersion() const
+{
+ return ControlSendVersion;
+}
+
+
+
diff --git a/AudioManagerDaemon/src/DBusWrapper.cpp b/AudioManagerDaemon/src/DBusWrapper.cpp
index 66a135a..cb332ef 100644
--- a/AudioManagerDaemon/src/DBusWrapper.cpp
+++ b/AudioManagerDaemon/src/DBusWrapper.cpp
@@ -39,7 +39,7 @@ DLT_IMPORT_CONTEXT(AudioManager)
#define ROOT_INTROSPECT_XML \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
"<node>" \
-"<interface name='orAudioManagerg.freedesktop.DBus.Introspectable'>" \
+"<interface name='org.AudioManager.freedesktop.DBus.Introspectable'>" \
"<method name='Introspect'>" \
" <arg name='xml_data' type='s' direction='out'/>" \
"</method>" \
diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp
index 021868c..76aadf8 100644
--- a/AudioManagerDaemon/src/DatabaseHandler.cpp
+++ b/AudioManagerDaemon/src/DatabaseHandler.cpp
@@ -23,6 +23,7 @@
*/
#include "DatabaseHandler.h"
+#include "DatabaseObserver.h"
#include <assert.h>
#include <vector>
#include <fstream>
diff --git a/AudioManagerDaemon/src/DatabaseObserver.cpp b/AudioManagerDaemon/src/DatabaseObserver.cpp
index f6b1930..63f3b02 100644
--- a/AudioManagerDaemon/src/DatabaseObserver.cpp
+++ b/AudioManagerDaemon/src/DatabaseObserver.cpp
@@ -23,9 +23,10 @@
*/
#include "DatabaseObserver.h"
-#include <assert.h>
#include "CommandSender.h"
#include "RoutingSender.h"
+#include "TelnetServer.h"
+#include <assert.h>
using namespace am;
@@ -37,6 +38,16 @@ DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender
assert(mRoutingSender!=0);
}
+DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, TelnetServer *iTelnetServer)
+ :mCommandSender(iCommandSender),
+ mRoutingSender(iRoutingSender),
+ mTelnetServer(iTelnetServer)
+{
+ assert(mCommandSender!=0);
+ assert(mRoutingSender!=0);
+ assert(mTelnetServer!=0);
+}
+
DatabaseObserver::~DatabaseObserver() {
// TODO Auto-generated destructor stub
}
@@ -206,3 +217,6 @@ void DatabaseObserver::timingInformationChanged(const am_mainConnectionID_t main
+
+
+
diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp
index 5629e67..93fd925 100644
--- a/AudioManagerDaemon/src/RoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/RoutingReceiver.cpp
@@ -24,6 +24,13 @@
*/
#include "RoutingReceiver.h"
+#include <SocketHandler.h>
+#ifdef WITH_DBUS_WRAPPER
+#include <dbus/DBusWrapper.h>
+#endif
+#include "DatabaseHandler.h"
+#include "RoutingSender.h"
+#include "ControlSender.h"
#include <assert.h>
using namespace am;
@@ -149,7 +156,6 @@ void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am
RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
if(error==E_OK && handleData.sinkID!=0)
{
- //todo: check if volume in handleData is same than volume. React to it.
mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID);
}
mRoutingSender->removeHandle(handle);
@@ -157,6 +163,21 @@ void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am
}
+void am::RoutingReceiver::ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+ RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
+ if(error==E_OK && handleData.sinkID!=0)
+ {
+ std::vector<am_SoundProperty_s>::const_iterator it=handleData.soundProperties->begin();
+ for(;it!=handleData.soundProperties->end();++it)
+ {
+ mDatabaseHandler->changeSinkSoundPropertyDB(*it,handleData.sinkID);
+ }
+ delete handleData.soundProperties;
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSinkSoundProperties(handle,error);
+}
void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
@@ -164,7 +185,6 @@ void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const
RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
if(error==E_OK && handleData.sourceID!=0)
{
- //todo: check if volume in handleData is same than volume. React to it.
mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID);
}
mRoutingSender->removeHandle(handle);
@@ -172,6 +192,21 @@ void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const
}
+void am::RoutingReceiver::ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+ RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
+ if(error==E_OK && handleData.sourceID!=0)
+ {
+ std::vector<am_SoundProperty_s>::const_iterator it=handleData.soundProperties->begin();
+ for(;it!=handleData.soundProperties->end();++it)
+ {
+ mDatabaseHandler->changeSourceSoundPropertyDB(*it,handleData.sourceID);
+ }
+ delete handleData.soundProperties;
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSourceSoundProperties(handle,error);
+}
void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
{
@@ -355,7 +390,7 @@ am_Error_e RoutingReceiver::peekSourceClassID(const std::string name, const am_s
return E_NOT_USED;
}
-am_Error_e am::RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *& dbusConnectionWrapper) const
+am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *& dbusConnectionWrapper) const
{
#ifdef WITH_DBUS_WRAPPER
dbusConnectionWrapper=mDBusWrapper;
@@ -366,7 +401,7 @@ am_Error_e am::RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *& dbusConn
}
-am_Error_e am::RoutingReceiver::getSocketHandler(SocketHandler *& socketHandler) const
+am_Error_e RoutingReceiver::getSocketHandler(SocketHandler *& socketHandler) const
{
#ifdef WITH_SOCKETHANDLER_LOOP
socketHandler=mSocketHandler;
@@ -376,5 +411,12 @@ am_Error_e am::RoutingReceiver::getSocketHandler(SocketHandler *& socketHandler)
#endif
}
+uint16_t RoutingReceiver::getInterfaceVersion() const
+{
+ return RoutingReceiveVersion;
+}
+
+
+
diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp
index 3b5bdad..2b2adb5 100644
--- a/AudioManagerDaemon/src/RoutingSender.cpp
+++ b/AudioManagerDaemon/src/RoutingSender.cpp
@@ -32,6 +32,8 @@
using namespace am;
+#define REQUIRED_INTERFACE_VERSION 1
+
#define CALL_ALL_INTERFACES(...) \
std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin(); \
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end(); \
@@ -99,7 +101,7 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
for (; iter != iterEnd; ++iter)
{
- //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading Hook plugin"),DLT_STRING(iter->c_str()));
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin: "),DLT_STRING(iter->c_str()));
RoutingSendInterface* (*createFunc)();
void* tempLibHandle=NULL;
@@ -107,7 +109,7 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
if (!createFunc)
{
- // DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of Communicator not found"));
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of RoutingPlugin not found"));
continue;
}
@@ -115,13 +117,21 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
if (!router)
{
- //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("HookPlugin initialization failed. Entry Function not callable"));
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Entry Function not callable"));
continue;
}
InterfaceNamePairs routerInterface;
routerInterface.routingInterface = router;
+ //check libversion
+ if (router->getInterfaceVersion()<REQUIRED_INTERFACE_VERSION)
+ {
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Version of Interface to old"));
+ continue;
+ }
+
+
//here, the busname is saved together with the interface. Later The domains will register with the name and sinks, sources etc with the domain....
router->returnBusName(routerInterface.busName);
assert(!routerInterface.busName.empty());
@@ -134,6 +144,16 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
RoutingSender::~RoutingSender()
{
unloadLibraries();
+ HandlesMap::iterator it=mlistActiveHandles.begin();
+
+ //clean up heap if existent
+ for(;it!=mlistActiveHandles.end();++it)
+ {
+ if (it->first.handleType==H_SETSINKSOUNDPROPERTIES || it->first.handleType==H_SETSOURCESOUNDPROPERTIES)
+ {
+ delete it->second.soundProperties;
+ }
+ }
}
void RoutingSender::routingInterfacesReady()
@@ -263,11 +283,10 @@ am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const a
handle=createHandle(handleData,H_SETSINKSOUNDPROPERTY);
mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSinkSoundProperty(handle,soundProperty,sinkID);
- return E_NON_EXISTENT;
+ return (E_NON_EXISTENT);
}
-
am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
am_handleData_c handleData;
@@ -279,11 +298,39 @@ am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const
handle=createHandle(handleData,H_SETSOURCESOUNDPROPERTY);
mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSourceSoundProperty(handle,soundProperty,sourceID);
- return E_NON_EXISTENT;
+ return (E_NON_EXISTENT);
}
+am_Error_e am::RoutingSender::asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sourceID_t sourceID)
+{
+ am_handleData_c handleData;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter=mMapSourceInterface.find(sourceID);
+ if (iter != mMapSourceInterface.end())
+ handleData.sourceID=sourceID;
+ handleData.soundProperties=new std::vector<am_SoundProperty_s>(listSoundProperties);
+ handle=createHandle(handleData,H_SETSOURCESOUNDPROPERTIES);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
+ return iter->second->asyncSetSourceSoundProperties(handle,listSoundProperties,sourceID);
+ return (E_NON_EXISTENT);
+}
+am_Error_e am::RoutingSender::asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sinkID_t sinkID)
+{
+ am_handleData_c handleData;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter=mMapSinkInterface.find(sinkID);
+ if (iter != mMapSinkInterface.end())
+ handleData.sinkID=sinkID;
+ handleData.soundProperties=new std::vector<am_SoundProperty_s>(listSoundProperties);
+ handle=createHandle(handleData,H_SETSINKSOUNDPROPERTIES);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
+ return iter->second->asyncSetSinkSoundProperties(handle,listSoundProperties,sinkID);
+ return (E_NON_EXISTENT);
+
+}
+
am_Error_e RoutingSender::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_handleData_c handleData;
@@ -455,9 +502,9 @@ am_Handle_s RoutingSender::createHandle(const am_handleData_c& handleData, const
return handle;
}
-RoutingSender::am_handleData_c RoutingSender::returnHandleData(am_Handle_s handle)
+RoutingSender::am_handleData_c RoutingSender::returnHandleData(const am_Handle_s handle) const
{
- HandlesMap::iterator it=mlistActiveHandles.begin();
+ HandlesMap::const_iterator it=mlistActiveHandles.begin();
it=mlistActiveHandles.find(handle);
return (it->second);
}
@@ -472,6 +519,26 @@ void RoutingSender::unloadLibraries(void)
mListLibraryHandles.clear();
}
+am_Error_e am::RoutingSender::getListPlugins(std::vector<std::string>& interfaces) const
+{
+ std::vector<InterfaceNamePairs>::const_iterator it=mListInterfaces.begin();
+ for(;it!=mListInterfaces.end();++it)
+ {
+ interfaces.push_back(it->busName);
+ }
+ return E_OK;
+}
+
+
+uint16_t RoutingSender::getInterfaceVersion() const
+{
+ return (RoutingSendVersion);
+}
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/TelnetServer.cpp b/AudioManagerDaemon/src/TelnetServer.cpp
new file mode 100644
index 0000000..3e77b0b
--- /dev/null
+++ b/AudioManagerDaemon/src/TelnetServer.cpp
@@ -0,0 +1,270 @@
+/**
+* Copyright (C) 2011, BMW AG
+*
+* GeniviAudioMananger AudioManagerDaemon
+*
+* \file TelnetServer.cpp
+*
+* \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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
+* 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.
+*
+*/
+
+#include "TelnetServer.h"
+#include <assert.h>
+#include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+#include <sys/ioctl.h>
+#include <string.h>
+#include <netdb.h>
+#include <dlt/dlt.h>
+#include <config.h>
+#include <errno.h>
+#include <sstream>
+#include <istream>
+#include <iostream>
+#include <iterator>
+#include "DatabaseHandler.h"
+#include "RoutingSender.h"
+
+using namespace am;
+
+DLT_IMPORT_CONTEXT(AudioManager)
+
+TelnetServer* TelnetServer::instance=NULL;
+
+#define PRINT_BOOL(var) var ? output+="true\t\t" : output+="false\t\t";
+
+TelnetServer::TelnetServer(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, unsigned int servPort, unsigned int maxConnections)
+ :telnetConnectFiredCB(this,&TelnetServer::connectSocket),
+ telnetReceiveFiredCB(this,&TelnetServer::receiveData),
+ telnetDispatchCB(this,&TelnetServer::dispatchData),
+ telnetCheckCB(this,&TelnetServer::check),
+ mSocketHandler(iSocketHandler),
+ mCommandSender(iCommandSender),
+ mCommandReceiver(iCommandReceiver),
+ mRoutingSender(iRoutingSender),
+ mRoutingReceiver(iRoutingReceiver),
+ mControlSender(iControlSender),
+ mControlReceiver(iControlReceiver),
+ mDatabasehandler(iDatabasehandler),
+ mConnecthandle(),
+ msgList(),
+ mListConnections(),
+ mConnectFD(NULL),
+ mServerPort(servPort),
+ mMaxConnections(maxConnections),
+ mMapCommands(createCommandMap())
+{
+ assert(mSocketHandler!=NULL);
+ assert(mCommandReceiver!=NULL);
+ assert(mCommandSender!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mControlReceiver!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mRoutingReceiver!=NULL);
+ assert(mDatabasehandler!=NULL);
+ assert(servPort!=0);
+ assert(mMaxConnections!=0);
+
+ instance=this;
+
+ int yes =1;
+ struct sockaddr_in servAddr;
+
+ //setup the port Listener
+ mConnectFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ setsockopt(mConnectFD, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
+ memset(&servAddr, 0, sizeof(servAddr));
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = INADDR_ANY;
+ servAddr.sin_port = htons(servPort);
+ bind(mConnectFD, (struct sockaddr *) &servAddr, sizeof(servAddr));
+
+ if (listen(mConnectFD,mMaxConnections) < 0)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("TelnetServer::TelnetServerk cannot listen "),DLT_INT(errno));
+ }
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("TelnetServer::TelnetServerk started listening on port"),DLT_INT(mServerPort));
+
+ int a=1;
+ ioctl (mConnectFD, FIONBIO, (char *) &a);
+ setsockopt (mConnectFD, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof (a));
+
+ short events=0;
+ events |= POLLIN;
+ mSocketHandler->addFDPoll(mConnectFD,events,NULL,&telnetConnectFiredCB,NULL,NULL,NULL,mConnecthandle);
+}
+
+TelnetServer::~TelnetServer()
+{
+}
+
+void TelnetServer::connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void *userData)
+{
+ //first, accept the connection, create a new filedescriptor
+ struct sockaddr answer;
+ socklen_t len=sizeof(answer);
+ connection_s connection;
+ connection.filedescriptor = accept(pfd.fd, (struct sockaddr*)&answer, &len);
+
+ mListConnections.push_back(connection);
+
+ //set the correct event:
+ short event = 0;
+ event |=POLLIN;
+
+ //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
+ mSocketHandler->addFDPoll(mListConnections.back().filedescriptor,event,NULL,&telnetReceiveFiredCB,&telnetCheckCB,&telnetDispatchCB,NULL,mListConnections.back().handle);
+}
+
+
+
+void TelnetServer::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
+{
+ //initialize buffer
+ char buffer[100];
+ //read until buffer is full or no more data is there
+ int read=recv(pollfd.fd,buffer,100,NULL);
+ if (read>1)
+ {
+ //read the message and store it in a queue - its a telnet connection so data will be sent on enter !
+ std::string msg=std::string(buffer,read);
+ msgList.push(msg);
+ }
+}
+
+
+
+bool TelnetServer::dispatchData(const sh_pollHandle_t handle, void *userData)
+{
+ std::vector<connection_s>::iterator iterator=mListConnections.begin();
+ for(;iterator!=mListConnections.end();++iterator)
+ {
+ if(iterator->handle==handle) break;
+ }
+ if (iterator==mListConnections.end()) return false;
+
+ std::string command;
+ std::vector<std::string> msg;
+ sliceCommand(msgList.front(),command,msg);
+ msgList.pop();
+ mMapCommand_t::iterator commandIter=mMapCommands.find(command);
+ if (commandIter==mMapCommands.end())
+ {
+ send(iterator->filedescriptor,"Command not found!\n",20,0);
+ }
+ else
+ {
+ (*commandIter).second(msg,iterator->filedescriptor);
+ }
+
+ //remove the message from the queue and return false if there is no more message to read.
+ if (msgList.size()!=0) return true;
+ return false;
+}
+
+
+
+
+bool TelnetServer::check(const sh_pollHandle_t handle, void *userData)
+{
+ if (msgList.size()!=0) return true;
+ return false;
+}
+
+void TelnetServer::listCommand(std::vector<std::string>& msg, int filedescriptor)
+{
+ instance->listCommandShadow(msg,filedescriptor);
+}
+
+void am::TelnetServer::listCommandShadow(std::vector<std::string> & msg, int filedescriptor)
+{
+ std::string output;
+ if(msg.empty())
+ {
+ output+="No second parameter given after list, please enter\n";
+ }
+ else if(msg.front().compare("plugins")==0)
+ {
+ std::vector<std::string> plugins;
+ mRoutingSender->getListPlugins(plugins);
+ std::vector<std::string>::iterator it=plugins.begin();
+ output="\n\nrouting plugins:\n-------------------------\n";
+ for(;it!=plugins.end();++it)
+ {
+ output+=*it+"\n";
+ }
+ }
+ else if(msg.front().compare("domains")==0)
+ {
+ output="domainID\t\tdomainName\t\tbusName\t\tnodeName\t\tearly\t\tstate\t\tcomplete\n";
+ output+="-------------------------------------------------------------------------------------\n";
+ std::vector<am_Domain_s> domainList;
+ mDatabasehandler->getListDomains(domainList);
+ std::vector<am_Domain_s>::iterator it=domainList.begin();
+ for(;it!=domainList.end();++it)
+ {
+ output+=it->domainID + "\t\t";
+ output+=it->name + "\t\t";
+ output+=it->busname + "\t\t";
+ output+=it->nodename + "\t\t";
+ PRINT_BOOL(it->early);
+ switch (it->state)
+ {
+ case DS_CONTROLLED:
+ output+="DS_CONTROLLED\t\t";
+ break;
+ case DS_INDEPENDENT_STARTUP:
+ output+="DS_INDEPENDENT_STARTUP\t\t";
+ break;
+ case DS_INDEPENDENT_RUNDOWN:
+ output+="DS_INDEPENDENT_RUNDOWN\t\t";
+ break;
+ default:
+ output+="undefined\t\t";
+ break;
+ }
+ PRINT_BOOL(it->complete);
+ }
+ }
+ else
+ {
+ output="did not recognize parameter: " + msg.front()+"\n";
+ }
+ send(filedescriptor,output.c_str(),output.size(),0);
+}
+
+
+void am::TelnetServer::sliceCommand(const std::string & string, std::string & command, std::vector<std::string> & msg)
+{
+ std::stringstream stream(string);
+ std::istream_iterator<std::string> begin(stream);
+ std::istream_iterator<std::string> end;
+ command=*begin++;
+ msg=std::vector<std::string>(begin, end);
+}
+
+TelnetServer::mMapCommand_t TelnetServer::createCommandMap()
+{
+ mMapCommand_t commands;
+ commands.insert(std::make_pair("list",&TelnetServer::listCommand));
+ return commands;
+}
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 5d840a9..d5c447d 100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -36,19 +36,21 @@
//todo: make sure all configurations are tested
#include <config.h>
+#include <SocketHandler.h>
#ifdef WITH_DBUS_WRAPPER
#include <dbus/DBusWrapper.h>
#endif
#include "DatabaseHandler.h"
-#include "DatabaseObserver.h"
-#include "RoutingReceiver.h"
-#include "CommandReceiver.h"
-#include "ControlReceiver.h"
#include "ControlSender.h"
#include "CommandSender.h"
#include "RoutingSender.h"
-#include <SocketHandler.h>
+#include "RoutingReceiver.h"
+#include "CommandReceiver.h"
+#include "ControlReceiver.h"
+#include "DatabaseObserver.h"
+#include "TelnetServer.h"
#include <sys/resource.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <cstdlib>
@@ -58,8 +60,6 @@
#include <string.h>
#include <stdio.h>
-
-
#include <dlt/dlt.h>
DLT_DECLARE_CONTEXT(AudioManager)
@@ -69,19 +69,24 @@ using namespace am;
const char* USAGE_DESCRIPTION = "Usage:\tAudioManagerDaemon [options]\n"
"options:\t\n"
"\t-h: print this message\t\n"
+ "\t-i: info about current settings \t\n"
"\t-v: print version\t\n"
"\t-d: daemonize AudioManager \t\n"
- "\t-p: path for sqlite database (default is in memory)\t\n"
- "\t-c: <Name> use controllerPlugin <Name> (full path with .so ending)\t\n"
- "\t-l: <Name> replace command plugin directory with <Name> (full path)\t\n"
- "\t-r: <Name> replace routing plugin directory with <Name> (full path)\t\n"
- "\t-L: <Name> add command plugin directory with <Name> (full path)\t\n"
- "\t-R: <Name> add routing plugin directory with <Name> (full path)\t\n";
+ "\t-p<path> path for sqlite database (default is in memory)\t\n"
+ "\t-t<port> port for telnetconnection\t\n"
+ "\t-m<max> number of max telnetconnections\t\n"
+ "\t-c<Name> use controllerPlugin <Name> (full path with .so ending)\t\n"
+ "\t-l<Name> replace command plugin directory with <Name> (full path)\t\n"
+ "\t-r<Name> replace routing plugin directory with <Name> (full path)\t\n"
+ "\t-L<Name> add command plugin directory with <Name> (full path)\t\n"
+ "\t-R<Name> add routing plugin directory with <Name> (full path)\t\n";
std::string controllerPlugin=std::string(CONTROLLER_PLUGIN);
std::vector<std::string> listCommandPluginDirs;
std::vector<std::string> listRoutingPluginDirs;
std::string databasePath=std::string(":memory:");
+unsigned int telnetport=DEFAULT_TELNETPORT;
+unsigned int maxConnections=MAX_TELNETCONNECTIONS;
void daemonize ()
{
@@ -136,10 +141,29 @@ void parseCommandLine(int argc, char **argv)
{
while (optind < argc)
{
- int option = getopt (argc, argv, "h::v::c::l::r::L::R::d");
+ int option = getopt (argc, argv, "h::v::c::l::r::L::R::d::t::m::i::");
switch (option)
{
+ case 'i':
+ printf("Current settings:\n");
+ printf("\tAudioManagerDaemon Version:\t\t%s\n",DAEMONVERSION);
+ printf("\tTelnet portNumber:\t\t\t%i\n",telnetport);
+ printf("\tTelnet maxConnections:\t\t\t%i\n",maxConnections);
+ printf("\tSqlite Database path:\t\t\t%s\n",databasePath.c_str());
+ printf("\tControllerPlugin: \t\t\t%s\n",controllerPlugin.c_str());
+ printf("\tDirectory of CommandPlugins: \t\t%s\n",listCommandPluginDirs.front().c_str());
+ printf("\tDirectory of RoutingPlugins: \t\t%s\n",listRoutingPluginDirs.front().c_str());
+ exit(0);
+ break;
+ case 't':
+ assert(atoi(optarg)!=0);
+ telnetport=atoi(optarg);
+ break;
+ case 'm':
+ assert(atoi(optarg)!=0);
+ maxConnections=atoi(optarg);
+ break;
case 'p':
assert(!controllerPlugin.empty());
databasePath=std::string(optarg);
@@ -215,7 +239,6 @@ int main(int argc, char *argv[])
signalChildAction.sa_flags = SA_NOCLDWAIT;
sigaction (SIGCHLD, &signalChildAction, NULL);
-
//Instantiate all classes. Keep in same order !
#ifdef WITH_SOCKETHANDLER_LOOP
SocketHandler iSocketHandler;
@@ -233,13 +256,15 @@ int main(int argc, char *argv[])
RoutingSender iRoutingSender(listRoutingPluginDirs);
CommandSender iCommandSender(listCommandPluginDirs);
ControlSender iControlSender(controllerPlugin);
- DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
#ifdef WITH_DBUS_WRAPPER
#ifdef WITH_SOCKETHANDLER_LOOP
CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler,&iDBusWrapper);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler,&iDBusWrapper);
ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
+#ifdef WITH_TELNET
+ TelnetServer iTelnetServer(&iSocketHandler,&iCommandSender,&iCommandReceiver,&iRoutingSender,&iRoutingReceiver,&iControlSender,&iControlReceiver,&iDatabaseHandler,telnetport,maxConnections);
+#endif
#else /*WITH_SOCKETHANDLER_LOOP */
CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iDBusWrapper);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iDBusWrapper);
@@ -249,8 +274,18 @@ int main(int argc, char *argv[])
CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
+#ifdef WITH_TELNET
+ TelnetServer iTelnetServer(&iSocketHandler,telnetport,maxConnections);
+#endif
#endif /*WITH_DBUS_WRAPPER*/
+#ifdef WITH_TELNET
+ DatabaseObserver iObserver(&iCommandSender, &iRoutingSender,&iTelnetServer);
+#else
+ DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
+#endif
+
+
//since the plugins have been loaded by the *Senders before, we can tell the Controller this:
iControlSender.hookAllPluginsLoaded();