From 1bc38e42019b7ca0988343ae7359371cb431bec9 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 12 Feb 2019 16:43:42 -0500 Subject: [PATCH] TT#52651 config options for forwarding option Change-Id: Ieaa2ee0e55a0c531158174bc6a534738a64dbee6 --- recording-daemon/.gitignore | 1 + recording-daemon/Makefile | 4 ++-- recording-daemon/log.h | 1 + recording-daemon/main.c | 17 ++++++++++++++--- recording-daemon/main.h | 3 +++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/recording-daemon/.gitignore b/recording-daemon/.gitignore index 828e6510e..13d93ffe2 100644 --- a/recording-daemon/.gitignore +++ b/recording-daemon/.gitignore @@ -11,3 +11,4 @@ codeclib.c resample.c str.c fix_frame_channel_layout.h +socket.c diff --git a/recording-daemon/Makefile b/recording-daemon/Makefile index a117f0828..246495bfd 100644 --- a/recording-daemon/Makefile +++ b/recording-daemon/Makefile @@ -1,6 +1,6 @@ TARGET= rtpengine-recording -CFLAGS= -g -Wall -pthread -I. -I../lib/ +CFLAGS= -g -Wall -pthread -I. -I../lib/ -I../kernel-module/ CFLAGS+= -std=c99 CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE CFLAGS+= $(shell pkg-config --cflags glib-2.0) @@ -26,7 +26,7 @@ LDLIBS+= $(shell pkg-config --libs openssl) SRCS= epoll.c garbage.c inotify.c main.c metafile.c stream.c recaux.c packet.c \ decoder.c output.c mix.c db.c log.c forward.c tag.c -LIBSRCS= loglib.c auxlib.c rtplib.c codeclib.c resample.c str.c +LIBSRCS= loglib.c auxlib.c rtplib.c codeclib.c resample.c str.c socket.c OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) include ../lib/common.Makefile diff --git a/recording-daemon/log.h b/recording-daemon/log.h index f005174c4..bb6574823 100644 --- a/recording-daemon/log.h +++ b/recording-daemon/log.h @@ -9,6 +9,7 @@ #include #define dbg(fmt, ...) ilog(LOG_DEBUG, "[%s:%i] " fmt, __FILE__, __LINE__, ##__VA_ARGS__) +#define __C_DBG(x...) ilog(LOG_DEBUG, x) void __ilog(int prio, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 03d03f030..b2fd0d8e6 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -24,6 +24,7 @@ #include "output.h" #include "forward.h" #include "codeclib.h" +#include "socket.h" @@ -42,6 +43,9 @@ const char *c_mysql_host, *c_mysql_db; int c_mysql_port; const char *forward_to = NULL; +static const char *tcp_send_to = NULL; +endpoint_t tcp_send_to_ep; +int tcp_resample = 8000; static GQueue threads = G_QUEUE_INIT; // only accessed from main thread @@ -153,20 +157,27 @@ static void options(int *argc, char ***argv) { { "mysql-user", 0, 0, G_OPTION_ARG_STRING, &c_mysql_user, "MySQL connection credentials", "USERNAME" }, { "mysql-pass", 0, 0, G_OPTION_ARG_STRING, &c_mysql_pass, "MySQL connection credentials", "PASSWORD" }, { "mysql-db", 0, 0, G_OPTION_ARG_STRING, &c_mysql_db, "MySQL database name", "STRING" }, - { "forward-to", 0, 0, G_OPTION_ARG_STRING, &forward_to, "Where to forward to (unix socket)", "PATH" }, + { "forward-to", 0, 0, G_OPTION_ARG_STRING, &forward_to, "Where to forward to (unix socket)", "PATH" }, + { "tcp-send-to", 0, 0, G_OPTION_ARG_STRING, &tcp_send_to, "Where to send to (TCP destination)", "IP:PORT" }, + { "tcp-resample", 0, 0, G_OPTION_ARG_INT, &tcp_resample, "Sampling rate for TCP PCM output", "INT" }, { NULL, } }; config_load(argc, argv, e, " - rtpengine recording daemon", "/etc/rtpengine/rtpengine-recording.conf", "rtpengine-recording", &rtpe_common_config); + if (tcp_send_to) { + if (endpoint_parse_any_getaddrinfo_full(&tcp_send_to_ep, tcp_send_to)) + die("Failed to parse 'tcp-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) { + if (!forward_to && !tcp_send_to_ep.address.family) { //the daemon has no function - die("Both output and packet forwarding are disabled"); + die("Both output and forwarding are disabled"); } } else if (!output_mixed && !output_single) output_mixed = output_single = 1; diff --git a/recording-daemon/main.h b/recording-daemon/main.h index 2973ea17c..56058c682 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -3,6 +3,7 @@ #include "auxlib.h" +#include "socket.h" enum output_storage_enum { @@ -25,6 +26,8 @@ extern const char *c_mysql_host, *c_mysql_db; extern int c_mysql_port; extern const char *forward_to; +extern endpoint_t tcp_send_to_ep; +extern int tcp_resample; extern volatile int shutdown_flag;