Merge pull request #976 from dragos-oancea/amrwb-log-session

[mod_amrwb] show the session in debug logs.
This commit is contained in:
Chris Rienzo 2021-02-13 12:06:49 -05:00 committed by GitHub
commit 69c1de9deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -127,7 +127,7 @@ static switch_bool_t switch_amrwb_pack_oa(unsigned char *shift_buf, int n)
return SWITCH_TRUE; return SWITCH_TRUE;
} }
static switch_bool_t switch_amrwb_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text) static switch_bool_t switch_amrwb_info(switch_codec_t *codec, unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
{ {
uint8_t *tocs; uint8_t *tocs;
int framesz, index, not_last_frame, q, ft; int framesz, index, not_last_frame, q, ft;
@ -144,7 +144,7 @@ static switch_bool_t switch_amrwb_info(unsigned char *encoded_buf, int encoded_d
tocs = encoded_buf; tocs = encoded_buf;
index = (tocs[0] >> 3) & 0x0f; index = (tocs[0] >> 3) & 0x0f;
if (index > SWITCH_AMRWB_MODES) { if (index > SWITCH_AMRWB_MODES) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMRWB decoder (OA): Invalid TOC 0x%x\n", index); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "AMRWB decoder (OA): Invalid TOC 0x%x\n", index);
return SWITCH_FALSE; return SWITCH_FALSE;
} }
framesz = switch_amrwb_frame_sizes[index]; framesz = switch_amrwb_frame_sizes[index];
@ -163,16 +163,18 @@ static switch_bool_t switch_amrwb_info(unsigned char *encoded_buf, int encoded_d
ft &= ~(1 << 5); /* Frame Type */ ft &= ~(1 << 5); /* Frame Type */
index = (shift_tocs[0] >> 3) & 0x0f; index = (shift_tocs[0] >> 3) & 0x0f;
if (index > SWITCH_AMRWB_MODES) { if (index > SWITCH_AMRWB_MODES) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMRWB decoder (BE): Invalid TOC 0x%x\n", index); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "AMRWB decoder (BE): Invalid TOC 0x%x\n", index);
return SWITCH_FALSE; return SWITCH_FALSE;
} }
framesz = switch_amrwb_frame_sizes[index]; framesz = switch_amrwb_frame_sizes[index];
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG,
print_text, payload_format ? "OA":"BE", ft, q, not_last_frame); "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMRWB encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n", print_text, payload_format ? "OA":"BE", ft, q, not_last_frame);
print_text, payload_format ? "OA":"BE", framesz, encoded_data_len); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG,
"%s (%s): AMRWB encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
print_text, payload_format ? "OA":"BE", framesz, encoded_data_len);
return SWITCH_TRUE; return SWITCH_TRUE;
} }
@ -371,7 +373,7 @@ static switch_status_t switch_amrwb_encode(switch_codec_t *codec,
} }
if (globals.debug) { if (globals.debug) {
switch_amrwb_info(shift_buf, *encoded_data_len, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, "AMRWB encoder"); switch_amrwb_info(codec, shift_buf, *encoded_data_len, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, "AMRWB encoder");
} }
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -399,7 +401,7 @@ static switch_status_t switch_amrwb_decode(switch_codec_t *codec,
} }
if (globals.debug) { if (globals.debug) {
switch_amrwb_info(buf, encoded_data_len, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, "AMRWB decoder"); switch_amrwb_info(codec, buf, encoded_data_len, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, "AMRWB decoder");
} }
if (switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN)) { if (switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN)) {