From cf15275f30a1c457faf5cca9d55ba2fe27a686f3 Mon Sep 17 00:00:00 2001 From: Claudiu Boriga Date: Wed, 20 Sep 2017 11:22:12 +0300 Subject: [PATCH 1/2] 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; }; From bb85236b674f1e480a9a73708813a798a793c907 Mon Sep 17 00:00:00 2001 From: Claudiu Boriga Date: Tue, 26 Sep 2017 13:38:30 +0300 Subject: [PATCH 2/2] update readme to add stop recording command --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9ead94c14..a8f711f37 100644 --- a/README.md +++ b/README.md @@ -748,6 +748,7 @@ a string and determines the type of message. Currently the following commands ar * delete * query * start recording +* stop recording The response dictionary must contain at least one key called `result`. The value can be either `ok` or `error`. For the `ping` command, the additional value `pong` is allowed. If the result is `error`, then another key @@ -1413,3 +1414,11 @@ call legs, therefore all keys other than `call-id` are currently ignored. If the chosen recording method doesn't support in-kernel packet forwarding, enabling call recording via this messages will force packet forwarding to happen in userspace only. + +`stop recording` Message +------------------------- + +The `stop recording` message must contain the key `call-id` as defined above. The reply dictionary contains +no additional keys. + +Disables call recording for the call. This can be sent during a call to imediatley stop recording it.