From c787ab9c4e487681314783c8ba97ff17dc08c9cb Mon Sep 17 00:00:00 2001 From: Dylan Mikus Date: Wed, 20 Jan 2016 17:01:52 +0000 Subject: [PATCH] Refactored NG protocol handling of "record call" settings I refactored the handling of the "record-call" flag in the "rtpengine_offer" and "rtpengine_answer" handler. We now set the recording data structures in a function called `set_record_call`. We also only handle "record-call" flags on OP_ANSWER for SDP answers. --- daemon/call_interfaces.c | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 7c4ba5fc4..92d0fae2d 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -25,7 +25,7 @@ int trust_address_def; int dtls_passive_def; - +int set_record_call(struct call *call, str recordcall); static int call_stream_address_gstring(GString *o, struct packet_stream *ps, enum stream_address_format format) { @@ -689,19 +689,9 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster if (!call) goto out; - if (recordcall.s) { - if (!str_cmp(&recordcall, "yes")) { - call->record_call = TRUE; - if (call->recording == NULL) { - call->recording = g_slice_alloc0(sizeof(struct recording)); - call->recording->recording_pd = NULL; - call->recording->recording_pdumper = NULL; - meta_setup_file(call->recording, call->callid); - } - } else if (!str_cmp(&recordcall, "no")) { - call->record_call = FALSE; - } else { - ilog(LOG_INFO, "\"record-call\" flag %s is invalid flag.", recordcall.s); + if (opmode == OP_ANSWER) { + if (recordcall.s) { + set_record_call(call, recordcall); } } @@ -1084,3 +1074,27 @@ const char *call_list_ng(bencode_item_t *input, struct callmaster *m, bencode_it return NULL; } + +/** + * Controls the setting of recording variables on a `struct call *`. + * Sets the `record_call` value on the `struct call`, initializing the + * recording struct if necessary. + * + * Returns a boolean for whether or not the call is being recorded. + */ +int set_record_call(struct call *call, str recordcall) { + if (!str_cmp(&recordcall, "yes")) { + call->record_call = TRUE; + if (call->recording == NULL) { + call->recording = g_slice_alloc0(sizeof(struct recording)); + call->recording->recording_pd = NULL; + call->recording->recording_pdumper = NULL; + meta_setup_file(call->recording, call->callid); + } + } else if (!str_cmp(&recordcall, "no")) { + call->record_call = FALSE; + } else { + ilog(LOG_INFO, "\"record-call\" flag %s is invalid flag.", recordcall.s); + } + return call->record_call; +}