summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2007-01-17 15:46:58 +0000
committerHenri Herscher <henri@oreka.org>2007-01-17 15:46:58 +0000
commit5c47f8ba4dbf7ce5abe26f1370b1b7be6b21fc85 (patch)
tree31d7ee354ee0b97b53e7c0daaa1c3ff9dcc10c7b
parentd6729c5be22c879150bf358f7094097c5080fa55 (diff)
Initial version of a transcoded tape file naming scheme. This makes it possible e.g. to name transcoded files after the SIP or Skinny native Call ID.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@390 09dcff7a-b715-0410-9601-b79a96267cd0
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.cpp6
-rw-r--r--orkbasecxx/AudioCapture.cpp6
-rw-r--r--orkbasecxx/AudioCapture.h4
-rw-r--r--orkbasecxx/AudioTape.cpp82
-rw-r--r--orkbasecxx/AudioTape.h5
-rw-r--r--orkbasecxx/Config.cpp1
-rw-r--r--orkbasecxx/Config.h2
7 files changed, 100 insertions, 6 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
index d65bc75..f6de084 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
@@ -396,6 +396,12 @@ void RtpSession::ReportMetadata()
event->m_value = m_orkUid;
g_captureEventCallBack(event, m_capturePort);
+ // Report native Call ID
+ event.reset(new CaptureEvent());
+ event->m_type = CaptureEvent::EtCallId;
+ event->m_value = m_callId;
+ g_captureEventCallBack(event, m_capturePort);
+
// Report end of metadata
event.reset(new CaptureEvent());
event->m_type = CaptureEvent::EtEndMetadata;
diff --git a/orkbasecxx/AudioCapture.cpp b/orkbasecxx/AudioCapture.cpp
index 4ec930b..20aa0d7 100644
--- a/orkbasecxx/AudioCapture.cpp
+++ b/orkbasecxx/AudioCapture.cpp
@@ -247,6 +247,8 @@ CStdString CaptureEvent::EventTypeToString(int eventTypeEnum)
return ET_READY;
case EtUpdate:
return ET_UPDATE;
+ case EtCallId:
+ return ET_CALLID;
}
return ET_INVALID;
}
@@ -314,6 +316,10 @@ int CaptureEvent::EventTypeToEnum(CStdString& eventTypeString)
{
eventTypeEnum = EtUpdate;
}
+ else if (eventTypeString.CompareNoCase(ET_CALLID) == 0)
+ {
+ eventTypeEnum = EtCallId;
+ }
return eventTypeEnum;
}
diff --git a/orkbasecxx/AudioCapture.h b/orkbasecxx/AudioCapture.h
index e9c6cee..6b69b9a 100644
--- a/orkbasecxx/AudioCapture.h
+++ b/orkbasecxx/AudioCapture.h
@@ -130,6 +130,7 @@ public:
#define ET_ENDMETADATA "endmetadata"
#define ET_READY "ready"
#define ET_UPDATE "update"
+#define ET_CALLID "callid"
#define ET_INVALID "invalid"
typedef enum
{
@@ -149,7 +150,8 @@ public:
EtEndMetadata = 13,
EtReady = 14,
EtUpdate = 15,
- EtInvalid = 16
+ EtCallId = 16,
+ EtInvalid = 17
} EventTypeEnum;
static CStdString EventTypeToString(int eventTypeEnum);
static int EventTypeToEnum(CStdString&);
diff --git a/orkbasecxx/AudioTape.cpp b/orkbasecxx/AudioTape.cpp
index f26ec94..27818d9 100644
--- a/orkbasecxx/AudioTape.cpp
+++ b/orkbasecxx/AudioTape.cpp
@@ -81,7 +81,7 @@ AudioTape::AudioTape(CStdString &portId)
m_readyForBatchProcessing = false;
m_trackingId = portId; // to make sure this has a value before we get the capture tracking Id.
- GenerateFilePathAndIdentifier();
+ GenerateCaptureFilePathAndIdentifier();
}
AudioTape::AudioTape(CStdString &portId, CStdString& file)
@@ -150,6 +150,12 @@ void AudioTape::Write()
{
// A file format was successfully added to the tape, open it
CStdString file = CONFIG.m_audioOutputPath + "/" + m_filePath + m_fileIdentifier;
+
+ // Prevent identifier collision
+ CStdString path = CONFIG.m_audioOutputPath + "/" + m_filePath;
+ PreventFileIdentifierCollision(path, m_fileIdentifier , m_audioFileRef->GetExtension());
+
+ // Open the capture file
m_audioFileRef->Open(file, AudioFile::WRITE, false, chunkRef->GetSampleRate());
// determine what final extension the file will have after optional compression
@@ -190,6 +196,7 @@ void AudioTape::Write()
if(m_audioFileRef.get())
{
m_audioFileRef->Close();
+ GenerateFinalFilePathAndIdentifier();
m_readyForBatchProcessing = true;
}
}
@@ -215,7 +222,7 @@ void AudioTape::AddCaptureEvent(CaptureEventRef eventRef, bool send)
{
// Media chunk stream not yet started, we can update begin date with the actual capture begin date
m_beginDate = eventRef->m_timestamp;
- GenerateFilePathAndIdentifier();
+ GenerateCaptureFilePathAndIdentifier();
}
break;
case CaptureEvent::EtStop:
@@ -265,6 +272,9 @@ void AudioTape::AddCaptureEvent(CaptureEventRef eventRef, bool send)
m_fileIdentifier = m_orkUid;
}
break;
+ case CaptureEvent::EtCallId:
+ m_nativeCallId = eventRef->m_value;
+ break;
}
// Store the capture event locally
@@ -294,7 +304,7 @@ void AudioTape::GetMessage(MessageRef& msgRef)
TapeMsg* pTapeMsg = (TapeMsg*)msgRef.get();
if(captureEventRef->m_type == CaptureEvent::EtStop || captureEventRef->m_type == CaptureEvent::EtStart || captureEventRef->m_type == CaptureEvent::EtReady || captureEventRef->m_type == CaptureEvent::EtUpdate)
{
- pTapeMsg->m_recId = m_fileIdentifier;
+ pTapeMsg->m_recId = m_orkUid;
pTapeMsg->m_fileName = m_filePath + m_fileIdentifier + m_fileExtension;
pTapeMsg->m_stage = CaptureEvent::EventTypeToString(captureEventRef->m_type);
pTapeMsg->m_capturePort = m_portId;
@@ -313,7 +323,7 @@ void AudioTape::GetMessage(MessageRef& msgRef)
}
}
-void AudioTape::GenerateFilePathAndIdentifier()
+void AudioTape::GenerateCaptureFilePathAndIdentifier()
{
struct tm date = {0};
ACE_OS::localtime_r(&m_beginDate, &date);
@@ -323,6 +333,70 @@ void AudioTape::GenerateFilePathAndIdentifier()
m_fileIdentifier.Format("%.4d%.2d%.2d_%.2d%.2d%.2d_%s", year, month, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec, m_portId);
}
+void AudioTape::GenerateFinalFilePathAndIdentifier()
+{
+ if(CONFIG.m_tapeFileNaming.size() > 0)
+ {
+ // The config file specifies a naming scheme for the recordings, build the final file identifier
+ CStdString fileIdentifier;
+ std::list<CStdString>::iterator it;
+ for(it = CONFIG.m_tapeFileNaming.begin(); it != CONFIG.m_tapeFileNaming.end(); it++)
+ {
+ CStdString element = *it;
+ if(element.CompareNoCase("nativecallid") == 0)
+ {
+ if(m_nativeCallId.size() > 0)
+ {
+ fileIdentifier += m_nativeCallId;
+ }
+ else
+ {
+ fileIdentifier += "nonativecallid";
+ }
+ }
+ else if (element.CompareNoCase("trackingid") == 0)
+ {
+ if(m_trackingId.size() > 0)
+ {
+ fileIdentifier += m_trackingId;
+ }
+ else
+ {
+ fileIdentifier += "notrackingid";
+ }
+ }
+ else
+ {
+ fileIdentifier += element;
+ }
+ }
+ if(fileIdentifier.size() > 0)
+ {
+ m_fileIdentifier = fileIdentifier;
+ }
+ m_filePath = "";
+ CStdString path = CONFIG.m_audioOutputPath + "/";
+ PreventFileIdentifierCollision(path, m_fileIdentifier , m_fileExtension);
+ }
+}
+
+void AudioTape::PreventFileIdentifierCollision(CStdString& path, CStdString& identifier, CStdString& extension)
+{
+ int fileIndex = 0;
+ CStdString identifierWithIndex;
+ CStdString file = path + identifier + extension;
+ while(FileCanOpen(file) == true)
+ {
+ fileIndex++;
+ identifierWithIndex.Format("%s-%d", identifier, fileIndex);
+ file = path + identifierWithIndex + extension;
+ }
+ if(fileIndex)
+ {
+ //identifier = identifierWithIndex;
+ identifier += "-" + m_orkUid;
+ }
+}
CStdString AudioTape::GetIdentifier()
{
diff --git a/orkbasecxx/AudioTape.h b/orkbasecxx/AudioTape.h
index fc93249..341797f 100644
--- a/orkbasecxx/AudioTape.h
+++ b/orkbasecxx/AudioTape.h
@@ -90,11 +90,14 @@ public:
CStdString m_localIp;
CStdString m_remoteIp;
CStdString m_trackingId;
+ CStdString m_nativeCallId;
TapeResponseRef m_tapeResponse;
private:
- void GenerateFilePathAndIdentifier();
+ void GenerateCaptureFilePathAndIdentifier();
+ void GenerateFinalFilePathAndIdentifier();
+ void PreventFileIdentifierCollision(CStdString& path, CStdString& identifier, CStdString& extension);
CStdString m_filePath;
CStdString m_fileIdentifier;
diff --git a/orkbasecxx/Config.cpp b/orkbasecxx/Config.cpp
index 2dfa2f3..e6d2b40 100644
--- a/orkbasecxx/Config.cpp
+++ b/orkbasecxx/Config.cpp
@@ -88,6 +88,7 @@ void Config::Define(Serializer* s)
s->CsvValue(TAPE_PROCESSORS_PARAM, m_tapeProcessors);
s->IntValue(CAPTURE_FILE_BATCH_SIZE_KBYTE_PARAM, m_captureFileBatchSizeKByte);
s->BoolValue(DEBUG_PARAM, m_debug);
+ s->CsvValue(TAPE_FILE_NAMING_PARAM, m_tapeFileNaming);
}
void Config::Validate()
diff --git a/orkbasecxx/Config.h b/orkbasecxx/Config.h
index 30b74c5..d3eb61a 100644
--- a/orkbasecxx/Config.h
+++ b/orkbasecxx/Config.h
@@ -75,6 +75,7 @@
#define CAPTURE_FILE_BATCH_SIZE_KBYTE_DEFAULT 4
#define DEBUG_PARAM "Debug"
#define DEBUG_DEFAULT false
+#define TAPE_FILE_NAMING_PARAM "TapeFileNaming"
class DLL_IMPORT_EXPORT_ORKBASE Config : public Object
{
@@ -117,6 +118,7 @@ public:
std::list<CStdString> m_tapeProcessors;
int m_captureFileBatchSizeKByte;
bool m_debug;
+ std::list<CStdString> m_tapeFileNaming;
private:
log4cxx::LoggerPtr m_log;