summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfaceDbus/include
diff options
context:
space:
mode:
authorSampreeth Ramavana <sampreeth.ramavana@aricent.com>2012-04-04 13:51:32 +0530
committerchristian mueller <christian.ei.mueller@bmw.de>2012-04-04 15:37:00 +0200
commit1f4b52faf447b12f1900c91db5090e04feb33578 (patch)
treeca39c1f1f91a7116076c3ea15c40bbf24a2911d8 /PluginRoutingInterfaceDbus/include
parent9a7af2bfaea3f3a84785e1379652020002452508 (diff)
downloadaudiomanager-1f4b52faf447b12f1900c91db5090e04feb33578.tar.gz
adding a pulseaudio plugin to genivi audiomanager implements dbus methods for registering domain, source and sinks implements dbus signals and methods for receiving information from pulseaudio calls dbus methods in pulseaudio
Signed-off-by: Sampreeth Ramavana <sampreeth.ramavana@aricent.com>
Diffstat (limited to 'PluginRoutingInterfaceDbus/include')
-rw-r--r--PluginRoutingInterfaceDbus/include/CAmDbusMessageHandler.h123
-rw-r--r--PluginRoutingInterfaceDbus/include/CAmDbusSend.h44
-rw-r--r--PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h17
-rw-r--r--PluginRoutingInterfaceDbus/include/IAmRoutingReceiverShadow.h98
-rw-r--r--PluginRoutingInterfaceDbus/include/RoutingReceiver.xml84
5 files changed, 366 insertions, 0 deletions
diff --git a/PluginRoutingInterfaceDbus/include/CAmDbusMessageHandler.h b/PluginRoutingInterfaceDbus/include/CAmDbusMessageHandler.h
new file mode 100644
index 0000000..69f5d34
--- /dev/null
+++ b/PluginRoutingInterfaceDbus/include/CAmDbusMessageHandler.h
@@ -0,0 +1,123 @@
+/**
+ * Copyright (c) copyright 2011-2012 Aricent® Group and its licensors
+ *
+ * \author: Sampreeth Ramavana
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef _CAMSDBUSMESSAGEHANDLER_H_
+#define _CAMSDBUSMESSAGEHANDLER_H_
+
+
+#include <audiomanagertypes.h>
+#include <dbus/dbus.h>
+#include <dlt/dlt.h>
+#include <vector>
+#include <sstream>
+#include <string>
+#include <list>
+
+namespace am {
+
+
+/**
+ * handles DBus Messages, is used to extract & append parameters and send messages
+ */
+class CAmDbusMessageHandler
+{
+public:
+ CAmDbusMessageHandler();
+ ~CAmDbusMessageHandler();
+
+ /**
+ * sets the DBus Connection
+ * @param connection pointer to the DBus Connection
+ */
+ void setDBusConnection(DBusConnection*& connection);
+
+ /**
+ * is called to initiate the receiving of a message
+ * @param msg pointer to the message to be received
+ */
+ void initReceive(DBusMessage* msg);
+
+ /**
+ * is called to initiate the reply to a message
+ * @param msg pointer to the message the reply is for
+ */
+ void initReply(DBusMessage* msg);
+
+ /**
+ * inits a signal to be sent via dbus
+ * parameters can be added before sending the signal
+ * @param path the path
+ * @param signalName the signal name
+ */
+ void initSignal(std::string path, std::string signalName);
+
+ /**
+ * sends out the message
+ */
+ void sendMessage();
+
+ /**
+ * the get functions return a value from the received dbus message
+ * @return
+ */
+ dbus_uint16_t getUInt();
+ dbus_int16_t getInt();
+ dbus_uint32_t getUInt32();
+ dbus_int32_t getInt32();
+ dbus_bool_t getBool();
+ char getByte();
+ double getDouble();
+ char* getString();
+ void getProperty(dbus_int16_t& type, dbus_int16_t& value);
+
+ /**
+ * the overloaded append function appends different datatypes to the dbusmessage
+ */
+ void append(dbus_int16_t toAppend);
+ void append(dbus_uint16_t toAppend);
+ void append(dbus_uint32_t toAppend);
+ void append(char toAppend);
+ void append(bool toAppend);
+ void append(double toAppend);
+ void append(const am::am_SinkType_s& sinkType);
+ void append(const am::am_SourceType_s& sourceType);
+ void append(const am::am_MainSoundProperty_s mainSoundProperty);
+ void append(const am::am_Availability_s & availability);
+ void append(const am::am_SystemProperty_s & SystemProperty);
+ void append(const std::vector<am::am_MainConnectionType_s>& listMainConnections);
+ void append(const std::vector<am::am_SinkType_s>& listMainSinks);
+ void append(const std::vector<am::am_SourceType_s>& listMainSources);
+ void append(const std::vector<am::am_MainSoundProperty_s>& listMainSoundProperties);
+ void append(const std::vector<am::am_SourceClass_s>& listSourceClasses);
+ void append(const std::vector<am::am_SinkClass_s>& listSinkClasses);
+ void append(const std::vector<am::am_SystemProperty_s>& listSystemProperties);
+
+private:
+
+ DBusMessageIter mDBusMessageIter;
+ DBusError mDBusError;
+ dbus_uint32_t mSerial;
+ std::string mErrorName;
+ std::string mErrorMsg;
+ DBusMessage* mDbusMessage;
+ DBusMessage* mReveiveMessage;
+ DBusConnection* mDBusConnection;
+};
+
+}
+
+#endif // _CAMSDBUSMESSAGEHANDLER_H_
diff --git a/PluginRoutingInterfaceDbus/include/CAmDbusSend.h b/PluginRoutingInterfaceDbus/include/CAmDbusSend.h
new file mode 100644
index 0000000..65fe0bd
--- /dev/null
+++ b/PluginRoutingInterfaceDbus/include/CAmDbusSend.h
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) copyright 2011-2012 Aricent® Group and its licensors
+ *
+ * \author: Sampreeth Ramavana
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef _CAMDBUSSEND_H_
+#define _CAMDBUSSEND_H_
+
+//#include "headers.h"
+#include <dbus/dbus.h>
+
+class CAmDbusSend {
+public:
+ CAmDbusSend(DBusConnection* conn, const char* bus_name,const char* path, const char* interface, const char* method);
+ virtual ~CAmDbusSend();
+ void appendString(char* string);
+ void appendInteger(int integer);
+ void sendReply(bool* reply);
+ void sendReply(int* reply);
+ void sendReply(void);
+ void Replyint32(int *reply);
+
+private:
+ DBusMessage* m_msg;
+ DBusMessageIter m_args;
+ DBusConnection* m_conn;
+ DBusMessage* replymsg;
+ //DBusMessageIter args;
+ DBusMessageIter mDBusMessageIter;
+};
+
+#endif /* _CAMDBUSSEND_H_ */
diff --git a/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h b/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h
index 5a63395..fb727a3 100644
--- a/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h
+++ b/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h
@@ -19,9 +19,16 @@
#define ROUTINGSENDER_H_
#include "routing/IAmRoutingSend.h"
+#include <dbus/dbus.h>
+#include <map>
+#include "CAmDbusMessageHandler.h"
+#include "IAmRoutingReceiverShadow.h"
+#include "shared/CAmDbusWrapper.h"
using namespace am;
+const char ROUTING_NODE[]="RoutingReceiver";
+
class CAmRoutingSenderDbus: public IAmRoutingSend
{
public:
@@ -44,6 +51,16 @@ public:
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ;
am_Error_e returnBusName(std::string& BusName) const ;
void getInterfaceVersion(std::string& version) const ;
+
+private:
+ CAmDbusMessageHandler mDBusMessageHandler;
+ IAmRoutingReceiverShadow mRoutingReceiverShadow;
+
+ CAmDbusWrapper* mDBusWrapper;
+ IAmRoutingReceive *mRoutingReceiveInterface;
+
+
+ DBusConnection* connection;
};
#endif /* ROUTINGSENDER_H_ */
diff --git a/PluginRoutingInterfaceDbus/include/IAmRoutingReceiverShadow.h b/PluginRoutingInterfaceDbus/include/IAmRoutingReceiverShadow.h
new file mode 100644
index 0000000..4cd1b2d
--- /dev/null
+++ b/PluginRoutingInterfaceDbus/include/IAmRoutingReceiverShadow.h
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) copyright 2011-2012 Aricent® Group and its licensors
+ *
+ * \author: Sampreeth Ramavana
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef _IAMROUTINGRECEIVERSHADOW_H_
+#define _IAMROUTINGRECEIVERSHADOW_H_
+
+#include "routing/IAmRoutingSend.h"
+#include <dbus/dbus.h>
+#include <dlt/dlt.h>
+#include <map>
+#include "shared/CAmDbusWrapper.h"
+#include "CAmDbusMessageHandler.h"
+
+namespace am {
+
+class IAmRoutingReceiverShadow;
+
+typedef void (IAmRoutingReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message);
+
+/**
+ * receives the DBus Callbacks, marhsalls and demarshalls the parameters and calls CommandReceive
+ */
+class IAmRoutingReceiverShadow {
+public:
+ IAmRoutingReceiverShadow();
+ virtual ~IAmRoutingReceiverShadow();
+ void ackConnect(DBusConnection *conn, DBusMessage *msg) ;
+ void ackDisconnect(DBusConnection *conn, DBusMessage *msg) ;
+ void ackSetSinkVolume(DBusConnection *conn, DBusMessage *msg);
+ void ackSetSourceVolume(DBusConnection *conn, DBusMessage *msg);
+ void ackSinkVolumeTick(DBusConnection *conn, DBusMessage *msg);
+ void ackSourceVolumeTick(DBusConnection *conn, DBusMessage *msg);
+ void ackSetSinkSoundProperty(DBusConnection *conn, DBusMessage *msg);
+ void ackSetSourceSoundProperty(DBusConnection *conn, DBusMessage *msg);
+
+ void registerDomain(DBusConnection *conn, DBusMessage *msg) ;
+ void registerSource(DBusConnection *conn, DBusMessage *msg) ;
+ void registerSink(DBusConnection *conn, DBusMessage *msg) ;
+ void registerGateway(DBusConnection *conn, DBusMessage *msg) ;
+ void hookDomainRegistrationComplete(DBusConnection *conn, DBusMessage *msg);
+
+ /**
+ * sets the pointer to the CommandReceiveInterface and registers Callback
+ * @param receiver
+ */
+ void setRoutingReceiver(IAmRoutingReceive*& receiver);
+private:
+ IAmRoutingReceive* mRoutingReceiveInterface;
+ CAmDbusWrapper* mDBusWrapper;
+ typedef std::map<std::string,CallBackMethod> functionMap_t;
+ functionMap_t mFunctionMap;
+ CAmDbusMessageHandler mDBUSMessageHandler;
+
+ /**
+ * receives a callback whenever the path of the plugin is called
+ */
+ static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
+
+ /**
+ * dynamic delegate that handles the Callback of the static receiveCallback
+ * @param conn DBus connection
+ * @param msg DBus message
+ * @param user_data pointer to instance of IAmRoutingReceiverShadow
+ * @return
+ */
+ DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg);
+
+ /**
+ * sends out introspectiondata read from an xml file.
+ * @param conn
+ * @param msg
+ */
+ void sendIntrospection(DBusConnection* conn, DBusMessage* msg) ;
+
+ /**
+ * creates the function map needed to combine DBus messages and function adresses
+ * @return the map
+ */
+ functionMap_t createMap();
+};
+
+}
+
+#endif /* _IAMROUTINGRECEIVERSHADOW_H_ */
diff --git a/PluginRoutingInterfaceDbus/include/RoutingReceiver.xml b/PluginRoutingInterfaceDbus/include/RoutingReceiver.xml
new file mode 100644
index 0000000..78e06e3
--- /dev/null
+++ b/PluginRoutingInterfaceDbus/include/RoutingReceiver.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node PUBLIC
+ "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
+ "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
+
+<node>
+ <interface name="org.genivi.audiomanager.RoutingReceiver">
+
+ <method name="ackConnect">
+ <arg name="handle" type="i" direction="in" />
+ <arg name="connectionID" type="i" direction="in" />
+ <arg name="error" type="i" direction="in" />
+ </method>
+ <method name="ackDisconnect">
+ <arg name="handle" type="i" direction="in" />
+ <arg name="connectionID" type="i" direction="in" />
+ <arg name="error" type="i" direction="in" />
+ </method>
+ <method name="ackSetSinkVolumeChange">
+ <arg name="handle" type="i" direction="in" />
+ <arg name="volume" type="i" direction="in" />
+ <arg name="error" type="i" direction="in" />
+ </method>
+ <method name="ackSetSourceVolumeChange">
+ <arg name="handle" type="i" direction="in" />
+ <arg name="connectionID" type="i" direction="in" />
+ <arg name="error" type="i" direction="in" />
+ </method>
+ <method name="ackSetSourceState">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="error" type="n" direction="in" />
+ </method>
+ <method name="ackSetSinkSoundProperty">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="error" type="n" direction="in" />
+ </method>
+ <method name="ackSetSourceSoundProperty">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="error" type="n" direction="in" />
+ </method>
+ <method name="ackCrossFading">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="hotsink" type="q" direction="in" />
+ <arg name="error" type="n" direction="in" />
+ </method>
+ <method name="ackSourceVolumeTick">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="source" type="q" direction="in" />
+ <arg name="volume" type="n" direction="in" />
+ </method>
+ <method name="ackSinkVolumeTick">
+ <arg name="handle" type="u" direction="in" />
+ <arg name="sink" type="q" direction="in" />
+ <arg name="volume" type="n" direction="in" />
+ </method>
+
+
+ <method name="peekDomain">
+ <arg name="name" type="s" direction="in" />
+ <arg name="domainid" type="q" direction="in" />
+ </method>
+ <method name="registerDomain">
+ <arg name="domaindata" type="(qsssbbq)" direction="in" />
+ <arg name="domainid" type="q" direction="in" />
+ </method>
+ <method name="deregisterDomain">
+ <arg name="domainid" type="q" direction="in" />
+ </method>
+
+
+ <method name="registerSource">
+ <arg name="soucedata" type="(qqsqqnb(qq)q)" direction="in" />
+ <arg name="sourceid" type="q" direction="in" />
+ </method>
+
+ <method name="deregisterSource">
+ <arg name="sourceid" type="q" direction="in" />
+ </method>
+
+ <signal name="signal_systemReady">
+ </signal>
+
+ </interface>
+</node>