From cf15275f30a1c457faf5cca9d55ba2fe27a686f3 Mon Sep 17 00:00:00 2001 From: Claudiu Boriga Date: Wed, 20 Sep 2017 11:22:12 +0300 Subject: [PATCH] add stop recording comand to ng interface --- daemon/call_interfaces.c | 18 ++++++++++++++++++ daemon/cli.c | 3 ++- daemon/control_ng.c | 4 ++++ daemon/control_ng.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index f13feb6b9..0bbcbe3c0 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1121,3 +1121,21 @@ const char *call_start_recording_ng(bencode_item_t *input, struct callmaster *m, return NULL; } + +const char *call_stop_recording_ng(bencode_item_t *input, struct callmaster *m, bencode_item_t *output) { + str callid; + struct call *call; + + if (!bencode_dictionary_get_str(input, "call-id", &callid)) + return "No call-id in message"; + call = call_get_opmode(&callid, m, OP_OTHER); + if (!call) + return "Unknown call-id"; + + recording_stop(call); + + rwlock_unlock_w(&call->master_lock); + obj_put(call); + + return NULL; +} diff --git a/daemon/cli.c b/daemon/cli.c index 4afba45af..deb509922 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -185,7 +185,7 @@ static void cli_incoming_list_totals(char* buffer, int len, struct callmaster* m } for (GList *l = list; l; l = l->next) { struct control_ng_stats* cur = l->data; - printlen = snprintf(replybuffer,(outbufend-replybuffer), " %20s | %10u | %10u | %10u | %10u | %10u | %10u | %10u | %10u \n", + printlen = snprintf(replybuffer,(outbufend-replybuffer), " %20s | %10u | %10u | %10u | %10u | %10u | %10u | %10u | %10u | %10u \n", sockaddr_print_buf(&cur->proxy), cur->offer, cur->answer, @@ -194,6 +194,7 @@ static void cli_incoming_list_totals(char* buffer, int len, struct callmaster* m cur->list, cur->query, cur->start_recording, + cur->stop_recording, cur->errors); ADJUSTLEN(printlen,outbufend,replybuffer); } diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 05c96fa61..c956be322 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -229,6 +229,10 @@ static void control_ng_incoming(struct obj *obj, str *buf, const endpoint_t *sin errstr = call_start_recording_ng(dict, c->callmaster, resp); g_atomic_int_inc(&cur->start_recording); } + else if (!str_cmp(&cmd, "stop recording")) { + errstr = call_stop_recording_ng(dict, c->callmaster, resp); + g_atomic_int_inc(&cur->stop_recording); + } else errstr = "Unrecognized command"; diff --git a/daemon/control_ng.h b/daemon/control_ng.h index ac3cf418a..fe4ee9a6c 100644 --- a/daemon/control_ng.h +++ b/daemon/control_ng.h @@ -19,6 +19,7 @@ struct control_ng_stats { int query; int list; int start_recording; + int stop_recording; int errors; };