diff --git a/docs/rtpengine-recording.md b/docs/rtpengine-recording.md index 7ab069f65..77a4e9a59 100644 --- a/docs/rtpengine-recording.md +++ b/docs/rtpengine-recording.md @@ -359,6 +359,10 @@ sufficient for a standard installation of rtpengine. Forces one channel per media instead of SSRC. Note that this option is only useful if __\-\-output-mixed__ is also enabled. + +- __\-\-flush-packets__ + + Forces that the output buffer will be flushed after every packet, ensuring that the recording file grows steadily and becomes available for processing without delays. ## EXIT STATUS - __0__ diff --git a/etc/rtpengine-recording.conf b/etc/rtpengine-recording.conf index 500e5937e..02dc8199f 100644 --- a/etc/rtpengine-recording.conf +++ b/etc/rtpengine-recording.conf @@ -38,6 +38,9 @@ table = 0 ### create one output file for each source # output-single = true +### flush output to disk after each packet +# flush-packets = true + ### TCP/TLS output of PCM audio # tcp-send-to = 10.4.1.7:15413 # tcp-resample = 16000 diff --git a/recording-daemon/main.c b/recording-daemon/main.c index b6bdb0726..1144767b8 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -68,6 +68,7 @@ int notify_retries = 10; gboolean notify_record; gboolean notify_purge; gboolean mix_output_per_media = 0; +gboolean flush_packets = 0; static GQueue threads = G_QUEUE_INIT; // only accessed from main thread @@ -230,6 +231,7 @@ static void options(int *argc, char ***argv) { #if CURL_AT_LEAST_VERSION(7,56,0) { "notify-record", 0, 0, G_OPTION_ARG_NONE, ¬ify_record, "Also attach recorded file to request", NULL }, { "notify-purge", 0, 0, G_OPTION_ARG_NONE, ¬ify_purge, "Remove the local file if notify success", NULL }, + { "flush-packets", 0, 0, G_OPTION_ARG_NONE, &flush_packets, "Output buffer will be flushed after every packet", NULL }, #endif { NULL, } }; diff --git a/recording-daemon/main.h b/recording-daemon/main.h index ac2861eee..e53923ef0 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -51,7 +51,7 @@ extern gboolean notify_record; extern gboolean notify_purge; extern gboolean mix_output_per_media; extern volatile int shutdown_flag; - +extern gboolean flush_packets; extern struct rtpengine_common_config rtpe_common_config; diff --git a/recording-daemon/output.c b/recording-daemon/output.c index ec594e891..9d0c14585 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -341,6 +341,10 @@ got_fn: if (av_ret) goto err; + if (flush_packets) { + output->fmtctx->flags |= AVFMT_FLAG_FLUSH_PACKETS; + } + db_config_stream(output); ilog(LOG_INFO, "Opened output media file '%s' for writing", full_fn); done: