]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4198 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 8 May 2012 12:43:01 +0000 (07:43 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 8 May 2012 12:43:01 +0000 (07:43 -0500)
src/include/switch_types.h
src/switch_ivr_bridge.c

index 5fda9c369e775a79c0e8eca14cac6108b2e7cc44..edd630ffcb6ff7ab7550e9b0fcc459388fe11cf0 100644 (file)
@@ -131,6 +131,7 @@ SWITCH_BEGIN_EXTERN_C
 #define SWITCH_READ_RESULT_VARIABLE "read_result"
 #define SWITCH_ATT_XFER_RESULT_VARIABLE "att_xfer_result"
 #define SWITCH_COPY_XML_CDR_VARIABLE "copy_xml_cdr"
+#define SWITCH_COPY_JSON_CDR_VARIABLE "copy_json_cdr"
 #define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application"
 #define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause"
 #define SWITCH_TRANSFER_HISTORY_VARIABLE "transfer_history"
index 8025c9d01c97d0622b7bf376e272d81db38d2791..b2cd384098949dbae1501ca36049edfc317952c3 100644 (file)
@@ -1366,21 +1366,41 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
                                switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_HANGUP_CAUSE_VARIABLE, switch_channel_cause2str(cause));
                        }
                        
-                       if (switch_channel_down_nosig(peer_channel) && switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_XML_CDR_VARIABLE))) {
-                               switch_xml_t cdr = NULL;
-                               char *xml_text;
+                       if (switch_channel_down_nosig(peer_channel)) {
+                               switch_bool_t copy_xml_cdr = switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_XML_CDR_VARIABLE));
+                               switch_bool_t copy_json_cdr = switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_JSON_CDR_VARIABLE));
 
-                               switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY);
+                               if (copy_xml_cdr || copy_json_cdr) {
+                                       char *cdr_text = NULL;                                  
 
-                               if (switch_ivr_generate_xml_cdr(peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
-                                       if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) {
-                                               switch_channel_set_variable(caller_channel, "b_leg_cdr", xml_text);
-                                               switch_safe_free(xml_text);
+                                       switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY);
+
+                                       if (copy_xml_cdr) {
+                                               switch_xml_t cdr = NULL;
+
+                                               if (switch_ivr_generate_xml_cdr(peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
+                                                       cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
+                                                       switch_xml_free(cdr);
+                                               }
+                                       }
+                                       if (copy_json_cdr) {
+                                               cJSON *cdr = NULL;
+
+                                               if (switch_ivr_generate_json_cdr(peer_session, &cdr, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
+                                                       cdr_text = cJSON_PrintUnformatted(cdr);
+                                                       cJSON_Delete(cdr);
+                                               }
+                                       }
+
+                                       if (cdr_text) {
+                                               switch_channel_set_variable(caller_channel, "b_leg_cdr", cdr_text);
+                                               switch_channel_set_variable_name_printf(caller_channel, cdr_text, "b_leg_cdr_%s", switch_core_session_get_uuid(peer_session));
+                                               switch_safe_free(cdr_text);
                                        }
-                                       switch_xml_free(cdr);
                                }
+                                       
                        }
-
+                       
                        switch_core_session_rwunlock(peer_session);
 
                } else {