summaryrefslogtreecommitdiff
path: root/orkbasecxx
diff options
context:
space:
mode:
authorGerald Begumisa <ben_g@users.sourceforge.net>2007-11-26 12:59:51 +0000
committerGerald Begumisa <ben_g@users.sourceforge.net>2007-11-26 12:59:51 +0000
commitbc9e02f50ffb374715994d4320faace5d8875576 (patch)
tree93cc5480e159aadfb044534cecabbbeb56d8b8b8 /orkbasecxx
parentf4b9b1d0e2e57532f6d838d2a5e88f8852fb5888 (diff)
Added configuration parameter, CaptureFileSizeLimitKb, which limits the size of the MCF file to the value specified in kilo bytes
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@509 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx')
-rw-r--r--orkbasecxx/AudioTape.cpp19
-rw-r--r--orkbasecxx/AudioTape.h3
-rw-r--r--orkbasecxx/Config.cpp2
-rw-r--r--orkbasecxx/Config.h3
4 files changed, 26 insertions, 1 deletions
diff --git a/orkbasecxx/AudioTape.cpp b/orkbasecxx/AudioTape.cpp
index 96d70d7..e68df00 100644
--- a/orkbasecxx/AudioTape.cpp
+++ b/orkbasecxx/AudioTape.cpp
@@ -81,6 +81,8 @@ AudioTape::AudioTape(CStdString &portId)
m_shouldStop = false;
m_readyForBatchProcessing = false;
m_trackingId = portId; // to make sure this has a value before we get the capture tracking Id.
+ m_bytesWritten = 0;
+ m_lastLogWarning = 0;
GenerateCaptureFilePathAndIdentifier();
}
@@ -177,7 +179,22 @@ void AudioTape::Write()
}
if (m_state == StateActive)
{
- m_audioFileRef->WriteChunk(chunkRef);
+ if((m_bytesWritten / 1024) > CONFIG.m_captureFileSizeLimitKb)
+ {
+ if((time(NULL) - m_lastLogWarning) > 3600)
+ {
+ CStdString logMsg;
+
+ logMsg.Format("[%s] capture file %s.mcf is over size limit (%u KBytes) - ignoring new data", m_trackingId, GetIdentifier(), CONFIG.m_captureFileSizeLimitKb);
+ LOG4CXX_INFO(LOG.portLog, logMsg);
+ m_lastLogWarning = time(NULL);
+ }
+ }
+ else
+ {
+ m_audioFileRef->WriteChunk(chunkRef);
+ m_bytesWritten += chunkRef->GetNumBytes();
+ }
if (CONFIG.m_logRms)
{
diff --git a/orkbasecxx/AudioTape.h b/orkbasecxx/AudioTape.h
index 91246d8..1464e5e 100644
--- a/orkbasecxx/AudioTape.h
+++ b/orkbasecxx/AudioTape.h
@@ -133,6 +133,9 @@ private:
CStdString m_orkUid;
std::map<CStdString, CStdString> m_tags;
+
+ int m_bytesWritten;
+ time_t m_lastLogWarning;
};
typedef boost::shared_ptr<AudioTape> AudioTapeRef;
diff --git a/orkbasecxx/Config.cpp b/orkbasecxx/Config.cpp
index d0bc296..c9f62dd 100644
--- a/orkbasecxx/Config.cpp
+++ b/orkbasecxx/Config.cpp
@@ -66,6 +66,7 @@ Config::Config()
m_httpServerPort = HTTP_SERVER_PORT_DEFAULT;
m_lookBackRecording = LOOKBACK_RECORDING_DEFAULT;
m_allowAutomaticRecording = ALLOW_AUTOMATIC_RECORDING_DEFAULT;
+ m_captureFileSizeLimitKb = CAPTURE_FILE_SIZE_LIMIT_KB_DEFAULT;
}
void Config::Define(Serializer* s)
@@ -135,6 +136,7 @@ void Config::Define(Serializer* s)
s->IntValue(HTTP_SERVER_PORT_PARAM, m_httpServerPort);
s->BoolValue(LOOKBACK_RECORDING_PARAM, m_lookBackRecording);
s->BoolValue(ALLOW_AUTOMATIC_RECORDING_PARAM, m_allowAutomaticRecording); // only valid in non-lookback mode
+ s->IntValue(CAPTURE_FILE_SIZE_LIMIT_KB_PARAM, m_captureFileSizeLimitKb);
}
void Config::Validate()
diff --git a/orkbasecxx/Config.h b/orkbasecxx/Config.h
index 2439d45..5baf30d 100644
--- a/orkbasecxx/Config.h
+++ b/orkbasecxx/Config.h
@@ -100,6 +100,8 @@
#define LOOKBACK_RECORDING_DEFAULT true
#define ALLOW_AUTOMATIC_RECORDING_PARAM "AllowAutomaticRecording"
#define ALLOW_AUTOMATIC_RECORDING_DEFAULT true
+#define CAPTURE_FILE_SIZE_LIMIT_KB_PARAM "CaptureFileSizeLimitKb"
+#define CAPTURE_FILE_SIZE_LIMIT_KB_DEFAULT 300000
class DLL_IMPORT_EXPORT_ORKBASE Config : public Object
{
@@ -157,6 +159,7 @@ public:
int m_httpServerPort;
bool m_lookBackRecording;
bool m_allowAutomaticRecording;
+ int m_captureFileSizeLimitKb;
private:
log4cxx::LoggerPtr m_log;