[Asterisk-code-review] pjsip/cli commands: pjsip show channelstats shows wrong codec (asterisk[master])

Daniel Journo asteriskteam at digium.com
Sun Mar 5 15:55:03 CST 2017


Daniel Journo has uploaded a new change for review. ( https://gerrit.asterisk.org/5121 )

Change subject: pjsip/cli_commands: pjsip show channelstats shows wrong codec
......................................................................

pjsip/cli_commands: pjsip show channelstats shows wrong codec

* cli_commands.c Fixed CLI output

ASTERISK-26822 #close

Change-Id: I3889ef6a8f6738fc312fab42db5efacd6e452b01
---
M channels/pjsip/cli_commands.c
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/21/5121/1

diff --git a/channels/pjsip/cli_commands.c b/channels/pjsip/cli_commands.c
index 8ea39d1..0dc19d4 100644
--- a/channels/pjsip/cli_commands.c
+++ b/channels/pjsip/cli_commands.c
@@ -344,11 +344,11 @@
 	struct ast_sip_channel_pvt *cpvt = channel ? ast_channel_tech_pvt(channel) : NULL;
 	struct chan_pjsip_pvt *pvt = cpvt ? cpvt->pvt : NULL;
 	struct ast_sip_session_media *media = pvt ? pvt->media[SIP_MEDIA_AUDIO] : NULL;
-	struct ast_rtp_codecs *codecs = media && media->rtp ? ast_rtp_instance_get_codecs(media->rtp) : NULL;
-	struct ast_format *format = codecs ? ast_rtp_codecs_get_payload_format(codecs, 0) : NULL;
+	struct ast_format_cap *format_cap = pvt ? ast_channel_nativeformats(channel) : NULL;
 	struct ast_rtp_instance_stats stats;
 	char *print_name = NULL;
 	char *print_time = alloca(32);
+	struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
 
 	ast_assert(context->output_buffer != NULL);
 
@@ -372,7 +372,7 @@
 			snapshot->bridgeid,
 			print_name,
 			print_time,
-			format ? ast_format_get_name(format) : "",
+			format_cap ? ast_format_cap_get_names(format_cap, &codec_buf) : "",
 			stats.rxcount > 100000 ? stats.rxcount / 1000 : stats.rxcount,
 			stats.rxcount > 100000 ? "K": " ",
 			stats.rxploss > 100000 ? stats.rxploss / 1000 : stats.rxploss,
@@ -389,7 +389,7 @@
 		);
 	}
 
-	ao2_cleanup(format);
+	ao2_cleanup(format_cap);
 	ao2_cleanup(channel);
 
 	return 0;

-- 
To view, visit https://gerrit.asterisk.org/5121
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3889ef6a8f6738fc312fab42db5efacd6e452b01
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Daniel Journo <dan at keshercommunications.com>



More information about the asterisk-code-review mailing list