summaryrefslogtreecommitdiff
path: root/orkbasecxx/TapeProcessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'orkbasecxx/TapeProcessor.cpp')
-rw-r--r--orkbasecxx/TapeProcessor.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/orkbasecxx/TapeProcessor.cpp b/orkbasecxx/TapeProcessor.cpp
new file mode 100644
index 0000000..a3d055b
--- /dev/null
+++ b/orkbasecxx/TapeProcessor.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 )
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include <log4cxx/logger.h>
+#include "TapeProcessor.h"
+#include "ConfigManager.h"
+
+using namespace log4cxx;
+
+TapeProcessor::TapeProcessor()
+{
+ ;
+}
+
+void TapeProcessor::SetNextProcessor(TapeProcessorRef& nextProcessor)
+{
+ m_nextProcessor = nextProcessor;
+}
+
+void TapeProcessor::RunNextProcessor(AudioTapeRef& tape)
+{
+ if(m_nextProcessor.get())
+ {
+ m_nextProcessor->AddAudioTape(tape);
+ }
+}
+
+
+//=====================================================
+LoggerPtr s_log;
+
+TapeProcessorRegistry::TapeProcessorRegistry()
+{
+ s_log = Logger::getLogger("tape.taperegistry");
+}
+
+
+void TapeProcessorRegistry::RegisterTapeProcessor(TapeProcessorRef& tapeProcessor)
+{
+ m_TapeProcessors.push_back(tapeProcessor);
+ LOG4CXX_INFO(s_log, CStdString("Registered processor: ") + tapeProcessor->GetName());
+}
+
+
+TapeProcessorRef TapeProcessorRegistry::GetNewTapeProcessor(CStdString& TapeProcessorName)
+{
+ for(std::list<TapeProcessorRef>::iterator it = m_TapeProcessors.begin(); it!=m_TapeProcessors.end(); it++)
+ {
+ TapeProcessorRef TapeProcessor = *it;
+
+ if( TapeProcessor->GetName().CompareNoCase(TapeProcessorName) == 0 )
+ {
+ return TapeProcessor->Instanciate();
+ }
+ }
+ return TapeProcessorRef(); // No TapeProcessor found
+}
+
+TapeProcessorRegistry* TapeProcessorRegistry::m_singleton = 0;
+
+TapeProcessorRegistry* TapeProcessorRegistry::instance()
+{
+ if(m_singleton == NULL)
+ {
+ m_singleton = new TapeProcessorRegistry();
+ }
+ return m_singleton;
+}
+
+void TapeProcessorRegistry::CreateProcessingChain()
+{
+ TapeProcessorRef previousProcessor;
+
+ //ConfigManager* cm = ConfigManagerSingleton::instance();
+
+ for(std::list<CStdString>::iterator it = CONFIG.m_tapeProcessors.begin(); it != CONFIG.m_tapeProcessors.end(); it++)
+ {
+ CStdString tapeProcessorName = *it;
+ TapeProcessorRef processor = GetNewTapeProcessor(tapeProcessorName);
+ if(processor.get())
+ {
+ if(m_firstTapeProcessor.get() == NULL)
+ {
+ m_firstTapeProcessor = processor;
+ }
+ if(previousProcessor.get())
+ {
+ previousProcessor->SetNextProcessor(processor);
+ }
+ previousProcessor = processor;
+ LOG4CXX_DEBUG(s_log, CStdString("Adding processor to chain:") + tapeProcessorName);
+ }
+ else
+ {
+ LOG4CXX_ERROR(s_log, CStdString("Processor:") + tapeProcessorName + " does not exist, please check <TapeProcessors> in config.xml");
+ }
+ }
+}
+
+void TapeProcessorRegistry::RunProcessingChain(AudioTapeRef& tape)
+{
+ if(m_firstTapeProcessor.get())
+ {
+ m_firstTapeProcessor->AddAudioTape(tape);
+ }
+}