[Asterisk-code-review] pjsip/cli commands: pjsip show channelstats shows wrong codec (asterisk[14])
Joshua Colp
asteriskteam at digium.com
Fri Mar 10 16:09:54 CST 2017
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5122 )
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, 12 insertions(+), 4 deletions(-)
Approvals:
George Joseph: Looks good to me, approved
Richard Mudgett: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/channels/pjsip/cli_commands.c b/channels/pjsip/cli_commands.c
index 8d99379..1d2fbb9 100644
--- a/channels/pjsip/cli_commands.c
+++ b/channels/pjsip/cli_commands.c
@@ -346,11 +346,10 @@
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_rtp_instance_stats stats;
char *print_name = NULL;
char *print_time = alloca(32);
+ char codec_in_use[7];
ast_assert(context->output_buffer != NULL);
@@ -358,6 +357,16 @@
ast_str_append(&context->output_buffer, 0, " %s not valid\n", snapshot->name);
ao2_cleanup(channel);
return -1;
+ }
+
+ codec_in_use[0] = '\0';
+
+ if (channel) {
+ ast_channel_lock(channel);
+ if (ast_channel_rawreadformat(channel)) {
+ ast_copy_string(codec_in_use, ast_format_get_name(ast_channel_rawreadformat(channel)), sizeof(codec_in_use));
+ }
+ ast_channel_unlock(channel);
}
print_name = ast_strdupa(snapshot->name);
@@ -374,7 +383,7 @@
snapshot->bridgeid,
print_name,
print_time,
- format ? ast_format_get_name(format) : "",
+ codec_in_use,
stats.rxcount > 100000 ? stats.rxcount / 1000 : stats.rxcount,
stats.rxcount > 100000 ? "K": " ",
stats.rxploss > 100000 ? stats.rxploss / 1000 : stats.rxploss,
@@ -391,7 +400,6 @@
);
}
- ao2_cleanup(format);
ao2_cleanup(channel);
return 0;
--
To view, visit https://gerrit.asterisk.org/5122
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3889ef6a8f6738fc312fab42db5efacd6e452b01
Gerrit-PatchSet: 7
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Daniel Journo <dan at keshercommunications.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list