diff --git a/docs/rtpengine-recording.md b/docs/rtpengine-recording.md index 34879d9cc..eb1ff28ac 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__\|__notify__ +- __\-\-output-storage=file__\|__db__\|__memory__\|__notify__\|__none__ 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 @@ -147,6 +147,9 @@ sufficient for a standard installation of rtpengine. The __file__ storage writes media files directly to the file system (see __output-dir__). + Setting __none__ overrides file storage as being the default and allows + forwarding-only operation. + The __db__ storage writes media files as a __BLOB__ in a MySQL database. The string __both__ is recognised as legacy alternative to enabling both @@ -241,7 +244,9 @@ sufficient for a standard installation of rtpengine. File format to be used for media files that are produced. Defaults to PCM WAV (RIFF) files. Applicable for both files stored on the file system and in a - database. If __none__ is selected then file output is disabled. + database. + + __none__ is a legacy alias for __output-storage=none__. - __\-\-resample-to=__*INT* diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 367d2fe49..25347e466 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -43,7 +43,6 @@ gboolean output_mixed; enum mix_method mix_method; int mix_num_inputs = MIX_MAX_INPUTS; gboolean output_single; -gboolean output_enabled = 1; mode_t output_chmod; mode_t output_chmod_dir; uid_t output_chown = -1; @@ -103,7 +102,7 @@ static void setup(void) { socket_init(); if (decoding_enabled) codeclib_init(0); - if (output_enabled) + if ((output_storage & OUTPUT_STORAGE_MASK)) output_init(output_format); mysql_library_init(0, NULL, NULL); signals(); @@ -197,6 +196,7 @@ static void options(int *argc, char ***argv) { g_autoptr(char) mix_method_str = NULL; g_autoptr(char) tcp_send_to = NULL; gboolean notify_record = FALSE; + bool no_output_allowed = false; GOptionEntry e[] = { { "table", 't', 0, G_OPTION_ARG_INT, &ktable, "Kernel table rtpengine uses", "INT" }, @@ -270,21 +270,8 @@ static void options(int *argc, char ***argv) { die("Failed to parse 'tcp-send-to' or 'tls-send-to' option"); } - if (!strcmp(output_format, "none")) { - output_enabled = 0; - if (output_mixed || output_single) - die("Output is disabled, but output-mixed or output-single is set"); - if (!forward_to && !tls_send_to_ep.port) { - //the daemon has no function - die("Both output and forwarding are disabled"); - } - g_free(output_format); - output_format = NULL; - } else if (!output_mixed && !output_single) - output_mixed = output_single = true; - - if (output_enabled || tls_send_to_ep.port) - decoding_enabled = true; + if (!strcmp(output_format, "none")) + no_output_allowed = true; if (!tls_send_to && !tcp_send_to) tls_mixed = false; @@ -307,24 +294,41 @@ static void options(int *argc, char ***argv) { output_storage |= OUTPUT_STORAGE_MEMORY; else if (!strcmp(*iter, "both")) output_storage |= OUTPUT_STORAGE_FILE | OUTPUT_STORAGE_DB; + else if (!strcmp(*iter, "none")) + no_output_allowed = true; else die("Invalid 'output-storage' option '%s'", *iter); } // default: - if (output_storage == 0) + if (output_storage == 0 && !no_output_allowed) output_storage = OUTPUT_STORAGE_FILE; output_storage |= notify_record ? OUTPUT_STORAGE_NOTIFY : 0; // sane config? - if ((output_storage & OUTPUT_STORAGE_MASK) == 0) + if ((output_storage & OUTPUT_STORAGE_MASK) == 0 && !no_output_allowed) 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 ((output_storage & OUTPUT_STORAGE_MASK) == 0) { + if (output_mixed || output_single) + die("Output is disabled, but output-mixed or output-single is set"); + if (!forward_to && !tls_send_to_ep.port) { + //the daemon has no function + die("Both output and forwarding are disabled"); + } + g_free(output_format); + output_format = NULL; + } else if (!output_mixed && !output_single) + output_mixed = output_single = true; + + if ((output_storage & OUTPUT_STORAGE_MASK) || tls_send_to_ep.port) + decoding_enabled = true; + if (!mix_method_str || !mix_method_str[0] || !strcmp(mix_method_str, "direct")) mix_method = MM_DIRECT; else if (!strcmp(mix_method_str, "channels")) diff --git a/recording-daemon/main.h b/recording-daemon/main.h index b09dc5d16..9b7bc4809 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -31,7 +31,6 @@ extern gboolean output_mixed; extern enum mix_method mix_method; extern int mix_num_inputs; extern gboolean output_single; -extern gboolean output_enabled; extern mode_t output_chmod; extern mode_t output_chmod_dir; extern uid_t output_chown; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index f49b08bf3..a2537f3c7 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -95,7 +95,9 @@ static void meta_destroy(metafile_t *mf) { // mf is locked // mix is locked static void meta_mix_file_output(metafile_t *mf) { - if (!output_enabled || !output_mixed || !mf->recording_on || !mf->random_tag) { + if ((output_storage & OUTPUT_STORAGE_MASK) == 0 || !output_mixed || !mf->recording_on + || !mf->random_tag) + { mix_destroy(mf->mix); mf->mix = NULL; return;