MT#59069 add option to override rec file pattern

Change-Id: Ibcdd09d3913b3f9e13e74082b5618815e05dc740
pull/1786/head
Richard Fuchs 2 years ago
parent b19f5982a4
commit e4630eb53c

@ -1779,6 +1779,12 @@ static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *valu
case CSH_LOOKUP("output-folder"):
out->recording_path = s;
break;
case CSH_LOOKUP("recording pattern"):
case CSH_LOOKUP("recording-pattern"):
case CSH_LOOKUP("output pattern"):
case CSH_LOOKUP("output-pattern"):
out->recording_pattern = s;
break;
case CSH_LOOKUP("repeat-times"):
out->repeat_times = bencode_get_integer_str(value, out->repeat_times);
break;

@ -290,6 +290,8 @@ void update_metadata_call(call_t *call, const sdp_ng_flags *flags) {
update_call_field(call, &call->metadata, flags ? &flags->metadata : NULL, "METADATA");
update_call_field(call, &call->recording_file, flags ? &flags->recording_file : NULL, "RECORDING_FILE");
update_call_field(call, &call->recording_path, flags ? &flags->recording_path : NULL, "RECORDING_PATH");
update_call_field(call, &call->recording_pattern, flags ? &flags->recording_pattern : NULL,
"RECORDING_PATTERN");
}
// lock must be held

@ -2083,6 +2083,8 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign)
call_str_cpy(c, &c->recording_file, &s);
redis_hash_get_str(&s, &call, "recording_path");
call_str_cpy(c, &c->recording_path, &s);
redis_hash_get_str(&s, &call, "recording_pattern");
call_str_cpy(c, &c->recording_pattern, &s);
recording_start(c);
}
@ -2376,6 +2378,8 @@ char* redis_encode_json(call_t *c) {
JSON_SET_SIMPLE_STR("recording_file", &c->recording_file);
if (c->recording_path.len)
JSON_SET_SIMPLE_STR("recording_path", &c->recording_path);
if (c->recording_pattern.len)
JSON_SET_SIMPLE_STR("recording_pattern", &c->recording_pattern);
}
json_builder_end_object(builder);

@ -1749,8 +1749,14 @@ option of the recording daemon. The value should refer to an existing directory
given as an absolute path. Setting this key does not affect the names of the
files that will be created in the directory.
If both `recording-file` and `recording-dir` are set, then `recording-file`
takes precedence.
If the optional `recording-pattern` key is set, then its value will be used as
the pattern to generate the output file name(s), overriding the
`output-pattern` config option of the recording daemon. Note that no validity
checking is performed on the given string, so make sure that the given pattern
does not yield duplicate file names.
The option `recording-file` takes precedence over both `recording-dir` and
`recording-pattern` if multiple options are set.
## `stop recording` Message

@ -709,6 +709,7 @@ struct call {
str recording_file;
str recording_random_tag;
str recording_path;
str recording_pattern;
struct call_iterator_entry iterator[NUM_CALL_ITERATORS];
int cpu_affinity;

@ -36,6 +36,7 @@ struct sdp_ng_flags {
str record_call_str;
str recording_file;
str recording_path;
str recording_pattern;
str metadata;
str label;
str set_label;

@ -222,6 +222,8 @@ static void meta_section(metafile_t *mf, char *section, char *content, unsigned
mf->output_dest = g_string_chunk_insert(mf->gsc, content);
else if (!strcmp(section, "RECORDING_PATH"))
mf->output_path = g_string_chunk_insert(mf->gsc, content);
else if (!strcmp(section, "RECORDING_PATTERN"))
mf->output_pattern = g_string_chunk_insert(mf->gsc, content);
}

@ -113,7 +113,9 @@ static output_t *output_new(const char *path, const metafile_t *mf, const char *
localtime_r(&now.tv_sec, &tm);
g_autoptr(GString) f = g_string_new("");
for (const char *p = output_pattern; *p; p++) {
const char *pattern = mf->output_pattern ?: output_pattern;
for (const char *p = pattern; *p; p++) {
if (*p != '%') {
g_string_append_c(f, *p);
continue;

@ -118,6 +118,7 @@ struct metafile_s {
char *metadata_db;
char *output_dest;
char *output_path;
char *output_pattern;
off_t pos;
unsigned long long db_id;
unsigned int db_streams;

Loading…
Cancel
Save