diff --git a/docs/rtpengine-recording.md b/docs/rtpengine-recording.md index 4df310e48..34879d9cc 100644 --- a/docs/rtpengine-recording.md +++ b/docs/rtpengine-recording.md @@ -138,7 +138,7 @@ sufficient for a standard installation of rtpengine. Points to the shared object file (__.so__) containing the reference implementation for the EVS codec. See the `README` for more details. -- __\-\-output-storage=file__\|__db__\|__memory__ +- __\-\-output-storage=file__\|__db__\|__memory__\|__notify__ Where to store media files. This option can be given multiple times (or, in the config file, using a comma-separated list) to enable multiple storage @@ -152,6 +152,8 @@ sufficient for a standard installation of rtpengine. The string __both__ is recognised as legacy alternative to enabling both __file__ and __db__ storage. + __notify__ is an alias for enabling the __notify-record__ option, see below. + The string __memory__ acts as a modifier and can be used if __file__ storage is not enabled. Without the __memory__ modifier, media is first written to a temporary file before being placed into its destination storage when diff --git a/recording-daemon/main.c b/recording-daemon/main.c index b80640ac5..367d2fe49 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -68,7 +68,6 @@ gboolean notify_nverify; int notify_threads = 5; int notify_retries = 10; char *notify_command; -gboolean notify_record; gboolean notify_purge; gboolean mix_output_per_media = 0; gboolean flush_packets = 0; @@ -197,12 +196,13 @@ static void options(int *argc, char ***argv) { g_autoptr(char) group_gid = NULL; g_autoptr(char) mix_method_str = NULL; g_autoptr(char) tcp_send_to = NULL; + gboolean notify_record = FALSE; GOptionEntry e[] = { { "table", 't', 0, G_OPTION_ARG_INT, &ktable, "Kernel table rtpengine uses", "INT" }, { "spool-dir", 0, 0, G_OPTION_ARG_FILENAME, &spool_dir, "Directory containing rtpengine metadata files", "PATH" }, { "num-threads", 0, 0, G_OPTION_ARG_INT, &num_threads, "Number of worker threads", "INT" }, - { "output-storage", 0, 0, G_OPTION_ARG_STRING_ARRAY,&os_a, "Where to store audio streams", "file|db|memory"}, + { "output-storage", 0, 0, G_OPTION_ARG_STRING_ARRAY,&os_a, "Where to store audio streams", "file|db|notify|memory"}, { "output-dir", 0, 0, G_OPTION_ARG_STRING, &output_dir, "Where to write media files to", "PATH" }, { "output-pattern", 0, 0, G_OPTION_ARG_STRING, &output_pattern,"File name pattern for recordings", "STRING" }, { "output-format", 0, 0, G_OPTION_ARG_STRING, &output_format, "Write audio files of this type", "wav|mp3|none" }, @@ -293,6 +293,12 @@ static void options(int *argc, char ***argv) { for (char *const *iter = os_a; iter && *iter; iter++) { if (!strcmp(*iter, "file")) output_storage |= OUTPUT_STORAGE_FILE; + else if (!strcmp(*iter, "notify")) +#if CURL_AT_LEAST_VERSION(7,56,0) + output_storage |= OUTPUT_STORAGE_NOTIFY; +#else + die("cURL version too old to support notify storage"); +#endif else if (!strcmp(*iter, "db")) output_storage |= OUTPUT_STORAGE_DB; else if (!strcmp(*iter, "db-mem")) @@ -309,11 +315,15 @@ static void options(int *argc, char ***argv) { if (output_storage == 0) output_storage = OUTPUT_STORAGE_FILE; + output_storage |= notify_record ? OUTPUT_STORAGE_NOTIFY : 0; + // sane config? if ((output_storage & OUTPUT_STORAGE_MASK) == 0) die("No output storage configured"); if ((output_storage & OUTPUT_STORAGE_DB) && (!c_mysql_host || !c_mysql_db)) die("DB output storage is enabled but no DB is configured"); + if ((output_storage & OUTPUT_STORAGE_NOTIFY) && !notify_uri) + die("Notify storage is enabled but notify URI is not set"); if (!mix_method_str || !mix_method_str[0] || !strcmp(mix_method_str, "direct")) mix_method = MM_DIRECT; diff --git a/recording-daemon/main.h b/recording-daemon/main.h index 81b13eafb..b09dc5d16 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -10,6 +10,7 @@ enum output_storage_enum { OUTPUT_STORAGE_FILE = 0x1, OUTPUT_STORAGE_DB = 0x2, + OUTPUT_STORAGE_NOTIFY = 0x4, OUTPUT_STORAGE_MASK = 0xff, @@ -54,7 +55,6 @@ extern gboolean notify_nverify; extern int notify_threads; extern int notify_retries; extern char *notify_command; -extern gboolean notify_record; extern gboolean notify_purge; extern gboolean mix_output_per_media; extern volatile int shutdown_flag; diff --git a/recording-daemon/notify.c b/recording-daemon/notify.c index 1e1b2c969..6975dd149 100644 --- a/recording-daemon/notify.c +++ b/recording-daemon/notify.c @@ -98,7 +98,7 @@ static bool do_notify_http(struct notif_req *req) { } #if CURL_AT_LEAST_VERSION(7,56,0) - if (notify_record && req->full_filename_path) { + if ((output_storage & OUTPUT_STORAGE_NOTIFY) && req->full_filename_path) { err = "initializing curl mime&part"; curl_mimepart *part; mime = curl_mime_init(c); @@ -134,7 +134,7 @@ static bool do_notify_http(struct notif_req *req) { ilog(LOG_NOTICE, "HTTP notification for '%s%s%s' was successful", FMT_M(req->name)); - if (notify_record && notify_purge && req->full_filename_path) { + if ((output_storage & OUTPUT_STORAGE_NOTIFY) && notify_purge && req->full_filename_path) { if (unlink(req->full_filename_path) == 0) ilog(LOG_NOTICE, "File '%s%s%s' deleted successfully.", FMT_M(req->full_filename_path)); else