From 42216b86f7fd50d8c3ccc0197392f182b0c4e6bd Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 6 Dec 2016 09:34:32 -0500 Subject: [PATCH] TT#5566 more output config options Change-Id: I8d9d1ec1274bbd0ac2e5f86408f4b6c8a60537c2 --- recording-daemon/decoder.c | 10 ++++++---- recording-daemon/main.c | 7 +++++++ recording-daemon/main.h | 2 ++ recording-daemon/metafile.c | 2 +- recording-daemon/mix.c | 2 ++ recording-daemon/packet.c | 3 ++- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/recording-daemon/decoder.c b/recording-daemon/decoder.c index ac85932da..f38dd037e 100644 --- a/recording-daemon/decoder.c +++ b/recording-daemon/decoder.c @@ -260,9 +260,11 @@ static int decoder_got_frame(decoder_t *dec, output_t *output, metafile_t *metaf } pthread_mutex_unlock(&metafile->mix_lock); - output_config(output, dec->out_clockrate, dec->channels); - if (output_add(output, dec_frame)) - ilog(LOG_ERR, "Failed to add decoded packet to individual output"); + if (output) { + output_config(output, dec->out_clockrate, dec->channels); + if (output_add(output, dec_frame)) + ilog(LOG_ERR, "Failed to add decoded packet to individual output"); + } return 0; } @@ -283,7 +285,7 @@ int decoder_input(decoder_t *dec, const str *data, unsigned long ts, output_t *o } else { // shift pts according to rtp ts shift - dec->pts += (ts - dec->rtp_ts) /* * output->avst->time_base.num * 8000 / output->avst->time_base.den */ ; + dec->pts += (ts - dec->rtp_ts); // XXX handle lost packets here if timestamps don't line up? } dec->rtp_ts = ts; diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 2350fb2c9..db785deab 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -28,6 +28,8 @@ int num_threads = 8; const char *spool_dir = "/var/spool/rtpengine"; const char *output_dir = "/var/lib/rtpengine-recording"; static const char *output_format = "wav"; +int output_mixed; +int output_single; static GQueue threads = G_QUEUE_INIT; // only accessed from main thread @@ -140,11 +142,16 @@ static void options(int *argc, char ***argv) { { "output-format", 0, 0, G_OPTION_ARG_STRING, &output_format, "Write audio files of this type", "wav|mp3" }, { "resample-to", 0, 0, G_OPTION_ARG_INT, &resample_audio,"Resample all output audio", "INT" }, { "mp3-bitrate", 0, 0, G_OPTION_ARG_INT, &mp3_bitrate, "Bits per second for MP3 encoding", "INT" }, + { "output-mixed", 0, 0, G_OPTION_ARG_NONE, &output_mixed, "Mix participating sources into a single output",NULL }, + { "output-single", 0, 0, G_OPTION_ARG_NONE, &output_single, "Create one output file for each source",NULL }, { NULL, } }; config_load(argc, argv, e, " - rtpengine recording daemon", "/etc/rtpengine/rtpengine-recording.conf", "rtpengine-recording"); + + if (!output_mixed && !output_single) + output_mixed = output_single = 1; } diff --git a/recording-daemon/main.h b/recording-daemon/main.h index c58659d31..b3d0070c0 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -6,6 +6,8 @@ extern int ktable; extern int num_threads; extern const char *spool_dir; extern const char *output_dir; +extern int output_mixed; +extern int output_single; extern volatile int shutdown_flag; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index ef35770fd..e4cc2340a 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -53,7 +53,7 @@ static void meta_destroy(metafile_t *mf) { // mf is locked static void meta_stream_interface(metafile_t *mf, unsigned long snum, char *content) { pthread_mutex_lock(&mf->mix_lock); - if (!mf->mix) { + if (!mf->mix && output_mixed) { char buf[256]; snprintf(buf, sizeof(buf), "%s/%s-mix", output_dir, mf->parent); mf->mix_out = output_new(buf); diff --git a/recording-daemon/mix.c b/recording-daemon/mix.c index a244d8d90..52b28f979 100644 --- a/recording-daemon/mix.c +++ b/recording-daemon/mix.c @@ -59,6 +59,8 @@ static void mix_shutdown(mix_t *mix) { void mix_destroy(mix_t *mix) { + if (!mix) + return; mix_shutdown(mix); av_frame_free(&mix->sink_frame); av_frame_free(&mix->swr_frame); diff --git a/recording-daemon/packet.c b/recording-daemon/packet.c index b4dd11387..7e5dfaac8 100644 --- a/recording-daemon/packet.c +++ b/recording-daemon/packet.c @@ -58,7 +58,8 @@ static ssrc_t *ssrc_get(metafile_t *mf, unsigned long ssrc) { char buf[256]; snprintf(buf, sizeof(buf), "%s/%s-%08lx", output_dir, mf->parent, ssrc); - ret->output = output_new(buf); + if (output_single) + ret->output = output_new(buf); g_hash_table_insert(mf->ssrc_hash, GUINT_TO_POINTER(ssrc), ret);