Skip to content
Snippets Groups Projects
Commit 018e0154 authored by Joshua Colp's avatar Joshua Colp Committed by Gerrit Code Review
Browse files

Merge "pjsip/cli_commands: pjsip show channelstats shows wrong codec"

parents 87aaaef8 36fed726
No related branches found
No related tags found
No related merge requests found
...@@ -344,11 +344,10 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags) ...@@ -344,11 +344,10 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags)
struct ast_sip_channel_pvt *cpvt = channel ? ast_channel_tech_pvt(channel) : NULL; struct ast_sip_channel_pvt *cpvt = channel ? ast_channel_tech_pvt(channel) : NULL;
struct chan_pjsip_pvt *pvt = cpvt ? cpvt->pvt : 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_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; struct ast_rtp_instance_stats stats;
char *print_name = NULL; char *print_name = NULL;
char *print_time = alloca(32); char *print_time = alloca(32);
char codec_in_use[7];
ast_assert(context->output_buffer != NULL); ast_assert(context->output_buffer != NULL);
...@@ -358,6 +357,16 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags) ...@@ -358,6 +357,16 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags)
return -1; 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); print_name = ast_strdupa(snapshot->name);
/* Skip the PJSIP/. We know what channel type it is and we need the space. */ /* Skip the PJSIP/. We know what channel type it is and we need the space. */
print_name += 6; print_name += 6;
...@@ -372,7 +381,7 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags) ...@@ -372,7 +381,7 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags)
snapshot->bridgeid, snapshot->bridgeid,
print_name, print_name,
print_time, print_time,
format ? ast_format_get_name(format) : "", codec_in_use,
stats.rxcount > 100000 ? stats.rxcount / 1000 : stats.rxcount, stats.rxcount > 100000 ? stats.rxcount / 1000 : stats.rxcount,
stats.rxcount > 100000 ? "K": " ", stats.rxcount > 100000 ? "K": " ",
stats.rxploss > 100000 ? stats.rxploss / 1000 : stats.rxploss, stats.rxploss > 100000 ? stats.rxploss / 1000 : stats.rxploss,
...@@ -389,7 +398,6 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags) ...@@ -389,7 +398,6 @@ static int cli_channelstats_print_body(void *obj, void *arg, int flags)
); );
} }
ao2_cleanup(format);
ao2_cleanup(channel); ao2_cleanup(channel);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment