astobj2: Add backtrace to log_bad_ao2.
[asterisk/asterisk.git] / funcs / func_frame_trace.c
index 45da969..e8c1094 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
 
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
@@ -157,6 +157,11 @@ static int frame_trace_helper(struct ast_channel *chan, const char *cmd, char *d
        };
        int i = 0;
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        if (!(framedata = ast_calloc(1, sizeof(*framedata)))) {
                return 0;
        }
@@ -180,6 +185,7 @@ static int frame_trace_helper(struct ast_channel *chan, const char *cmd, char *d
                        id = datastore->data;
                        ast_framehook_detach(chan, *id);
                        ast_channel_datastore_remove(chan, datastore);
+                       ast_datastore_free(datastore);
                }
 
                if (!(datastore = ast_datastore_alloc(&frame_trace_datastore, NULL))) {
@@ -209,18 +215,19 @@ static void print_frame(struct ast_frame *frame)
        switch (frame->frametype) {
        case AST_FRAME_DTMF_END:
                ast_verbose("FrameType: DTMF END\n");
-               ast_verbose("Digit: %d\n", frame->subclass.integer);
+               ast_verbose("Digit: 0x%02X '%c'\n", (unsigned)frame->subclass.integer,
+                       frame->subclass.integer < ' ' ? ' ' : frame->subclass.integer);
                break;
        case AST_FRAME_VOICE:
                ast_verbose("FrameType: VOICE\n");
-               ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+               ast_verbose("Codec: %s\n", ast_format_get_name(frame->subclass.format));
                ast_verbose("MS: %ld\n", frame->len);
                ast_verbose("Samples: %d\n", frame->samples);
                ast_verbose("Bytes: %d\n", frame->datalen);
                break;
        case AST_FRAME_VIDEO:
                ast_verbose("FrameType: VIDEO\n");
-               ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+               ast_verbose("Codec: %s\n", ast_format_get_name(frame->subclass.format));
                ast_verbose("MS: %ld\n", frame->len);
                ast_verbose("Samples: %d\n", frame->samples);
                ast_verbose("Bytes: %d\n", frame->datalen);
@@ -327,6 +334,10 @@ static void print_frame(struct ast_frame *frame)
                case AST_CONTROL_PVT_CAUSE_CODE:
                        ast_verbose("SubClass: PVT_CAUSE_CODE\n");
                        break;
+               case AST_CONTROL_MASQUERADE_NOTIFY:
+                       /* Should never happen. */
+                       ast_assert(0);
+                       break;
                case AST_CONTROL_STREAM_STOP:
                        ast_verbose("SubClass: STREAM_STOP\n");
                        break;
@@ -342,6 +353,18 @@ static void print_frame(struct ast_frame *frame)
                case AST_CONTROL_STREAM_FORWARD:
                        ast_verbose("SubClass: STREAM_FORWARD\n");
                        break;
+               case AST_CONTROL_RECORD_CANCEL:
+                       ast_verbose("SubClass: RECORD_CANCEL\n");
+                       break;
+               case AST_CONTROL_RECORD_STOP:
+                       ast_verbose("SubClass: RECORD_STOP\n");
+                       break;
+               case AST_CONTROL_RECORD_SUSPEND:
+                       ast_verbose("SubClass: RECORD_SUSPEND\n");
+                       break;
+               case AST_CONTROL_RECORD_MUTE:
+                       ast_verbose("SubClass: RECORD_MUTE\n");
+                       break;
                }
 
                if (frame->subclass.integer == -1) {
@@ -372,7 +395,16 @@ static void print_frame(struct ast_frame *frame)
                break;
        case AST_FRAME_DTMF_BEGIN:
                ast_verbose("FrameType: DTMF BEGIN\n");
-               ast_verbose("Digit: %d\n", frame->subclass.integer);
+               ast_verbose("Digit: 0x%02X '%c'\n", (unsigned)frame->subclass.integer,
+                       frame->subclass.integer < ' ' ? ' ' : frame->subclass.integer);
+               break;
+       case AST_FRAME_BRIDGE_ACTION:
+               ast_verbose("FrameType: Bridge\n");
+               ast_verbose("SubClass: %d\n", frame->subclass.integer);
+               break;
+       case AST_FRAME_BRIDGE_ACTION_SYNC:
+               ast_verbose("Frametype: Synchronous Bridge\n");
+               ast_verbose("Subclass: %d\n", frame->subclass.integer);
                break;
        }
 
@@ -396,5 +428,6 @@ static int load_module(void)
        return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Frame Trace for internal ast_frame debugging.");
+AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Frame Trace for internal ast_frame debugging.");
+