diff options
author | Henri Herscher <henri@oreka.org> | 2006-06-30 19:39:27 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2006-06-30 19:39:27 +0000 |
commit | 868a99733ddb6a44f660f4aab9089fd619f38cfa (patch) | |
tree | 487309e2706b8389bc8985283c5d29334343bf7e /orkaudio | |
parent | 3868172df25ae59bd0ecc524b782ac4734812891 (diff) |
Moved more stuff to orkbasecxx
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@287 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio')
-rw-r--r-- | orkaudio/ThreadSafeQueue.h | 97 | ||||
-rw-r--r-- | orkaudio/audiofile/AudioFile.cpp | 63 | ||||
-rw-r--r-- | orkaudio/audiofile/AudioFile.h | 71 | ||||
-rw-r--r-- | orkaudio/audiofile/LibSndFileFile.cpp | 138 | ||||
-rw-r--r-- | orkaudio/audiofile/LibSndFileFile.h | 46 | ||||
-rw-r--r-- | orkaudio/audiofile/Makefile.am | 6 | ||||
-rw-r--r-- | orkaudio/audiofile/MediaChunkFile.cpp | 154 | ||||
-rw-r--r-- | orkaudio/audiofile/MediaChunkFile.h | 40 | ||||
-rw-r--r-- | orkaudio/audiofile/PcmFile.cpp | 117 | ||||
-rw-r--r-- | orkaudio/audiofile/PcmFile.h | 41 | ||||
-rw-r--r-- | orkaudio/messages/CaptureMsg.cpp | 84 | ||||
-rw-r--r-- | orkaudio/messages/CaptureMsg.h | 51 | ||||
-rw-r--r-- | orkaudio/messages/DeleteTapeMsg.cpp | 60 | ||||
-rw-r--r-- | orkaudio/messages/DeleteTapeMsg.h | 33 | ||||
-rw-r--r-- | orkaudio/messages/PingMsg.cpp | 60 | ||||
-rw-r--r-- | orkaudio/messages/PingMsg.h | 46 | ||||
-rw-r--r-- | orkaudio/messages/TapeMsg.cpp | 88 | ||||
-rw-r--r-- | orkaudio/messages/TapeMsg.h | 85 | ||||
-rw-r--r-- | orkaudio/messages/TestMsg.cpp | 53 | ||||
-rw-r--r-- | orkaudio/messages/TestMsg.h | 55 |
20 files changed, 0 insertions, 1388 deletions
diff --git a/orkaudio/ThreadSafeQueue.h b/orkaudio/ThreadSafeQueue.h deleted file mode 100644 index 4fd0cda..0000000 --- a/orkaudio/ThreadSafeQueue.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 = 10000) - { - m_size = size; - m_semaphore.acquire(); // reset count to zero - }; - - bool push(T &); - T pop(); - int numElements(); - void setSize(int size); - -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() -{ -// #### Fixme: when timeout specified under Linux CentOS 4.2, acquire returns immediately instead of waiting for the timeout -> causes CPU to spike at 100% -#ifdef WIN32 - ACE_Time_Value timeout(time(NULL)+2); - m_semaphore.acquire(&timeout); -#else - m_semaphore.acquire(); -#endif - MutexSentinel mutexSentinel(m_mutex); - - T element; - - if(m_queue.size() > 0) - { - element = m_queue.front(); - m_queue.pop(); - } - return element; -} - -template <class T> int ThreadSafeQueue<T>::numElements() -{ - return m_queue.size(); -} - -template <class T> void ThreadSafeQueue<T>::setSize(int size) -{ - m_size = size; -} - -#endif // __THREADSAFEQUEUE_H__ - diff --git a/orkaudio/audiofile/AudioFile.cpp b/orkaudio/audiofile/AudioFile.cpp deleted file mode 100644 index 848f55b..0000000 --- a/orkaudio/audiofile/AudioFile.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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); -} - -int AudioFile::GetSampleRate() -{ - return m_sampleRate; -}
\ No newline at end of file diff --git a/orkaudio/audiofile/AudioFile.h b/orkaudio/audiofile/AudioFile.h deleted file mode 100644 index bc9cbcf..0000000 --- a/orkaudio/audiofile/AudioFile.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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; - virtual int GetSampleRate(); - - static void RecursiveMkdir(CStdString& path); -protected: - CStdString m_filename; - fileOpenModeEnum m_mode; - int m_numChunksWritten; - int m_sampleRate; -}; - -typedef boost::shared_ptr<AudioFile> AudioFileRef; - -#endif - diff --git a/orkaudio/audiofile/LibSndFileFile.cpp b/orkaudio/audiofile/LibSndFileFile.cpp deleted file mode 100644 index 0589466..0000000 --- a/orkaudio/audiofile/LibSndFileFile.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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; - m_sampleRate = 0; -} - -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; - if(m_sampleRate == 0) - { - m_sampleRate = sampleRate; - 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(chunkRef.get() == NULL) - { - return; - } - if(chunkRef->GetDetails()->m_numBytes == 0) - { - return; - } - - if (m_pFile) - { - if( chunkRef->GetEncoding() == AlawAudio || chunkRef->GetEncoding() == 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->GetEncoding() == 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); - AudioChunkDetails details; - details.m_encoding = PcmAudio; - chunk->SetBuffer(temp, sizeof(short)*numRead, details); - } - 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 deleted file mode 100644 index e0516a8..0000000 --- a/orkaudio/audiofile/LibSndFileFile.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 deleted file mode 100644 index d737e11..0000000 --- a/orkaudio/audiofile/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -METASOURCES = AUTO -noinst_LTLIBRARIES = libaudiofile.la -libaudiofile_la_SOURCES = MediaChunkFile.cpp AudioFile.cpp LibSndFileFile.cpp PcmFile.cpp -AM_CPPFLAGS = -D_REENTRANT -libaudiofile_la_LIBADD = -INCLUDES = -I@top_srcdir@ -I../../orkbasecxx diff --git a/orkaudio/audiofile/MediaChunkFile.cpp b/orkaudio/audiofile/MediaChunkFile.cpp deleted file mode 100644 index 47b2e8b..0000000 --- a/orkaudio/audiofile/MediaChunkFile.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 "MediaChunkFile.h" - -#define MAX_CHUNK_SIZE 100000 - - -MediaChunkFile::MediaChunkFile() -{ - m_stream = NULL; - m_mode = READ; - m_numChunksWritten = 0; - m_sampleRate = 0; -} - -MediaChunkFile::~MediaChunkFile() -{ - Close(); -} - - -void MediaChunkFile::Close() -{ - if(m_stream) - { - ACE_OS::fclose(m_stream); - m_stream = NULL; - } -} - -void MediaChunkFile::WriteChunk(AudioChunkRef chunkRef) -{ - if(chunkRef.get() == NULL) - { - return; - } - if(chunkRef->GetDetails()->m_numBytes == 0) - { - return; - } - - unsigned int numWritten = 0; - bool writeError = false; - if (m_stream) - { - int tmp = sizeof(AudioChunkDetails); - numWritten = ACE_OS::fwrite(chunkRef->GetDetails(), sizeof(AudioChunkDetails), 1, m_stream); - if(numWritten != 1) - { - writeError = true; - } - numWritten = ACE_OS::fwrite(chunkRef->m_pBuffer, sizeof(char), chunkRef->GetNumBytes(), m_stream); - if(numWritten != chunkRef->GetNumBytes()) - { - writeError = true; - } - } - else - { - throw(CStdString("Write attempt on unopened file:")+ m_filename); - } - - if (writeError) - { - throw(CStdString("Could not write to file:")+ m_filename); - } -} - -int MediaChunkFile::ReadChunkMono(AudioChunkRef& chunkRef) -{ - unsigned int numRead = 0; - bool readError = false; - - if (m_stream) - { - chunkRef.reset(new AudioChunk()); - short temp[MAX_CHUNK_SIZE]; - numRead = ACE_OS::fread(temp, sizeof(AudioChunkDetails), 1, m_stream); - if(numRead == 1) - { - AudioChunkDetails details; - memcpy(&details, temp, sizeof(AudioChunkDetails)); - - if(details.m_marker != MEDIA_CHUNK_MARKER) - { - throw(CStdString("Invalid marker in file:")+ m_filename); - } - if(details.m_numBytes >= MAX_CHUNK_SIZE) - { - throw(CStdString("Chunk too big in file:")+ m_filename); - } - else - { - numRead = ACE_OS::fread(temp, sizeof(char), details.m_numBytes, m_stream); - if(numRead != details.m_numBytes) - { - throw(CStdString("Incomplete chunk in file:")+ m_filename); - } - chunkRef->SetBuffer(temp, details.m_numBytes, details); - } - } - } - else - { - throw(CStdString("Read attempt on unopened file:")+ m_filename); - } - - return numRead; -} - - -void MediaChunkFile::Open(CStdString& filename, fileOpenModeEnum mode, bool stereo, int sampleRate) -{ - if(m_sampleRate == 0) - { - m_sampleRate = sampleRate; - } - - if(!m_filename.Equals(filename)) - { - m_filename = filename + GetExtension(); - } - 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 MediaChunkFile::GetExtension() -{ - return ".mcf"; -} diff --git a/orkaudio/audiofile/MediaChunkFile.h b/orkaudio/audiofile/MediaChunkFile.h deleted file mode 100644 index b8e69ed..0000000 --- a/orkaudio/audiofile/MediaChunkFile.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 __MEDIACHUNKFILE_H__ -#define __MEDIACHUNKFILE_H__ - -#include "audiofile/AudioFile.h" - - -/** File class for saving audio chunks as-is */ -class MediaChunkFile : public AudioFile -{ -public: - MediaChunkFile(); - ~MediaChunkFile(); - - 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/audiofile/PcmFile.cpp b/orkaudio/audiofile/PcmFile.cpp deleted file mode 100644 index 9d1a6d0..0000000 --- a/orkaudio/audiofile/PcmFile.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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; - m_sampleRate = 0; -} - -PcmFile::~PcmFile() -{ - Close(); -} - - -void PcmFile::Close() -{ - if(m_stream) - { - ACE_OS::fclose(m_stream); - m_stream = NULL; - } -} - -void PcmFile::WriteChunk(AudioChunkRef chunkRef) -{ - if(chunkRef.get() == NULL) - { - return; - } - if(chunkRef->GetDetails()->m_numBytes == 0) - { - return; - } - - 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); - AudioChunkDetails details; - details.m_encoding = PcmAudio; - chunkRef->SetBuffer(temp, sizeof(short)*numRead, details); - } - 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_sampleRate == 0) - { - m_sampleRate = 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 deleted file mode 100644 index 91c1325..0000000 --- a/orkaudio/audiofile/PcmFile.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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/messages/CaptureMsg.cpp b/orkaudio/messages/CaptureMsg.cpp deleted file mode 100644 index f013e1f..0000000 --- a/orkaudio/messages/CaptureMsg.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 deleted file mode 100644 index 782f70f..0000000 --- a/orkaudio/messages/CaptureMsg.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9dc8dae..0000000 --- a/orkaudio/messages/DeleteTapeMsg.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 deleted file mode 100644 index 33fb9ae..0000000 --- a/orkaudio/messages/DeleteTapeMsg.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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/PingMsg.cpp b/orkaudio/messages/PingMsg.cpp deleted file mode 100644 index 1f90bbe..0000000 --- a/orkaudio/messages/PingMsg.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 deleted file mode 100644 index 21b659a..0000000 --- a/orkaudio/messages/PingMsg.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 deleted file mode 100644 index b624d08..0000000 --- a/orkaudio/messages/TapeMsg.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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) -{ - DefineMessage(s); - - CStdString tapeMessageName(TAPE_MESSAGE_NAME); - s->StringValue(OBJECT_TYPE_TAG, tapeMessageName, true); - s->StringValue(REC_ID_PARAM, m_recId, 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); - - s->StringValue(LOCAL_IP_PARAM, m_localIp); - s->StringValue(REMOTE_IP_PARAM, m_remoteIp); - //s->StringValue(LOCAL_MAC_PARAM, m_localMac); - //s->StringValue(REMOTE_MAC_PARAM, m_remoteMac); -} - -void TapeMsg::Validate() -{ -} - -CStdString TapeMsg::GetClassName() -{ - return CStdString(TAPE_MESSAGE_NAME); -} - -ObjectRef TapeMsg::NewInstance() -{ - return ObjectRef(new TapeMsg); -} - - -//========================================================== -TapeResponse::TapeResponse() -{ - m_deleteTape = false; -} - - -void TapeResponse::Define(Serializer* s) -{ - SimpleResponseMsg::Define(s); - s->BoolValue("deletetape", m_deleteTape); -} - -CStdString TapeResponse::GetClassName() -{ - return CStdString("taperesponse"); -} - -ObjectRef TapeResponse::NewInstance() -{ - return ObjectRef(new TapeResponse); -} - diff --git a/orkaudio/messages/TapeMsg.h b/orkaudio/messages/TapeMsg.h deleted file mode 100644 index 3165bb4..0000000 --- a/orkaudio/messages/TapeMsg.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 "messages/AsyncMessage.h" -#include "AudioTape.h" - -#define TAPE_MESSAGE_NAME "tape" -#define REC_ID_PARAM "recid" -#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" -#define LOCAL_IP_PARAM "localip" -#define REMOTE_IP_PARAM "remoteip" -#define LOCAL_MAC_PARAM "localmac" -#define REMOTE_MAC_PARAM "remotemac" - -class TapeMsg : public SyncMessage -{ -public: - TapeMsg(); - - void Define(Serializer* s); - void Validate(); - - CStdString GetClassName(); - ObjectRef NewInstance(); - inline ObjectRef Process() {return ObjectRef();}; - - CStdString m_recId; - 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; - CStdString m_localIp; - CStdString m_remoteIp; - CStdString m_localMac; - CStdString m_remoteMac; -}; - -typedef boost::shared_ptr<TapeMsg> TapeMsgRef; - -/** A TapeResponse is a response to TapeMsg -*/ -class TapeResponse : public SimpleResponseMsg -{ -public: - TapeResponse(); - void Define(Serializer* s); - inline void Validate() {}; - - CStdString GetClassName(); - ObjectRef NewInstance(); - inline ObjectRef Process() {return ObjectRef();}; - - bool m_deleteTape; -}; - -#endif - diff --git a/orkaudio/messages/TestMsg.cpp b/orkaudio/messages/TestMsg.cpp deleted file mode 100644 index 68e2f3e..0000000 --- a/orkaudio/messages/TestMsg.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 deleted file mode 100644 index 13aed71..0000000 --- a/orkaudio/messages/TestMsg.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 - |