[Asterisk-code-review] frame.c: Make debugging easier (asterisk[master])
George Joseph
asteriskteam at digium.com
Mon Jul 6 11:02:37 CDT 2020
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14630 )
Change subject: frame.c: Make debugging easier
......................................................................
frame.c: Make debugging easier
* ast_frame_subclass2str() and ast_frame_type2str() now return
a pointer to the buffer that was passed in instead of void.
This makes it easier to use these functions inline in
printf-style debugging statements.
* Added many missing control frame entries in
ast_frame_subclass2str.
Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc
---
M include/asterisk/frame.h
M main/frame.c
2 files changed, 89 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/14630/1
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 9c18227..c8359ec 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -635,9 +635,10 @@
* \param slen Length of subclass buffer
* \param moreinfo Buffer to fill with additional information
* \param mlen Length of moreinfo buffer
+ * \return Pointer to subclass
* \since 11
*/
-void ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen);
+char *ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen);
/*!
* \brief Copy the discription of a frame type into the provided string
@@ -645,9 +646,10 @@
* \param frame_type The frame type to be described
* \param ftype Buffer to fill with frame type description
* \param len Length of subclass buffer
+ * \return Pointer to ftype
* \since 11
*/
-void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len);
+char *ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len);
#if defined(__cplusplus) || defined(c_plusplus)
}
diff --git a/main/frame.c b/main/frame.c
index 4ae732b..4eeb3b6 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -394,7 +394,7 @@
dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
}
-void ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
+char *ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen)
{
switch(f->frametype) {
case AST_FRAME_DTMF_BEGIN:
@@ -477,6 +477,85 @@
snprintf(subclass, slen, "T38_Parameters/%s", message);
break;
}
+
+ case AST_CONTROL_STREAM_STOP:
+ ast_copy_string(subclass, "Stop stream", slen);
+ break;
+ case AST_CONTROL_STREAM_SUSPEND:
+ ast_copy_string(subclass, "Suspend stream", slen);
+ break;
+ case AST_CONTROL_STREAM_RESTART:
+ ast_copy_string(subclass, "Restart stream", slen);
+ break;
+ case AST_CONTROL_STREAM_REVERSE:
+ ast_copy_string(subclass, "Reverse stream", slen);
+ break;
+ case AST_CONTROL_STREAM_FORWARD:
+ ast_copy_string(subclass, "Forward stream", slen);
+ break;
+ case AST_CONTROL_RECORD_CANCEL:
+ ast_copy_string(subclass, "Cancel stream", slen);
+ break;
+ case AST_CONTROL_RECORD_STOP:
+ ast_copy_string(subclass, "Record stop", slen);
+ break;
+ case AST_CONTROL_RECORD_SUSPEND:
+ ast_copy_string(subclass, "Record suspend", slen);
+ break;
+ case AST_CONTROL_RECORD_MUTE:
+ ast_copy_string(subclass, "Record mute", slen);
+ break;
+ case AST_CONTROL_SRCUPDATE:
+ ast_copy_string(subclass, "Media source update", slen);
+ break;
+ case AST_CONTROL_TRANSFER:
+ ast_copy_string(subclass, "Transfer", slen);
+ break;
+ case AST_CONTROL_CONNECTED_LINE:
+ ast_copy_string(subclass, "Connected line update", slen);
+ break;
+ case AST_CONTROL_REDIRECTING:
+ ast_copy_string(subclass, "Redirect", slen);
+ break;
+ case AST_CONTROL_CC:
+ ast_copy_string(subclass, "CC", slen);
+ break;
+ case AST_CONTROL_SRCCHANGE:
+ ast_copy_string(subclass, "Media SSRC change", slen);
+ break;
+ case AST_CONTROL_READ_ACTION:
+ ast_copy_string(subclass, "Read action", slen);
+ break;
+ case AST_CONTROL_AOC:
+ ast_copy_string(subclass, "AOC", slen);
+ break;
+ case AST_CONTROL_END_OF_Q:
+ ast_copy_string(subclass, "Endof Q", slen);
+ break;
+ case AST_CONTROL_INCOMPLETE:
+ ast_copy_string(subclass, "Incomplete", slen);
+ break;
+ case AST_CONTROL_MCID:
+ ast_copy_string(subclass, "MCID", slen);
+ break;
+ case AST_CONTROL_UPDATE_RTP_PEER:
+ ast_copy_string(subclass, "Update RTP peer", slen);
+ break;
+ case AST_CONTROL_PVT_CAUSE_CODE:
+ ast_copy_string(subclass, "Private Cause Code", slen);
+ break;
+ case AST_CONTROL_MASQUERADE_NOTIFY:
+ ast_copy_string(subclass, "Masquerade notify", slen);
+ break;
+ case AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE:
+ ast_copy_string(subclass, "Stream topology request change", slen);
+ break;
+ case AST_CONTROL_STREAM_TOPOLOGY_CHANGED:
+ ast_copy_string(subclass, "Stream topology changed", slen);
+ break;
+ case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:
+ ast_copy_string(subclass, "Stream topology source changed", slen);
+ break;
case -1:
ast_copy_string(subclass, "Stop generators", slen);
break;
@@ -567,9 +646,11 @@
ast_copy_string(subclass, "Unknown Subclass", slen);
break;
}
+
+ return subclass;
}
-void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
+char *ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
{
switch (frame_type) {
case AST_FRAME_DTMF_BEGIN:
@@ -624,6 +705,8 @@
snprintf(ftype, len, "Unknown Frametype '%u'", frame_type);
break;
}
+
+ return ftype;
}
/*! Dump a frame for debugging purposes */
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14630
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc
Gerrit-Change-Number: 14630
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200706/07519431/attachment-0001.html>
More information about the asterisk-code-review
mailing list