diff options
-rw-r--r-- | orkaudio/BatchProcessing.cpp | 7 | ||||
-rw-r--r-- | orkaudio/Daemon.cpp | 10 | ||||
-rw-r--r-- | orkaudio/Daemon.h | 4 | ||||
-rw-r--r-- | orkaudio/OrkAudio.cpp | 60 | ||||
-rw-r--r-- | orkbasecxx/AudioTape.cpp | 13 | ||||
-rw-r--r-- | orkbasecxx/AudioTape.h | 3 | ||||
-rw-r--r-- | orkbasecxx/Utils.cpp | 15 | ||||
-rw-r--r-- | orkbasecxx/Utils.h | 1 | ||||
-rw-r--r-- | orkbasecxx/audiofile/AudioFile.cpp | 6 | ||||
-rw-r--r-- | orkbasecxx/audiofile/AudioFile.h | 1 |
10 files changed, 115 insertions, 5 deletions
diff --git a/orkaudio/BatchProcessing.cpp b/orkaudio/BatchProcessing.cpp index 5584b9d..efad036 100644 --- a/orkaudio/BatchProcessing.cpp +++ b/orkaudio/BatchProcessing.cpp @@ -106,17 +106,20 @@ void BatchProcessing::ThreadHandler(void *args) { stop = true; } + if(DaemonSingleton::instance()->GetShortLived()) + { + DaemonSingleton::instance()->Stop(); + } } else { fileRef = audioTapeRef->GetAudioFileRef(); - CStdString filename = audioTapeRef->GetFilename(); // Let's work on the tape we have pulled //CStdString threadIdString = IntToString(threadId); LOG4CXX_INFO(LOG.batchProcessingLog, CStdString("Th") + threadIdString + " processing: " + audioTapeRef->GetIdentifier()); - fileRef->MoveOrig(); + //fileRef->MoveOrig(); // #### could do this only when original and output file have the same extension. Irrelevant for now as everything is captured as mcf file fileRef->Open(AudioFile::READ); AudioChunkRef chunkRef; diff --git a/orkaudio/Daemon.cpp b/orkaudio/Daemon.cpp index a4f9314..91ac27e 100644 --- a/orkaudio/Daemon.cpp +++ b/orkaudio/Daemon.cpp @@ -59,6 +59,7 @@ void Daemon::Initialize(CStdString serviceName, DaemonHandler runHandler, Daemon m_serviceName = serviceName; m_stopping = false; + m_shortLived = false; } void Daemon::Start() @@ -232,3 +233,12 @@ bool Daemon::IsStopping() return m_stopping; } +void Daemon::SetShortLived() +{ + m_shortLived = true; +} + +bool Daemon::GetShortLived() +{ + return m_shortLived; +} diff --git a/orkaudio/Daemon.h b/orkaudio/Daemon.h index 352b311..e331c83 100644 --- a/orkaudio/Daemon.h +++ b/orkaudio/Daemon.h @@ -30,6 +30,9 @@ public: void Install(); void Uninstall(); bool IsStopping(); + + void SetShortLived(); + bool GetShortLived(); private: #ifdef WIN32 static void WINAPI Run( DWORD /*argc*/, TCHAR* /*argv*/[] ); @@ -42,6 +45,7 @@ private: CStdString m_serviceName; bool m_stopping; + bool m_shortLived; }; typedef ACE_Singleton<Daemon, ACE_Thread_Mutex> DaemonSingleton; diff --git a/orkaudio/OrkAudio.cpp b/orkaudio/OrkAudio.cpp index 5a161b7..60a3a2b 100644 --- a/orkaudio/OrkAudio.cpp +++ b/orkaudio/OrkAudio.cpp @@ -112,6 +112,49 @@ void LoadPlugins(std::list<ACE_DLL>& pluginDlls) } } +void Transcode(CStdString &file) +{ + OrkLogManager::Instance()->Initialize(); + + ObjectFactorySingleton::instance()->Initialize(); + + ConfigManager::Instance()->Initialize(); + + std::list<ACE_DLL> pluginDlls; + LoadPlugins(pluginDlls); + + // Register in-built filters + FilterRef filter(new AlawToPcmFilter()); + FilterRegistry::instance()->RegisterFilter(filter); + filter.reset(new UlawToPcmFilter()); + FilterRegistry::instance()->RegisterFilter(filter); + + // Register in-built tape processors and build the processing chain + BatchProcessing::Initialize(); + + if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(BatchProcessing::ThreadHandler))) + { + LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create batch processing thread")); + } + + + + // Transmit the tape to the BatchProcessing + TapeProcessorRef bp = TapeProcessorRegistry::instance()->GetNewTapeProcessor(CStdString("BatchProcessing")); + AudioTapeRef tape(new AudioTape(CStdString("SinglePort"), file)); + bp->AddAudioTape(tape); + + // Make sure it stops after processing + tape.reset(); + bp->AddAudioTape(tape); + + // Wait for completion + while(!DaemonSingleton::instance()->IsStopping()) + { + ACE_OS::sleep(1); + } +} + void MainThread() { OrkLogManager::Instance()->Initialize(); @@ -231,6 +274,19 @@ int main(int argc, char* argv[]) { MainThread(); } + else if (argument.CompareNoCase("transcode") == 0) + { + if(argc == 3) + { + DaemonSingleton::instance()->SetShortLived(); + CStdString file = argv[2]; + Transcode(file); + } + else + { + printf("Please specify file to transcode\n\n"); + } + } else if (argument.CompareNoCase("install") == 0) { DaemonSingleton::instance()->Install(); @@ -242,9 +298,9 @@ int main(int argc, char* argv[]) else { #ifdef WIN32 - printf("Argument incorrect. Possibilies are:\n\tinstall:\t\tinstall NT service\n\tuninstall:\t\tuninstall NT service\n\n"); + printf("Argument incorrect. Possibilies are:\ninstall: install NT service\nuninstall: uninstall NT service\ntranscode <file>: convert .mcf file to storage format specified in config.xml\n\n"); #else - printf("Argument incorrect. Possibilies are:\n\tdebug:\trun attached to tty\n\n"); + printf("Argument incorrect. Possibilies are:\ndebug: run attached to tty\ntranscode <file>: convert .mcf file to storage format specified in config.xml\n\n"); #endif } } diff --git a/orkbasecxx/AudioTape.cpp b/orkbasecxx/AudioTape.cpp index 9697bc6..9bb7239 100644 --- a/orkbasecxx/AudioTape.cpp +++ b/orkbasecxx/AudioTape.cpp @@ -83,6 +83,19 @@ AudioTape::AudioTape(CStdString &portId) GenerateFilePathAndIdentifier(); } +AudioTape::AudioTape(CStdString &portId, CStdString& file) +{ + m_portId = portId; + + // Extract Path and Identifier + m_filePath = FilePath(file); + CStdString basename = FileBaseName(file); + m_fileIdentifier = FileStripExtension(basename); + + // Create the audiofile + m_audioFileRef.reset(new MediaChunkFile()); + m_audioFileRef->SetFilename(file); +} void AudioTape::AddAudioChunk(AudioChunkRef chunkRef) { diff --git a/orkbasecxx/AudioTape.h b/orkbasecxx/AudioTape.h index b179e46..2e212a2 100644 --- a/orkbasecxx/AudioTape.h +++ b/orkbasecxx/AudioTape.h @@ -60,7 +60,8 @@ public: StateInvalid = 5 } StateEnum; - AudioTape(CStdString &portId); + AudioTape(CStdString& portId); + AudioTape(CStdString& portId, CStdString& file); void AddAudioChunk(AudioChunkRef chunkRef); void Write(); diff --git a/orkbasecxx/Utils.cpp b/orkbasecxx/Utils.cpp index c1ba665..cec44eb 100644 --- a/orkbasecxx/Utils.cpp +++ b/orkbasecxx/Utils.cpp @@ -23,6 +23,21 @@ CStdString FileBaseName(CStdString& path) return result; } +CStdString FilePath(CStdString& path) +{ + CStdString result; + int lastSeparatorPosition = path.ReverseFind('/'); + if(lastSeparatorPosition == -1) + { + lastSeparatorPosition = path.ReverseFind('\\'); + } + if(lastSeparatorPosition != -1 && path.GetLength()>3) + { + result = path.Left(lastSeparatorPosition + 1); + } + return result; +} + CStdString FileStripExtension(CStdString& filename) { CStdString result; diff --git a/orkbasecxx/Utils.h b/orkbasecxx/Utils.h index 3b7d5c6..31abf5d 100644 --- a/orkbasecxx/Utils.h +++ b/orkbasecxx/Utils.h @@ -67,6 +67,7 @@ inline double StringToDouble(CStdString& value) // file related stuff CStdString DLL_IMPORT_EXPORT_ORKBASE FileBaseName(CStdString& path); +CStdString DLL_IMPORT_EXPORT_ORKBASE FilePath(CStdString& path); CStdString DLL_IMPORT_EXPORT_ORKBASE FileStripExtension(CStdString& filename); bool DLL_IMPORT_EXPORT_ORKBASE FileCanOpen(CStdString& path); diff --git a/orkbasecxx/audiofile/AudioFile.cpp b/orkbasecxx/audiofile/AudioFile.cpp index 848f55b..9e2f8b7 100644 --- a/orkbasecxx/audiofile/AudioFile.cpp +++ b/orkbasecxx/audiofile/AudioFile.cpp @@ -57,6 +57,12 @@ void AudioFile::Delete() ACE_OS::unlink((PCSTR)m_filename); } +void AudioFile::SetFilename(CStdString& filename) +{ + m_filename = filename; +} + + int AudioFile::GetSampleRate() { return m_sampleRate; diff --git a/orkbasecxx/audiofile/AudioFile.h b/orkbasecxx/audiofile/AudioFile.h index 3d3b566..ef43373 100644 --- a/orkbasecxx/audiofile/AudioFile.h +++ b/orkbasecxx/audiofile/AudioFile.h @@ -53,6 +53,7 @@ public: /** Move the file to a new name including ".orig" suffix */ void MoveOrig(); + void SetFilename(CStdString&); void Delete(); virtual CStdString GetExtension() = 0; virtual int GetSampleRate(); |