summaryrefslogtreecommitdiff
path: root/orkaudio/messages
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2005-10-20 13:40:58 +0000
committerHenri Herscher <henri@oreka.org>2005-10-20 13:40:58 +0000
commit7e1d63dd9fd149e4934bf77095c8610fac786b04 (patch)
tree5fe486a1b0300c3b84fb559107a868e5cc2c95da /orkaudio/messages
parent467768fc956fc3e5a253373f26c71c681b31b6b8 (diff)
First checkin
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@2 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio/messages')
-rw-r--r--orkaudio/messages/CaptureMsg.cpp84
-rw-r--r--orkaudio/messages/CaptureMsg.h51
-rw-r--r--orkaudio/messages/DeleteTapeMsg.cpp60
-rw-r--r--orkaudio/messages/DeleteTapeMsg.h33
-rw-r--r--orkaudio/messages/Makefile.am7
-rw-r--r--orkaudio/messages/PingMsg.cpp60
-rw-r--r--orkaudio/messages/PingMsg.h46
-rw-r--r--orkaudio/messages/TapeMsg.cpp56
-rw-r--r--orkaudio/messages/TapeMsg.h58
-rw-r--r--orkaudio/messages/TestMsg.cpp53
-rw-r--r--orkaudio/messages/TestMsg.h55
11 files changed, 563 insertions, 0 deletions
diff --git a/orkaudio/messages/CaptureMsg.cpp b/orkaudio/messages/CaptureMsg.cpp
new file mode 100644
index 0000000..f013e1f
--- /dev/null
+++ b/orkaudio/messages/CaptureMsg.cpp
@@ -0,0 +1,84 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Utils.h"
+#include "CaptureMsg.h"
+//#include "LogManager.h"
+#include "CapturePluginProxy.h"
+
+#define CAPTURE_CLASS "capture"
+#define CAPTURE_RESPONSE_CLASS "captureresponse"
+#define CAPTURE_STATE_PARAM "state"
+#define COMMENT_PARAM "comment"
+
+void CaptureResponseMsg::Define(Serializer* s)
+{
+ s->BoolValue(SUCCESS_PARAM, m_success);
+ s->StringValue(COMMENT_PARAM, m_comment);
+}
+
+CStdString CaptureResponseMsg::GetClassName()
+{
+ return CStdString(CAPTURE_RESPONSE_CLASS);
+}
+
+ObjectRef CaptureResponseMsg::NewInstance()
+{
+ return ObjectRef(new CaptureResponseMsg);
+}
+
+//===============================
+
+void CaptureMsg::Define(Serializer* s)
+{
+ CStdString captureClass(CAPTURE_CLASS);
+ s->StringValue(OBJECT_TYPE_TAG, captureClass, true);
+ s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true);
+ s->EnumValue(CAPTURE_STATE_PARAM, (int&)m_eventType, CaptureEvent::EventTypeToEnum, CaptureEvent::EventTypeToString, true);
+}
+
+
+CStdString CaptureMsg::GetClassName()
+{
+ return CStdString(CAPTURE_CLASS);
+}
+
+ObjectRef CaptureMsg::NewInstance()
+{
+ return ObjectRef(new CaptureMsg);
+}
+
+ObjectRef CaptureMsg::Process()
+{
+ CaptureResponseMsg* msg = new CaptureResponseMsg;
+ ObjectRef ref(msg);
+
+ if(m_eventType == CaptureEvent::EtStart)
+ {
+ CapturePluginProxySingleton::instance()->StartCapture(m_capturePort);
+ msg->m_success = true;
+ }
+ else if(m_eventType == CaptureEvent::EtStop)
+ {
+ CapturePluginProxySingleton::instance()->StopCapture(m_capturePort);
+ msg->m_success = true;
+ }
+ else
+ {
+ msg->m_success = false;
+ msg->m_comment = CAPTURE_STATE_PARAM;
+ msg->m_comment += " needs to be start or stop";
+ }
+ return ref;
+}
+
diff --git a/orkaudio/messages/CaptureMsg.h b/orkaudio/messages/CaptureMsg.h
new file mode 100644
index 0000000..782f70f
--- /dev/null
+++ b/orkaudio/messages/CaptureMsg.h
@@ -0,0 +1,51 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef __CAPTUREMSG_H__
+#define __CAPTUREMSG_H__
+
+#include "messages/SyncMessage.h"
+#include "messages/AsyncMessage.h"
+#include "AudioCapture.h"
+
+
+class CaptureResponseMsg : public AsyncMessage
+{
+public:
+ void Define(Serializer* s);
+ inline void Validate() {};
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ bool m_success;
+ CStdString m_comment;
+};
+
+class CaptureMsg : public SyncMessage
+{
+public:
+ void Define(Serializer* s);
+ inline void Validate() {};
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ ObjectRef Process();
+
+ CaptureEvent::EventTypeEnum m_eventType;
+ CStdString m_capturePort;
+};
+
+#endif
+
diff --git a/orkaudio/messages/DeleteTapeMsg.cpp b/orkaudio/messages/DeleteTapeMsg.cpp
new file mode 100644
index 0000000..9dc8dae
--- /dev/null
+++ b/orkaudio/messages/DeleteTapeMsg.cpp
@@ -0,0 +1,60 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "DeleteTapeMsg.h"
+#include "messages/AsyncMessage.h"
+
+#define DELETE_TAPE_CLASS "deletetape"
+
+void DeleteTapeMsg::Define(Serializer* s)
+{
+ CStdString deleteTapeClass(DELETE_TAPE_CLASS);
+ s->StringValue(OBJECT_TYPE_TAG, deleteTapeClass, true);
+ s->StringValue(FILENAME_PARAM, m_filename, true);
+}
+
+
+CStdString DeleteTapeMsg::GetClassName()
+{
+ return CStdString(DELETE_TAPE_CLASS);
+}
+
+ObjectRef DeleteTapeMsg::NewInstance()
+{
+ return ObjectRef(new DeleteTapeMsg);
+}
+
+ObjectRef DeleteTapeMsg::Process()
+{
+ SimpleResponseMsg* msg = new SimpleResponseMsg;
+ ObjectRef ref(msg);
+
+ // Check that the audio file to delete is actually an audio file
+ if(m_filename.Find('/') != -1 && (m_filename.Find(".pcm") != -1 || m_filename.Find(".wav") != -1 ))
+ {
+ if (ACE_OS::unlink((PCSTR)m_filename) == -1)
+ {
+ msg->m_success = false;
+ msg->m_comment = "could not delete file";
+ }
+
+ }
+ else
+ {
+ msg->m_success = false;
+ msg->m_comment = "filename not valid";
+ }
+
+ return ref;
+}
+
diff --git a/orkaudio/messages/DeleteTapeMsg.h b/orkaudio/messages/DeleteTapeMsg.h
new file mode 100644
index 0000000..33fb9ae
--- /dev/null
+++ b/orkaudio/messages/DeleteTapeMsg.h
@@ -0,0 +1,33 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef __DELETETAPEMSG_H__
+#define __DELETETAPEMSG_H__
+
+#include "messages/SyncMessage.h"
+
+class DeleteTapeMsg : public SyncMessage
+{
+public:
+ void Define(Serializer* s);
+ inline void Validate() {};
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ ObjectRef Process();
+
+ CStdString m_filename;
+};
+
+#endif
+
diff --git a/orkaudio/messages/Makefile.am b/orkaudio/messages/Makefile.am
new file mode 100644
index 0000000..2367e4b
--- /dev/null
+++ b/orkaudio/messages/Makefile.am
@@ -0,0 +1,7 @@
+METASOURCES = AUTO
+noinst_LTLIBRARIES = libmessages.la
+libmessages_la_SOURCES = CaptureMsg.cpp DeleteTapeMsg.cpp PingMsg.cpp \
+ TapeMsg.cpp TestMsg.cpp
+AM_CPPFLAGS = -D_REENTRANT
+libmessages_la_LIBADD = -L../../orkbasecxx/ -lorkbase
+INCLUDES = -I@top_srcdir@ -I../../orkbasecxx
diff --git a/orkaudio/messages/PingMsg.cpp b/orkaudio/messages/PingMsg.cpp
new file mode 100644
index 0000000..1f90bbe
--- /dev/null
+++ b/orkaudio/messages/PingMsg.cpp
@@ -0,0 +1,60 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "PingMsg.h"
+
+#define PING_CLASS "ping"
+#define PING_RESPONSE_CLASS "pingresponse"
+
+void PingResponseMsg::Define(Serializer* s)
+{
+ s->BoolValue(SUCCESS_PARAM, m_success);
+}
+
+CStdString PingResponseMsg::GetClassName()
+{
+ return CStdString(PING_RESPONSE_CLASS);
+}
+
+ObjectRef PingResponseMsg::NewInstance()
+{
+ return ObjectRef(new PingResponseMsg);
+}
+
+//===============================
+
+void PingMsg::Define(Serializer* s)
+{
+ CStdString pingClass(PING_CLASS);
+ s->StringValue(OBJECT_TYPE_TAG, pingClass, true);
+}
+
+
+CStdString PingMsg::GetClassName()
+{
+ return CStdString(PING_CLASS);
+}
+
+ObjectRef PingMsg::NewInstance()
+{
+ return ObjectRef(new PingMsg);
+}
+
+ObjectRef PingMsg::Process()
+{
+ PingResponseMsg* msg = new PingResponseMsg;
+ ObjectRef ref(msg);
+ msg->m_success = true;
+ return ref;
+}
+
diff --git a/orkaudio/messages/PingMsg.h b/orkaudio/messages/PingMsg.h
new file mode 100644
index 0000000..21b659a
--- /dev/null
+++ b/orkaudio/messages/PingMsg.h
@@ -0,0 +1,46 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef __PINGMSG_H__
+#define __PINGMSG_H__
+
+#include "messages/SyncMessage.h"
+#include "messages/AsyncMessage.h"
+
+
+class PingResponseMsg : public AsyncMessage
+{
+public:
+ void Define(Serializer* s);
+ inline void Validate() {};
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ bool m_success;
+};
+
+class PingMsg : public SyncMessage
+{
+public:
+ void Define(Serializer* s);
+ inline void Validate() {};
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ ObjectRef Process();
+};
+
+#endif
+
diff --git a/orkaudio/messages/TapeMsg.cpp b/orkaudio/messages/TapeMsg.cpp
new file mode 100644
index 0000000..86c86b4
--- /dev/null
+++ b/orkaudio/messages/TapeMsg.cpp
@@ -0,0 +1,56 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Utils.h"
+#include "TapeMsg.h"
+#include "ConfigManager.h"
+
+TapeMsg::TapeMsg()
+{
+ // Here is where default values are set
+ m_timestamp = 0;
+ m_direction = CaptureEvent::DirectionToString(CaptureEvent::DirUnkn);
+ m_duration = 0;
+ m_serviceName = CONFIG.m_serviceName;
+}
+
+void TapeMsg::Define(Serializer* s)
+{
+ CStdString tapeMessageName(TAPE_MESSAGE_NAME);
+ s->StringValue(OBJECT_TYPE_TAG, tapeMessageName, true);
+ s->StringValue(STAGE_PARAM, m_stage, true);
+ s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true);
+ s->IntValue(TIMESTAMP_PARAM, (int&)m_timestamp, true);
+ s->StringValue(FILENAME_PARAM, m_fileName, true);
+ s->StringValue(LOCALPARTY_PARAM, m_localParty);
+ s->StringValue(LOCALENTRYPOINT_PARAM, m_localEntryPoint);
+ s->StringValue(REMOTEPARTY_PARAM, m_remoteParty);
+ s->StringValue(DIRECTION_PARAM, m_direction);
+ s->IntValue(DURATION_PARAM, m_duration);
+ s->StringValue(SERVICE_PARAM, m_serviceName);
+}
+
+void TapeMsg::Validate()
+{
+}
+
+CStdString TapeMsg::GetClassName()
+{
+ return CStdString(TAPE_MESSAGE_NAME);
+}
+
+ObjectRef TapeMsg::NewInstance()
+{
+ return ObjectRef(new TapeMsg);
+}
+
diff --git a/orkaudio/messages/TapeMsg.h b/orkaudio/messages/TapeMsg.h
new file mode 100644
index 0000000..d127c6d
--- /dev/null
+++ b/orkaudio/messages/TapeMsg.h
@@ -0,0 +1,58 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef __TAPEMSG_H__
+#define __TAPEMSG_H__
+
+#include "messages/SyncMessage.h"
+#include "AudioTape.h"
+
+#define TAPE_MESSAGE_NAME "tape"
+#define FILENAME_PARAM "filename"
+#define STAGE_PARAM "stage"
+#define LOCALPARTY_PARAM "localparty"
+#define REMOTEPARTY_PARAM "remoteparty"
+#define DIRECTION_PARAM "direction"
+#define LOCALENTRYPOINT_PARAM "localentrypoint"
+#define DURATION_PARAM "duration"
+#define SERVICE_PARAM "service"
+
+class TapeMsg : public SyncMessage
+{
+public:
+ TapeMsg();
+
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ CStdString m_stage;
+ time_t m_timestamp;
+ CStdString m_fileName;
+ CStdString m_capturePort;
+ CStdString m_localParty;
+ CStdString m_localEntryPoint;
+ CStdString m_remoteParty;
+ CStdString m_direction;
+ CStdString m_loginString;
+ int m_duration;
+ CStdString m_serviceName;
+};
+
+typedef boost::shared_ptr<TapeMsg> TapeMsgRef;
+
+#endif
+
diff --git a/orkaudio/messages/TestMsg.cpp b/orkaudio/messages/TestMsg.cpp
new file mode 100644
index 0000000..68e2f3e
--- /dev/null
+++ b/orkaudio/messages/TestMsg.cpp
@@ -0,0 +1,53 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Utils.h"
+#include "TestMsg.h"
+
+TestMsg::TestMsg()
+{
+ // Here is where default values are set
+ m_timestamp = 0;
+}
+
+void TestMsg::Define(Serializer* s)
+{
+ CStdString testMessageName("test");
+ s->StringValue("test", testMessageName, true);
+ s->StringValue(STAGE_PARAM, m_stage, true);
+ s->StringValue(CAPTURE_PORT_PARAM, m_capturePort, true);
+ s->IntValue(TIMESTAMP_PARAM, (int&)m_timestamp, true);
+ s->StringValue(FILENAME_PARAM, m_fileName, true);
+
+ s->StringValue(LOCALPARTY_PARAM, m_localParty);
+ s->StringValue(LOCALENTRYPOINT_PARAM, m_localEntryPoint);
+ s->StringValue(REMOTEPARTY_PARAM, m_remoteParty);
+ s->StringValue(DIRECTION_PARAM, m_direction);
+ s->CsvValue("csv", m_csv);
+ s->DateValue("date", m_time);
+}
+
+void TestMsg::Validate()
+{
+}
+
+CStdString TestMsg::GetClassName()
+{
+ return CStdString("test");
+}
+
+ObjectRef TestMsg::NewInstance()
+{
+ return ObjectRef(new TestMsg);
+}
+
diff --git a/orkaudio/messages/TestMsg.h b/orkaudio/messages/TestMsg.h
new file mode 100644
index 0000000..13aed71
--- /dev/null
+++ b/orkaudio/messages/TestMsg.h
@@ -0,0 +1,55 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifndef __TESTMSG_H__
+#define __TESTMSG_H__
+
+#include <list>
+#include "messages/SyncMessage.h"
+
+#define FILENAME_PARAM "filename"
+#define STAGE_PARAM "stage"
+#define LOCALPARTY_PARAM "localparty"
+#define REMOTEPARTY_PARAM "remoteparty"
+#define DIRECTION_PARAM "direction"
+#define LOCALENTRYPOINT_PARAM "localentrypoint"
+
+class TestMsg : public SyncMessage
+{
+public:
+ TestMsg();
+
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ CStdString m_stage;
+ time_t m_timestamp;
+ CStdString m_fileName;
+ CStdString m_capturePort;
+ CStdString m_localParty;
+ CStdString m_localEntryPoint;
+ CStdString m_remoteParty;
+ CStdString m_direction;
+ CStdString m_loginString;
+ std::list<CStdString> m_csv;
+ time_t m_time;
+};
+
+typedef boost::shared_ptr<TestMsg> TestMsgRef;
+
+#endif
+