From b19f5982a49bc77747a10ec6f4219cb8a9eecc69 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 3 Jan 2024 12:20:49 -0500 Subject: [PATCH] MT#59069 add recording-path option Add an option to override the default output path of created recording files. Change-Id: I3fcabeb55ea118b22913630ce3473bd40a8ef85d --- daemon/call_interfaces.c | 18 ++++++++++++++++++ daemon/recording.c | 1 + daemon/redis.c | 4 ++++ docs/ng_control_protocol.md | 9 +++++++++ include/call.h | 1 + include/call_interfaces.h | 1 + recording-daemon/metafile.c | 2 ++ recording-daemon/output.c | 5 +++-- recording-daemon/types.h | 1 + 9 files changed, 40 insertions(+), 2 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 22ce08a2c..7c2ac05c8 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1761,6 +1761,24 @@ static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *valu case CSH_LOOKUP("record-call"): out->record_call_str = s; break; + case CSH_LOOKUP("recording path"): + case CSH_LOOKUP("recording dir"): + case CSH_LOOKUP("recording directory"): + case CSH_LOOKUP("recording folder"): + case CSH_LOOKUP("output path"): + case CSH_LOOKUP("output dir"): + case CSH_LOOKUP("output directory"): + case CSH_LOOKUP("output folder"): + case CSH_LOOKUP("recording-path"): + case CSH_LOOKUP("recording-dir"): + case CSH_LOOKUP("recording-directory"): + case CSH_LOOKUP("recording-folder"): + case CSH_LOOKUP("output-path"): + case CSH_LOOKUP("output-dir"): + case CSH_LOOKUP("output-directory"): + case CSH_LOOKUP("output-folder"): + out->recording_path = s; + break; case CSH_LOOKUP("repeat-times"): out->repeat_times = bencode_get_integer_str(value, out->repeat_times); break; diff --git a/daemon/recording.c b/daemon/recording.c index f32772711..996349fcf 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -289,6 +289,7 @@ static void update_call_field(call_t *call, str *dst_field, const str *src_field 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"); } // lock must be held diff --git a/daemon/redis.c b/daemon/redis.c index ac393a8ee..efe618d56 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2081,6 +2081,8 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) call_str_cpy(c, &c->metadata, &s); redis_hash_get_str(&s, &call, "recording_file"); call_str_cpy(c, &c->recording_file, &s); + redis_hash_get_str(&s, &call, "recording_path"); + call_str_cpy(c, &c->recording_path, &s); recording_start(c); } @@ -2372,6 +2374,8 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE_STR("recording_meta_prefix", &c->recording_meta_prefix); if (c->recording_file.len) JSON_SET_SIMPLE_STR("recording_file", &c->recording_file); + if (c->recording_path.len) + JSON_SET_SIMPLE_STR("recording_path", &c->recording_path); } json_builder_end_object(builder); diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index e3058ce8a..4c6489111 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -1743,6 +1743,15 @@ If the optional `recording-file` key is set, then its value will be used as an output file. Note that the value must refer to a complete (absolute) path including file name, and a file name extension will not be added. +If the optional `recording-dir` key is set, then its value will be used as the +directory path for the output file(s), overriding the `output-dir` config +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. + ## `stop recording` Message The `stop recording` message must contain the key `call-id` as defined above. diff --git a/include/call.h b/include/call.h index c57a951f6..9b9e65a9a 100644 --- a/include/call.h +++ b/include/call.h @@ -708,6 +708,7 @@ struct call { str recording_meta_prefix; str recording_file; str recording_random_tag; + str recording_path; struct call_iterator_entry iterator[NUM_CALL_ITERATORS]; int cpu_affinity; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index a563d5531..c1dc0275f 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -35,6 +35,7 @@ struct sdp_ng_flags { int tos; str record_call_str; str recording_file; + str recording_path; str metadata; str label; str set_label; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index c595e27e8..d0dd3efb5 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -220,6 +220,8 @@ static void meta_section(metafile_t *mf, char *section, char *content, unsigned stream_forwarding_on(mf, lu, u); else if (!strcmp(section, "RECORDING_FILE")) 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); } diff --git a/recording-daemon/output.c b/recording-daemon/output.c index a02b449c8..adfce13db 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -202,6 +202,7 @@ static output_t *output_new_from_full_path(const char *path, char *name, const c } output_t *output_new_ext(metafile_t *mf, const char *type, const char *kind, const char *label) { + const char *output_path = mf->output_path ?: output_dir; output_t *ret; dbg("Metadata %s, output destination %s", mf->metadata, mf->output_dest); if (mf->output_dest) { @@ -214,11 +215,11 @@ output_t *output_new_ext(metafile_t *mf, const char *type, const char *kind, con ret->skip_filename_extension = TRUE; } else - ret = output_new_from_full_path(output_dir, path, kind); + ret = output_new_from_full_path(output_path, path, kind); g_free(path); } else - ret = output_new(output_dir, mf, type, kind, label); + ret = output_new(output_path, mf, type, kind, label); return ret; } diff --git a/recording-daemon/types.h b/recording-daemon/types.h index f3369a63a..5227d9d9d 100644 --- a/recording-daemon/types.h +++ b/recording-daemon/types.h @@ -117,6 +117,7 @@ struct metafile_s { char *metadata; char *metadata_db; char *output_dest; + char *output_path; off_t pos; unsigned long long db_id; unsigned int db_streams;