summaryrefslogtreecommitdiff
path: root/orkbasecxx/CapturePort.h
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2007-07-30 14:32:19 +0000
committerHenri Herscher <henri@oreka.org>2007-07-30 14:32:19 +0000
commit72fda6ebe7d6245b57178441c6355eb9d2402747 (patch)
treed5683a93b1e4d0efee26995caeeccd55faae0d8c /orkbasecxx/CapturePort.h
parent483b0c94e1754d01c934dc3421527fc6eefa3ebd (diff)
Added non-lookback recording mode.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@458 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/CapturePort.h')
-rw-r--r--orkbasecxx/CapturePort.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/orkbasecxx/CapturePort.h b/orkbasecxx/CapturePort.h
new file mode 100644
index 0000000..aa80e29
--- /dev/null
+++ b/orkbasecxx/CapturePort.h
@@ -0,0 +1,78 @@
+/*
+ * 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 <list>
+#include "boost/shared_ptr.hpp"
+#include "ace/Thread_Mutex.h"
+#include "ace/Singleton.h"
+
+#include "StdString.h"
+
+#include "AudioCapture.h"
+#include "AudioTape.h"
+#include "Filter.h"
+
+
+/** Base class for all types of capture ports. */
+class DLL_IMPORT_EXPORT_ORKBASE CapturePort
+{
+public:
+ CapturePort(CStdString& Id);
+ CStdString ToString();
+ CStdString GetId();
+
+ void AddAudioChunk(AudioChunkRef chunkRef);
+ void AddCaptureEvent(CaptureEventRef eventRef);
+ bool IsExpired(time_t now);
+private:
+ void LoadFilters();
+ void FilterAudioChunk(AudioChunkRef& chunkRef);
+ void FilterCaptureEvent(CaptureEventRef& eventRef);
+
+ CStdString m_id;
+ AudioTapeRef m_audioTapeRef;
+ ACE_Thread_Mutex m_mutex;
+ bool m_capturing;
+ double m_vadBelowThresholdSec;
+ bool m_vadUp;
+ time_t m_lastUpdated;
+ std::list<FilterRef> m_filters;
+};
+
+typedef boost::shared_ptr<CapturePort> CapturePortRef;
+
+/** This singleton holds all dynamically created capture ports and allows convenient access. */
+class DLL_IMPORT_EXPORT_ORKBASE CapturePorts
+{
+public:
+ CapturePorts();
+ 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);
+ void Hoover();
+private:
+ std::map<CStdString, CapturePortRef> m_ports;
+ ACE_Thread_Mutex m_mutex;
+ time_t m_lastHooveringTime;
+};
+
+typedef ACE_Singleton<CapturePorts, ACE_Thread_Mutex> CapturePortsSingleton;
+
+#endif
+