diff --git a/daemon/recording.c b/daemon/recording.c index 6cc9e5729..f32772711 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -348,6 +348,7 @@ void recording_start(call_t *call) { rand_hex_str(rand_str, rand_bytes); g_autoptr(char) meta_prefix = g_strdup_printf("%s-%s", escaped_callid, rand_str); call_str_cpy(call, &call->recording_meta_prefix, &STR_INIT(meta_prefix)); + call_str_cpy(call, &call->recording_random_tag, &STR_CONST_INIT(rand_str)); } _rm(init_struct, call); @@ -834,6 +835,7 @@ static void proc_init(call_t *call) { append_meta_chunk_str(recording, &call->callid, "CALL-ID"); append_meta_chunk_s(recording, call->recording_meta_prefix.s, "PARENT"); + append_meta_chunk_s(recording, call->recording_random_tag.s, "RANDOM_TAG"); if (call->metadata.len) recording_meta_chunk(recording, "METADATA", &call->metadata); } diff --git a/docs/rtpengine-recording.md b/docs/rtpengine-recording.md index 19a6bb984..6a3f56aa9 100644 --- a/docs/rtpengine-recording.md +++ b/docs/rtpengine-recording.md @@ -155,7 +155,7 @@ sufficient for a standard installation of rtpengine. File name pattern to be used for recording files. The pattern can reference sub-directories. Parent directories will be created on demand. The default - setting is __%c-%t__. + setting is __%c-%r-%t__. The pattern must include __printf__-style format sequences. Supported format sequences are: @@ -169,6 +169,11 @@ sufficient for a standard installation of rtpengine. The call ID. It is mandatory for the output pattern to include this format sequence. + - __%r__ + + A random tag generated by __rtpengine__ to distinguish possibly + repeated or duplicated call IDs. + - __%t__ The stream type. For __single__ streams this is the SSRC written as hexadecimal; diff --git a/include/call.h b/include/call.h index f14620428..c57a951f6 100644 --- a/include/call.h +++ b/include/call.h @@ -707,6 +707,7 @@ struct call { str metadata; str recording_meta_prefix; str recording_file; + str recording_random_tag; struct call_iterator_entry iterator[NUM_CALL_ITERATORS]; int cpu_affinity; diff --git a/recording-daemon/main.c b/recording-daemon/main.c index c3220fe74..bbaa9a2e0 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -317,7 +317,7 @@ static void options(int *argc, char ***argv) { num_threads = num_cpu_cores(8); if (!output_pattern) - output_pattern = g_strdup("%c-%t"); + output_pattern = g_strdup("%c-%r-%t"); if (!strstr(output_pattern, "%c")) die("Invalid output pattern '%s' (no '%%c' format present)", output_pattern); if (!strstr(output_pattern, "%t")) diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index 6a061513b..c595e27e8 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -185,6 +185,8 @@ static void meta_section(metafile_t *mf, char *section, char *content, unsigned mf->call_id = g_string_chunk_insert(mf->gsc, content); else if (!strcmp(section, "PARENT")) mf->parent = g_string_chunk_insert(mf->gsc, content); + else if (!strcmp(section, "RANDOM_TAG")) + mf->random_tag = g_string_chunk_insert(mf->gsc, content); else if (!strcmp(section, "METADATA")) if (mf->forward_fd >= 0) { ilog(LOG_INFO, "Connection already established, sending mid-call metadata %.*s", (int)len, content); diff --git a/recording-daemon/output.c b/recording-daemon/output.c index 619a46200..a02b449c8 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -106,7 +106,8 @@ static output_t *output_new(const char *path, const metafile_t *mf, const char * // construct output file name struct timeval now; struct tm tm; - const char *ax = mf->parent; + g_autoptr(char) escaped_callid = g_uri_escape_string(mf->call_id, NULL, 0); + const char *ax = escaped_callid; gettimeofday(&now, NULL); localtime_r(&now.tv_sec, &tm); @@ -126,7 +127,10 @@ static output_t *output_new(const char *path, const metafile_t *mf, const char * g_string_append_c(f, '%'); break; case 'c': - g_string_append(f, mf->parent); + g_string_append(f, escaped_callid); + break; + case 'r': + g_string_append(f, mf->random_tag); break; case 't': g_string_append(f, type); diff --git a/recording-daemon/types.h b/recording-daemon/types.h index 98f3b02fc..f3369a63a 100644 --- a/recording-daemon/types.h +++ b/recording-daemon/types.h @@ -113,6 +113,7 @@ struct metafile_s { char *name; char *parent; char *call_id; + char *random_tag; char *metadata; char *metadata_db; char *output_dest;