summaryrefslogtreecommitdiff
path: root/orkaudio
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
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')
-rw-r--r--orkaudio/App.h14
-rw-r--r--orkaudio/AudioCapturePlugin.h47
-rw-r--r--orkaudio/AudioTape.cpp385
-rw-r--r--orkaudio/AudioTape.h122
-rw-r--r--orkaudio/BUILD.txt2
-rw-r--r--orkaudio/BatchProcessing.cpp107
-rw-r--r--orkaudio/BatchProcessing.h39
-rw-r--r--orkaudio/CapturePluginProxy.cpp197
-rw-r--r--orkaudio/CapturePluginProxy.h49
-rw-r--r--orkaudio/CapturePort.cpp248
-rw-r--r--orkaudio/CapturePort.h66
-rw-r--r--orkaudio/Config.cpp112
-rw-r--r--orkaudio/Config.h98
-rw-r--r--orkaudio/ConfigManager.cpp98
-rw-r--r--orkaudio/ConfigManager.h38
-rw-r--r--orkaudio/Daemon.cpp194
-rw-r--r--orkaudio/Daemon.h47
-rw-r--r--orkaudio/ImmediateProcessing.cpp61
-rw-r--r--orkaudio/ImmediateProcessing.h34
-rw-r--r--orkaudio/LogManager.cpp37
-rw-r--r--orkaudio/LogManager.h44
-rw-r--r--orkaudio/Makefile.am18
-rw-r--r--orkaudio/Makefile.cvs8
-rw-r--r--orkaudio/MultiThreadedServer.cpp223
-rw-r--r--orkaudio/MultiThreadedServer.h53
-rw-r--r--orkaudio/OrkAudio.cpp151
-rw-r--r--orkaudio/OrkAudio.dsp278
-rw-r--r--orkaudio/OrkAudio.dsw89
-rw-r--r--orkaudio/OrkAudio.h13
-rw-r--r--orkaudio/Reporting.cpp65
-rw-r--r--orkaudio/Reporting.h33
-rw-r--r--orkaudio/ThreadSafeQueue.h76
-rw-r--r--orkaudio/audiocaptureplugins/Makefile.am2
-rw-r--r--orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.cpp29
-rw-r--r--orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.h36
-rw-r--r--orkaudio/audiocaptureplugins/generator/Generator.cpp147
-rw-r--r--orkaudio/audiocaptureplugins/generator/Generator.dsp126
-rw-r--r--orkaudio/audiocaptureplugins/generator/GeneratorConfig.cpp70
-rw-r--r--orkaudio/audiocaptureplugins/generator/GeneratorConfig.h66
-rw-r--r--orkaudio/audiocaptureplugins/generator/Makefile.am10
-rw-r--r--orkaudio/audiocaptureplugins/sounddevice/SoundDevice.cpp252
-rw-r--r--orkaudio/audiocaptureplugins/sounddevice/SoundDevice.dsp130
-rw-r--r--orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.cpp70
-rw-r--r--orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.h60
-rw-r--r--orkaudio/audiocaptureplugins/voip/Makefile.am10
-rw-r--r--orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h71
-rw-r--r--orkaudio/audiocaptureplugins/voip/Rtp.cpp257
-rw-r--r--orkaudio/audiocaptureplugins/voip/Rtp.h77
-rw-r--r--orkaudio/audiocaptureplugins/voip/SipSession.cpp282
-rw-r--r--orkaudio/audiocaptureplugins/voip/SipSession.h87
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIp.cpp465
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIp.dsp158
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp127
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.h68
-rw-r--r--orkaudio/audiocaptureplugins/voip/g711.c285
-rw-r--r--orkaudio/audiocaptureplugins/voip/g711.h21
-rw-r--r--orkaudio/audiofile/AudioFile.cpp58
-rw-r--r--orkaudio/audiofile/AudioFile.h69
-rw-r--r--orkaudio/audiofile/LibSndFileFile.cpp123
-rw-r--r--orkaudio/audiofile/LibSndFileFile.h46
-rw-r--r--orkaudio/audiofile/Makefile.am6
-rw-r--r--orkaudio/audiofile/PcmFile.cpp100
-rw-r--r--orkaudio/audiofile/PcmFile.h41
-rw-r--r--orkaudio/config-template.xml24
-rw-r--r--orkaudio/config.guess1
-rw-r--r--orkaudio/config.sub1
-rw-r--r--orkaudio/configure.in10
-rw-r--r--orkaudio/install-sh276
-rw-r--r--orkaudio/logging-template.properties43
-rw-r--r--orkaudio/ltmain.sh1
-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
-rw-r--r--orkaudio/missing336
-rw-r--r--orkaudio/mkinstalldirs111
83 files changed, 7761 insertions, 0 deletions
diff --git a/orkaudio/App.h b/orkaudio/App.h
new file mode 100644
index 0000000..19b5b95
--- /dev/null
+++ b/orkaudio/App.h
@@ -0,0 +1,14 @@
+/*
+ * 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
+ *
+ */
+
+
diff --git a/orkaudio/AudioCapturePlugin.h b/orkaudio/AudioCapturePlugin.h
new file mode 100644
index 0000000..b3469ec
--- /dev/null
+++ b/orkaudio/AudioCapturePlugin.h
@@ -0,0 +1,47 @@
+/*
+ * 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 __AUDIOCAPTUREPLUGIN_H__
+#define __AUDIOCAPTUREPLUGIN_H__
+
+#include "AudioCapture.h"
+#include "LogManager.h"
+#include "xercesc/dom/DOMNode.hpp"
+
+using namespace XERCES_CPP_NAMESPACE;
+
+#ifdef WIN32
+#define __CDECL__ __cdecl
+#else
+#define __CDECL__
+#endif
+
+#define AUDIO_CAPTURE_PLUGIN_INTERFACE_VERSION 1
+
+// Callback definitions
+typedef void (__CDECL__*AudioChunkCallBackFunction)(AudioChunkRef, CStdString& capturePort, bool remote = false);
+typedef void (__CDECL__*CaptureEventCallBackFunction)(CaptureEventRef, CStdString& capturePort);
+
+
+// Exported functions definitions
+typedef void (__CDECL__* RegisterCallBacksFunction)(AudioChunkCallBackFunction, CaptureEventCallBackFunction, LogManager*);
+typedef void (__CDECL__* InitializeFunction)();
+typedef void (__CDECL__* RunFunction)();
+typedef void (__CDECL__* ConfigureFunction)(DOMNode*);
+typedef void (__CDECL__* StartCaptureFunction)(CStdString& port);
+typedef void (__CDECL__* StopCaptureFunction)(CStdString& port);
+
+
+
+#endif
+
diff --git a/orkaudio/AudioTape.cpp b/orkaudio/AudioTape.cpp
new file mode 100644
index 0000000..312524a
--- /dev/null
+++ b/orkaudio/AudioTape.cpp
@@ -0,0 +1,385 @@
+/*
+ * 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 "ConfigManager.h"
+#include "AudioTape.h"
+#include "ace/OS_NS_time.h"
+#include "Utils.h"
+#include "ThreadSafeQueue.h"
+#include "audiofile/PcmFile.h"
+#include "LogManager.h"
+#include "audiofile/LibSndFileFile.h"
+#include "messages/TapeMsg.h"
+
+AudioTapeDescription::AudioTapeDescription()
+{
+ m_direction = CaptureEvent::DirUnkn;
+ m_duration = 0;
+ m_beginDate = 0;
+}
+
+void AudioTapeDescription::Define(Serializer* s)
+{
+ s->DateValue("date", m_beginDate);
+ s->IntValue("duration", m_duration);
+ s->EnumValue("direction", (int&)m_direction, CaptureEvent::DirectionToEnum, CaptureEvent::DirectionToString);
+ s->StringValue("capturePort", m_capturePort);
+ s->StringValue("localParty", m_localParty);
+ s->StringValue("remoteParty", m_remoteParty);
+ s->StringValue("localEntryPoint", m_localEntryPoint);
+}
+
+void AudioTapeDescription::Validate(){}
+
+CStdString AudioTapeDescription::GetClassName()
+{
+ return "tapedescription";
+}
+
+ObjectRef AudioTapeDescription::NewInstance()
+{
+ ObjectRef ref(new AudioTapeDescription());
+ return ref;
+}
+
+ObjectRef AudioTapeDescription::Process()
+{
+ ObjectRef ref;
+ return ref;
+}
+
+
+//===================================================
+AudioTape::AudioTape(CStdString &portId)
+{
+ m_portId = portId;
+ m_state = StateCreated;
+ m_beginDate = ACE_OS::time(NULL);
+ m_endDate = 0;
+ m_duration = 0;
+ m_direction = CaptureEvent::DirUnkn;
+ m_shouldStop = false;
+
+ GenerateFilePathAndIdentifier();
+}
+
+
+void AudioTape::AddAudioChunk(AudioChunkRef chunkRef, bool remote)
+{
+ // Add the chunk to the local queue
+ {
+ MutexSentinel sentinel(m_mutex);
+ if(remote)
+ {
+ m_remoteChunkQueue.push(chunkRef);
+ }
+ else
+ {
+ m_chunkQueue.push(chunkRef);
+ }
+ }
+}
+
+void AudioTape::Write()
+{
+ // Get the latest audio chunks and write them to disk
+ bool done = false;
+ while(!done && m_state != StateStopped && m_state != StateError)
+ {
+ // Get the oldest audio chunk
+ AudioChunkRef chunkRef;
+ {
+ MutexSentinel sentinel(m_mutex);
+ if (m_chunkQueue.size() > 0)
+ {
+ chunkRef = m_chunkQueue.front();
+ m_chunkQueue.pop();
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ if(!done)
+ {
+ try
+ {
+ // Need to create file appender when receiving first audio chunk
+ if (m_state == StateCreated)
+ {
+ m_state = StateActive;
+
+ switch(chunkRef->m_encoding)
+ {
+ case AudioChunk::PcmAudio:
+ m_audioFileRef.reset(new PcmFile);
+ break;
+ case AudioChunk::UlawAudio:
+ m_audioFileRef.reset(new LibSndFileFile(SF_FORMAT_ULAW | SF_FORMAT_WAV));
+ break;
+ case AudioChunk::AlawAudio:
+ m_audioFileRef.reset(new LibSndFileFile(SF_FORMAT_ALAW | SF_FORMAT_WAV));
+ break;
+ default:
+ LOG4CXX_ERROR(LOG.portLog, "#" + m_portId + ": received unsupported audio encoding from capture plugin:" + FileFormatToString(chunkRef->m_encoding));
+ m_state = StateError;
+ }
+ if (m_state == StateActive)
+ {
+ // A file format was successfully added to the tape, open it
+ CStdString file = m_filePath + m_fileIdentifier;
+ m_audioFileRef->Open(file, AudioFile::WRITE);
+
+ // determine what final extension the file will have after optional compression
+ if(CONFIG.m_storageAudioFormat == FfNative)
+ {
+ m_fileExtension = m_audioFileRef->GetExtension();
+ }
+ else
+ {
+ m_fileExtension = GetFileFormatExtension(CONFIG.m_storageAudioFormat);
+ }
+ }
+ }
+ if (m_state == StateActive)
+ {
+ m_audioFileRef->WriteChunk(chunkRef);
+
+ if (CONFIG.m_logRms)
+ {
+ // Compute RMS, RMS dB and log
+ CStdString rmsString;
+ rmsString.Format("%.1f dB:%.1f", chunkRef.get()->ComputeRms(), chunkRef.get()->ComputeRmsDb());
+ LOG4CXX_INFO(LOG.portLog, m_portId + " RMS: " + rmsString);
+ }
+ }
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_INFO(LOG.portLog, "#" + m_portId + ": " + e);
+ m_state = StateError;
+ }
+ }
+ }
+
+ if (m_shouldStop)
+ {
+ m_state = StateStopped;
+ }
+
+ if (m_state == StateStopped || m_state == StateError)
+ {
+ if(m_audioFileRef.get())
+ {
+ m_audioFileRef->Close();
+ }
+ }
+}
+
+void AudioTape::SetShouldStop()
+{
+ m_shouldStop = true;
+}
+
+void AudioTape::AddCaptureEvent(CaptureEventRef eventRef, bool send)
+{
+ // Extract useful info from well known events
+ switch(eventRef->m_type)
+ {
+ case CaptureEvent::EtStop:
+ m_shouldStop = true;
+
+ m_duration = time(NULL) - m_beginDate;
+
+ {
+ // Log the call details
+ AudioTapeDescription atd;
+ atd.m_beginDate = m_beginDate;
+ atd.m_capturePort = m_portId;
+ atd.m_direction = m_direction;
+ atd.m_duration = m_duration;
+ atd.m_localEntryPoint = m_localEntryPoint;
+ atd.m_localParty = m_localParty;
+ atd.m_remoteParty = m_remoteParty;
+ CStdString description = atd.SerializeSingleLine();
+ LOG4CXX_INFO(LOG.tapelistLog, description);
+ }
+ break;
+ case CaptureEvent::EtDirection:
+ m_direction = (CaptureEvent::DirectionEnum)CaptureEvent::DirectionToEnum(eventRef->m_value);
+ break;
+ case CaptureEvent::EtRemoteParty:
+ m_remoteParty = eventRef->m_value;
+ break;
+ case CaptureEvent::EtLocalParty:
+ m_localParty = eventRef->m_value;
+ break;
+ case CaptureEvent::EtLocalEntryPoint:
+ m_localEntryPoint = eventRef->m_value;
+ break;
+ }
+
+ // Store the capture event locally
+ {
+ MutexSentinel sentinel(m_mutex);
+ m_eventQueue.push(eventRef);
+ if (send)
+ {
+ m_toSendEventQueue.push(eventRef);
+ }
+ }
+}
+
+void AudioTape::GetMessage(MessageRef& msgRef)
+{
+ CaptureEventRef captureEventRef;
+ {
+ MutexSentinel sentinel(m_mutex);
+ captureEventRef = m_toSendEventQueue.front();
+ m_toSendEventQueue.pop();
+ }
+
+ msgRef.reset(new TapeMsg);
+ TapeMsg* pTapeMsg = (TapeMsg*)msgRef.get();
+ if(captureEventRef->m_type == CaptureEvent::EtStart || captureEventRef->m_type == CaptureEvent::EtStop)
+ {
+ if (captureEventRef->m_type == CaptureEvent::EtStart)
+ {
+ pTapeMsg->m_timestamp = m_beginDate;
+ }
+ else
+ {
+ pTapeMsg->m_timestamp = m_endDate;
+ }
+
+ pTapeMsg->m_fileName = m_filePath + m_fileIdentifier + m_fileExtension;
+ pTapeMsg-> m_stage = CaptureEvent::EventTypeToString(captureEventRef->m_type);
+ pTapeMsg->m_capturePort = m_portId;
+ pTapeMsg->m_localParty = m_localParty;
+ pTapeMsg->m_localEntryPoint = m_localEntryPoint;
+ pTapeMsg->m_remoteParty = m_remoteParty;
+ pTapeMsg->m_direction = CaptureEvent::DirectionToString(m_direction);
+ pTapeMsg->m_duration = m_duration;
+ pTapeMsg->m_timestamp = m_beginDate;
+ }
+ else
+ {
+ // This should be a key-value pair message
+ }
+}
+
+void AudioTape::GenerateFilePathAndIdentifier()
+{
+ struct tm date = {0};
+ ACE_OS::localtime_r(&m_beginDate, &date);
+ int month = date.tm_mon + 1; // january=0, decembre=11
+ int year = date.tm_year + 1900;
+ m_filePath.Format("%.4d/%.2d/%.2d/%.2d/", year, month, date.tm_mday, date.tm_hour);
+ m_fileIdentifier.Format("%.4d%.2d%.2d_%.2d%.2d%.2d_%s", year, month, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec, m_portId);
+}
+
+
+CStdString AudioTape::GetIdentifier()
+{
+ return m_fileIdentifier;
+}
+
+CStdString AudioTape::GetPath()
+{
+ return m_filePath;
+}
+
+bool AudioTape::IsStoppedAndValid()
+{
+ if (m_state == StateStopped)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+AudioFileRef AudioTape::GetAudioFileRef()
+{
+ return m_audioFileRef;
+}
+
+//========================================
+// File format related methods
+
+int AudioTape::FileFormatToEnum(CStdString& format)
+{
+ int formatEnum = FfUnknown;
+ if(format.CompareNoCase(FF_NATIVE) == 0)
+ {
+ formatEnum = FfNative;
+ }
+ else if (format.CompareNoCase(FF_GSM) == 0)
+ {
+ formatEnum = FfGsm;
+ }
+ else if (format.CompareNoCase(FF_ULAW) == 0)
+ {
+ formatEnum = FfUlaw;
+ }
+ else if (format.CompareNoCase(FF_ALAW) == 0)
+ {
+ formatEnum = FfAlaw;
+ }
+ return formatEnum;
+}
+
+CStdString AudioTape::FileFormatToString(int formatEnum)
+{
+ CStdString formatString;
+ switch (formatEnum)
+ {
+ case FfNative:
+ formatString = FF_NATIVE;
+ break;
+ case FfGsm:
+ formatString = FF_GSM;
+ break;
+ case FfUlaw:
+ formatString = FF_ULAW;
+ break;
+ case FfAlaw:
+ formatString = FF_ALAW;
+ break;
+ default:
+ formatString = FF_UNKNOWN;
+ }
+ return formatString;
+}
+
+CStdString AudioTape::GetFileFormatExtension(FileFormatEnum formatEnum)
+{
+ CStdString extension;
+ switch (formatEnum)
+ {
+ case FfGsm:
+ case FfUlaw:
+ case FfAlaw:
+ extension = ".wav";
+ break;
+ default:
+ CStdString formatEnumString = IntToString(formatEnum);
+ throw (CStdString("AudioTape::GetFileFormatExtension: unknown file format:") + formatEnumString);
+ }
+ return extension;
+}
+
+
+
diff --git a/orkaudio/AudioTape.h b/orkaudio/AudioTape.h
new file mode 100644
index 0000000..113ff23
--- /dev/null
+++ b/orkaudio/AudioTape.h
@@ -0,0 +1,122 @@
+/*
+ * 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 __AUDIOTAPE_H__
+#define __AUDIOTAPE_H__
+
+#include "ace/Thread_Mutex.h"
+#include "time.h"
+#include "StdString.h"
+#include "boost/shared_ptr.hpp"
+#include <queue>
+#include "AudioCapture.h"
+#include "audiofile/AudioFile.h"
+#include "messages/Message.h"
+
+class AudioTapeDescription : public Object
+{
+public:
+ AudioTapeDescription();
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+
+ ObjectRef Process();
+
+ CStdString m_capturePort;
+ CStdString m_localParty;
+ CStdString m_localEntryPoint;
+ CStdString m_remoteParty;
+ CaptureEvent::DirectionEnum m_direction;
+ time_t m_beginDate;
+ int m_duration;
+};
+
+class AudioTape
+{
+public:
+ typedef enum
+ {
+ StateUnknown = 0,
+ StateCreated = 1,
+ StateActive = 2,
+ StateStopped = 3,
+ StateError = 4,
+ StateInvalid = 5
+ } StateEnum;
+
+#define FF_NATIVE "native"
+#define FF_GSM "GSM"
+#define FF_ULAW "ulaw"
+#define FF_ALAW "alaw"
+#define FF_UNKNOWN "unknown"
+ typedef enum
+ {
+ FfUnknown = 0,
+ FfNative = 1,
+ FfGsm = 2,
+ FfUlaw = 3,
+ FfAlaw = 4,
+ FfInvalid = 5
+ } FileFormatEnum;
+ static int FileFormatToEnum(CStdString& format);
+ static CStdString FileFormatToString(int formatEnum);
+ static CStdString GetFileFormatExtension(FileFormatEnum);
+
+
+ AudioTape(CStdString &portId);
+
+ void AddAudioChunk(AudioChunkRef chunkRef, bool remote = false);
+ void Write();
+ void SetShouldStop();
+ bool IsStoppedAndValid();
+ void AddCaptureEvent(CaptureEventRef eventRef, bool send = true);
+ void GetMessage(MessageRef& msg);
+ /** Returns an identifier for the tape which corresponds to the filename without extension */
+ CStdString GetIdentifier();
+ CStdString GetPath();
+ AudioFileRef GetAudioFileRef();
+
+ CStdString m_portId;
+ CStdString m_localParty;
+ CStdString m_localEntryPoint;
+ CStdString m_remoteParty;
+ CaptureEvent::DirectionEnum m_direction;
+ time_t m_beginDate;
+ time_t m_endDate;
+ time_t m_duration;
+private:
+ void GenerateFilePathAndIdentifier();
+
+ CStdString m_filePath;
+ CStdString m_fileIdentifier;
+ CStdString m_fileExtension; //Corresponds to the extension the tape will have after compression
+
+ std::queue<AudioChunkRef> m_chunkQueue;
+ std::queue<AudioChunkRef> m_remoteChunkQueue; // used if stereo capture
+
+ std::queue<CaptureEventRef> m_eventQueue;
+ std::queue<CaptureEventRef> m_toSendEventQueue;
+
+ AudioFileRef m_audioFileRef;
+ ACE_Thread_Mutex m_mutex;
+ StateEnum m_state;
+ bool m_shouldStop;
+};
+
+typedef boost::shared_ptr<AudioTape> AudioTapeRef;
+
+#endif
+
diff --git a/orkaudio/BUILD.txt b/orkaudio/BUILD.txt
new file mode 100644
index 0000000..70f9ba3
--- /dev/null
+++ b/orkaudio/BUILD.txt
@@ -0,0 +1,2 @@
+
+To build this, please see ../BUILD_C++.txt \ No newline at end of file
diff --git a/orkaudio/BatchProcessing.cpp b/orkaudio/BatchProcessing.cpp
new file mode 100644
index 0000000..6aa1600
--- /dev/null
+++ b/orkaudio/BatchProcessing.cpp
@@ -0,0 +1,107 @@
+/*
+ * 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 "ConfigManager.h"
+#include "BatchProcessing.h"
+#include "LogManager.h"
+#include "ace/OS_NS_unistd.h"
+#include "audiofile/LibSndFileFile.h"
+
+BatchProcessing BatchProcessing::m_batchProcessingSingleton;
+
+BatchProcessing::BatchProcessing()
+{
+ m_threadCount = 0;
+}
+
+
+BatchProcessing* BatchProcessing::GetInstance()
+{
+ return &m_batchProcessingSingleton;
+}
+
+void BatchProcessing::AddAudioTape(AudioTapeRef audioTapeRef)
+{
+ if (!m_audioTapeQueue.push(audioTapeRef))
+ {
+ // Log error
+ LOG4CXX_ERROR(LOG.batchProcessingLog, CStdString("BatchProcessing: queue full"));
+ }
+}
+
+void BatchProcessing::ThreadHandler(void *args)
+{
+ BatchProcessing* pBatchProcessing = BatchProcessing::GetInstance();
+ int threadId = 0;
+ {
+ MutexSentinel sentinel(pBatchProcessing->m_mutex);
+ threadId = pBatchProcessing->m_threadCount++;
+ }
+ CStdString threadIdString = IntToString(threadId);
+ LOG4CXX_DEBUG(LOG.batchProcessingLog, CStdString("Created thread #") + threadIdString);
+
+ for(;;)
+ {
+ try
+ {
+ AudioTapeRef audioTapeRef = pBatchProcessing->m_audioTapeQueue.pop();
+ CStdString threadIdString = IntToString(threadId);
+ LOG4CXX_INFO(LOG.batchProcessingLog, CStdString("Th") + threadIdString + " processing: " + audioTapeRef->GetIdentifier());
+
+ AudioFileRef fileRef = audioTapeRef->GetAudioFileRef();
+ fileRef->MoveOrig();
+ fileRef->Open(AudioFile::READ);
+
+ AudioChunkRef chunkRef;
+ AudioFileRef outFileRef;
+
+ switch(CONFIG.m_storageAudioFormat)
+ {
+ case AudioTape::FfUlaw:
+ outFileRef.reset(new LibSndFileFile(SF_FORMAT_ULAW | SF_FORMAT_WAV));
+ break;
+ case AudioTape::FfAlaw:
+ outFileRef.reset(new LibSndFileFile(SF_FORMAT_ALAW | SF_FORMAT_WAV));
+ break;
+ case AudioTape::FfGsm:
+ default:
+ outFileRef.reset(new LibSndFileFile(SF_FORMAT_GSM610 | SF_FORMAT_WAV));
+ }
+ CStdString file = audioTapeRef->GetPath() + audioTapeRef->GetIdentifier();
+ outFileRef->Open(file, AudioFile::WRITE);
+
+ while(fileRef->ReadChunkMono(chunkRef))
+ {
+ outFileRef->WriteChunk(chunkRef);
+ }
+
+ if(CONFIG.m_deleteNativeFile)
+ {
+ fileRef->Close();
+ fileRef->Delete();
+ CStdString threadIdString = IntToString(threadId);
+ LOG4CXX_INFO(LOG.batchProcessingLog, CStdString("Th") + threadIdString + " deleting native: " + audioTapeRef->GetIdentifier());
+ }
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_ERROR(LOG.batchProcessingLog, CStdString("BatchProcessing: ") + e);
+ }
+ catch(...)
+ {
+ }
+
+ }
+}
+
+
diff --git a/orkaudio/BatchProcessing.h b/orkaudio/BatchProcessing.h
new file mode 100644
index 0000000..73a62f0
--- /dev/null
+++ b/orkaudio/BatchProcessing.h
@@ -0,0 +1,39 @@
+/*
+ * 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 __BATCHPROCESSING_H__
+#define __BATCHPROCESSING_H__
+
+#include "ThreadSafeQueue.h"
+#include "AudioTape.h"
+#include "ace/Thread_Mutex.h"
+
+class BatchProcessing
+{
+public:
+ static BatchProcessing* GetInstance();
+ static void ThreadHandler(void *args);
+
+ void AddAudioTape(AudioTapeRef audioTapeRef);
+private:
+ BatchProcessing();
+
+ static BatchProcessing m_batchProcessingSingleton;
+ ThreadSafeQueue<AudioTapeRef> m_audioTapeQueue;
+
+ size_t m_threadCount;
+ ACE_Thread_Mutex m_mutex;
+};
+
+#endif
+
diff --git a/orkaudio/CapturePluginProxy.cpp b/orkaudio/CapturePluginProxy.cpp
new file mode 100644
index 0000000..7c4acbc
--- /dev/null
+++ b/orkaudio/CapturePluginProxy.cpp
@@ -0,0 +1,197 @@
+/*
+ * 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 "CapturePluginProxy.h"
+#include "ace/OS_NS_dirent.h"
+#include "ace/OS_NS_string.h"
+#include "ConfigManager.h"
+#include "CapturePort.h"
+
+CapturePluginProxy::CapturePluginProxy()
+{
+ m_configureFunction = NULL;
+ m_registerCallBacksFunction = NULL;
+ m_initializeFunction = NULL;
+ m_runFunction = NULL;
+ m_startCaptureFunction = NULL;
+ m_stopCaptureFunction = NULL;
+
+ m_loaded = false;
+}
+
+bool CapturePluginProxy::Initialize()
+{
+ // Get the desired capture plugin from the config file, or else, use the first dll encountered.
+ CStdString pluginDirectory = CONFIG.m_capturePluginPath + "/";
+ CStdString pluginPath;
+ if (!CONFIG.m_capturePlugin.IsEmpty())
+ {
+ // A specific plugin was specified in the config file
+ pluginPath = pluginDirectory + CONFIG.m_capturePlugin;
+ }
+ else
+ {
+ // No plugin specified, find the first one in the plugin directory
+ ACE_DIR* dir = ACE_OS::opendir((PCSTR)pluginDirectory);
+ if (!dir)
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Capture plugin directory could not be found:" + pluginDirectory));
+ }
+ else
+ {
+ dirent* dirEntry = NULL;
+ bool found = false;
+ bool done = false;
+ while(!found && !done)
+ {
+ dirEntry = ACE_OS::readdir(dir);
+ if(dirEntry)
+ {
+ if (ACE_OS::strstr(dirEntry->d_name, ".dll"))
+ {
+ found = true;
+ done = true;
+ pluginPath = pluginDirectory + dirEntry->d_name;
+ }
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ ACE_OS::closedir(dir);
+ }
+ }
+ if (!pluginPath.IsEmpty())
+ {
+ m_dll.open((PCSTR)pluginPath);
+ ACE_TCHAR* error = m_dll.error();
+ if(error)
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Failed to load the following plugin: ") + pluginPath);
+ }
+ else
+ {
+ // Ok, the dll has been successfully loaded
+ RegisterCallBacksFunction registerCallBacks;
+ registerCallBacks = (RegisterCallBacksFunction)m_dll.symbol("RegisterCallBacks");
+ registerCallBacks(AudioChunkCallBack, CaptureEventCallBack, LogManagerSingleton::instance());
+
+ m_configureFunction = (ConfigureFunction)m_dll.symbol("Configure");
+ if (m_configureFunction)
+ {
+ ConfigManagerSingleton::instance()->AddConfigureFunction(m_configureFunction);
+
+ m_initializeFunction = (InitializeFunction)m_dll.symbol("Initialize");
+ if (m_initializeFunction)
+ {
+ m_initializeFunction();
+
+ m_runFunction = (RunFunction)m_dll.symbol("Run");
+ if (m_runFunction)
+ {
+ m_startCaptureFunction = (StartCaptureFunction)m_dll.symbol("StartCapture");
+ if (m_startCaptureFunction)
+ {
+ m_stopCaptureFunction = (StopCaptureFunction)m_dll.symbol("StopCapture");
+ if (m_stopCaptureFunction)
+ {
+ m_loaded = true;
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Could not find StopCapture function in ") + pluginPath);
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Could not find StartCapture function in ") + pluginPath);
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Could not find Run function in ") + pluginPath);
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Could not find Initialize function in ") + pluginPath);
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Could not find Configure function in ") + pluginPath);
+ }
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Failed to find any capture plugin in: ") + pluginDirectory);
+ }
+
+ return m_loaded;
+}
+
+void CapturePluginProxy::Run()
+{
+ m_runFunction();
+}
+
+void CapturePluginProxy::StartCapture(CStdString& capturePort)
+{
+ if(m_loaded)
+ {
+ m_startCaptureFunction(capturePort);
+ }
+ else
+ {
+ throw(CStdString("StartCapture: Capture plugin not yet loaded"));
+ }
+}
+
+void CapturePluginProxy::StopCapture(CStdString& capturePort)
+{
+ if(m_loaded)
+ {
+ m_stopCaptureFunction(capturePort);
+ }
+ else
+ {
+ throw(CStdString("StopCapture: Capture plugin not yet loaded"));
+ }
+}
+
+void __CDECL__ CapturePluginProxy::AudioChunkCallBack(AudioChunkRef chunkRef, CStdString& capturePort, bool remote)
+{
+ // find the right port and give it the audio chunk
+ CapturePortRef portRef = CapturePortsSingleton::instance()->AddAndReturnPort(capturePort);
+ portRef->AddAudioChunk(chunkRef, remote);
+}
+
+void __CDECL__ CapturePluginProxy::CaptureEventCallBack(CaptureEventRef eventRef, CStdString& capturePort)
+{
+ if(CONFIG.m_vad || CONFIG.m_audioSegmentation)
+ {
+ if (eventRef->m_type == CaptureEvent::EtStart || eventRef->m_type == CaptureEvent::EtStop)
+ {
+ LOG4CXX_ERROR(LOG.portLog, "#" + capturePort + ": received start or stop while in VAD or audio segmentation mode");
+ }
+ }
+ else
+ {
+ // find the right port and give it the event
+ CapturePortRef portRef = CapturePortsSingleton::instance()->AddAndReturnPort(capturePort);
+ portRef->AddCaptureEvent(eventRef);
+ }
+}
+
diff --git a/orkaudio/CapturePluginProxy.h b/orkaudio/CapturePluginProxy.h
new file mode 100644
index 0000000..1efc520
--- /dev/null
+++ b/orkaudio/CapturePluginProxy.h
@@ -0,0 +1,49 @@
+/*
+ * 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 __CAPTUREPLUGINPROXY_H__
+#define __CAPTUREPLUGINPROXY_H__
+
+#include "ace/Singleton.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/DLL.h"
+#include "AudioCapture.h"
+#include "AudioCapturePlugin.h"
+
+class CapturePluginProxy
+{
+public:
+ CapturePluginProxy();
+ bool Initialize();
+ void Run();
+ void StartCapture(CStdString& capturePort);
+ void StopCapture(CStdString& capturePort);
+
+ static void __CDECL__ AudioChunkCallBack(AudioChunkRef chunkRef, CStdString& capturePort, bool remote = false);
+ static void __CDECL__ CaptureEventCallBack(CaptureEventRef eventRef, CStdString& capturePort);
+private:
+ ConfigureFunction m_configureFunction;
+ RegisterCallBacksFunction m_registerCallBacksFunction;
+ InitializeFunction m_initializeFunction;
+ RunFunction m_runFunction;
+ StartCaptureFunction m_startCaptureFunction;
+ StopCaptureFunction m_stopCaptureFunction;
+
+ ACE_DLL m_dll;
+ bool m_loaded;
+};
+
+typedef ACE_Singleton<CapturePluginProxy, ACE_Thread_Mutex> CapturePluginProxySingleton;
+
+#endif
+
diff --git a/orkaudio/CapturePort.cpp b/orkaudio/CapturePort.cpp
new file mode 100644
index 0000000..52ca35c
--- /dev/null
+++ b/orkaudio/CapturePort.cpp
@@ -0,0 +1,248 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "CapturePort.h"
+#include "Utils.h"
+#include "ImmediateProcessing.h"
+#include "LogManager.h"
+#include "Reporting.h"
+#include "ConfigManager.h"
+
+CapturePort::CapturePort(CStdString& Id)
+{
+ m_Id = Id;
+ m_vadBelowThresholdSec = 0.0;
+ m_vadUp = false;
+ m_capturing = false;
+}
+
+CStdString CapturePort::ToString()
+{
+ CStdString ret;
+ return ret;
+}
+
+void CapturePort::AddAudioChunk(AudioChunkRef chunkRef, bool remote)
+{
+ time_t now = time(NULL);
+
+ if(CONFIG.m_audioSegmentation)
+ {
+ if (m_audioTapeRef.get())
+ {
+ if ((now - m_audioTapeRef->m_beginDate) >= CONFIG.m_audioSegmentDuration)
+ {
+ // signal current tape stop event
+ CaptureEventRef eventRef(new CaptureEvent);
+ eventRef->m_type = CaptureEvent::EtStop;
+ eventRef->m_timestamp = now;
+ AddCaptureEvent(eventRef);
+
+ // create new tape
+ m_audioTapeRef.reset(new AudioTape(m_Id));
+
+ // signal new tape start event
+ eventRef.reset(new CaptureEvent);
+ eventRef->m_type = CaptureEvent::EtStart;
+ eventRef->m_timestamp = now;
+ AddCaptureEvent(eventRef);
+ }
+ }
+ else
+ {
+ // create new tape
+ m_audioTapeRef.reset(new AudioTape(m_Id));
+
+ // signal new tape start event
+ CaptureEventRef eventRef(new CaptureEvent);
+ eventRef->m_type = CaptureEvent::EtStart;
+ eventRef->m_timestamp = now;
+ AddCaptureEvent(eventRef);
+ }
+ }
+ else if (CONFIG.m_vad)
+ {
+ if(chunkRef->m_encoding == AudioChunk::PcmAudio)
+ {
+ if(m_vadUp)
+ {
+ // There is an ongoing capture
+ if (chunkRef->ComputeRmsDb() < CONFIG.m_vadLowThresholdDb)
+ {
+ // Level has gone below low threshold, increase holdon counter
+ m_vadBelowThresholdSec += chunkRef->GetDurationSec();
+ }
+ else
+ {
+ // Level has gone above low threshold, reset holdon counter
+ m_vadBelowThresholdSec = 0.0;
+ }
+
+ if (m_vadBelowThresholdSec > CONFIG.m_vadHoldOnSec)
+ {
+ // no activity detected for more than hold on time
+ m_vadUp = false;
+
+ // signal current tape stop event
+ CaptureEventRef eventRef(new CaptureEvent);
+ eventRef->m_type = CaptureEvent::EtStop;
+ eventRef->m_timestamp = now;
+ AddCaptureEvent(eventRef);
+ }
+ }
+ else
+ {
+ // No capture is taking place yet
+ if (chunkRef->ComputeRmsDb() > CONFIG.m_vadHighThresholdDb)
+ {
+ // Voice detected, start a new capture
+ m_vadBelowThresholdSec = 0.0;
+ m_vadUp = true;
+
+ // create new tape
+ m_audioTapeRef.reset(new AudioTape(m_Id));
+
+ // signal new tape start event
+ CaptureEventRef eventRef(new CaptureEvent);
+ eventRef->m_type = CaptureEvent::EtStart;
+ eventRef->m_timestamp = now;
+ AddCaptureEvent(eventRef);
+ }
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.portLog, CStdString("Voice activity detection cannot be used on non PCM audio"));
+ }
+ }
+
+ // ############
+ //if (!m_audioTapeRef.get())
+ //{
+ // m_audioTapeRef.reset(new AudioTape(m_Id));
+ // LOG4CXX_WARN(LOG.portLog, CStdString("Got impromptu audio"));
+ //}
+
+ if (m_audioTapeRef.get() && m_capturing)
+ {
+ m_audioTapeRef->AddAudioChunk(chunkRef, remote);
+
+ // Signal to immediate processing thread that tape has new stuff
+ ImmediateProcessing::GetInstance()->AddAudioTape(m_audioTapeRef);
+ }
+}
+
+void CapturePort::AddCaptureEvent(CaptureEventRef eventRef)
+{
+ AudioTapeRef audioTapeRef = m_audioTapeRef;
+
+ // First of all, handle tape start
+ if (eventRef->m_type == CaptureEvent::EtStart)
+ {
+ m_capturing = true;
+ if (audioTapeRef.get())
+ {
+ audioTapeRef->SetShouldStop(); // force stop of previous tape
+ }
+ audioTapeRef.reset(new AudioTape(m_Id)); // Create a new tape
+ audioTapeRef->AddCaptureEvent(eventRef, true);
+ Reporting::GetInstance()->AddAudioTape(audioTapeRef);
+ m_audioTapeRef = audioTapeRef;
+ LOG4CXX_INFO(LOG.portLog, "#" + m_Id + ": start");
+ }
+
+ if (!audioTapeRef.get())
+ {
+ LOG4CXX_WARN(LOG.portLog, "#" + m_Id + ": received unexpected capture event:"
+ + CaptureEvent::EventTypeToString(eventRef->m_type));
+ }
+ else
+ {
+ // Ok, at this point, we know we have a valid audio tape
+ switch(eventRef->m_type)
+ {
+ case CaptureEvent::EtStop:
+
+ m_capturing = false;
+ LOG4CXX_INFO(LOG.portLog, "#" + m_Id + ": stop");
+ audioTapeRef->AddCaptureEvent(eventRef, true);
+
+ if (m_audioTapeRef->GetAudioFileRef().get())
+ {
+ // Notify immediate processing that tape has stopped
+ ImmediateProcessing::GetInstance()->AddAudioTape(m_audioTapeRef);
+ // Reporting needs to send a stop message
+ Reporting::GetInstance()->AddAudioTape(audioTapeRef);
+ }
+ else
+ {
+ // Received a stop but there is no valid audio file associated with the tape
+ LOG4CXX_WARN(LOG.portLog, "#" + m_Id + ": no audio reported between last start and stop");
+ }
+ break;
+ case CaptureEvent::EtDirection:
+ case CaptureEvent::EtRemoteParty:
+ case CaptureEvent::EtLocalParty:
+ case CaptureEvent::EtLocalEntryPoint:
+ default:
+ audioTapeRef->AddCaptureEvent(eventRef, false);
+ }
+ }
+}
+
+
+//=======================================
+
+void CapturePorts::Initialize()
+{
+ m_ports.clear();
+}
+
+CapturePortRef CapturePorts::GetPort(CStdString & portId)
+{
+ std::map<CStdString, CapturePortRef>::iterator pair;
+
+ pair = m_ports.find(portId);
+
+ if (pair == m_ports.end())
+ {
+ CapturePortRef nullPortRef;
+ return nullPortRef;
+ }
+ else
+ {
+ return pair->second;
+ }
+}
+
+CapturePortRef CapturePorts::AddAndReturnPort(CStdString & portId)
+{
+ //MutexGuard mutexGuard(m_mutex); // To make sure a channel cannot be created twice
+
+ CapturePortRef portRef = GetPort(portId);
+ if (portRef.get() == NULL)
+ {
+ // The port does not already exist, create it.
+ CapturePortRef newPortRef(new CapturePort(portId));
+ m_ports.insert(std::make_pair(portId, newPortRef));
+ return newPortRef;
+ }
+ else
+ {
+ return portRef;
+ }
+}
+
+
diff --git a/orkaudio/CapturePort.h b/orkaudio/CapturePort.h
new file mode 100644
index 0000000..6d665b1
--- /dev/null
+++ b/orkaudio/CapturePort.h
@@ -0,0 +1,66 @@
+/*
+ * 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
+ *
+ */
+
+#pragma warning( disable: 4786 )
+
+#ifndef __PORT_H__
+#define __PORT_H__
+
+#include <map>
+#include "boost/shared_ptr.hpp"
+#include "ace/Thread_Mutex.h"
+#include "ace/Singleton.h"
+
+#include "StdString.h"
+
+#include "AudioCapture.h"
+#include "AudioTape.h"
+
+
+/** Base class for all types of capture ports. */
+class CapturePort
+{
+public:
+ CapturePort(CStdString& Id);
+ CStdString ToString();
+
+ void AddAudioChunk(AudioChunkRef chunkRef, bool remote = false);
+ void AddCaptureEvent(CaptureEventRef eventRef);
+private:
+ CStdString m_Id;
+ AudioTapeRef m_audioTapeRef;
+ ACE_Thread_Mutex m_mutex;
+ bool m_capturing;
+ double m_vadBelowThresholdSec;
+ bool m_vadUp;
+};
+
+typedef boost::shared_ptr<CapturePort> CapturePortRef;
+
+/** This singleton holds all dynamically created capture ports and allows convenient access. */
+class CapturePorts
+{
+public:
+ void Initialize();
+ CapturePortRef GetPort(CStdString & portId);
+ /** Tries to find a capture port from its ID. If unsuccessful, creates a new one and returns it */
+ CapturePortRef AddAndReturnPort(CStdString & portId);
+private:
+ std::map<CStdString, CapturePortRef> m_ports;
+ ACE_Thread_Mutex m_mutex;
+};
+
+typedef ACE_Singleton<CapturePorts, ACE_Thread_Mutex> CapturePortsSingleton;
+
+#endif
+
diff --git a/orkaudio/Config.cpp b/orkaudio/Config.cpp
new file mode 100644
index 0000000..0f6d0cc
--- /dev/null
+++ b/orkaudio/Config.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "serializers/Serializer.h"
+#include "Config.h"
+#include "LogManager.h"
+
+Config::Config()
+{
+ m_logMessages = LOG_MESSAGES_DEFAULT;
+ m_logRms = LOG_RMS_DEFAULT;
+ m_enableReporting = ENABLE_REPORTING_DEFAULT;
+ m_capturePluginPath = CAPTURE_PLUGIN_PATH_DEFAULT;
+ m_storageAudioFormat = STORAGE_AUDIO_FORMAT_DEFAULT;
+ m_numBatchThreads = NUM_BATCH_THREADS_DEFAULT;
+ m_deleteNativeFile = DELETE_NATIVE_FILE_DEFAULT;
+ m_audioChunkDefaultSize = AUDIO_CHUNK_DEFAULT_SIZE_DEFAULT;
+ m_audioSegmentation = AUDIO_SEGMENTATION_DEFAULT;
+ m_audioSegmentDuration = AUDIO_SEGMENT_DURATION_DEFAULT;
+ m_vad = VAD_DEFAULT;
+ m_vadHighThresholdDb = VAD_HIGH_THRESHOLD_DB_DEFAULT;
+ m_vadLowThresholdDb = VAD_LOW_THRESHOLD_DB_DEFAULT;
+ m_vadHoldOnSec = VAD_HOLD_ON_SEC_DEFAULT;
+ m_trackerHostname = TRACKER_HOSTNAME_DEFAULT;
+ m_trackerTcpPort = TRACKER_TCP_PORT_DEFAULT;
+ m_trackerServicename = TRACKER_SERVICENAME_DEFAULT;
+
+ char hostname[40];
+ ACE_OS::hostname(hostname, 40);
+ ACE_OS::hostname(hostname, HOSTNAME_BUF_LEN);
+ m_serviceName = CStdString("orkaudio-") + hostname;
+
+ m_reportingRetryDelay = 5;
+ m_clientTimeout = 5;
+}
+
+void Config::Define(Serializer* s)
+{
+ s->BoolValue(LOG_MESSAGES_PARAM, m_logMessages);
+ s->BoolValue(LOG_RMS_PARAM, m_logRms);
+ s->BoolValue(ENABLE_REPORTING_PARAM, m_enableReporting);
+ s->StringValue(CAPTURE_PLUGIN_PARAM, m_capturePlugin);
+ s->StringValue(CAPTURE_PLUGIN_PATH_PARAM, m_capturePluginPath);
+ s->EnumValue(STORAGE_AUDIO_FORMAT_PARAM, (int&)m_storageAudioFormat, AudioTape::FileFormatToEnum, AudioTape::FileFormatToString);
+ s->IntValue(NUM_BATCH_THREADS_PARAM, m_numBatchThreads);
+ s->BoolValue(DELETE_NATIVE_FILE_PARAM, m_deleteNativeFile);
+ s->IntValue(AUDIO_CHUNK_DEFAULT_SIZE_PARAM, m_audioChunkDefaultSize);
+ s->BoolValue(AUDIO_SEGMENTATION_PARAM, m_audioSegmentation);
+ s->IntValue(AUDIO_SEGMENT_DURATION_PARAM, m_audioSegmentDuration);
+ s->BoolValue(VAD_PARAM, m_vad);
+ s->DoubleValue(VAD_HIGH_THRESHOLD_DB_PARAM, m_vadHighThresholdDb);
+ s->DoubleValue(VAD_LOW_THRESHOLD_DB_PARAM, m_vadLowThresholdDb);
+ s->DoubleValue(VAD_HOLD_ON_SEC_PARAM, m_vadHoldOnSec);
+ s->StringValue(TRACKER_HOSTNAME_PARAM, m_trackerHostname);
+ s->IntValue(TRACKER_TCP_PORT_PARAM, m_trackerTcpPort);
+ s->StringValue(TRACKER_SERVICENAME_PARAM, m_trackerServicename);
+ s->StringValue(SERVICE_NAME_PARAM, m_serviceName);
+ s->IntValue(REPORTING_RETRY_DELAY_PARAM, m_reportingRetryDelay);
+ s->IntValue(CLIENT_TIMEOUT_PARAM, m_clientTimeout);
+}
+
+void Config::Validate()
+{
+ if (m_storageAudioFormat <= AudioTape::FfUnknown || m_storageAudioFormat >= AudioTape::FfInvalid)
+ {
+ throw CStdString(CStdString("Config::Validate: value out of range:") + STORAGE_AUDIO_FORMAT_PARAM);
+ }
+ if (m_numBatchThreads > 2)
+ {
+ LOG4CXX_WARN(LOG.configLog, "It is not recommended to have more batch threads than CPUs");
+ }
+ if (m_vadHighThresholdDb < -45.0 || m_vadHighThresholdDb>0.0)
+ {
+ throw CStdString(CStdString("Config::Validate: value out of range:") + VAD_HIGH_THRESHOLD_DB_PARAM);
+ }
+ if (m_vadLowThresholdDb < -45.0 || m_vadLowThresholdDb>0.0)
+ {
+ throw CStdString(CStdString("Config::Validate: value out of range:") + VAD_LOW_THRESHOLD_DB_PARAM);
+ }
+ if (m_vadHighThresholdDb < m_vadLowThresholdDb)
+ {
+ throw CStdString(CStdString("Config::Validate: ") + VAD_LOW_THRESHOLD_DB_PARAM + " should be lower than " + VAD_HIGH_THRESHOLD_DB_PARAM);
+ }
+ if (m_vad && m_audioSegmentation)
+ {
+ throw CStdString(CStdString("Config::Validate: please choose between audio segmentation and VAD ! Both cannot be true at the same time"));
+ }
+}
+
+CStdString Config::GetClassName()
+{
+ return CStdString("Config");
+}
+
+ObjectRef Config::NewInstance()
+{
+ return ObjectRef(new Config);
+}
+
diff --git a/orkaudio/Config.h b/orkaudio/Config.h
new file mode 100644
index 0000000..6b0567a
--- /dev/null
+++ b/orkaudio/Config.h
@@ -0,0 +1,98 @@
+/*
+ * 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 __CONFIG_H__
+#define __CONFIG_H__
+
+#include "StdString.h"
+#include "Object.h"
+#include "AudioTape.h"
+
+#define LOG_MESSAGES_PARAM "LogMessages"
+#define LOG_MESSAGES_DEFAULT false
+#define CAPTURE_PLUGIN_PARAM "CapturePlugin"
+#define CAPTURE_PLUGIN_DEFAULT ""
+#define CAPTURE_PLUGIN_PATH_PARAM "CapturePluginPath"
+#define CAPTURE_PLUGIN_PATH_DEFAULT "AudioCapturePlugins"
+#define STORAGE_AUDIO_FORMAT_PARAM "StorageAudioFormat"
+#define STORAGE_AUDIO_FORMAT_DEFAULT (AudioTape::FfGsm)
+#define NUM_BATCH_THREADS_PARAM "NumBatchThreads"
+#define NUM_BATCH_THREADS_DEFAULT 1
+#define DELETE_NATIVE_FILE_PARAM "DeleteNativeFile"
+#define DELETE_NATIVE_FILE_DEFAULT true
+#define ENABLE_REPORTING_PARAM "EnableReporting"
+#define ENABLE_REPORTING_DEFAULT true
+#define AUDIO_CHUNK_DEFAULT_SIZE_PARAM "AudioChunkDefaultSize"
+#define AUDIO_CHUNK_DEFAULT_SIZE_DEFAULT 8000
+#define AUDIO_SEGMENTATION_PARAM "AudioSegmentation"
+#define AUDIO_SEGMENTATION_DEFAULT false
+#define AUDIO_SEGMENT_DURATION_PARAM "AudioSegmentDuration"
+#define AUDIO_SEGMENT_DURATION_DEFAULT 60
+#define LOG_RMS_PARAM "LogRms"
+#define LOG_RMS_DEFAULT false
+#define VAD_PARAM "VAD"
+#define VAD_DEFAULT false
+#define VAD_HIGH_THRESHOLD_DB_PARAM "VadHighThresholdDb"
+#define VAD_HIGH_THRESHOLD_DB_DEFAULT -12.2
+#define VAD_LOW_THRESHOLD_DB_PARAM "VadLowThresholdDb"
+#define VAD_LOW_THRESHOLD_DB_DEFAULT -12.5
+#define VAD_HOLD_ON_SEC_PARAM "VadHoldOnSec"
+#define VAD_HOLD_ON_SEC_DEFAULT 4
+#define TRACKER_HOSTNAME_PARAM "TrackerHostname"
+#define TRACKER_HOSTNAME_DEFAULT "localhost"
+#define TRACKER_TCP_PORT_PARAM "TrackerTcpPort"
+#define TRACKER_TCP_PORT_DEFAULT 8080
+#define TRACKER_SERVICENAME_PARAM "TrackerServicename"
+#define TRACKER_SERVICENAME_DEFAULT "orktrack"
+#define SERVICE_NAME_PARAM "ServiceName"
+#define REPORTING_RETRY_DELAY_PARAM "ReportingRetryDelay"
+#define CLIENT_TIMEOUT_PARAM "ClientTimeout"
+
+
+class Config : public Object
+{
+public:
+ Config();
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ bool m_logMessages;
+ bool m_logRms;
+ bool m_enableReporting;
+ CStdString m_capturePlugin;
+ CStdString m_capturePluginPath;
+ int m_numBatchThreads;
+ bool m_deleteNativeFile;
+ int m_audioChunkDefaultSize;
+ bool m_audioSegmentation;
+ int m_audioSegmentDuration;
+ AudioTape::FileFormatEnum m_storageAudioFormat;
+ bool m_vad;
+ double m_vadHighThresholdDb;
+ double m_vadLowThresholdDb;
+ double m_vadHoldOnSec;
+ CStdString m_trackerHostname;
+ CStdString m_trackerServicename;
+ int m_trackerTcpPort;
+ CStdString m_serviceName;
+ int m_reportingRetryDelay;
+ int m_clientTimeout;
+};
+
+
+#endif
+
diff --git a/orkaudio/ConfigManager.cpp b/orkaudio/ConfigManager.cpp
new file mode 100644
index 0000000..df38818
--- /dev/null
+++ b/orkaudio/ConfigManager.cpp
@@ -0,0 +1,98 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/dom/DOMWriter.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
+#include <xercesc/dom/DOMImplementationRegistry.hpp>
+#include "serializers/DomSerializer.h"
+#include "ConfigManager.h"
+#include "LogManager.h"
+
+#define CONFIG_FILE_NAME "config.xml"
+
+
+void ConfigManager::Initialize()
+{
+ bool failed = false;
+ m_configTopNode = NULL;
+
+ try
+ {
+ XMLPlatformUtils::Initialize();
+ XercesDOMParser *parser = new XercesDOMParser;
+ parser->parse(CONFIG_FILE_NAME);
+ DOMNode *doc = NULL;
+ doc = parser->getDocument();
+
+ if (doc)
+ {
+ DOMNode *firstChild = doc->getFirstChild();
+ if (firstChild)
+ {
+ m_configTopNode = firstChild;
+ m_config.DeSerializeDom(firstChild);
+
+ /*
+ // Write out config to a file
+ DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(XStr("Core").unicodeForm());
+ XERCES_CPP_NAMESPACE::DOMDocument* myDoc;
+ myDoc = impl->createDocument(
+ 0, // root element namespace URI.
+ XStr("root").unicodeForm(), // root element name
+ 0); // document type object (DTD).
+ m_config.SerializeDom(myDoc);
+ CStdString toto = DomSerializer::DomNodeToString(myDoc);
+ FILE* file = fopen("zzz.xml", "w");
+ fwrite((PCSTR)toto,1,toto.GetLength(),file);
+ fclose(file);
+ */
+ }
+ else
+ {
+ LOG4CXX_ERROR(LOG.configLog, CStdString("Could not parse config file:") + CONFIG_FILE_NAME);
+ failed = true;
+ }
+ }
+ else
+ {
+ LOG4CXX_WARN(LOG.configLog, CStdString("Could not find config file:") + CONFIG_FILE_NAME);
+ }
+ }
+ catch (const CStdString& e)
+ {
+ LOG4CXX_ERROR(LOG.configLog, e);
+ failed = true;
+ }
+ catch(const XMLException& e)
+ {
+ LOG4CXX_ERROR(LOG.configLog, e.getMessage());
+ failed = true;
+ }
+ if (failed)
+ {
+ exit(0);
+ }
+}
+
+
+void ConfigManager::AddConfigureFunction(ConfigureFunction configureFunction)
+{
+ m_configureFunction = configureFunction;
+ // Cal the external configure callback straight away
+ m_configureFunction(m_configTopNode);
+}
+
diff --git a/orkaudio/ConfigManager.h b/orkaudio/ConfigManager.h
new file mode 100644
index 0000000..a3eb42b
--- /dev/null
+++ b/orkaudio/ConfigManager.h
@@ -0,0 +1,38 @@
+/*
+ * 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 __CONFIGMANAGER_H__
+#define __CONFIGMANAGER_H__
+
+#include "ace/Singleton.h"
+#include "Config.h"
+#include "AudioCapturePlugin.h"
+
+class ConfigManager
+{
+public:
+ void Initialize();
+ void AddConfigureFunction(ConfigureFunction);
+
+ Config m_config;
+private:
+ ConfigureFunction m_configureFunction;
+ DOMNode* m_configTopNode;
+};
+
+typedef ACE_Singleton<ConfigManager, ACE_Thread_Mutex> ConfigManagerSingleton;
+
+#define CONFIG ConfigManagerSingleton::instance()->m_config
+
+#endif
+
diff --git a/orkaudio/Daemon.cpp b/orkaudio/Daemon.cpp
new file mode 100644
index 0000000..f834a7a
--- /dev/null
+++ b/orkaudio/Daemon.cpp
@@ -0,0 +1,194 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#ifdef WIN32
+#include <windows.h>
+#include <tchar.h>
+SERVICE_STATUS serviceStatus;
+SERVICE_STATUS_HANDLE serviceStatusHandle = 0;
+HANDLE stopServiceEvent = 0;
+#endif
+#include "Daemon.h"
+
+#ifdef WIN32
+void WINAPI ServiceControlHandler( DWORD controlCode )
+{
+ switch ( controlCode )
+ {
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+
+ case SERVICE_CONTROL_SHUTDOWN:
+ case SERVICE_CONTROL_STOP:
+ serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+ DaemonSingleton::instance()->Stop();
+ return;
+
+ case SERVICE_CONTROL_PAUSE:
+ break;
+
+ case SERVICE_CONTROL_CONTINUE:
+ break;
+
+ default:
+ ;
+ }
+
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+}
+#endif
+
+void Daemon::Initialize(CStdString serviceName, DaemonHandler runHandler, DaemonHandler stopHandler)
+{
+ m_runHandler = runHandler;
+ m_stopHandler = stopHandler;
+ m_serviceName = serviceName;
+}
+
+void Daemon::Start()
+{
+#ifdef WIN32
+ // change current directory to service location (default for NT services is system32)
+ CStdString workingDirectory;
+
+ TCHAR path[ _MAX_PATH + 1 ];
+ if ( GetModuleFileName( 0, path, sizeof(path)/sizeof(path[0]) ) > 0 )
+ {
+ CStdString pathString = path;
+ int lastBackSlashPosition = pathString.ReverseFind("\\");
+ if (lastBackSlashPosition != -1)
+ {
+ workingDirectory = pathString.Left(lastBackSlashPosition);
+ chdir((PCSTR)workingDirectory);
+ }
+ }
+
+ SERVICE_TABLE_ENTRY serviceTable[] =
+ {
+ { (char *)(PCSTR)m_serviceName, Daemon::Run },
+ { 0, 0 }
+ };
+
+ StartServiceCtrlDispatcher( serviceTable );
+#else
+ Daemon::Run();
+#endif
+}
+
+#ifdef WIN32
+void WINAPI Daemon::Run( DWORD /*argc*/, TCHAR* /*argv*/[] )
+#else
+void Daemon::Run()
+#endif
+{
+#ifdef WIN32
+ // initialise service status
+ serviceStatus.dwServiceType = SERVICE_WIN32;
+ serviceStatus.dwCurrentState = SERVICE_START_PENDING;
+ serviceStatus.dwControlsAccepted = 0;
+ serviceStatus.dwWin32ExitCode = NO_ERROR;
+ serviceStatus.dwServiceSpecificExitCode = NO_ERROR;
+ serviceStatus.dwCheckPoint = 0;
+ serviceStatus.dwWaitHint = 0;
+
+ serviceStatusHandle = RegisterServiceCtrlHandler( (PCSTR)DaemonSingleton::instance()->m_serviceName, ServiceControlHandler );
+ if ( serviceStatusHandle )
+ {
+ // service is starting
+ serviceStatus.dwCurrentState = SERVICE_START_PENDING;
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+
+ // running
+ serviceStatus.dwControlsAccepted |= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
+ serviceStatus.dwCurrentState = SERVICE_RUNNING;
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+ }
+#endif
+
+ DaemonSingleton::instance()->m_runHandler();
+
+#ifdef WIN32
+ // service was stopped
+ serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+
+ // do cleanup here
+ CloseHandle( stopServiceEvent );
+ stopServiceEvent = 0;
+
+ // service is now stopped
+ serviceStatus.dwControlsAccepted &= ~(SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
+ serviceStatus.dwCurrentState = SERVICE_STOPPED;
+ SetServiceStatus( serviceStatusHandle, &serviceStatus );
+#endif
+}
+
+void Daemon::Stop()
+{
+ m_stopHandler();
+}
+
+void Daemon::Install()
+{
+#ifdef WIN32
+ SC_HANDLE serviceControlManager = OpenSCManager( 0, 0, SC_MANAGER_CREATE_SERVICE );
+
+ if ( serviceControlManager )
+ {
+ TCHAR path[ _MAX_PATH + 1 ];
+ if ( GetModuleFileName( 0, path, sizeof(path)/sizeof(path[0]) ) > 0 )
+ {
+ SC_HANDLE service = CreateService( serviceControlManager,
+ (PCSTR)m_serviceName, (PCSTR)m_serviceName,
+ SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, path,
+ 0, 0, 0, 0, 0 );
+ if ( service )
+ CloseServiceHandle( service );
+ }
+
+ CloseServiceHandle( serviceControlManager );
+ }
+#endif
+}
+
+void Daemon::Uninstall()
+{
+#ifdef WIN32
+ SC_HANDLE serviceControlManager = OpenSCManager( 0, 0, SC_MANAGER_CONNECT );
+
+ if ( serviceControlManager )
+ {
+ SC_HANDLE service = OpenService( serviceControlManager,
+ (PCSTR)m_serviceName, SERVICE_QUERY_STATUS | DELETE );
+ if ( service )
+ {
+ SERVICE_STATUS serviceStatus;
+ if ( QueryServiceStatus( service, &serviceStatus ) )
+ {
+ if ( serviceStatus.dwCurrentState == SERVICE_STOPPED )
+ DeleteService( service );
+ }
+
+ CloseServiceHandle( service );
+ }
+
+ CloseServiceHandle( serviceControlManager );
+ }
+#endif
+}
+
diff --git a/orkaudio/Daemon.h b/orkaudio/Daemon.h
new file mode 100644
index 0000000..e19fff7
--- /dev/null
+++ b/orkaudio/Daemon.h
@@ -0,0 +1,47 @@
+/*
+ * 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 __DAEMON_H__
+#define __DAEMON_H__
+
+#include "StdString.h"
+#include "ace/Singleton.h"
+#include "ace/Thread_Mutex.h"
+
+typedef void (*DaemonHandler)(void);
+
+class Daemon
+{
+public:
+ //void Initialize(CStdString serviceName, void (*RunHandler)(void), void(*StopHandler)(void));
+ void Initialize(CStdString serviceName, DaemonHandler runHandler, DaemonHandler stopHandler);
+ void Start();
+ void Stop();
+ void Install();
+ void Uninstall();
+private:
+#ifdef WIN32
+ static void WINAPI Run( DWORD /*argc*/, TCHAR* /*argv*/[] );
+#else
+ static void Run();
+#endif
+
+ DaemonHandler m_runHandler;
+ DaemonHandler m_stopHandler;
+ CStdString m_serviceName;
+};
+
+typedef ACE_Singleton<Daemon, ACE_Thread_Mutex> DaemonSingleton;
+
+#endif
+
diff --git a/orkaudio/ImmediateProcessing.cpp b/orkaudio/ImmediateProcessing.cpp
new file mode 100644
index 0000000..197f505
--- /dev/null
+++ b/orkaudio/ImmediateProcessing.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "ImmediateProcessing.h"
+#include "LogManager.h"
+#include "ace/OS_NS_unistd.h"
+#include "BatchProcessing.h"
+
+ImmediateProcessing ImmediateProcessing::m_immediateProcessingSingleton;
+
+ImmediateProcessing* ImmediateProcessing::GetInstance()
+{
+ return &m_immediateProcessingSingleton;
+}
+
+void ImmediateProcessing::AddAudioTape(AudioTapeRef audioTapeRef)
+{
+ if (!m_audioTapeQueue.push(audioTapeRef))
+ {
+ // Log error
+ LOG4CXX_ERROR(LOG.immediateProcessingLog, CStdString("ImmediateProcessing: queue full"));
+ }
+}
+
+void ImmediateProcessing::ThreadHandler(void *args)
+{
+ ImmediateProcessing* pImmediateProcessing = ImmediateProcessing::GetInstance();
+
+ for(;;)
+ {
+ try
+ {
+ AudioTapeRef audioTapeRef = pImmediateProcessing->m_audioTapeQueue.pop();
+ //LOG4CXX_DEBUG(LOG.immediateProcessingLog, CStdString("Got chunk"));
+
+ audioTapeRef->Write();
+
+ if (audioTapeRef->IsStoppedAndValid())
+ {
+ // Forward to batch processing thread
+ BatchProcessing::GetInstance()->AddAudioTape(audioTapeRef);
+ }
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_ERROR(LOG.immediateProcessingLog, CStdString("ImmediateProcessing: ") + e);
+ }
+ }
+}
+
+
diff --git a/orkaudio/ImmediateProcessing.h b/orkaudio/ImmediateProcessing.h
new file mode 100644
index 0000000..617f105
--- /dev/null
+++ b/orkaudio/ImmediateProcessing.h
@@ -0,0 +1,34 @@
+/*
+ * 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 __IMMEDIATEPROCESSING_H__
+#define __IMMEDIATEPROCESSING_H__
+
+#include "ThreadSafeQueue.h"
+#include "AudioTape.h"
+
+class ImmediateProcessing
+{
+public:
+ static ImmediateProcessing* GetInstance();
+ static void ThreadHandler(void *args);
+
+ void AddAudioTape(AudioTapeRef audioTapeRef);
+private:
+ static ImmediateProcessing m_immediateProcessingSingleton;
+ ThreadSafeQueue<AudioTapeRef> m_audioTapeQueue;
+
+};
+
+#endif
+
diff --git a/orkaudio/LogManager.cpp b/orkaudio/LogManager.cpp
new file mode 100644
index 0000000..6639c98
--- /dev/null
+++ b/orkaudio/LogManager.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "LogManager.h"
+#include <log4cxx/propertyconfigurator.h>
+#include <log4cxx/basicconfigurator.h>
+
+void LogManager::Initialize()
+{
+ BasicConfigurator::configure();
+
+ // If this one fails, the above default configuration stays valid
+ PropertyConfigurator::configure("logging.properties");
+
+ rootLog = Logger::getLogger("root");
+ topLog = Logger::getLogger("top");
+ immediateProcessingLog = Logger::getLogger("immediateProcessing");
+ batchProcessingLog = Logger::getLogger("batchProcessing");
+ portLog = Logger::getLogger("port");
+ fileLog = Logger::getLogger("file");
+ reportingLog = Logger::getLogger("reporting");
+ configLog = Logger::getLogger("config");
+ tapelistLog = Logger::getLogger("tapelist");
+}
+
diff --git a/orkaudio/LogManager.h b/orkaudio/LogManager.h
new file mode 100644
index 0000000..e605aa5
--- /dev/null
+++ b/orkaudio/LogManager.h
@@ -0,0 +1,44 @@
+/*
+ * 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 __LOGMANAGER_H__
+#define __LOGMANAGER_H__
+
+#include <log4cxx/logger.h>
+#include "ace/Singleton.h"
+
+using namespace log4cxx;
+
+
+class LogManager
+{
+public:
+ void Initialize();
+
+ LoggerPtr rootLog;
+ LoggerPtr topLog;
+ LoggerPtr immediateProcessingLog;
+ LoggerPtr batchProcessingLog;
+ LoggerPtr portLog;
+ LoggerPtr fileLog;
+ LoggerPtr reportingLog;
+ LoggerPtr configLog;
+ LoggerPtr tapelistLog;
+};
+
+typedef ACE_Singleton<LogManager, ACE_Thread_Mutex> LogManagerSingleton;
+
+#define LOG (*LogManagerSingleton::instance())
+
+#endif
+
diff --git a/orkaudio/Makefile.am b/orkaudio/Makefile.am
new file mode 100644
index 0000000..659c8d1
--- /dev/null
+++ b/orkaudio/Makefile.am
@@ -0,0 +1,18 @@
+# not a GNU package. You can remove this line, if
+# have all needed files, that a GNU package needs
+AUTOMAKE_OPTIONS = foreign 1.4
+
+
+bin_PROGRAMS = orkaudio
+orkaudio_LDADD =
+orkaudio_LDFLAGS = -lsndfile -lACE -lxerces-c -llog4cxx -lorkbase
+orkaudio_SOURCES = OrkAudio.cpp AudioTape.cpp \
+ BatchProcessing.cpp CapturePluginProxy.cpp \
+ CapturePort.cpp Config.cpp ConfigManager.cpp \
+ Daemon.cpp ImmediateProcessing.cpp LogManager.cpp \
+ MultiThreadedServer.cpp Reporting.cpp
+AM_CPPFLAGS = -D_REENTRANT
+INCLUDES = -I@top_srcdir@ -I../orkbasecxx
+SUBDIRS = audiocaptureplugins messages audiofile
+orkaudio_LDADD = $(top_builddir)/messages/libmessages.la \
+ $(top_builddir)/audiofile/libaudiofile.la
diff --git a/orkaudio/Makefile.cvs b/orkaudio/Makefile.cvs
new file mode 100644
index 0000000..d160702
--- /dev/null
+++ b/orkaudio/Makefile.cvs
@@ -0,0 +1,8 @@
+default: all
+
+all:
+ aclocal
+ autoheader
+ automake
+ autoconf
+
diff --git a/orkaudio/MultiThreadedServer.cpp b/orkaudio/MultiThreadedServer.cpp
new file mode 100644
index 0000000..458f781
--- /dev/null
+++ b/orkaudio/MultiThreadedServer.cpp
@@ -0,0 +1,223 @@
+/*
+ * 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 "MultiThreadedServer.h"
+
+#include "ace/INET_Addr.h"
+#include "ace/OS_NS_string.h"
+#include "ObjectFactory.h"
+#include "serializers/SingleLineSerializer.h"
+#include "serializers/DomSerializer.h"
+#include "serializers/UrlSerializer.h"
+#include "LogManager.h"
+#include "Utils.h"
+#include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/dom/DOMWriter.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
+#include <xercesc/dom/DOMImplementationRegistry.hpp>
+
+
+int CommandLineServer::open (void *void_acceptor)
+{
+ return this->activate (THR_DETACHED);
+}
+
+
+void CommandLineServer::run(void* args)
+{
+ unsigned short tcpPort = (unsigned short)args;
+ CommandLineAcceptor peer_acceptor;
+ ACE_INET_Addr addr (tcpPort);
+ ACE_Reactor reactor;
+
+ if (peer_acceptor.open (addr, &reactor) == -1)
+ {
+ CStdString tcpPortString = IntToString(tcpPort);
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Failed to start command line server on port:") + tcpPortString);
+ }
+ else
+ {
+ for(;;)
+ {
+ reactor.handle_events();
+ }
+ }
+}
+
+int CommandLineServer::svc(void)
+{
+ for (bool active = true;active == true;)
+ {
+ char buf[2048];
+ ACE_Time_Value timeout;
+ timeout.sec(3600);
+ int i = 0;
+
+ // Display prompt
+ char prompt[] = "\r\n>";
+ peer().send(prompt, 3);
+
+ // Get one command line
+ bool foundCRLF = false;
+ while(active && !foundCRLF && i<2040)
+ {
+ ssize_t size = peer().recv(buf+i, 2040-i, &timeout);
+
+ if (size == 0 || size == -1)
+ {
+ active = false;
+ }
+ else
+ {
+ for(int j=0; j<size && !foundCRLF;j++)
+ {
+ if(buf[i+j] == '\r' || buf[i+j] == '\n')
+ {
+ foundCRLF = true;
+ buf[i+j] = '\0';
+ CStdString command(buf);
+ try
+ {
+ CStdString className = SingleLineSerializer::FindClass(command);
+ ObjectRef objRef = ObjectFactorySingleton::instance()->NewInstance(className);
+ if (objRef.get())
+ {
+ objRef->DeSerializeSingleLine(command);
+ ObjectRef response = objRef->Process();
+ CStdString responseString = response->SerializeSingleLine();
+ peer().send((PCSTR)responseString, responseString.GetLength());
+ }
+ else
+ {
+ CStdString error = "Unrecognized command";
+ peer().send(error, error.GetLength()); ;
+ }
+ }
+ catch (CStdString& e)
+ {
+ peer().send(e, e.GetLength()); ;
+ }
+ }
+ }
+ i += size;
+ }
+ }
+ }
+ return 0;
+}
+
+
+//==============================================================
+
+int HttpServer::open (void *void_acceptor)
+{
+ return this->activate (THR_DETACHED);
+}
+
+
+void HttpServer::run(void* args)
+{
+ unsigned short tcpPort = (unsigned short)args;
+ HttpAcceptor peer_acceptor;
+ ACE_INET_Addr addr (tcpPort);
+ ACE_Reactor reactor;
+
+ if (peer_acceptor.open (addr, &reactor) == -1)
+ {
+ CStdString tcpPortString = IntToString(tcpPort);
+ LOG4CXX_ERROR(LOG.rootLog, CStdString("Failed to start http server on port:") + tcpPortString);
+ }
+ else
+ {
+ for(;;)
+ {
+ reactor.handle_events();
+ }
+ }
+}
+
+int HttpServer::svc(void)
+{
+ char buf[2048];
+ buf[2047] = '\0'; // security
+ ACE_Time_Value timeout;
+
+ ssize_t size = peer().recv(buf, 2040);
+
+ if (size > 5)
+ {
+ try
+ {
+ int startUrlOffset = 5; // get rid of "GET /" from Http request, so skip 5 chars
+ char* stopUrl = ACE_OS::strstr(buf+startUrlOffset, " HTTP"); // detect location of post-URL trailing stuff
+ if(!stopUrl)
+ {
+ throw (CStdString("Malformed http request")); ;
+ }
+ *stopUrl = '\0'; // Remove post-URL trailing stuff
+ CStdString url(buf+startUrlOffset);
+ int queryOffset = url.Find("?");
+ if (queryOffset > 0)
+ {
+ // Strip beginning of URL in case the command is received as an URL "query" of the form:
+ // http://hostname/service/command?type=ping
+ url = url.Right(url.size() - queryOffset - 1);
+ }
+
+
+ CStdString className = UrlSerializer::FindClass(url);
+ ObjectRef objRef = ObjectFactorySingleton::instance()->NewInstance(className);
+ if (objRef.get())
+ {
+ objRef->DeSerializeUrl(url);
+ ObjectRef response = objRef->Process();
+
+ DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(XStr("Core").unicodeForm());
+ XERCES_CPP_NAMESPACE::DOMDocument* myDoc;
+ myDoc = impl->createDocument(
+ 0, // root element namespace URI.
+ XStr("response").unicodeForm(), // root element name
+ 0); // document type object (DTD).
+ response->SerializeDom(myDoc);
+ CStdString pingResponse = DomSerializer::DomNodeToString(myDoc);
+
+ CStdString httpOk("HTTP/1.0 200 OK\r\nContent-type: text/xml\r\n\r\n");
+ peer().send(httpOk, httpOk.GetLength());
+ peer().send(pingResponse, pingResponse.GetLength());
+ }
+ else
+ {
+ throw (CStdString("Command not found:") + className); ;
+ }
+
+ }
+ catch (CStdString &e)
+ {
+ CStdString error("HTTP/1.0 404 not found\r\nContent-type: text/html\r\n\r\nError\r\n");
+ error = error + e + "\r\n";
+ peer().send(error, error.GetLength());
+ }
+ catch(const XMLException& e)
+ {
+ CStdString error("HTTP/1.0 404 not found\r\nContent-type: text/html\r\n\r\nXML Error\r\n");
+ peer().send(error, error.GetLength());
+ }
+ }
+ else
+ {
+ CStdString notFound("HTTP/1.0 404 not found\r\nContent-type: text/html\r\n\r\nNot found\r\n");
+ peer().send(notFound, notFound.GetLength());
+ }
+ return 0;
+}
+
diff --git a/orkaudio/MultiThreadedServer.h b/orkaudio/MultiThreadedServer.h
new file mode 100644
index 0000000..19c58bc
--- /dev/null
+++ b/orkaudio/MultiThreadedServer.h
@@ -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
+ *
+ */
+
+#ifndef __MULTITHREADEDSERVER_H__
+#define __MULTITHREADEDSERVER_H__
+
+#include "ace/Acceptor.h"
+#include "ace/SOCK_Acceptor.h"
+
+/** This server accepts permanent telnet like connections.
+ commands are accepted in "single line" format.
+ one thread per connection
+*/
+class CommandLineServer : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
+{
+public:
+ virtual int open (void *);
+ /** daemon thread */
+ static void run(void *args);
+ /** service routine */
+ virtual int svc (void);
+};
+typedef ACE_Acceptor<CommandLineServer, ACE_SOCK_ACCEPTOR> CommandLineAcceptor;
+
+
+/** This server is a lightweight http server that extracts commands from URLs and outputs results in xml format
+ one thread per connection
+ Example url:
+ http://localhost:23000/message=print&text=hello
+*/
+class HttpServer : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
+{
+public:
+ virtual int open (void *);
+ /** daemon thread */
+ static void run(void *args);
+ /** service routine */
+ virtual int svc (void);
+};
+typedef ACE_Acceptor<HttpServer, ACE_SOCK_ACCEPTOR> HttpAcceptor;
+
+#endif
+
diff --git a/orkaudio/OrkAudio.cpp b/orkaudio/OrkAudio.cpp
new file mode 100644
index 0000000..45a1434
--- /dev/null
+++ b/orkaudio/OrkAudio.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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 "stdio.h"
+
+#include "MultiThreadedServer.h"
+#include "ace/Thread_Manager.h"
+#include "OrkAudio.h"
+#include "Utils.h"
+#include "messages/TapeMsg.h"
+#include "messages/PingMsg.h"
+#include "messages/DeleteTapeMsg.h"
+#include "messages/CaptureMsg.h"
+#include "messages/TestMsg.h"
+#include "Config.h"
+#include "LogManager.h"
+#include "ImmediateProcessing.h"
+#include "BatchProcessing.h"
+#include "Reporting.h"
+#include "ConfigManager.h"
+#include "Daemon.h"
+#include "ObjectFactory.h"
+#include "CapturePluginProxy.h"
+#include "ace/OS_NS_arpa_inet.h"
+
+
+static volatile bool serviceStop = false;
+
+void StopHandler()
+{
+ serviceStop = true;
+}
+
+void MainThread()
+{
+ LogManagerSingleton::instance()->Initialize();
+ LOG4CXX_INFO(LOG.rootLog, CStdString("\n\nOrkAudio service starting\n"));
+
+ // Initialize object factory and register existing objects
+ ObjectFactorySingleton::instance()->Initialize();
+
+ ObjectRef objRef;
+ objRef.reset(new PingMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+ objRef.reset(new TapeMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+ objRef.reset(new SimpleResponseMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+ objRef.reset(new DeleteTapeMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+ objRef.reset(new CaptureMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+ objRef.reset(new TestMsg);
+ ObjectFactorySingleton::instance()->RegisterObject(objRef);
+
+ ConfigManagerSingleton::instance()->Initialize();
+
+ if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(ImmediateProcessing::ThreadHandler)))
+ {
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create immediate processing thread"));
+ }
+ if(CONFIG.m_storageAudioFormat != AudioTape::FfNative)
+ {
+ // storage format is not native, which means we need batch workers to compress to wanted format
+ if (!ACE_Thread_Manager::instance()->spawn_n(CONFIG.m_numBatchThreads, ACE_THR_FUNC(BatchProcessing::ThreadHandler)))
+ {
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create batch processing thread"));
+ }
+ }
+ if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(Reporting::ThreadHandler)))
+ {
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create reporting thread"));
+ }
+ // Create command line server on port 10000
+ if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(CommandLineServer::run), (void *)10000))
+ {
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create command line server"));
+ }
+
+ // Create Http server on port 20000
+ if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(HttpServer::run), (void *)20000))
+ {
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create Http server"));
+ }
+
+ if(CapturePluginProxySingleton::instance()->Initialize())
+ {
+ CapturePluginProxySingleton::instance()->Run();
+ }
+
+ //ACE_Thread_Manager::instance ()->wait ();
+ while(serviceStop == false)
+ {
+ ACE_OS::sleep(1);
+ }
+ LOG4CXX_INFO(LOG.rootLog, CStdString("Stopping service"));
+}
+
+
+int main(int argc, char* argv[])
+{
+ // figure out service name
+ CStdString program(argv[0]);
+ CStdString serviceNameWithExtension = BaseName(program);
+ CStdString serviceName = StripFileExtension(serviceNameWithExtension);
+ if (serviceName.IsEmpty())
+ {
+ return -1;
+ }
+
+ DaemonSingleton::instance()->Initialize(serviceName, MainThread, StopHandler);
+ CStdString argument = argv[1];
+
+ if (argc>1)
+ {
+ if (argument.CompareNoCase("debug") == 0)
+ {
+ MainThread();
+ }
+ else if (argument.CompareNoCase("install") == 0)
+ {
+ DaemonSingleton::instance()->Install();
+ }
+ else if (argument.CompareNoCase("uninstall") == 0)
+ {
+ DaemonSingleton::instance()->Uninstall();
+ }
+ else
+ {
+ printf("Argument incorrect. Possibilies are:\n\tdebug\n\tinstall\n\tuninstall\n");
+ }
+ }
+ else
+ {
+ // No arguments, launch the daemon
+ DaemonSingleton::instance()->Start();
+ }
+ return 0;
+}
+
diff --git a/orkaudio/OrkAudio.dsp b/orkaudio/OrkAudio.dsp
new file mode 100644
index 0000000..d32442d
--- /dev/null
+++ b/orkaudio/OrkAudio.dsp
@@ -0,0 +1,278 @@
+# Microsoft Developer Studio Project File - Name="OrkAudio" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=OrkAudio - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "OrkAudio.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "OrkAudio.mak" CFG="OrkAudio - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "OrkAudio - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "OrkAudio - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "OrkAudio - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /Op /Ob0 /I "." /I "..\OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0\\" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "C:\devExt\libsndfile\src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 OrkBase.lib LIBSNDFILE.lib xerces-c_2.lib log4cxx.lib ace.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"..\OrkbaseCxx\Release" /libpath:"C:\devExt\ACE_wrappers\lib" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Release" /libpath:"C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\lib" /libpath:"C:\devExt\libsndfile\Release"
+
+!ELSEIF "$(CFG)" == "OrkAudio - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0\\" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "C:\devExt\libsndfile\src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 OrkBaseD.lib LIBSNDFILE.lib xerces-c_2D.lib log4cxx.lib aced.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\OrkbaseCxx\Debug" /libpath:"C:\devExt\ACE_wrappers\lib" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Debug" /libpath:"C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\lib" /libpath:"C:\devExt\libsndfile\Debug"
+
+!ENDIF
+
+# Begin Target
+
+# Name "OrkAudio - Win32 Release"
+# Name "OrkAudio - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Group "Messages"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Messages\CaptureMsg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\CaptureMsg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\DeleteTapeMsg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\DeleteTapeMsg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\PingMsg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\PingMsg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\TapeMsg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Messages\TapeMsg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\messages\TestMsg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\messages\TestMsg.h
+# End Source File
+# End Group
+# Begin Group "AudioFile"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\AudioFile\AudioFile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioFile\AudioFile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioFile\LibSndFileFile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioFile\LibSndFileFile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioFile\PcmFile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioFile\PcmFile.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\App.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioCapturePlugin.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioTape.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\AudioTape.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BatchProcessing.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BatchProcessing.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\CapturePluginProxy.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CapturePluginProxy.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\CapturePort.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CapturePort.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Config.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Config.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ConfigManager.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ConfigManager.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Daemon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Daemon.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ImmediateProcessing.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ImmediateProcessing.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LogManager.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\LogManager.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\MultiThreadedServer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MultiThreadedServer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\OrkAudio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\OrkAudio.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Reporting.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Reporting.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ThreadSafeQueue.h
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/orkaudio/OrkAudio.dsw b/orkaudio/OrkAudio.dsw
new file mode 100644
index 0000000..5c6f152
--- /dev/null
+++ b/orkaudio/OrkAudio.dsw
@@ -0,0 +1,89 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ACE"=..\..\devExt\ACE_wrappers\ace\ACE.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Generator"=.\AUDIOCAPTUREPLUGINS\Generator\Generator.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "OrkAudio"=.\OrkAudio.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "OrkBase"=..\OrkBaseCxx\OrkBase.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "SoundDevice"=.\AudioCapturePlugins\SoundDevice\SoundDevice.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "VoIp"=.\audiocaptureplugins\voip\VoIp.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/orkaudio/OrkAudio.h b/orkaudio/OrkAudio.h
new file mode 100644
index 0000000..f9a8c47
--- /dev/null
+++ b/orkaudio/OrkAudio.h
@@ -0,0 +1,13 @@
+/*
+ * 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
+ *
+ */
+
diff --git a/orkaudio/Reporting.cpp b/orkaudio/Reporting.cpp
new file mode 100644
index 0000000..1360dfe
--- /dev/null
+++ b/orkaudio/Reporting.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "ConfigManager.h"
+#include "Reporting.h"
+#include "LogManager.h"
+#include "messages/Message.h"
+#include "OrkClient.h"
+
+Reporting Reporting::m_reportingSingleton;
+
+Reporting* Reporting::GetInstance()
+{
+ return &m_reportingSingleton;
+}
+
+void Reporting::AddAudioTape(AudioTapeRef audioTapeRef)
+{
+ if (!m_audioTapeQueue.push(audioTapeRef))
+ {
+ LOG4CXX_ERROR(LOG.reportingLog, CStdString("Reporting: queue full"));
+ }
+}
+
+void Reporting::ThreadHandler(void *args)
+{
+ Reporting* pReporting = Reporting::GetInstance();
+
+ for(;;)
+ {
+ AudioTapeRef audioTapeRef = pReporting->m_audioTapeQueue.pop();
+
+ MessageRef msgRef;
+ audioTapeRef->GetMessage(msgRef);
+ if(msgRef.get() && CONFIG.m_enableReporting)
+ {
+ CStdString msgAsSingleLineString = msgRef->SerializeSingleLine();
+ LOG4CXX_INFO(LOG.reportingLog, msgAsSingleLineString);
+
+ OrkHttpSingleLineClient c;
+ SimpleResponseMsg srm;
+ while (!c.Execute((SyncMessage&)(*msgRef.get()), srm, CONFIG.m_trackerHostname, CONFIG.m_trackerTcpPort, CONFIG.m_trackerServicename, CONFIG.m_clientTimeout))
+ {
+ ACE_OS::sleep(5);
+ }
+ //CStdString host("foo");
+ //while (!msgRef->InvokeXmlRpc(host, 10000))
+ //{
+ // ACE_OS::sleep(5);
+ //}
+ }
+ }
+}
+
+
diff --git a/orkaudio/Reporting.h b/orkaudio/Reporting.h
new file mode 100644
index 0000000..0d09333
--- /dev/null
+++ b/orkaudio/Reporting.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 __REPORTING_H__
+#define __REPORTING_H__
+
+#include "ThreadSafeQueue.h"
+#include "AudioTape.h"
+
+class Reporting
+{
+public:
+ static Reporting* GetInstance();
+ static void ThreadHandler(void *args);
+
+ void AddAudioTape(AudioTapeRef audioTapeRef);
+private:
+ static Reporting m_reportingSingleton;
+ ThreadSafeQueue<AudioTapeRef> m_audioTapeQueue;
+};
+
+#endif
+
diff --git a/orkaudio/ThreadSafeQueue.h b/orkaudio/ThreadSafeQueue.h
new file mode 100644
index 0000000..4fcc330
--- /dev/null
+++ b/orkaudio/ThreadSafeQueue.h
@@ -0,0 +1,76 @@
+/*
+ * 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 __THREADSAFEQUEUE_H__
+#define __THREADSAFEQUEUE_H__
+
+#include <queue>
+#include "ace/Thread_Mutex.h"
+#include "ace/Thread_Semaphore.h"
+#include "Utils.h"
+
+/** Thread safe queue holding objects of arbitrary class.
+ Enqueuing is never blocking
+ Dequeuing is blocking when the queue is empty
+ */
+template <class T> class ThreadSafeQueue
+{
+public:
+ ThreadSafeQueue(int size = 1000)
+ {
+ m_size = size;
+ m_semaphore.acquire(); // reset count to zero
+ };
+
+ bool push(T &);
+ T pop();
+private:
+ int m_size;
+ ACE_Thread_Mutex m_mutex;
+ ACE_Thread_Semaphore m_semaphore;
+ std::queue<T> m_queue;
+};
+
+
+/** Push an element onto the queue, returns false if queue full (never blocks) */
+template <class T> bool ThreadSafeQueue<T>::push(T &element)
+{
+ bool result = false;
+ MutexSentinel mutexSentinel(m_mutex);
+
+ if (m_queue.size() < (unsigned int)m_size)
+ {
+ m_queue.push(element);
+ result = true;
+ }
+
+ m_semaphore.release();
+ return result;
+}
+
+/** Pop and element from the queue, or blocks until one available */
+template <class T> T ThreadSafeQueue<T>::pop()
+{
+ m_semaphore.acquire();
+
+ MutexSentinel mutexSentinel(m_mutex);
+
+ T element = m_queue.front();
+ m_queue.pop();
+
+ return element;
+}
+
+
+#endif // __THREADSAFEQUEUE_H__
+
diff --git a/orkaudio/audiocaptureplugins/Makefile.am b/orkaudio/audiocaptureplugins/Makefile.am
new file mode 100644
index 0000000..bc31197
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/Makefile.am
@@ -0,0 +1,2 @@
+METASOURCES = AUTO
+SUBDIRS = generator voip
diff --git a/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.cpp b/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.cpp
new file mode 100644
index 0000000..31c8503
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "AudioCapturePluginCommon.h"
+
+
+AudioChunkCallBackFunction g_audioChunkCallBack;
+CaptureEventCallBackFunction g_captureEventCallBack;
+LogManager* g_logManager;
+
+void __CDECL__ RegisterCallBacks(AudioChunkCallBackFunction audioCallBack, CaptureEventCallBackFunction captureEventCallBack, LogManager* logManager)
+{
+ g_audioChunkCallBack = audioCallBack;
+ g_captureEventCallBack = captureEventCallBack;
+ g_logManager = logManager;
+}
diff --git a/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.h b/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.h
new file mode 100644
index 0000000..b7940ef
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/common/AudioCapturePluginCommon.h
@@ -0,0 +1,36 @@
+/*
+ * 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 __AUDIOCAPTUREPLUGINCOMMON_H__
+#define __AUDIOCAPTUREPLUGINCOMMON_H__
+
+#include "AudioCapturePlugin.h"
+
+#ifdef WIN32
+ #define DLL_EXPORT __declspec( dllexport )
+#else
+ #define DLL_EXPORT
+#endif
+
+// Shared library exports
+extern "C" // to avoid function name decoration, makes them easier to lookup
+{
+DLL_EXPORT void __CDECL__ RegisterCallBacks(AudioChunkCallBackFunction, CaptureEventCallBackFunction, LogManager*);
+DLL_EXPORT void __CDECL__ Run();
+DLL_EXPORT void __CDECL__ Initialize();
+DLL_EXPORT void __CDECL__ Configure(DOMNode*);
+DLL_EXPORT void __CDECL__ StartCapture(CStdString& capturePort);
+DLL_EXPORT void __CDECL__ StopCapture(CStdString& capturePort);
+}
+
+#endif
diff --git a/orkaudio/audiocaptureplugins/generator/Generator.cpp b/orkaudio/audiocaptureplugins/generator/Generator.cpp
new file mode 100644
index 0000000..77bfdf9
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/generator/Generator.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "AudioCapturePlugin.h"
+#include "AudioCapturePluginCommon.h"
+#include "ConfigManager.h"
+#include "GeneratorConfig.h"
+
+extern AudioChunkCallBackFunction g_audioChunkCallBack;
+extern CaptureEventCallBackFunction g_captureEventCallBack;
+extern LogManager* g_logManager;
+
+GeneratorConfigTopObjectRef g_generatorConfigTopObjectRef;
+#define GCONFIG g_generatorConfigTopObjectRef.get()->m_config
+
+void Configure(DOMNode* node)
+{
+ if (node)
+ {
+ GeneratorConfigTopObjectRef generatorConfigTopObjectRef(new GeneratorConfigTopObject);
+ try
+ {
+ generatorConfigTopObjectRef.get()->DeSerializeDom(node);
+ g_generatorConfigTopObjectRef = generatorConfigTopObjectRef;
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "Generator.dll: " + e + " - using defaults");
+ }
+ }
+ else
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "Generator.dll: got empty DOM tree");
+ }
+}
+
+void Initialize()
+{
+ // create a default config object in case it was not properly initialized by Configure
+ if (!g_generatorConfigTopObjectRef.get())
+ {
+ g_generatorConfigTopObjectRef.reset(new GeneratorConfigTopObject);
+ }
+}
+
+void Run()
+{
+
+#define NUM_SAMPLES_PER_CHUNK 8000
+
+ // Load test file data into memory
+ int fileSize = 0;
+ int audioBufferSize = 0;
+ int numChunks;
+ short* audioBuffer = NULL;
+ FILE* file = fopen((PCSTR)GCONFIG.m_audioFilename,"rb");
+ if (file)
+ {
+ fseek (file, 0, SEEK_END);
+ fileSize = ftell(file);
+ fseek (file, 0, SEEK_SET);
+
+ // round up file size to the next NUM_SAMPLES_PER_CHUNK multiple
+ numChunks = (fileSize/NUM_SAMPLES_PER_CHUNK) + 1;
+ fileSize = numChunks * NUM_SAMPLES_PER_CHUNK;
+
+ audioBuffer = (short *)malloc(sizeof(short)*fileSize);
+ audioBufferSize = fileSize/sizeof(short);
+ for(int i=0; i<fileSize; i++)
+ {
+ audioBuffer[i] = 0;
+ }
+ int numRead = fread(audioBuffer, sizeof(short), fileSize, file);
+ fclose(file);
+ }
+ else
+ {
+ // can't find test file - have a single zeroed buffer in memory
+ LOG4CXX_WARN(g_logManager->rootLog, "Generator.dll: Could not load audio test file:" + GCONFIG.m_audioFilename + " using empty buffer instead");
+
+ numChunks = 1;
+ audioBuffer = (short *)malloc(sizeof(short)*NUM_SAMPLES_PER_CHUNK);
+ audioBufferSize = NUM_SAMPLES_PER_CHUNK;
+ for(int i=0; i<NUM_SAMPLES_PER_CHUNK; i++)
+ {
+ audioBuffer[i] = 0;
+ }
+ }
+
+ int elapsed = 0;
+
+ for(;;)
+ {
+
+ for(int portId = 0; portId<GCONFIG.m_numConcurrentPorts; portId++)
+ {
+ CStdString portName;
+ portName.Format("port%d", portId);
+
+ if ((elapsed%GCONFIG.m_audioDuration) == 0)
+ {
+ // signal call stop and start on all ports
+ CaptureEventRef stopEvent(new CaptureEvent);
+ stopEvent->m_type = CaptureEvent::EtStop;
+ stopEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(stopEvent, portName);
+
+ CaptureEventRef startEvent(new CaptureEvent);
+ startEvent->m_type = CaptureEvent::EtStart;
+ startEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(startEvent, portName);
+ }
+ // send audio buffer
+ AudioChunkRef chunkRef(new AudioChunk);
+ int sampleOffset = (elapsed % numChunks)*NUM_SAMPLES_PER_CHUNK;
+ chunkRef->SetBuffer(audioBuffer+sampleOffset, sizeof(short)*NUM_SAMPLES_PER_CHUNK, AudioChunk::PcmAudio);
+ g_audioChunkCallBack(chunkRef, portName);
+ }
+
+ ACE_OS::sleep(1);
+ elapsed++;
+ }
+}
+
+
+void __CDECL__ StartCapture(CStdString& capturePort)
+{
+ ;
+}
+
+void __CDECL__ StopCapture(CStdString& capturePort)
+{
+ ;
+}
diff --git a/orkaudio/audiocaptureplugins/generator/Generator.dsp b/orkaudio/audiocaptureplugins/generator/Generator.dsp
new file mode 100644
index 0000000..23353c7
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/generator/Generator.dsp
@@ -0,0 +1,126 @@
+# Microsoft Developer Studio Project File - Name="Generator" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=Generator - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Generator.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Generator.mak" CFG="Generator - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Generator - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Generator - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Generator - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GENERATOR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GENERATOR_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 OrkBase.lib ace.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"../../../OrkBaseCxx/Release" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Release" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ELSEIF "$(CFG)" == "Generator - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GENERATOR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GENERATOR_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 OrkBaseD.lib aced.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"../../../OrkBaseCxx/Debug" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Debug" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Generator - Win32 Release"
+# Name "Generator - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\AudioCapturePlugin.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Generator.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\GeneratorConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\GeneratorConfig.h
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/orkaudio/audiocaptureplugins/generator/GeneratorConfig.cpp b/orkaudio/audiocaptureplugins/generator/GeneratorConfig.cpp
new file mode 100644
index 0000000..785e33f
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/generator/GeneratorConfig.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "serializers/Serializer.h"
+#include "GeneratorConfig.h"
+
+GeneratorConfig::GeneratorConfig()
+{
+ m_numConcurrentPorts = NUM_CONCURRENT_PORTS_DEFAULT;
+ m_audioDuration = AUDIO_DURATION_DEFAULT;
+ m_audioFilename = AUDIO_FILE_NAME_DEFAULT;
+}
+
+void GeneratorConfig::Define(Serializer* s)
+{
+ s->IntValue(NUM_CONCURRENT_PORTS_PARAM, m_numConcurrentPorts);
+ s->IntValue(AUDIO_DURATION_PARAM, m_audioDuration);
+ s->StringValue(AUDIO_FILE_NAME_PARAM, m_audioFilename);
+}
+
+void GeneratorConfig::Validate()
+{
+ ;
+}
+
+CStdString GeneratorConfig::GetClassName()
+{
+ return CStdString("GeneratorConfig");
+}
+
+ObjectRef GeneratorConfig::NewInstance()
+{
+ return ObjectRef(new GeneratorConfig);
+}
+
+//====================================
+
+
+void GeneratorConfigTopObject::Define(Serializer* s)
+{
+ s->ObjectValue(GENERATOR_CONFIG_PARAM, m_config, true);
+}
+
+void GeneratorConfigTopObject::Validate()
+{
+ ;
+}
+
+CStdString GeneratorConfigTopObject::GetClassName()
+{
+ return CStdString("GeneratorConfigTopObject");
+}
+
+ObjectRef GeneratorConfigTopObject::NewInstance()
+{
+ return ObjectRef(new GeneratorConfigTopObject);
+}
+
diff --git a/orkaudio/audiocaptureplugins/generator/GeneratorConfig.h b/orkaudio/audiocaptureplugins/generator/GeneratorConfig.h
new file mode 100644
index 0000000..8e9c6a1
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/generator/GeneratorConfig.h
@@ -0,0 +1,66 @@
+/*
+ * 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 __GENERATORCONFIG_H__
+#define __GENERATORCONFIG_H__
+
+#include "StdString.h"
+#include "Object.h"
+#include "boost/shared_ptr.hpp"
+
+#define NUM_CONCURRENT_PORTS_PARAM "NumConcurrentPorts"
+#define NUM_CONCURRENT_PORTS_DEFAULT 10
+#define AUDIO_DURATION_PARAM "AudioDuration"
+#define AUDIO_DURATION_DEFAULT 10
+#define AUDIO_FILE_NAME_PARAM "AudioFilename"
+#define AUDIO_FILE_NAME_DEFAULT "test.wav"
+
+/** This class defines various configuration parameters for the generator. */
+class GeneratorConfig : public Object
+{
+public:
+ GeneratorConfig();
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ int m_numConcurrentPorts;
+ int m_audioDuration;
+ CStdString m_audioFilename;
+};
+
+//========================================
+
+#define GENERATOR_CONFIG_PARAM "Generator"
+
+/** This class represents the top of the configuration hierarchy for the generator. */
+class GeneratorConfigTopObject : public Object
+{
+public:
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ GeneratorConfig m_config;
+};
+
+typedef boost::shared_ptr<GeneratorConfigTopObject> GeneratorConfigTopObjectRef;
+
+
+#endif
diff --git a/orkaudio/audiocaptureplugins/generator/Makefile.am b/orkaudio/audiocaptureplugins/generator/Makefile.am
new file mode 100644
index 0000000..44624f8
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/generator/Makefile.am
@@ -0,0 +1,10 @@
+METASOURCES = AUTO
+lib_LTLIBRARIES = libgenerator.la
+libgenerator_la_SOURCES = GeneratorConfig.cpp Generator.cpp \
+ AudioCapturePluginCommon.cpp
+libgenerator_la_LDFLAGS = -module
+AM_CPPFLAGS = -D_REENTRANT
+libgenerator_la_LIBADD = -lACE -lxerces-c -llog4cxx -lorkbase
+INCLUDES = -I@top_srcdir@ -I../../../orkbasecxx -I../common
+AudioCapturePluginCommon.cpp:
+ ln -s ../common/AudioCapturePluginCommon.cpp AudioCapturePluginCommon.cpp
diff --git a/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.cpp b/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.cpp
new file mode 100644
index 0000000..2a6bef4
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.cpp
@@ -0,0 +1,252 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/Singleton.h"
+#include "ace/Min_Max.h"
+#include "AudioCapturePlugin.h"
+#include "AudioCapturePluginCommon.h"
+#include "portaudio.h"
+#include "Utils.h"
+#include "SoundDeviceConfig.h"
+
+extern AudioChunkCallBackFunction g_audioChunkCallBack;
+extern CaptureEventCallBackFunction g_captureEventCallBack;
+extern LogManager* g_logManager;
+
+SoundDeviceConfigTopObjectRef g_soundDeviceConfigTopObjectRef;
+#define DLLCONFIG g_soundDeviceConfigTopObjectRef.get()->m_config
+
+
+typedef struct
+{
+ PaDeviceID deviceID;
+ int channelCount;
+ PortAudioStream* stream;
+} DeviceUserData;
+
+int portAudioCallBack(void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData)
+{
+ DeviceUserData *device = (DeviceUserData *)userData;
+ short * inputSamples = (short *)inputBuffer;
+ CStdString portName;
+
+ if (device->channelCount == 2)
+ {
+ // stereo -> split into two different chunks
+ short* rightBuffer = new short[DLLCONFIG.m_audioChunkSize];
+ short* leftBuffer = new short[DLLCONFIG.m_audioChunkSize];
+
+ for (int sampleId=0; sampleId<DLLCONFIG.m_audioChunkSize ; sampleId++)
+ {
+ rightBuffer[sampleId] = inputSamples[2*sampleId];
+ leftBuffer[sampleId] = inputSamples[2*sampleId+1];
+ }
+ AudioChunkRef chunkRef(new AudioChunk);
+ chunkRef->SetBuffer(rightBuffer, sizeof(short)*framesPerBuffer, AudioChunk::PcmAudio);
+ portName.Format("port%d-%d", device->deviceID, 1);
+ g_audioChunkCallBack(chunkRef, portName);
+
+ chunkRef.reset(new AudioChunk);
+ chunkRef->SetBuffer(leftBuffer, sizeof(short)*framesPerBuffer, AudioChunk::PcmAudio);
+ portName.Format("port%d-%d", device->deviceID, 2);
+ g_audioChunkCallBack(chunkRef, portName);
+
+ delete rightBuffer;
+ delete leftBuffer;
+ }
+ else
+ {
+ // mono
+ AudioChunkRef chunkRef(new AudioChunk);
+ chunkRef->SetBuffer(inputSamples, sizeof(short)*framesPerBuffer, AudioChunk::PcmAudio);
+ portName.Format("port%d", device->deviceID);
+ g_audioChunkCallBack(chunkRef, portName);
+ }
+
+ return 0;
+}
+
+
+class SoundDevice
+{
+public:
+ SoundDevice();
+ void Initialize();
+ void Run();
+ void StartCapture(CStdString& port);
+ void StopCapture(CStdString& port);
+private:
+ DeviceUserData** m_devices;
+ int m_deviceCount;
+ PaStream* m_stream;
+};
+
+typedef ACE_Singleton<SoundDevice, ACE_Thread_Mutex> SoundDeviceSingleton;
+
+SoundDevice::SoundDevice()
+{
+ m_deviceCount = 0;
+ m_devices = NULL;
+}
+
+void Configure(DOMNode* node)
+{
+ if (node)
+ {
+ SoundDeviceConfigTopObjectRef soundDeviceConfigTopObjectRef(new SoundDeviceConfigTopObject);
+ try
+ {
+ soundDeviceConfigTopObjectRef.get()->DeSerializeDom(node);
+ g_soundDeviceConfigTopObjectRef = soundDeviceConfigTopObjectRef;
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "SoundDevice.dll: " + e + " - using defaults");
+ }
+ }
+ else
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "SoundDevice.dll: got empty DOM tree");
+ }
+}
+
+
+void SoundDevice::Initialize()
+{
+ LOG4CXX_INFO(g_logManager->rootLog, "Initializing Sound Device plugin");
+
+ // create a default config object in case it was not properly initialized by Configure
+ if(!g_soundDeviceConfigTopObjectRef.get())
+ {
+ g_soundDeviceConfigTopObjectRef.reset(new SoundDeviceConfigTopObject);
+ }
+
+
+ PaError result = Pa_Initialize();
+ if (result)
+ {
+ LOG4CXX_ERROR(g_logManager->rootLog, "Could not initialize Sound Device plugin");
+ }
+
+ m_deviceCount = Pa_CountDevices();
+ m_devices = new DeviceUserData*[m_deviceCount];
+
+ for( PaDeviceID deviceID=0; deviceID<m_deviceCount; deviceID++ )
+ {
+ const PaDeviceInfo* deviceInfo = Pa_GetDeviceInfo( deviceID );
+
+ m_devices[deviceID] = new DeviceUserData;
+ m_devices[deviceID]->deviceID = deviceID;
+ m_devices[deviceID]->channelCount = ace_max(deviceInfo->maxInputChannels,2);
+ m_devices[deviceID]->stream = NULL;
+ CStdString deviceName(deviceInfo->name);
+
+ if (deviceInfo->maxInputChannels > 0 && deviceName.Find("Primary") == -1) // Primary audio device is a duplicate of one of the devices
+ {
+ CStdString capturePorts;
+ if (deviceInfo->maxInputChannels > 1)
+ {
+ capturePorts.Format("port%d-1, port%d-2", deviceID, deviceID); // stereo
+ }
+ else
+ {
+ capturePorts.Format("port%d-1", deviceID); // mono
+ }
+
+ CStdString maxInputChannelsString = IntToString(deviceInfo->maxInputChannels);
+ LOG4CXX_INFO(g_logManager->rootLog, "Ports:" + capturePorts + " Name:" + deviceName + " Channels:" + maxInputChannelsString);
+
+ result = Pa_OpenStream( &m_devices[deviceID]->stream,
+ deviceID,
+ m_devices[deviceID]->channelCount,
+ paInt16,
+ NULL,
+ paNoDevice ,
+ 0,
+ paInt16,
+ NULL,
+ 8000.0,
+ DLLCONFIG.m_audioChunkSize,
+ 0,
+ 0,
+ portAudioCallBack,
+ (void*)m_devices[deviceID] );
+
+ if (result)
+ {
+ CStdString deviceIdString = IntToString(deviceID);
+ LOG4CXX_ERROR(g_logManager->rootLog, "Device:" + deviceIdString + CStdString(" Pa_OpenStream error:") + Pa_GetErrorText(result));
+ }
+ }
+ }
+}
+
+void SoundDevice::Run()
+{
+ for( PaDeviceID deviceID=0; deviceID<m_deviceCount; deviceID++ )
+ {
+ if (m_devices[deviceID]->channelCount > 0 && m_devices[deviceID]->stream)
+ {
+ PaError result = Pa_StartStream(m_devices[deviceID]->stream);
+ if (result)
+ {
+ CStdString deviceIdString = IntToString(deviceID);
+ LOG4CXX_ERROR(g_logManager->rootLog, "Device:" + deviceIdString + CStdString(" Pa_StartStream error:") + Pa_GetErrorText(result));
+ }
+ }
+ }
+}
+
+void SoundDevice::StartCapture(CStdString& port)
+{
+ CaptureEventRef startEvent(new CaptureEvent);
+ startEvent->m_type = CaptureEvent::EtStart;
+ startEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(startEvent, port);
+}
+
+void SoundDevice::StopCapture(CStdString& port)
+{
+ CaptureEventRef stopEvent(new CaptureEvent);
+ stopEvent->m_type = CaptureEvent::EtStop;
+ stopEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(stopEvent, port);
+}
+
+void __CDECL__ Initialize()
+{
+ SoundDeviceSingleton::instance()->Initialize();
+}
+
+void __CDECL__ Run()
+{
+ SoundDeviceSingleton::instance()->Run();
+ for(;;)
+ {
+ // if this idle thread is missing, it will crash winmm
+ ACE_OS::sleep(5);
+ }
+}
+
+void __CDECL__ StartCapture(CStdString& capturePort)
+{
+ SoundDeviceSingleton::instance()->StartCapture(capturePort);
+}
+
+void __CDECL__ StopCapture(CStdString& capturePort)
+{
+ SoundDeviceSingleton::instance()->StopCapture(capturePort);
+} \ No newline at end of file
diff --git a/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.dsp b/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.dsp
new file mode 100644
index 0000000..844f5a6
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/sounddevice/SoundDevice.dsp
@@ -0,0 +1,130 @@
+# Microsoft Developer Studio Project File - Name="SoundDevice" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=SoundDevice - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "SoundDevice.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "SoundDevice.mak" CFG="SoundDevice - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "SoundDevice - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "SoundDevice - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "SoundDevice - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOUNDDEVICE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\portaudio_v18\pa_common" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOUNDDEVICE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 OrkBase.lib winmm.lib dsound.lib ace.lib PAStaticDS.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"../../../OrkBaseCxx/Release" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Release" /libpath:"C:\devExt\portaudio_v18\winproj\Lib" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ELSEIF "$(CFG)" == "SoundDevice - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOUNDDEVICE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\portaudio_v18\pa_common" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOUNDDEVICE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 OrkBaseD.lib winmm.lib dsound.lib aced.lib PAStaticDSD.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"../../../OrkBaseCxx/Debug" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Debug" /libpath:"C:\devExt\portaudio_v18\winproj\Lib" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "SoundDevice - Win32 Release"
+# Name "SoundDevice - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\AudioCapturePlugin.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\ConfigManager.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SoundDevice.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SoundDeviceConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SoundDeviceConfig.h
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.cpp b/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.cpp
new file mode 100644
index 0000000..998eb72
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "Serializers/Serializer.h"
+#include "SoundDeviceConfig.h"
+
+SoundDeviceConfig::SoundDeviceConfig()
+{
+ m_audioChunkSize = AUDIO_CHUNK_SIZE_DEFAULT;
+}
+
+void SoundDeviceConfig::Define(Serializer* s)
+{
+ s->IntValue(AUDIO_CHUNK_SIZE_PARAM, m_audioChunkSize);
+}
+
+void SoundDeviceConfig::Validate()
+{
+ if(m_audioChunkSize > 80000 || m_audioChunkSize<100)
+ {
+ CStdString audioChunkSizeString = IntToString(m_audioChunkSize);
+ throw(CStdString("SoundDeviceConfig: ") + AUDIO_CHUNK_SIZE_PARAM + "=" + audioChunkSizeString + " this is out of range");
+ }
+}
+
+CStdString SoundDeviceConfig::GetClassName()
+{
+ return CStdString("SoundDeviceConfig");
+}
+
+ObjectRef SoundDeviceConfig::NewInstance()
+{
+ return ObjectRef(new SoundDeviceConfig);
+}
+
+//====================================
+
+
+void SoundDeviceConfigTopObject::Define(Serializer* s)
+{
+ s->ObjectValue(SOUND_DEVICE_CONFIG_PARAM, m_config, true);
+}
+
+void SoundDeviceConfigTopObject::Validate()
+{
+ ;
+}
+
+CStdString SoundDeviceConfigTopObject::GetClassName()
+{
+ return CStdString("SoundDeviceConfigTopObject");
+}
+
+ObjectRef SoundDeviceConfigTopObject::NewInstance()
+{
+ return ObjectRef(new SoundDeviceConfigTopObject);
+} \ No newline at end of file
diff --git a/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.h b/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.h
new file mode 100644
index 0000000..6453523
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/sounddevice/SoundDeviceConfig.h
@@ -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
+ *
+ */
+
+#ifndef __SOUNDDEVICECONFIG_H__
+#define __SOUNDDEVICECONFIG_H__
+
+#include "StdString.h"
+#include "Object.h"
+#include "boost/shared_ptr.hpp"
+
+#define AUDIO_CHUNK_SIZE_PARAM "AudioChunkSize"
+#define AUDIO_CHUNK_SIZE_DEFAULT 8000
+
+/** This class defines various configuration parameters for the generator. */
+class SoundDeviceConfig : public Object
+{
+public:
+ SoundDeviceConfig();
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ int m_audioChunkSize;
+};
+
+//========================================
+
+#define SOUND_DEVICE_CONFIG_PARAM "SoundDevicePlugin"
+
+/** This class represents the top of the configuration hierarchy for the generator. */
+class SoundDeviceConfigTopObject : public Object
+{
+public:
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ SoundDeviceConfig m_config;
+};
+
+typedef boost::shared_ptr<SoundDeviceConfigTopObject> SoundDeviceConfigTopObjectRef;
+
+
+#endif \ No newline at end of file
diff --git a/orkaudio/audiocaptureplugins/voip/Makefile.am b/orkaudio/audiocaptureplugins/voip/Makefile.am
new file mode 100644
index 0000000..a11ff07
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/Makefile.am
@@ -0,0 +1,10 @@
+METASOURCES = AUTO
+lib_LTLIBRARIES = libvoip.la
+libvoip_la_SOURCES = VoIpConfig.cpp VoIp.cpp g711.c Rtp.cpp SipSession.cpp \
+ AudioCapturePluginCommon.cpp
+libvoip_la_LDFLAGS = -module
+AM_CPPFLAGS = -D_REENTRANT
+libvoip_la_LIBADD = -lACE -lxerces-c -llog4cxx -lorkbase -lpcap
+INCLUDES = -I@top_srcdir@ -I../../../orkbasecxx -I../common
+AudioCapturePluginCommon.cpp:
+ ln -s ../common/AudioCapturePluginCommon.cpp AudioCapturePluginCommon.cpp
diff --git a/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h
new file mode 100644
index 0000000..1293c5c
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h
@@ -0,0 +1,71 @@
+/*
+ * 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 __PACKETHEADERDEFS_H__
+#define __PACKETHEADERDEFS_H__
+
+
+// Structure of Ethernet header
+typedef struct
+{
+ unsigned char sourceMac[6];
+ unsigned char destinationMac[6];
+ unsigned short length;
+
+} EthernetHeaderStruct;
+
+// Structure of an internet header, naked of options, only valid for little endian
+typedef struct
+{
+ unsigned char ip_hl:4; // Header length
+ unsigned char ip_v:4; // IP protocol version
+ unsigned char ip_tos; // Type of service
+ unsigned short ip_len; // Total length
+ unsigned short ip_id; // Identification
+ unsigned short ip_off; // Fragment offset field
+ unsigned char ip_ttl; // Time to live
+ unsigned char ip_p; // Protocol
+ unsigned short ip_sum; // Header checksum
+ struct in_addr ip_src; // Source address
+ struct in_addr ip_dest; // Destination address
+} IpHeaderStruct;
+
+// Structure of UDP header
+typedef struct
+{
+ unsigned short source; // Source port
+ unsigned short dest; // Destination port
+ unsigned short len; // UDP length
+ unsigned short check; // UDP Checksum
+} UdpHeaderStruct;
+
+#define RTP_PT_PCMU 0
+#define RTP_PT_PCMA 8
+
+// Structure of RTP header, only valid for little endian
+typedef struct {
+ unsigned short cc:4; // CSRC count
+ unsigned short x:1; // header extension flag
+ unsigned short p:1; // padding flag
+ unsigned short version:2; // protocol version
+ unsigned short pt:7; // payload type
+ unsigned short m:1; // marker bit
+ unsigned short seq; // sequence number
+ unsigned int ts; // timestamp
+ unsigned int ssrc; // synchronization source
+ //unsigned int csrc[1]; // optional CSRC list
+} RtpHeaderStruct;
+
+#endif
+
diff --git a/orkaudio/audiocaptureplugins/voip/Rtp.cpp b/orkaudio/audiocaptureplugins/voip/Rtp.cpp
new file mode 100644
index 0000000..931aed7
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/Rtp.cpp
@@ -0,0 +1,257 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "Rtp.h"
+#include "AudioCapturePlugin.h"
+#include "AudioCapturePluginCommon.h"
+#include "PacketHeaderDefs.h"
+#include "assert.h"
+
+extern "C"
+{
+#include "g711.h"
+}
+extern AudioChunkCallBackFunction g_audioChunkCallBack;
+
+
+RtpRingBuffer::RtpRingBuffer()
+{
+ m_writePtr = m_buffer;
+ m_readPtr = m_buffer;
+ m_bufferEnd = m_buffer + NUM_SAMPLES_CIRCULAR_BUFFER;
+ m_writeTimestamp = 0;
+ m_readTimestamp = 0;
+ m_log = Logger::getLogger("rtpringbuffer");
+ m_shippedSamples = 0;
+}
+
+
+void RtpRingBuffer::AddRtpPacket(RtpPacketInfoRef& rtpInfo)
+{
+ unsigned int rtpEndTimestamp = rtpInfo->m_timestamp + rtpInfo->m_payloadSize;
+
+ if(m_writeTimestamp == 0)
+ {
+ // First RTP packet of the session
+ LOG4CXX_DEBUG(m_log, m_capturePort + " first packet");
+ m_writeTimestamp = rtpInfo->m_timestamp;
+ m_readTimestamp = m_writeTimestamp;
+ StoreRtpPacket(rtpInfo);
+ }
+ else if (rtpInfo->m_timestamp >= m_readTimestamp) // drop packets that are older than last shipment
+ {
+ if( (int)(rtpEndTimestamp - m_writeTimestamp) <= (int)FreeSpace())
+ {
+ // RTP packet fits into current buffer
+ StoreRtpPacket(rtpInfo);
+
+ if(UsedSpace() > NUM_SAMPLES_TRIGGER)
+ {
+ // We have enough stuff, make a shipment
+ CreateShipment(0);
+ }
+ }
+ else
+ {
+ // RTP packet does not fit into current buffer
+ // work out how much silence we need to add to the current buffer when shipping
+ size_t silenceSize = rtpInfo->m_timestamp - m_writeTimestamp;
+ CreateShipment(silenceSize);
+
+ // reset buffer
+ m_writePtr = m_buffer;
+ m_readPtr = m_buffer;
+ m_writeTimestamp = rtpInfo->m_timestamp;
+ m_readTimestamp = m_writeTimestamp;
+
+ // Store new packet
+ StoreRtpPacket(rtpInfo);
+ }
+ }
+ else
+ {
+ LOG4CXX_DEBUG(m_log, m_capturePort + " packet too old, dropped");
+ }
+ CStdString debug;
+ debug.Format("free:%u used:%u wr:%x rd:%x wrts:%u rdts:%d", FreeSpace(), UsedSpace(), m_writePtr, m_readPtr, m_writeTimestamp, m_readTimestamp);
+ LOG4CXX_DEBUG(m_log, debug);
+}
+
+// Writes to the internal buffer without any size verification
+void RtpRingBuffer::StoreRtpPacket(RtpPacketInfoRef& rtpInfo)
+{
+ CStdString debug;
+
+ // 1. Silence from write pointer until end of RTP packet
+ unsigned int endRtpTimestamp = rtpInfo->m_timestamp + rtpInfo->m_payloadSize;
+ if (endRtpTimestamp > m_writeTimestamp)
+ {
+ for(int i=0; i<(endRtpTimestamp - m_writeTimestamp); i++)
+ {
+ *m_writePtr = 0;
+ m_writePtr++;
+ if(m_writePtr >= m_bufferEnd)
+ {
+ m_writePtr = m_buffer;
+ }
+ }
+ int silenceSize = endRtpTimestamp - m_writeTimestamp;
+ m_writeTimestamp = endRtpTimestamp;
+ debug.Format("Zeroed %d samples, wr:%x wrts:%u", silenceSize, m_writePtr, m_writeTimestamp);
+ LOG4CXX_DEBUG(m_log, debug);
+ }
+
+ // 2. Mix in the latest samples from this RTP packet
+ unsigned int timestampDelta = m_writeTimestamp - rtpInfo->m_timestamp;
+ ASSERT(timestampDelta>=0);
+ short* tempWritePtr = CicularPointerSubtractOffset(m_writePtr, timestampDelta);
+ unsigned char* payload = rtpInfo->m_payload;
+
+ for(int i=0; i<rtpInfo->m_payloadSize ; i++)
+ {
+ if(rtpInfo->m_payloadType == RTP_PT_PCMA)
+ {
+ *tempWritePtr += (short)alaw2linear(payload[i]);
+ }
+ else if(rtpInfo->m_payloadType == RTP_PT_PCMU)
+ {
+ *tempWritePtr += (short)ulaw2linear(payload[i]);
+ }
+ tempWritePtr++;
+ if(tempWritePtr >= m_bufferEnd)
+ {
+ tempWritePtr = m_buffer;
+ }
+ }
+ debug.Format("Copied %d samples, tmpwr:%x", rtpInfo->m_payloadSize, tempWritePtr);
+ LOG4CXX_DEBUG(m_log, debug);
+}
+
+short* RtpRingBuffer::CircularPointerAddOffset(short *ptr, size_t offset)
+{
+ if((ptr + offset) >= m_bufferEnd)
+ {
+ return m_buffer + offset - (m_bufferEnd-ptr);
+ }
+ else
+ {
+ return ptr + offset;
+ }
+}
+
+short* RtpRingBuffer::CicularPointerSubtractOffset(short *ptr, size_t offset)
+{
+ if((ptr-offset) < m_buffer)
+ {
+ return m_bufferEnd - offset + (ptr-m_buffer);
+ }
+ else
+ {
+ return ptr - offset;
+ }
+}
+
+void RtpRingBuffer::CreateShipment(size_t silenceSize)
+{
+ // 1. ship from readPtr until stop pointer or until end of buffer if wrapped
+ bool bufferWrapped = false;
+ short* stopPtr = NULL;
+ short* wrappedStopPtr = NULL;
+ if (silenceSize)
+ {
+ // There is additional silence to ship, do not take holdoff into account
+ stopPtr = m_writePtr;
+ }
+ else
+ {
+ stopPtr = CicularPointerSubtractOffset(m_writePtr, NUM_SAMPLES_SHIPMENT_HOLDOFF);
+ }
+
+ if (stopPtr < m_readPtr)
+ {
+ wrappedStopPtr = stopPtr;
+ stopPtr = m_bufferEnd;
+ bufferWrapped = true;
+ }
+ size_t shortSize = stopPtr-m_readPtr;
+ size_t byteSize = shortSize*2;
+ AudioChunkRef chunk(new AudioChunk());
+ chunk->SetBuffer((void*)m_readPtr, byteSize, AudioChunk::PcmAudio);
+ g_audioChunkCallBack(chunk, m_capturePort);
+ m_shippedSamples += shortSize;
+ m_readPtr = CircularPointerAddOffset(m_readPtr ,shortSize);
+ m_readTimestamp += shortSize;
+
+ CStdString debug;
+ debug.Format("Ship %d samples, rd:%x rdts:%u", shortSize, m_readPtr, m_readTimestamp);
+ LOG4CXX_DEBUG(m_log, debug);
+
+
+ // 2. ship from beginning of buffer until stop ptr
+ if(bufferWrapped)
+ {
+ shortSize = wrappedStopPtr - m_buffer;
+ byteSize = shortSize*2;
+ chunk.reset(new AudioChunk());
+ chunk->SetBuffer((void*)m_buffer, byteSize, AudioChunk::PcmAudio);
+ g_audioChunkCallBack(chunk, m_capturePort);
+ m_shippedSamples += shortSize;
+ m_readPtr = CircularPointerAddOffset(m_readPtr ,shortSize);
+ m_readTimestamp += shortSize;
+ debug.Format("Ship wrapped %d samples, rd:%x rdts:%u", shortSize, m_readPtr, m_readTimestamp);
+ LOG4CXX_DEBUG(m_log, debug);
+ }
+
+ // 3. ship silence
+ if (silenceSize)
+ {
+ byteSize = silenceSize*2;
+ char* silenceBuffer = (char*)calloc(byteSize, 1);
+ if (silenceBuffer)
+ {
+ AudioChunkRef chunk(new AudioChunk());
+ chunk->SetBuffer((void*)silenceBuffer, byteSize, AudioChunk::PcmAudio);
+ g_audioChunkCallBack(chunk, m_capturePort);
+ m_shippedSamples += silenceSize;
+ m_readPtr = CircularPointerAddOffset(m_readPtr ,silenceSize);
+ m_readTimestamp += silenceSize;
+ }
+ debug.Format("Ship %d silence samples, rd:%x rdts:%u", silenceSize, m_readPtr, m_readTimestamp);
+ LOG4CXX_DEBUG(m_log, debug);
+ }
+}
+
+
+unsigned int RtpRingBuffer::UsedSpace()
+{
+ if(m_writePtr >= m_readPtr)
+ {
+ return m_writePtr - m_readPtr;
+ }
+ return NUM_SAMPLES_CIRCULAR_BUFFER + m_writePtr - m_readPtr;
+}
+
+
+unsigned int RtpRingBuffer::FreeSpace()
+{
+ return NUM_SAMPLES_CIRCULAR_BUFFER - UsedSpace();
+}
+
+void RtpRingBuffer::SetCapturePort(CStdString& port)
+{
+ m_capturePort = port;
+}
+
diff --git a/orkaudio/audiocaptureplugins/voip/Rtp.h b/orkaudio/audiocaptureplugins/voip/Rtp.h
new file mode 100644
index 0000000..0366ef4
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/Rtp.h
@@ -0,0 +1,77 @@
+/*
+ * 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 __RTP_H__
+#define __RTP_H__
+
+#include "AudioCapture.h"
+#include "boost/shared_ptr.hpp"
+#include "StdString.h"
+#include "LogManager.h"
+
+#define NUM_SAMPLES_CIRCULAR_BUFFER 8000
+#define NUM_SAMPLES_TRIGGER 4000 // when we have this number of available samples make a shipment
+#define NUM_SAMPLES_SHIPMENT_HOLDOFF 2000 // when shipping, ship everything but this number of samples
+
+
+// useful info we extract from an RTP packet
+class RtpPacketInfo
+{
+public:
+ //CStdString m_sourceMac;
+ //CStdString m_destMac;
+ struct in_addr m_sourceIp;
+ struct in_addr m_destIp;
+ unsigned short m_sourcePort;
+ unsigned short m_destPort;
+ unsigned int m_payloadSize;
+ unsigned short m_payloadType;
+ unsigned char* m_payload;
+ unsigned short m_seqNum;
+ unsigned int m_timestamp;
+};
+typedef boost::shared_ptr<RtpPacketInfo> RtpPacketInfoRef;
+
+
+// Ring buffer based on RTP timestamps
+// Gathers both sides of the conversation and mixes them into single channel
+// Robust to silence suppression
+// Supports RTP buffers of arbitrary sizes in both directions.
+class RtpRingBuffer
+{
+public:
+ RtpRingBuffer();
+ void AddRtpPacket(RtpPacketInfoRef&);
+ void SetCapturePort(CStdString& port);
+private:
+ void StoreRtpPacket(RtpPacketInfoRef&);
+ void CreateShipment(size_t silenceSize);
+ unsigned int FreeSpace();
+ unsigned int UsedSpace();
+ short* GetHoldOffPtr();
+ short* CircularPointerAddOffset(short *ptr, size_t offset);
+ short* CicularPointerSubtractOffset(short *ptr, size_t offset);
+
+ short* m_writePtr; // pointer after newest RTP data we've received
+ short* m_readPtr; // where to read from next
+ unsigned int m_readTimestamp; // timestamp that the next shipment will have
+ unsigned int m_writeTimestamp; // timestamp that the next RTP buffer should have
+ short* m_bufferEnd;
+ short m_buffer[NUM_SAMPLES_CIRCULAR_BUFFER];
+ CStdString m_capturePort;
+ LoggerPtr m_log;
+ unsigned int m_shippedSamples;
+};
+
+#endif
+
diff --git a/orkaudio/audiocaptureplugins/voip/SipSession.cpp b/orkaudio/audiocaptureplugins/voip/SipSession.cpp
new file mode 100644
index 0000000..e62a612
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/SipSession.cpp
@@ -0,0 +1,282 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "SipSession.h"
+#include "AudioCapturePlugin.h"
+#include "AudioCapturePluginCommon.h"
+#include <list>
+#include "VoIpConfig.h"
+#include "ace/OS_NS_arpa_inet.h"
+
+extern AudioChunkCallBackFunction g_audioChunkCallBack;
+extern CaptureEventCallBackFunction g_captureEventCallBack;
+
+extern VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef;
+#define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config
+
+
+SipSession::SipSession()
+{
+ m_lastUpdated = time(NULL);
+ m_log = Logger::getLogger("sipsession");
+ m_invitorIp.s_addr = 0;
+ m_inviteeIp.s_addr = 0;
+ m_direction = CaptureEvent::DirUnkn;
+}
+
+void SipSession::Stop()
+{
+ LOG4CXX_DEBUG(m_log, m_ipAndPort + " SIP Session stop");
+ CaptureEventRef stopEvent(new CaptureEvent);
+ stopEvent->m_type = CaptureEvent::EtStop;
+ stopEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(stopEvent, m_ipAndPort);
+}
+
+void SipSession::Start()
+{
+ LOG4CXX_DEBUG(m_log, m_ipAndPort + " SIP Session start");
+ m_rtpRingBuffer.SetCapturePort(m_ipAndPort);
+ CaptureEventRef startEvent(new CaptureEvent);
+ startEvent->m_type = CaptureEvent::EtStart;
+ startEvent->m_timestamp = time(NULL);
+ g_captureEventCallBack(startEvent, m_ipAndPort);
+}
+
+void SipSession::ProcessMetadataIncoming()
+{
+ m_remoteParty = m_invite->m_from;
+ m_localParty = m_invite->m_to;
+ m_direction = CaptureEvent::DirIn;
+}
+
+void SipSession::ProcessMetadataOutgoing()
+{
+ m_remoteParty = m_invite->m_to;
+ m_localParty = m_invite->m_from;
+ m_direction = CaptureEvent::DirOut;
+}
+
+void SipSession::ProcessMetadata(RtpPacketInfoRef& rtpPacket)
+{
+ bool done = false;
+
+ // work out invitee IP address
+ if(rtpPacket->m_sourceIp.s_addr == m_invitorIp.s_addr)
+ {
+ m_inviteeIp = rtpPacket->m_destIp;
+ }
+ else if(rtpPacket->m_destIp.s_addr == m_invitorIp.s_addr)
+ {
+ m_inviteeIp = rtpPacket->m_sourceIp;
+ }
+ else
+ {
+ LOG4CXX_DEBUG(m_log, m_ipAndPort + " alien RTP packet");
+ }
+
+ // work out capture port and direction
+ if(DLLCONFIG.IsMediaGateway(m_invitorIp))
+ {
+ if(DLLCONFIG.IsMediaGateway(m_inviteeIp))
+ {
+ // dismiss
+ }
+ if(DLLCONFIG.IsPartOfLan(m_inviteeIp))
+ {
+ ProcessMetadataIncoming();
+ }
+ }
+ else if (DLLCONFIG.IsPartOfLan(m_invitorIp))
+ {
+ ProcessMetadataOutgoing();
+ }
+ else
+ {
+ // SIP invitor IP address is an outside IP address
+ if(DLLCONFIG.IsMediaGateway(m_inviteeIp))
+ {
+ // dismiss
+ }
+ else if(DLLCONFIG.IsPartOfLan(m_inviteeIp))
+ {
+ ProcessMetadataIncoming();
+ }
+ else
+ {
+ // SIP invitee IP address is an outside IP address
+ ProcessMetadataOutgoing();
+ }
+ }
+ ReportMetadata();
+}
+
+void SipSession::ReportMetadata()
+{
+ // report Local party
+ CaptureEventRef event(new CaptureEvent());
+ event->m_type = CaptureEvent::EtLocalParty;
+ event->m_value = m_localParty;
+ g_captureEventCallBack(event, m_ipAndPort);
+
+ // Report remote party
+ event.reset(new CaptureEvent());
+ event->m_type = CaptureEvent::EtRemoteParty;
+ event->m_value = m_remoteParty;
+ g_captureEventCallBack(event, m_ipAndPort);
+
+ // report direction
+ event.reset(new CaptureEvent());
+ event->m_type = CaptureEvent::EtDirection;
+ event->m_value = CaptureEvent::DirectionToString(m_direction);
+ g_captureEventCallBack(event, m_ipAndPort);
+}
+
+
+void SipSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket)
+{
+ // if first RTP packet, start session
+ if(m_lastRtpPacket.get() == NULL)
+ {
+ Start();
+ ProcessMetadata(rtpPacket);
+ }
+ m_lastRtpPacket = rtpPacket;
+
+ // send audio buffer
+ //AudioChunkRef chunkRef(new AudioChunk);
+ //chunkRef->SetBuffer(rtpPacket->m_payload, rtpPacket->m_payloadSize, AudioChunk::AlawAudio);
+ //g_audioChunkCallBack(chunkRef, m_ipAndPort);
+
+ m_rtpRingBuffer.AddRtpPacket(rtpPacket);
+
+ m_lastUpdated = time(NULL);
+}
+
+
+void SipSession::ReportSipInvite(SipInviteInfoRef& invite)
+{
+ m_invite = invite;
+ m_invitorIp = invite->m_fromIp;
+}
+
+//=====================================================================
+SipSessions::SipSessions()
+{
+ m_log = Logger::getLogger("sipsessions");
+}
+
+
+void SipSessions::ReportSipInvite(SipInviteInfoRef& invite)
+{
+ CStdString key = CStdString(ACE_OS::inet_ntoa(invite->m_fromIp)) + "," + invite->m_fromRtpPort;
+ std::map<CStdString, SipSessionRef>::iterator pair;
+
+ pair = m_byIpAndPort.find(key);
+
+ if (pair != m_byIpAndPort.end())
+ {
+ // A session exists ont the same IP+port, stop old session
+ SipSessionRef session = pair->second;
+ Stop(session);
+ }
+ // create new session and insert into both maps
+ SipSessionRef session(new SipSession());
+ session->m_ipAndPort = key;
+ session->ReportSipInvite(invite);
+ m_byCallId.insert(std::make_pair(invite->m_callId, session));
+ m_byIpAndPort.insert(std::make_pair(key, session));
+}
+
+void SipSessions::ReportSipBye(SipByeInfo bye)
+{
+ std::map<CStdString, SipSessionRef>::iterator pair;
+ pair = m_byCallId.find(bye.m_callId);
+
+ if (pair != m_byCallId.end())
+ {
+ // Session found: stop it
+ SipSessionRef session = pair->second;
+ Stop(session);
+ }
+}
+
+void SipSessions::Stop(SipSessionRef& session)
+{
+ session->Stop();
+ m_byIpAndPort.erase(session->m_ipAndPort);
+ m_byCallId.erase(session->m_invite->m_callId);
+}
+
+
+void SipSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
+{
+ // Does a session exist with this source Ip+Port
+ SipSessionRef session;
+ CStdString port = IntToString(rtpPacket->m_sourcePort);
+ CStdString ipAndPort = CStdString(ACE_OS::inet_ntoa(rtpPacket->m_sourceIp)) + "," + port;
+ std::map<CStdString, SipSessionRef>::iterator pair;
+
+ pair = m_byIpAndPort.find(ipAndPort);
+ if (pair != m_byIpAndPort.end())
+ {
+ session = pair->second;
+ }
+ else
+ {
+ // Does a session exist with this destination Ip+Port
+ port = IntToString(rtpPacket->m_destPort);
+ ipAndPort = CStdString(ACE_OS::inet_ntoa(rtpPacket->m_destIp)) + "," + port;
+ pair = m_byIpAndPort.find(ipAndPort);
+ if (pair != m_byIpAndPort.end())
+ {
+ session = pair->second;
+ }
+ }
+ if (!session.get() == NULL)
+ {
+ // Found a session give it the RTP packet info
+ session->AddRtpPacket(rtpPacket);
+ }
+}
+
+void SipSessions::Hoover(time_t now)
+{
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, "Hoover - check " + numSessions + " sessions time:" + IntToString(now));
+
+ // Go round the sessions and find inactive ones
+ std::map<CStdString, SipSessionRef>::iterator pair;
+ std::list<SipSessionRef> toDismiss;
+
+ for(pair = m_byIpAndPort.begin(); pair != m_byIpAndPort.end(); pair++)
+ {
+ SipSessionRef session = pair->second;
+ if((now - session->m_lastUpdated) > 10)
+ {
+ toDismiss.push_back(session);
+ }
+ }
+
+ // discard inactive sessions
+ for (std::list<SipSessionRef>::iterator it = toDismiss.begin(); it != toDismiss.end() ; it++)
+ {
+ SipSessionRef session = *it;
+ LOG4CXX_DEBUG(m_log, session->m_ipAndPort + " Expired");
+ Stop(session);
+ }
+}
+
diff --git a/orkaudio/audiocaptureplugins/voip/SipSession.h b/orkaudio/audiocaptureplugins/voip/SipSession.h
new file mode 100644
index 0000000..4702bac
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/SipSession.h
@@ -0,0 +1,87 @@
+/*
+ * 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 __SIPSESSION_H__
+#define __SIPSESSION_H__
+
+#include "SipSession.h"
+#include "Rtp.h"
+#include <map>
+#include "ace/Singleton.h"
+
+class SipInviteInfo
+{
+public:
+ struct in_addr m_fromIp;
+ CStdString m_fromRtpPort;
+ CStdString m_from;
+ CStdString m_to;
+ CStdString m_callId;
+};
+typedef boost::shared_ptr<SipInviteInfo> SipInviteInfoRef;
+
+class SipByeInfo
+{
+public:
+ CStdString m_callId;
+};
+
+
+class SipSession
+{
+public:
+ SipSession();
+ void Stop();
+ void Start();
+ void AddRtpPacket(RtpPacketInfoRef& rtpPacket);
+ void ReportSipInvite(SipInviteInfoRef& invite);
+
+ CStdString m_ipAndPort;
+ SipInviteInfoRef m_invite;
+ time_t m_lastUpdated;
+private:
+ void ProcessMetadata(RtpPacketInfoRef&);
+ void ProcessMetadataIncoming();
+ void ProcessMetadataOutgoing();
+ void ReportMetadata();
+
+ RtpPacketInfoRef m_lastRtpPacket;
+ RtpRingBuffer m_rtpRingBuffer;
+ struct in_addr m_invitorIp;
+ struct in_addr m_inviteeIp;
+ LoggerPtr m_log;
+ CStdString m_capturePort;
+ CStdString m_localParty;
+ CStdString m_remoteParty;
+ CaptureEvent::DirectionEnum m_direction;
+};
+typedef boost::shared_ptr<SipSession> SipSessionRef;
+
+class SipSessions
+{
+public:
+ SipSessions();
+ void Stop(SipSessionRef& session);
+ void ReportSipInvite(SipInviteInfoRef& invite);
+ void ReportSipBye(SipByeInfo bye);
+ void ReportRtpPacket(RtpPacketInfoRef& rtpPacket);
+ void Hoover(time_t now);
+private:
+ std::map<CStdString, SipSessionRef> m_byIpAndPort;
+ std::map<CStdString, SipSessionRef> m_byCallId;
+ LoggerPtr m_log;
+};
+typedef ACE_Singleton<SipSessions, ACE_Thread_Mutex> SipSessionsSingleton;
+
+#endif
+
diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
new file mode 100644
index 0000000..e7a3b6d
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
@@ -0,0 +1,465 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_string.h"
+#include "ace/Singleton.h"
+#include "ace/Min_Max.h"
+#include "ace/OS_NS_arpa_inet.h"
+#include "ace/OS_NS_ctype.h"
+#include "AudioCapturePlugin.h"
+#include "AudioCapturePluginCommon.h"
+#include "Utils.h"
+#include "VoIpConfig.h"
+#include "pcap.h"
+#include "PacketHeaderDefs.h"
+#include "Rtp.h"
+#include "SipSession.h"
+
+extern AudioChunkCallBackFunction g_audioChunkCallBack;
+extern CaptureEventCallBackFunction g_captureEventCallBack;
+extern LogManager* g_logManager;
+
+#include "LogManager.h"
+
+static LoggerPtr s_log;
+static LoggerPtr s_sipExtractionLog;
+time_t lastHooveringTime;
+
+VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef;
+#define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config
+
+// find the address that follows the given search string between start and stop pointers
+char* memFindAfter(char* toFind, char* start, char* stop)
+{
+ for(char * ptr = start; (ptr<stop) && (ptr != NULL); ptr = (char *)memchr(ptr+1, toFind[0],(stop - start)))
+ {
+ if(memcmp(toFind, ptr, strlen(toFind)) == 0)
+ {
+ return (ptr+strlen(toFind));
+ }
+ }
+ return NULL;
+}
+
+char* memFindEOL(char* start, char* limit)
+{
+ char* c = start;
+ while(*c != '\r' && *c != '\n' && c<limit)
+ {
+ c++;
+ }
+ if(*c == '\r' || *c == '\n')
+ {
+ return c;
+ }
+ return start;
+}
+
+void GrabToken(char* in, CStdString& out)
+{
+ for(char* c = in; *c != '\0' && *c != 0x20 && *c != 0x0D && *c != 0x0A; c = c+1)
+ {
+ out += *c;
+ }
+}
+
+void GrabAlphaNumToken(char * in, char* limit, CStdString& out)
+{
+ // Look for first alphanum character
+ char* start = in;
+ while (!ACE_OS::ace_isalnum(*start) && start<limit)
+ {
+ start++;
+ }
+
+ if(start != (limit -1))
+ {
+ for(char* c = start; ACE_OS::ace_isalnum(*c); c = c+1)
+ {
+ out += *c;
+ }
+ }
+}
+
+void GrabString(char* start, char* stop, CStdString& out)
+{
+ char* c = start;
+ while(c <= stop)
+ {
+ out += *c++;
+ }
+}
+
+// Grabs a line of characters in memory from start pointer
+// returns the end of line
+char* GrabLine(char* start, char* limit, CStdString& out)
+{
+ char* c = start;
+ while(c < limit && *c != 0x0D && *c != 0x0A)
+ {
+ out += *c++;
+ }
+ return c;
+}
+
+bool TryRtp(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, UdpHeaderStruct* udpHeader, u_char* udpPayload)
+{
+ bool result = false;
+ RtpHeaderStruct* rtpHeader = (RtpHeaderStruct*)udpPayload;
+
+ if (rtpHeader->version == 2)
+ {
+ u_short source = ntohs(udpHeader->source);
+ u_short dest = ntohs(udpHeader->dest);
+ if(!(ntohs(udpHeader->source)%2) && !(ntohs(udpHeader->dest)%2)) // udp ports must be even
+ {
+ if(rtpHeader->pt == RTP_PT_PCMU || rtpHeader->pt == RTP_PT_PCMA)
+ {
+ result = true;
+ u_char* payload = (u_char *)rtpHeader + sizeof(RtpHeaderStruct);
+ u_char* packetEnd = (u_char *)ipHeader + ntohs(ipHeader->ip_len);
+ u_int payloadLength = packetEnd - payload;
+
+ RtpPacketInfoRef rtpInfo(new RtpPacketInfo());
+ rtpInfo->m_sourceIp = ipHeader->ip_src;
+ rtpInfo->m_destIp = ipHeader->ip_dest;
+ rtpInfo->m_sourcePort = ntohs(udpHeader->source);
+ rtpInfo->m_destPort = ntohs(udpHeader->dest);
+ rtpInfo->m_payloadSize = payloadLength;
+ rtpInfo->m_payloadType = rtpHeader->pt;
+ rtpInfo->m_seqNum = ntohs(rtpHeader->seq);
+ rtpInfo->m_timestamp = ntohl(rtpHeader->ts);
+ rtpInfo->m_payload = payload;
+
+ CStdString debug;
+ debug.Format("%s,%d seq:%u ts:%u len:%d", ACE_OS::inet_ntoa(rtpInfo->m_sourceIp), rtpInfo->m_sourcePort, ntohs(rtpHeader->seq), ntohl(rtpHeader->ts), payloadLength);
+ LOG4CXX_DEBUG(s_log, debug);
+
+ SipSessionsSingleton::instance()->ReportRtpPacket(rtpInfo);
+ }
+ }
+ }
+ return result;
+}
+
+
+bool TrySipBye(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, UdpHeaderStruct* udpHeader, u_char* udpPayload)
+{
+ bool result = false;
+ if (memcmp("BYE", (void*)udpPayload, 1) == 0)
+ {
+ result = true;
+ int sipLength = ntohs(udpHeader->len);
+ char* sipEnd = (char*)udpPayload + sipLength;
+ SipByeInfo info;
+ char* callIdField = memFindAfter("Call-ID: ", (char*)udpPayload, sipEnd);
+ if(callIdField)
+ {
+ GrabToken(callIdField, info.m_callId);
+ SipSessionsSingleton::instance()->ReportSipBye(info);
+ }
+ LOG4CXX_DEBUG(s_log, "SIP BYE");
+ }
+ return result;
+}
+
+bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, UdpHeaderStruct* udpHeader, u_char* udpPayload)
+{
+ bool result = false;
+ if (memcmp("INVITE", (void*)udpPayload, 1) == 0)
+ {
+ result = true;
+
+ int sipLength = ntohs(udpHeader->len);
+ char* sipEnd = (char*)udpPayload + sipLength;
+
+ SipInviteInfoRef info(new SipInviteInfo());
+
+ char* fromField = memFindAfter("From: ", (char*)udpPayload, sipEnd);
+ char* toField = NULL;
+ char* callIdField = NULL;
+ char* audioField = NULL;
+
+ if(fromField)
+ {
+ if(s_sipExtractionLog->isDebugEnabled())
+ {
+ CStdString from;
+ GrabLine(fromField, sipEnd, from);
+ s_sipExtractionLog->forcedLog(Level::DEBUG, "from: " + from);
+ }
+
+ char* fromFieldEnd = memFindEOL(fromField, sipEnd);
+
+ char* sipUser = memFindAfter("sip:", fromField, fromFieldEnd);
+ if(sipUser)
+ {
+ GrabAlphaNumToken(sipUser, fromFieldEnd, info->m_from);
+ }
+ else
+ {
+ GrabAlphaNumToken(fromField, fromFieldEnd, info->m_from);
+ }
+ toField = memFindAfter("To: ", fromField, sipEnd);
+ }
+ if(toField)
+ {
+ char* toFieldEnd = NULL;
+ if(s_sipExtractionLog->isDebugEnabled())
+ {
+ CStdString to;
+ toFieldEnd = GrabLine(toField, sipEnd, to);
+ s_sipExtractionLog->forcedLog(Level::DEBUG, "to: " + to);
+ }
+
+ char* sipUser = memFindAfter("sip:", toField, toFieldEnd);
+ if(sipUser)
+ {
+ GrabAlphaNumToken(sipUser, toFieldEnd, info->m_to);
+ }
+ else
+ {
+ GrabAlphaNumToken(toField, toFieldEnd, info->m_to);
+ }
+ callIdField = memFindAfter("Call-ID: ", toField, sipEnd);
+ }
+ if(callIdField)
+ {
+ GrabToken(callIdField, info->m_callId);
+ audioField = memFindAfter("m=audio ", callIdField, sipEnd);
+ }
+ if(audioField)
+ {
+ GrabToken(audioField, info->m_fromRtpPort);
+ info->m_fromIp = ipHeader->ip_src;
+ SipSessionsSingleton::instance()->ReportSipInvite(info);
+ }
+ LOG4CXX_DEBUG(s_log, "SIP INVITE");
+ }
+ return result;
+}
+
+void HandlePacket(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
+{
+ EthernetHeaderStruct* ethernetHeader = (EthernetHeaderStruct *)pkt_data;
+ IpHeaderStruct* ipHeader = (IpHeaderStruct*)((char*)ethernetHeader + sizeof(EthernetHeaderStruct));
+ int ipHeaderLength = ipHeader->ip_hl*4;
+
+ //CStdString source = ACE_OS::inet_ntoa(ipHeader->ip_src);
+ //CStdString dest = ACE_OS::inet_ntoa(ipHeader->ip_dest);
+ //CStdString debug;
+ //debug.Format("%x, %x", ethernetHeader, ipHeader);
+ //LOG4CXX_INFO(s_log, source + "-" + dest);
+
+ //LOG4CXX_DEBUG(s_log, "*");
+
+ if(ipHeader->ip_p == IPPROTO_UDP)
+ {
+ UdpHeaderStruct* udpHeader = (UdpHeaderStruct*)((char *)ipHeader + ipHeaderLength);
+
+ if( ntohs(udpHeader->source) > 5000 && ntohs(udpHeader->dest) > 5000 )
+ {
+ u_char* udpPayload = (u_char *)udpHeader + sizeof(UdpHeaderStruct);
+
+
+ bool detectedUsefulPacket = TryRtp(ethernetHeader, ipHeader, udpHeader, udpPayload);
+
+ if(!detectedUsefulPacket)
+ {
+ detectedUsefulPacket= TrySipInvite(ethernetHeader, ipHeader, udpHeader, udpPayload);
+ }
+ if(!detectedUsefulPacket)
+ {
+ detectedUsefulPacket = TrySipBye(ethernetHeader, ipHeader, udpHeader, udpPayload);
+ }
+ }
+ }
+
+ time_t now = time(NULL);
+ if((now - lastHooveringTime) > 5)
+ {
+ lastHooveringTime = now;
+ SipSessionsSingleton::instance()->Hoover(now);
+ }
+}
+
+
+class VoIp
+{
+public:
+ VoIp();
+ void Initialize();
+ void Run();
+ void StartCapture(CStdString& port);
+ void StopCapture(CStdString& port);
+private:
+ pcap_t* m_pcapHandle;
+};
+
+typedef ACE_Singleton<VoIp, ACE_Thread_Mutex> VoIpSingleton;
+
+VoIp::VoIp()
+{
+ m_pcapHandle = NULL;
+}
+
+void Configure(DOMNode* node)
+{
+ if (node)
+ {
+ VoIpConfigTopObjectRef VoIpConfigTopObjectRef(new VoIpConfigTopObject);
+ try
+ {
+ VoIpConfigTopObjectRef.get()->DeSerializeDom(node);
+ g_VoIpConfigTopObjectRef = VoIpConfigTopObjectRef;
+ }
+ catch (CStdString& e)
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "VoIp.dll: " + e);
+ }
+ }
+ else
+ {
+ LOG4CXX_WARN(g_logManager->rootLog, "VoIp.dll: got empty DOM tree");
+ }
+}
+
+
+void VoIp::Initialize()
+{
+ s_log = Logger::getLogger("voip");
+ s_sipExtractionLog = Logger::getLogger("sipextraction");
+ LOG4CXX_INFO(s_log, "Initializing VoIP plugin");
+
+ // create a default config object in case it was not properly initialized by Configure
+ if(!g_VoIpConfigTopObjectRef.get())
+ {
+ g_VoIpConfigTopObjectRef.reset(new VoIpConfigTopObject);
+ }
+
+/*
+ char addr1[] = "10.1.2.3";
+ char addr2[] = "192.168.5.6";
+ char addr3[] = "45.168.5.6";
+ struct in_addr addr;
+ ACE_OS::inet_aton(addr1, &addr);
+ bool result = DLLCONFIG.IsPartOfLan(addr);
+ result = DLLCONFIG.IsMediaGateway(addr);
+ ACE_OS::inet_aton(addr2, &addr);
+ result = DLLCONFIG.IsPartOfLan(addr);
+ result = DLLCONFIG.IsMediaGateway(addr);
+ ACE_OS::inet_aton(addr3, &addr);
+ result = DLLCONFIG.IsPartOfLan(addr);
+ result = DLLCONFIG.IsMediaGateway(addr);
+*/
+
+ pcap_if_t* devices = NULL;
+ pcap_if_t* deviceToSniff = NULL;
+ lastHooveringTime = time(NULL);
+
+ char * error = NULL;
+ if (pcap_findalldevs(&devices, error) == -1)
+ {
+ LOG4CXX_ERROR(s_log, CStdString("pcap error when discovering devices: ") + error);
+ }
+ else
+ {
+ if(devices)
+ {
+ LOG4CXX_INFO(s_log, CStdString("Available pcap devices:"));
+
+ for (pcap_if_t* device = devices; device != NULL; device = device->next)
+ {
+ LOG4CXX_INFO(s_log, CStdString("\t* ") + device->description + " " + device->name );
+ if(DLLCONFIG.m_device.Equals(device->name))
+ {
+ deviceToSniff = device;
+ }
+ }
+ if (!deviceToSniff)
+ {
+ LOG4CXX_ERROR(s_log, CStdString("pcap could not find wanted device: ") + DLLCONFIG.m_device);
+ }
+ else
+ {
+ #define PROMISCUOUS 1
+ if ((m_pcapHandle = pcap_open_live(deviceToSniff->name, 1500, PROMISCUOUS,
+ 500, error)) == NULL)
+ {
+ LOG4CXX_ERROR(s_log, CStdString("pcap error when opening device: ") + deviceToSniff->name);
+ }
+ else
+ {
+ LOG4CXX_INFO(s_log, CStdString("successfully opened device: ") + deviceToSniff->name);
+
+ //unsigned int netMask = 0xffffff;
+ //if(deviceToSniff->addresses != NULL)
+ //{
+ // netMask=((struct sockaddr_in *)(device->addresses->netmask))->sin_addr.s_addr;
+ //}
+
+ //struct bpf_program program;
+ //if (pcap_compile(m_pcapHandle, &program, "ip proto icmp", 1, 0xffffffff) < 0)
+ //{
+ // LOG4CXX_ERROR(s_log, CStdString("unable to compile pcap filter"));
+ //}
+ }
+ }
+ }
+ else
+ {
+ LOG4CXX_ERROR(s_log, CStdString("pcap could not find any device"));
+ }
+ }
+
+}
+
+void VoIp::Run()
+{
+ LOG4CXX_INFO(s_log, "Running VoIp.dll");
+ pcap_loop(m_pcapHandle, 0, HandlePacket, NULL);
+}
+
+void VoIp::StartCapture(CStdString& port)
+{
+ ;
+}
+
+void VoIp::StopCapture(CStdString& port)
+{
+ ;
+}
+
+void __CDECL__ Initialize()
+{
+ VoIpSingleton::instance()->Initialize();
+}
+
+void __CDECL__ Run()
+{
+ VoIpSingleton::instance()->Run();
+}
+
+void __CDECL__ StartCapture(CStdString& capturePort)
+{
+ ;
+}
+
+void __CDECL__ StopCapture(CStdString& capturePort)
+{
+ ;
+}
+
diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.dsp b/orkaudio/audiocaptureplugins/voip/VoIp.dsp
new file mode 100644
index 0000000..c58a936
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/VoIp.dsp
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="VoIp" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=VoIp - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "VoIp.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "VoIp.mak" CFG="VoIp - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "VoIp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "VoIp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "VoIp - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VoIp_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\devExt\winpcap\WpdPack\Include" /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VoIp_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 packet.lib wpcap.lib wininet.lib OrkBase.lib ace.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"C:\devExt\winpcap\WpdPack\Lib" /libpath:"../../../OrkBaseCxx/Release" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Release" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ELSEIF "$(CFG)" == "VoIp - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VoIp_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "C:\devExt\winpcap\WpdPack\Include" /I "../.." /I "../../../OrkBaseCxx" /I "C:\devExt\boost\boost_1_32_0" /I "C:\devExt\ACE_wrappers" /I "C:\devExt\xerces++\xerces-c_2_6_0-windows_nt-msvc_60\include" /I "../Common" /I "C:\devExt\log4cxx\log4cxx-0.9.7\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VoIp_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 packet.lib wpcap.lib wininet.lib OrkBaseD.lib aced.lib log4cxx.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\devExt\winpcap\WpdPack\Lib" /libpath:"../../../OrkBaseCxx/Debug" /libpath:"C:\devExt\log4cxx\log4cxx-0.9.7\msvc\Lib\Debug" /libpath:"C:\devExt\ACE_wrappers\lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "VoIp - Win32 Release"
+# Name "VoIp - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\AudioCapturePlugin.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\AudioCapturePluginCommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\ConfigManager.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\g711.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\g711.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\PacketHeaderDefs.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rtp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Rtp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SipSession.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SipSession.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\VoIp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\VoIpConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\VoIpConfig.h
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
new file mode 100644
index 0000000..a632bdc
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
@@ -0,0 +1,127 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "serializers/Serializer.h"
+#include "VoIpConfig.h"
+#include "ace/OS_NS_arpa_inet.h"
+
+VoIpConfig::VoIpConfig()
+{
+ // Standard LAN internal IP range masks
+ m_asciiLanMasks.push_back("192.168.255.255");
+ m_asciiLanMasks.push_back("10.255.255.255");
+ m_asciiLanMasks.push_back("172.31.255.255");
+}
+
+void VoIpConfig::Define(Serializer* s)
+{
+ s->StringValue(DEVICE_PARAM, m_device);
+ s->CsvValue("LanMasks", m_asciiLanMasks);
+ s->CsvValue("MediaGateways", m_asciiMediaGateways);
+}
+
+void VoIpConfig::Validate()
+{
+ // iterate over ascii LAN masks and populate the binary LAN Masks list
+ m_lanMasks.clear();
+ std::list<CStdString>::iterator it;
+ for(it = m_asciiLanMasks.begin(); it != m_asciiLanMasks.end(); it++)
+ {
+ struct in_addr a;
+ if(ACE_OS::inet_aton((PCSTR)*it, &a))
+ {
+ m_lanMasks.push_back((unsigned int)a.s_addr);
+ }
+ else
+ {
+ throw (CStdString("VoIpConfig: invalid IP address in LanMasks:" + *it));
+ }
+ }
+
+ // iterate over ascii Media gateway IP addresses and populate the binary Media gateway IP addresses list
+ m_mediaGateways.clear();
+ for(it = m_asciiMediaGateways.begin(); it != m_asciiMediaGateways.end(); it++)
+ {
+ struct in_addr a;
+ if(ACE_OS::inet_aton((PCSTR)*it, &a))
+ {
+ m_mediaGateways.push_back((unsigned int)a.s_addr);
+ }
+ else
+ {
+ throw (CStdString("VoIpConfig: invalid IP address in MediaGateways:" + *it));
+ }
+ }
+}
+
+bool VoIpConfig::IsPartOfLan(struct in_addr addr)
+{
+ for(std::list<unsigned int>::iterator it = m_lanMasks.begin(); it != m_lanMasks.end(); it++)
+ {
+ if(((unsigned int)addr.s_addr & *it) == (unsigned int)addr.s_addr)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool VoIpConfig::IsMediaGateway(struct in_addr addr)
+{
+ for(std::list<unsigned int>::iterator it = m_mediaGateways.begin(); it != m_mediaGateways.end(); it++)
+ {
+ if((unsigned int)addr.s_addr == *it)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+CStdString VoIpConfig::GetClassName()
+{
+ return CStdString("VoIpConfig");
+}
+
+ObjectRef VoIpConfig::NewInstance()
+{
+ return ObjectRef(new VoIpConfig);
+}
+
+//====================================
+
+
+void VoIpConfigTopObject::Define(Serializer* s)
+{
+ s->ObjectValue(SOUND_DEVICE_CONFIG_PARAM, m_config, true);
+}
+
+void VoIpConfigTopObject::Validate()
+{
+ ;
+}
+
+CStdString VoIpConfigTopObject::GetClassName()
+{
+ return CStdString("VoIpConfigTopObject");
+}
+
+ObjectRef VoIpConfigTopObject::NewInstance()
+{
+ return ObjectRef(new VoIpConfigTopObject);
+}
+
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
new file mode 100644
index 0000000..7bea647
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
@@ -0,0 +1,68 @@
+/*
+ * 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 __VOIPCONFIG_H__
+#define __VOIPCONFIG_H__
+
+#include <list>
+#include "StdString.h"
+#include "Object.h"
+#include "boost/shared_ptr.hpp"
+
+#define DEVICE_PARAM "Device"
+
+/** This class defines various configuration parameters for the generator. */
+class VoIpConfig : public Object
+{
+public:
+ VoIpConfig();
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ bool IsPartOfLan(struct in_addr);
+ bool IsMediaGateway(struct in_addr);
+
+ CStdString m_device;
+ std::list<unsigned int> m_mediaGateways;
+ std::list<CStdString> m_asciiMediaGateways;
+ std::list<unsigned int> m_lanMasks;
+ std::list<CStdString> m_asciiLanMasks;
+};
+
+//========================================
+
+#define SOUND_DEVICE_CONFIG_PARAM "VoIpPlugin"
+
+/** This class represents the top of the configuration hierarchy for the generator. */
+class VoIpConfigTopObject : public Object
+{
+public:
+ void Define(Serializer* s);
+ void Validate();
+
+ CStdString GetClassName();
+ ObjectRef NewInstance();
+ inline ObjectRef Process() {return ObjectRef();};
+
+ VoIpConfig m_config;
+};
+
+typedef boost::shared_ptr<VoIpConfigTopObject> VoIpConfigTopObjectRef;
+
+
+#endif
+
diff --git a/orkaudio/audiocaptureplugins/voip/g711.c b/orkaudio/audiocaptureplugins/voip/g711.c
new file mode 100644
index 0000000..7317dbb
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/g711.c
@@ -0,0 +1,285 @@
+/*
+ * This source code is a product of Sun Microsystems, Inc. and is provided
+ * for unrestricted use. Users may copy or modify this source code without
+ * charge.
+ *
+ * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
+ * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun source code is provided with no support and without any obligation on
+ * the part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+#include "g711.h"
+
+/*
+ * g711.c
+ *
+ * u-law, A-law and linear PCM conversions.
+ */
+#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
+#define QUANT_MASK (0xf) /* Quantization field mask. */
+#define NSEGS (8) /* Number of A-law segments. */
+#define SEG_SHIFT (4) /* Left shift for segment number. */
+#define SEG_MASK (0x70) /* Segment field mask. */
+
+static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
+ 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
+
+/* copy from CCITT G.711 specifications */
+unsigned char _u2a[128] = { /* u- to A-law conversions */
+ 1, 1, 2, 2, 3, 3, 4, 4,
+ 5, 5, 6, 6, 7, 7, 8, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 27, 29, 31, 33, 34, 35, 36,
+ 37, 38, 39, 40, 41, 42, 43, 44,
+ 46, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62,
+ 64, 65, 66, 67, 68, 69, 70, 71,
+ 72, 73, 74, 75, 76, 77, 78, 79,
+ 81, 82, 83, 84, 85, 86, 87, 88,
+ 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120,
+ 121, 122, 123, 124, 125, 126, 127, 128};
+
+unsigned char _a2u[128] = { /* A- to u-law conversions */
+ 1, 3, 5, 7, 9, 11, 13, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 32, 33, 33, 34, 34, 35, 35,
+ 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 48, 49, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57,
+ 58, 59, 60, 61, 62, 63, 64, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127};
+
+static int
+search(
+ int val,
+ short *table,
+ int size)
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (val <= *table++)
+ return (i);
+ }
+ return (size);
+}
+
+/*
+ * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
+ *
+ * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
+ *
+ * Linear Input Code Compressed Code
+ * ------------------------ ---------------
+ * 0000000wxyza 000wxyz
+ * 0000001wxyza 001wxyz
+ * 000001wxyzab 010wxyz
+ * 00001wxyzabc 011wxyz
+ * 0001wxyzabcd 100wxyz
+ * 001wxyzabcde 101wxyz
+ * 01wxyzabcdef 110wxyz
+ * 1wxyzabcdefg 111wxyz
+ *
+ * For further information see John C. Bellamy's Digital Telephony, 1982,
+ * John Wiley & Sons, pps 98-111 and 472-476.
+ */
+unsigned char
+linear2alaw(
+ int pcm_val) /* 2's complement (16-bit range) */
+{
+ int mask;
+ int seg;
+ unsigned char aval;
+
+ if (pcm_val >= 0) {
+ mask = 0xD5; /* sign (7th) bit = 1 */
+ } else {
+ mask = 0x55; /* sign bit = 0 */
+ pcm_val = -pcm_val - 8;
+ }
+
+ /* Convert the scaled magnitude to segment number. */
+ seg = search(pcm_val, seg_end, 8);
+
+ /* Combine the sign, segment, and quantization bits. */
+
+ if (seg >= 8) /* out of range, return maximum value. */
+ return (0x7F ^ mask);
+ else {
+ aval = seg << SEG_SHIFT;
+ if (seg < 2)
+ aval |= (pcm_val >> 4) & QUANT_MASK;
+ else
+ aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
+ return (aval ^ mask);
+ }
+}
+
+/*
+ * alaw2linear() - Convert an A-law value to 16-bit linear PCM
+ *
+ */
+int
+alaw2linear(
+ unsigned char a_val)
+{
+ int t;
+ int seg;
+
+ a_val ^= 0x55;
+
+ t = (a_val & QUANT_MASK) << 4;
+ seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
+ switch (seg) {
+ case 0:
+ t += 8;
+ break;
+ case 1:
+ t += 0x108;
+ break;
+ default:
+ t += 0x108;
+ t <<= seg - 1;
+ }
+ return ((a_val & SIGN_BIT) ? t : -t);
+}
+
+#define BIAS (0x84) /* Bias for linear code. */
+
+/*
+ * linear2ulaw() - Convert a linear PCM value to u-law
+ *
+ * In order to simplify the encoding process, the original linear magnitude
+ * is biased by adding 33 which shifts the encoding range from (0 - 8158) to
+ * (33 - 8191). The result can be seen in the following encoding table:
+ *
+ * Biased Linear Input Code Compressed Code
+ * ------------------------ ---------------
+ * 00000001wxyza 000wxyz
+ * 0000001wxyzab 001wxyz
+ * 000001wxyzabc 010wxyz
+ * 00001wxyzabcd 011wxyz
+ * 0001wxyzabcde 100wxyz
+ * 001wxyzabcdef 101wxyz
+ * 01wxyzabcdefg 110wxyz
+ * 1wxyzabcdefgh 111wxyz
+ *
+ * Each biased linear code has a leading 1 which identifies the segment
+ * number. The value of the segment number is equal to 7 minus the number
+ * of leading 0's. The quantization interval is directly available as the
+ * four bits wxyz. * The trailing bits (a - h) are ignored.
+ *
+ * Ordinarily the complement of the resulting code word is used for
+ * transmission, and so the code word is complemented before it is returned.
+ *
+ * For further information see John C. Bellamy's Digital Telephony, 1982,
+ * John Wiley & Sons, pps 98-111 and 472-476.
+ */
+unsigned char
+linear2ulaw(
+ int pcm_val) /* 2's complement (16-bit range) */
+{
+ int mask;
+ int seg;
+ unsigned char uval;
+
+ /* Get the sign and the magnitude of the value. */
+ if (pcm_val < 0) {
+ pcm_val = BIAS - pcm_val;
+ mask = 0x7F;
+ } else {
+ pcm_val += BIAS;
+ mask = 0xFF;
+ }
+
+ /* Convert the scaled magnitude to segment number. */
+ seg = search(pcm_val, seg_end, 8);
+
+ /*
+ * Combine the sign, segment, quantization bits;
+ * and complement the code word.
+ */
+ if (seg >= 8) /* out of range, return maximum value. */
+ return (0x7F ^ mask);
+ else {
+ uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
+ return (uval ^ mask);
+ }
+
+}
+
+/*
+ * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
+ *
+ * First, a biased linear code is derived from the code word. An unbiased
+ * output can then be obtained by subtracting 33 from the biased code.
+ *
+ * Note that this function expects to be passed the complement of the
+ * original code word. This is in keeping with ISDN conventions.
+ */
+int
+ulaw2linear(
+ unsigned char u_val)
+{
+ int t;
+
+ /* Complement to obtain normal u-law value. */
+ u_val = ~u_val;
+
+ /*
+ * Extract and bias the quantization bits. Then
+ * shift up by the segment number and subtract out the bias.
+ */
+ t = ((u_val & QUANT_MASK) << 3) + BIAS;
+ t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
+
+ return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
+}
+
+/* A-law to u-law conversion */
+unsigned char
+alaw2ulaw(
+ unsigned char aval)
+{
+ aval &= 0xff;
+ return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
+ (0x7F ^ _a2u[aval ^ 0x55]));
+}
+
+/* u-law to A-law conversion */
+unsigned char
+ulaw2alaw(
+ unsigned char uval)
+{
+ uval &= 0xff;
+ return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
+ (0x55 ^ (_u2a[0x7F ^ uval] - 1)));
+}
diff --git a/orkaudio/audiocaptureplugins/voip/g711.h b/orkaudio/audiocaptureplugins/voip/g711.h
new file mode 100644
index 0000000..f15df4d
--- /dev/null
+++ b/orkaudio/audiocaptureplugins/voip/g711.h
@@ -0,0 +1,21 @@
+/*
+ * 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 __G711_H__
+#define __G711_H__
+
+int ulaw2linear(unsigned char u_val);
+int alaw2linear(unsigned char a_val);
+
+#endif
+
diff --git a/orkaudio/audiofile/AudioFile.cpp b/orkaudio/audiofile/AudioFile.cpp
new file mode 100644
index 0000000..377963b
--- /dev/null
+++ b/orkaudio/audiofile/AudioFile.cpp
@@ -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
+ *
+ */
+
+#include "AudioFile.h"
+#include "ace/OS_NS_unistd.h"
+
+void AudioFile::Open(fileOpenModeEnum mode, bool stereo , int sampleRate)
+{
+ Open(m_filename, mode, stereo, sampleRate);
+}
+
+
+void AudioFile::RecursiveMkdir(CStdString& path)
+{
+ int position = 0;
+ bool done = false;
+ while (!done)
+ {
+ position = path.Find('/', position+1);
+ if (position == -1)
+ {
+ done = true;
+ }
+ else
+ {
+ CStdString level = path.Left(position);
+ ACE_OS::mkdir((PCSTR)level);
+ }
+ }
+}
+
+void AudioFile::MoveOrig()
+{
+ CStdString newName = m_filename + ".orig";
+ if (ACE_OS::rename((PCSTR)m_filename, (PCSTR)newName) == 0)
+ {
+ m_filename = newName;
+ }
+ else
+ {
+ throw(CStdString("AudioFile::MoveOrig: could not rename file:" + m_filename));
+ }
+}
+
+void AudioFile::Delete()
+{
+ ACE_OS::unlink((PCSTR)m_filename);
+}
diff --git a/orkaudio/audiofile/AudioFile.h b/orkaudio/audiofile/AudioFile.h
new file mode 100644
index 0000000..cd7d6f6
--- /dev/null
+++ b/orkaudio/audiofile/AudioFile.h
@@ -0,0 +1,69 @@
+/*
+ * 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 __AUDIOFILE_H__
+#define __AUDIOFILE_H__
+
+#include "boost/shared_ptr.hpp"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#include "StdString.h"
+#include "AudioCapture.h"
+
+
+/** Base class for all file accessor classes. */
+class AudioFile
+{
+public:
+ typedef enum {READ = 0, WRITE = 1} fileOpenModeEnum;
+
+ /** Open audio file for reading or writing.
+ Filename should include path information but not extension (which is automatically appended)
+ If the underlying format does not support stereo, data is transparently read from two files in read mode
+ or two files are transparently written to in write mode */
+ virtual void Open(CStdString& filename, fileOpenModeEnum mode, bool stereo = false, int sampleRate = 8000) = 0;
+ /** Same as above but uses the intenal filename */
+ void Open(fileOpenModeEnum mode, bool stereo = false, int sampleRate = 8000);
+ /** Explicitely close the underlying file(s). This is also done automatically by the destructor */
+ virtual void Close() = 0;
+
+ /** Writes a chunk of audio to disk.
+ If stereo capture, this represents the local party */
+ virtual void WriteChunk(AudioChunkRef chunkRef) = 0;
+ /** Writes a chunk of audio from the remote pary to disk (if stereo capture)
+ //virtual bool WriteRemoteChunk(AudioChunkRef chunkRef) = 0;
+ /** Reads a chunk of audio stereo-wise
+ If underlying storage is mono, remoteChunk will be NULL
+ ReadChunkStereo guarantees that local and remote chunks returned are in sync */
+ //virtual bool ReadChunkStereo(AudioChunkRef& chunk, AudioChunkRef& remoteChunk) = 0;
+ /** Reads a chunk of audio mono-wise
+ If underlying file is stereo, ReadChunkMono merges the two streams in a synchronized manner and returns the result */
+ virtual int ReadChunkMono(AudioChunkRef& chunk) = 0;
+
+ /** Move the file to a new name including ".orig" suffix */
+ void MoveOrig();
+ void Delete();
+ virtual CStdString GetExtension() = 0;
+
+ static void RecursiveMkdir(CStdString& path);
+protected:
+ CStdString m_filename;
+ fileOpenModeEnum m_mode;
+ int m_numChunksWritten;
+};
+
+typedef boost::shared_ptr<AudioFile> AudioFileRef;
+
+#endif
+
diff --git a/orkaudio/audiofile/LibSndFileFile.cpp b/orkaudio/audiofile/LibSndFileFile.cpp
new file mode 100644
index 0000000..cc5bf82
--- /dev/null
+++ b/orkaudio/audiofile/LibSndFileFile.cpp
@@ -0,0 +1,123 @@
+/*
+ * 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
+ *
+ */
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include "Utils.h"
+#include "LibSndFileFile.h"
+
+LibSndFileFile::LibSndFileFile(int fileFormat)
+{
+ m_fileInfo.format = fileFormat;
+ m_fileInfo.frames = 0;
+ m_fileInfo.samplerate = 0;
+ m_fileInfo.channels = 0;
+ m_fileInfo.sections = 0;
+ m_fileInfo.seekable = 0;
+ m_pFile = NULL;
+ m_numChunksWritten = 0;
+ m_mode = READ;
+}
+
+LibSndFileFile::~LibSndFileFile()
+{
+ Close();
+}
+
+void LibSndFileFile::Open(CStdString& filename, fileOpenModeEnum mode, bool stereo, int sampleRate)
+{
+ if(!m_filename.Equals(filename))
+ {
+ m_filename = filename + ".wav";
+ }
+ m_mode = mode;
+ stereo ? m_fileInfo.channels = 2 : m_fileInfo.channels = 1;
+ m_fileInfo.samplerate = sampleRate;
+
+ if( (mode==WRITE) && !sf_format_check(&m_fileInfo))
+ {
+ throw(CStdString("libsndfile: Selected output format not supported"));
+ }
+
+ RecursiveMkdir(m_filename);
+
+ int sndFileMode;
+ mode == READ ? sndFileMode = SFM_READ : sndFileMode = SFM_WRITE;
+ m_pFile = sf_open((PCSTR)m_filename, sndFileMode, &m_fileInfo);
+
+ if(!m_pFile)
+ {
+ throw(CStdString("sf_open failed, audio file could not be created:"+ m_filename));
+ }
+}
+
+void LibSndFileFile::WriteChunk(AudioChunkRef chunkRef)
+{
+ if (m_pFile)
+ {
+
+ if( chunkRef->m_encoding == AudioChunk::AlawAudio || chunkRef->m_encoding == AudioChunk::UlawAudio)
+ {
+ if(sf_write_raw(m_pFile, chunkRef->m_pBuffer, chunkRef->GetNumSamples()) != chunkRef->GetNumSamples())
+ {
+ CStdString numChunksWrittenString = IntToString(m_numChunksWritten);
+ throw(CStdString("sf_write_raw failed, audio file " + m_filename + " could not be written after " + numChunksWrittenString + " chunks written"));
+ }
+ }
+ else if (chunkRef->m_encoding == AudioChunk::PcmAudio)
+ {
+ if(sf_write_short(m_pFile, (short*)chunkRef->m_pBuffer, chunkRef->GetNumSamples()) != chunkRef->GetNumSamples())
+ {
+ CStdString numChunksWrittenString = IntToString(m_numChunksWritten);
+ throw(CStdString("sf_write_short failed, audio file " + m_filename + " could not be written after " + numChunksWrittenString + " chunks written"));
+ }
+ }
+ m_numChunksWritten++;
+ }
+ else
+ {
+ throw(CStdString("Write attempt on unopened file:")+ m_filename);
+ }
+}
+
+int LibSndFileFile::ReadChunkMono(AudioChunkRef& chunk)
+{
+ unsigned int numRead = 0;
+ if (m_pFile)
+ {
+ chunk.reset(new AudioChunk());
+ short temp[8000];
+ numRead = sf_read_short(m_pFile, temp, 8000);
+ chunk->SetBuffer(temp, sizeof(short)*numRead, AudioChunk::PcmAudio);
+ }
+ else
+ {
+ throw(CStdString("Read attempt on unopened file:")+ m_filename);
+ }
+ return numRead;
+}
+
+
+void LibSndFileFile::Close()
+{
+ if (m_pFile)
+ {
+ sf_close(m_pFile);
+ m_pFile = NULL;
+ }
+}
+
+CStdString LibSndFileFile::GetExtension()
+{
+ return ".wav";
+}
diff --git a/orkaudio/audiofile/LibSndFileFile.h b/orkaudio/audiofile/LibSndFileFile.h
new file mode 100644
index 0000000..e0516a8
--- /dev/null
+++ b/orkaudio/audiofile/LibSndFileFile.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 __LIBSNDFILEFILE_H__
+#define __LIBSNDFILEFILE_H__
+
+
+#include "StdString.h"
+#include "AudioCapture.h"
+#include "sndfile.h"
+#include "AudioFile.h"
+
+
+/** file accessor class for all file types supported by the libsndfile library.
+ The library can be found at http://www.mega-nerd.com/libsndfile/
+*/
+class LibSndFileFile : public AudioFile
+{
+public:
+ LibSndFileFile(int fileFormat); // fileFormat is described at http://www.mega-nerd.com/libsndfile/api.html
+ ~LibSndFileFile();
+
+ void Open(CStdString& filename, fileOpenModeEnum mode, bool stereo = false, int sampleRate = 8000);
+ void Close();
+
+ void WriteChunk(AudioChunkRef chunkRef);
+ int ReadChunkMono(AudioChunkRef& chunk);
+
+ CStdString GetExtension();
+private:
+ SF_INFO m_fileInfo;
+ SNDFILE* m_pFile;
+};
+
+#endif
+
diff --git a/orkaudio/audiofile/Makefile.am b/orkaudio/audiofile/Makefile.am
new file mode 100644
index 0000000..d6bddad
--- /dev/null
+++ b/orkaudio/audiofile/Makefile.am
@@ -0,0 +1,6 @@
+METASOURCES = AUTO
+noinst_LTLIBRARIES = libaudiofile.la
+libaudiofile_la_SOURCES = AudioFile.cpp LibSndFileFile.cpp PcmFile.cpp
+AM_CPPFLAGS = -D_REENTRANT
+libaudiofile_la_LIBADD =
+INCLUDES = -I@top_srcdir@ -I../../orkbasecxx
diff --git a/orkaudio/audiofile/PcmFile.cpp b/orkaudio/audiofile/PcmFile.cpp
new file mode 100644
index 0000000..93f4743
--- /dev/null
+++ b/orkaudio/audiofile/PcmFile.cpp
@@ -0,0 +1,100 @@
+/*
+ * 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 "PcmFile.h"
+
+PcmFile::PcmFile()
+{
+ m_stream = NULL;
+ m_mode = READ;
+ m_numChunksWritten = 0;
+}
+
+PcmFile::~PcmFile()
+{
+ Close();
+}
+
+
+void PcmFile::Close()
+{
+ if(m_stream)
+ {
+ ACE_OS::fclose(m_stream);
+ m_stream = NULL;
+ }
+}
+
+void PcmFile::WriteChunk(AudioChunkRef chunkRef)
+{
+ unsigned int numWritten = 0;
+ if (m_stream)
+ {
+ numWritten = ACE_OS::fwrite(chunkRef->m_pBuffer, sizeof(short), chunkRef->GetNumSamples(), m_stream);
+ }
+ else
+ {
+ throw(CStdString("Write attempt on unopened file:")+ m_filename);
+ }
+
+ if (numWritten != chunkRef->GetNumSamples())
+ {
+ throw(CStdString("Could not write to file:")+ m_filename);
+ }
+}
+
+int PcmFile::ReadChunkMono(AudioChunkRef& chunkRef)
+{
+ unsigned int numRead = 0;
+ if (m_stream)
+ {
+ chunkRef.reset(new AudioChunk());
+ short temp[PCM_FILE_DEFAULT_CHUNK_NUM_SAMPLES];
+ numRead = ACE_OS::fread(temp, sizeof(short), PCM_FILE_DEFAULT_CHUNK_NUM_SAMPLES, m_stream);
+ chunkRef->SetBuffer(temp, sizeof(short)*numRead, AudioChunk::PcmAudio);
+ }
+ else
+ {
+ throw(CStdString("Read attempt on unopened file:")+ m_filename);
+ }
+ return numRead;
+}
+
+
+void PcmFile::Open(CStdString& filename, fileOpenModeEnum mode, bool stereo, int sampleRate)
+{
+ if(!m_filename.Equals(filename))
+ {
+ m_filename = filename + ".pcm";
+ }
+ m_stream = NULL;
+ m_mode = mode;
+ if (mode == READ)
+ {
+ m_stream = ACE_OS::fopen((PCSTR)m_filename, "rb");
+ }
+ else
+ {
+ RecursiveMkdir(m_filename);
+ m_stream = ACE_OS::fopen((PCSTR)m_filename, "wb");
+ }
+ if(!m_stream)
+ {
+ throw(CStdString("Could not open file: ") + m_filename);
+ }
+}
+
+CStdString PcmFile::GetExtension()
+{
+ return ".pcm";
+}
diff --git a/orkaudio/audiofile/PcmFile.h b/orkaudio/audiofile/PcmFile.h
new file mode 100644
index 0000000..91c1325
--- /dev/null
+++ b/orkaudio/audiofile/PcmFile.h
@@ -0,0 +1,41 @@
+/*
+ * 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 __PCMFILE_H__
+#define __PCMFILE_H__
+
+#include "audiofile/AudioFile.h"
+
+#define PCM_FILE_DEFAULT_CHUNK_NUM_SAMPLES 8000
+
+/** File class for raw 16 bit signed PCM output */
+class PcmFile : public AudioFile
+{
+public:
+ PcmFile();
+ ~PcmFile();
+
+ void Open(CStdString& filename, fileOpenModeEnum mode, bool stereo = false, int sampleRate = 8000);
+ void Close();
+
+ void WriteChunk(AudioChunkRef chunkRef);
+ int ReadChunkMono(AudioChunkRef& chunkRef);
+
+ CStdString GetExtension();
+protected:
+
+ FILE* m_stream;
+};
+
+#endif
+
diff --git a/orkaudio/config-template.xml b/orkaudio/config-template.xml
new file mode 100644
index 0000000..f0132a7
--- /dev/null
+++ b/orkaudio/config-template.xml
@@ -0,0 +1,24 @@
+<!-- This is an example configuration file for the Oreka orkaudio capture service -->
+<!-- Copy this to config.xml and modify according to taste -->
+<config>
+ <TrackerHostname>hostname</TrackerHostname>
+ <EnableReporting>true</EnableReporting>
+ <ClientTimeout>1000</ClientTimeout>
+ <CapturePluginPath>audiocaptureplugins/</CapturePluginPath>
+ <CapturePlugin>Generator.dll</CapturePlugin>
+ <StorageAudioFormat>gsm</StorageAudioFormat>
+ <NumBatchThreads></NumBatchThreads>
+ <DeleteNativeFile>no</DeleteNativeFile>
+ <AudioSegmentation>false</AudioSegmentation>
+ <AudioSegmentDuration>10</AudioSegmentDuration>
+ <VoIpPlugin>
+ <Device>\Device\NPF_{2FEDB9F0-F584-48A8-B164-117965F80986}</Device>
+ <!--<LanMasks>10.4.3.4, 1.2.3.4</LanMasks>-->
+ <MediaGateways>10.0.0.102</MediaGateways>
+ </VoIpPlugin>
+ <Generator>
+ <NumConcurrentPorts>1</NumConcurrentPorts>
+ <AudioDuration>5</AudioDuration>
+ <AudioFilename>sine.8KHz.pcm.wav</AudioFileName>
+ </Generator>
+</config> \ No newline at end of file
diff --git a/orkaudio/config.guess b/orkaudio/config.guess
new file mode 100644
index 0000000..182e141
--- /dev/null
+++ b/orkaudio/config.guess
@@ -0,0 +1 @@
+link /usr/share/libtool/config.guess \ No newline at end of file
diff --git a/orkaudio/config.sub b/orkaudio/config.sub
new file mode 100644
index 0000000..ea4beb2
--- /dev/null
+++ b/orkaudio/config.sub
@@ -0,0 +1 @@
+link /usr/share/libtool/config.sub \ No newline at end of file
diff --git a/orkaudio/configure.in b/orkaudio/configure.in
new file mode 100644
index 0000000..b92725d
--- /dev/null
+++ b/orkaudio/configure.in
@@ -0,0 +1,10 @@
+AC_INIT(configure.in)
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(orkaudio, 0.1)
+
+AC_LANG_CPLUSPLUS
+AC_PROG_CXX
+AM_PROG_LIBTOOL
+
+AC_OUTPUT(Makefile messages/Makefile audiofile/Makefile audiocaptureplugins/Makefile audiocaptureplugins/generator/Makefile audiocaptureplugins/voip/Makefile)
diff --git a/orkaudio/install-sh b/orkaudio/install-sh
new file mode 100644
index 0000000..36f96f3
--- /dev/null
+++ b/orkaudio/install-sh
@@ -0,0 +1,276 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd=$cpprog
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd=$stripprog
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "$0: no input file specified" >&2
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d "$dst" ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "$0: $src does not exist" >&2
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "$0: no destination specified" >&2
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dst" ]
+ then
+ dst=$dst/`basename "$src"`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-$defaultIFS}"
+
+oIFS=$IFS
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS=$oIFS
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp=$pathcomp$1
+ shift
+
+ if [ ! -d "$pathcomp" ] ;
+ then
+ $mkdirprog "$pathcomp"
+ else
+ :
+ fi
+
+ pathcomp=$pathcomp/
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd "$dst" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ dstfile=`basename "$dst" $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ :
+ fi
+
+# Make a couple of temp file names in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+ rmtmp=$dstdir/#rm.$$#
+
+# Trap to clean up temp files at exit.
+
+ trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+ trap '(exit $?); exit' 1 2 13 15
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd "$src" "$dsttmp" &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+
+# Now remove or move aside any old file at destination location. We try this
+# two ways since rm can't unlink itself on some systems and the destination
+# file might be busy for other reasons. In this case, the final cleanup
+# might fail but the new file should still install successfully.
+
+{
+ if [ -f "$dstdir/$dstfile" ]
+ then
+ $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
+ $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
+ {
+ echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+ (exit 1); exit
+ }
+ else
+ :
+ fi
+} &&
+
+# Now rename the file to the real destination.
+
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+
+fi &&
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+
+{
+ (exit 0); exit
+}
diff --git a/orkaudio/logging-template.properties b/orkaudio/logging-template.properties
new file mode 100644
index 0000000..b441d54
--- /dev/null
+++ b/orkaudio/logging-template.properties
@@ -0,0 +1,43 @@
+# This is an example configuration file for the Oreka orkaudio capture service logging -->
+# Copy this to logging.properties and modify according to needs -->
+
+# console
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+# main logfile
+log4j.appender.A1=org.apache.log4j.RollingFileAppender
+log4j.appender.A1.File=orkaudio.log
+log4j.appender.A1.MaxFileSize=5000KB
+log4j.appender.A1.MaxBackupIndex=2
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+# messages logfile
+log4j.appender.messages=org.apache.log4j.RollingFileAppender
+log4j.appender.messages.File=messages.log
+log4j.appender.messages.MaxFileSize=5000KB
+log4j.appender.messages.MaxBackupIndex=2
+log4j.appender.messages.layout=org.apache.log4j.PatternLayout
+log4j.appender.messages.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+#tapelist logfile
+log4j.appender.tapelist=org.apache.log4j.RollingFileAppender
+log4j.appender.tapelist.File=tapelist.log
+log4j.appender.tapelist.MaxFileSize=5000KB
+log4j.appender.tapelist.MaxBackupIndex=2
+log4j.appender.tapelist.layout=org.apache.log4j.PatternLayout
+log4j.appender.tapelist.layout.ConversionPattern=%m%n
+
+
+# Set root logger level to DEBUG
+log4j.rootLogger=INFO, A1, stdout
+log4j.logger.reporting=INFO, messages
+log4j.logger.tapelist=INFO, tapelist
+log4j.logger.rtpringbuffer=INFO
+log4j.logger.voip=INFO
+log4j.logger.sipsessions=INFO
+log4j.logger.sipsession=DEBUG
+log4j.logger.sipextraction=DEBUG
diff --git a/orkaudio/ltmain.sh b/orkaudio/ltmain.sh
new file mode 100644
index 0000000..7404ae3
--- /dev/null
+++ b/orkaudio/ltmain.sh
@@ -0,0 +1 @@
+link /usr/share/libtool/ltmain.sh \ No newline at end of file
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
+
diff --git a/orkaudio/missing b/orkaudio/missing
new file mode 100644
index 0000000..6a37006
--- /dev/null
+++ b/orkaudio/missing
@@ -0,0 +1,336 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing 0.4 - GNU automake"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case "$f" in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+ test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+ fi
+ if [ -f "$file" ]; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ makeinfo)
+ if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+ # We have makeinfo, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ tar)
+ shift
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ fi
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case "$firstarg" in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case "$firstarg" in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/orkaudio/mkinstalldirs b/orkaudio/mkinstalldirs
new file mode 100644
index 0000000..d2d5f21
--- /dev/null
+++ b/orkaudio/mkinstalldirs
@@ -0,0 +1,111 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ fi
+ ;;
+esac
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# End:
+# mkinstalldirs ends here