From bda1b937cb17508e65a525d463d28293bc1933e2 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 4 Jan 2024 12:51:59 -0500 Subject: [PATCH] MT#59071 support selective DB updates Introduce flag to suppress recording DB update. Change-Id: Ie9006f3608fc90296caf86120124da98fe50f8a1 --- daemon/call_interfaces.c | 4 ++++ daemon/recording.c | 8 ++++++++ docs/ng_control_protocol.md | 5 +++++ include/call.h | 1 + include/call_interfaces.h | 1 + recording-daemon/db.c | 6 ++++++ recording-daemon/metafile.c | 2 ++ recording-daemon/types.h | 1 + 8 files changed, 28 insertions(+) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 9a8de2da8..d34f51d3c 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1135,6 +1135,10 @@ static void call_ng_flags_flags(sdp_ng_flags *out, str *s, helper_arg dummy) { case CSH_LOOKUP("siprec"): out->siprec = 1; break; + case CSH_LOOKUP("skip-recording-db"): + case CSH_LOOKUP("skip-recording-database"): + out->skip_recording_db = 1; + break; case CSH_LOOKUP("static-codec"): case CSH_LOOKUP("static-codecs"): out->static_codecs = 1; diff --git a/daemon/recording.c b/daemon/recording.c index e507be7b1..837e95a1d 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -287,6 +287,14 @@ static void update_call_field(call_t *call, str *dst_field, const str *src_field // lock must be held void update_metadata_call(call_t *call, const sdp_ng_flags *flags) { + if (flags && flags->skip_recording_db) + CALL_SET(call, NO_REC_DB); + if (call->recording) { + // must come first because METADATA triggers update to DB + if (CALL_ISSET(call, NO_REC_DB)) + append_meta_chunk_null(call->recording, "SKIP_DATABASE"); + } + 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"); diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index aa3f31461..ccf672efd 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -844,6 +844,11 @@ Spaces in each string may be replaced by hyphens. recorded. When used within an offer/answer exchange, applies to both call parties involved. +* `skip-recording-db` + + Suppress writing the information about the call recording to the configured + metadata DB. + * `early media` Used in conjunction with the audio player. If set, audio playback is diff --git a/include/call.h b/include/call.h index 8322e2fce..9d8dbd5ec 100644 --- a/include/call.h +++ b/include/call.h @@ -216,6 +216,7 @@ enum { #define CALL_FLAG_DEBUG 0x08000000 #define CALL_FLAG_BLOCK_MEDIA 0x10000000 #define CALL_FLAG_SILENCE_MEDIA 0x20000000 +#define CALL_FLAG_NO_REC_DB 0x40000000 /* access macros */ #define SP_ISSET(p, f) bf_isset(&(p)->sp_flags, SP_FLAG_ ## f) diff --git a/include/call_interfaces.h b/include/call_interfaces.h index b3daed48f..eb0b8a76c 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -160,6 +160,7 @@ struct sdp_ng_flags { record_call:1, discard_recording:1, exclude_recording:1, + skip_recording_db:1, debug:1, inactive:1, loop_protect:1, diff --git a/recording-daemon/db.c b/recording-daemon/db.c index 515e9c655..a75467bca 100644 --- a/recording-daemon/db.c +++ b/recording-daemon/db.c @@ -255,6 +255,8 @@ static void db_do_call_id(metafile_t *mf) { return; if (!mf->call_id) return; + if (mf->skip_db) + return; MYSQL_BIND b[2]; my_cstr(&b[0], mf->call_id); @@ -267,6 +269,8 @@ static void db_do_call_metadata(metafile_t *mf) { return; if (mf->db_id == 0) return; + if (mf->skip_db) + return; MYSQL_BIND b[3]; my_ull(&b[0], &mf->db_id); // stays persistent @@ -301,6 +305,8 @@ void db_do_stream(metafile_t *mf, output_t *op, stream_t *stream, unsigned long return; if (op->db_id > 0) return; + if (mf->skip_db) + return; unsigned long id = stream ? stream->id : 0; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index 8c632be2f..8c4161c58 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -245,6 +245,8 @@ static void meta_section(metafile_t *mf, char *section, char *content, unsigned 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); + else if (!strcmp(section, "SKIP_DATABASE")) + mf->skip_db = 1; } diff --git a/recording-daemon/types.h b/recording-daemon/types.h index 492189a57..2dfd04d3c 100644 --- a/recording-daemon/types.h +++ b/recording-daemon/types.h @@ -152,6 +152,7 @@ struct metafile_s { unsigned int forwarding_on:1; unsigned int discard:1; unsigned int db_metadata_done:1; + unsigned int skip_db:1; };