[mod_amr] introduce new cfg setting force-oa to change between OA/BE when originating, show session in debug logs, update configs.
This commit is contained in:
parent
e5277a874b
commit
4734904d2d
|
@ -0,0 +1,22 @@
|
|||
<configuration name="amrwb.conf">
|
||||
<settings>
|
||||
<!-- AMRWB modes (supported bitrates):
|
||||
mode 8 AMR-WB_23.85 23.85 Kbit/s
|
||||
mode 7 AMR-WB_23.05 23.05 Kbit/s
|
||||
mode 7 AMR-WB_19.85 19.85 Kbit/s
|
||||
mode 6 AMR-WB_18.25 18.25 Kbit/s
|
||||
mode 5 AMR-WB_15.85 15.85 Kbit/s
|
||||
mode 4 AMR-WB_14.25 14.25 Kbit/s
|
||||
mode 3 AMR-WB_12.65 12.65 Kbit/s
|
||||
mode 2 AMR-WB_8.85 8.85 Kbit/s
|
||||
mode 1 AMR-WB_6.60 6.60 Kbit/s
|
||||
-->
|
||||
<param name="default-bitrate" value="8"/>
|
||||
<!-- Enable VoLTE specific FMTP -->
|
||||
<param name="volte" value="1"/>
|
||||
<!-- Enable automatic bitrate variation during the call based on RTCP feedback -->
|
||||
<param name="adjust-bitrate" value="0"/>
|
||||
<!-- force OA when originating -->
|
||||
<param name="force-oa" value="0"/>
|
||||
</settings>
|
||||
</configuration>
|
|
@ -15,5 +15,7 @@
|
|||
<param name="volte" value="0"/>
|
||||
<!-- Enable automatic bitrate variation during the call based on RTCP feedback -->
|
||||
<param name="adjust-bitrate" value="0"/>
|
||||
<!-- force OA when originating -->
|
||||
<param name="force-oa" value="0"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
<configuration name="amrwb.conf">
|
||||
<settings>
|
||||
<param name="default-bitrate" value="8"/>
|
||||
<param name="volte" value="1"/>
|
||||
<param name="adjust-bitrate" value="0"/>
|
||||
<settings>
|
||||
<!-- AMRWB modes (supported bitrates):
|
||||
mode 8 AMR-WB_23.85 23.85 Kbit/s
|
||||
mode 7 AMR-WB_23.05 23.05 Kbit/s
|
||||
mode 7 AMR-WB_19.85 19.85 Kbit/s
|
||||
mode 6 AMR-WB_18.25 18.25 Kbit/s
|
||||
mode 5 AMR-WB_15.85 15.85 Kbit/s
|
||||
mode 4 AMR-WB_14.25 14.25 Kbit/s
|
||||
mode 3 AMR-WB_12.65 12.65 Kbit/s
|
||||
mode 2 AMR-WB_8.85 8.85 Kbit/s
|
||||
mode 1 AMR-WB_6.60 6.60 Kbit/s
|
||||
-->
|
||||
<param name="default-bitrate" value="8"/>
|
||||
<!-- Enable VoLTE specific FMTP -->
|
||||
<param name="volte" value="1"/>
|
||||
<!-- Enable automatic bitrate variation during the call based on RTCP feedback -->
|
||||
<param name="adjust-bitrate" value="0"/>
|
||||
<!-- force OA when originating -->
|
||||
<param name="force-oa" value="0"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
|
|
@ -137,6 +137,7 @@ static struct {
|
|||
switch_byte_t volte; /* enable special fmtp for VoLTE compliance */
|
||||
switch_byte_t adjust_bitrate;
|
||||
int debug;
|
||||
switch_byte_t force_oa; /*force OA when originating*/
|
||||
} globals;
|
||||
|
||||
const int switch_amr_frame_sizes[] = {12,13,15,17,19,20,26,31,5,0,0,0,0,0,0,1};
|
||||
|
@ -179,7 +180,7 @@ static switch_bool_t switch_amr_pack_oa(unsigned char *shift_buf, int n)
|
|||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
static switch_bool_t switch_amr_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
|
||||
static switch_bool_t switch_amr_info(switch_codec_t *codec, unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
|
||||
{
|
||||
uint8_t *tocs;
|
||||
int framesz, index, not_last_frame, q, ft;
|
||||
|
@ -196,7 +197,7 @@ static switch_bool_t switch_amr_info(unsigned char *encoded_buf, int encoded_dat
|
|||
tocs = encoded_buf;
|
||||
index = (tocs[0] >> 3) & 0x0f;
|
||||
if (index > SWITCH_AMR_MODES && index != 0xf) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMR decoder (OA): Invalid Table Of Contents (TOC): 0x%x\n", index);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "AMR decoder (OA): Invalid Table Of Contents (TOC): 0x%x\n", index);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
framesz = switch_amr_frame_sizes[index];
|
||||
|
@ -216,15 +217,15 @@ static switch_bool_t switch_amr_info(unsigned char *encoded_buf, int encoded_dat
|
|||
ft &= ~(1 << 5); /* Frame Type */
|
||||
index = (shift_tocs[0] >> 3) & 0x0f;
|
||||
if (index > SWITCH_AMR_MODES && index != 0xf) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMR decoder (BE): Invalid Table Of Contents (TOC): 0x%x\n", index);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "AMR decoder (BE): Invalid Table Of Contents (TOC): 0x%x\n", index);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
framesz = switch_amr_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, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
|
||||
print_text, payload_format ? "OA":"BE", ft, q, not_last_frame);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMR encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "%s (%s): AMR encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
|
||||
print_text, payload_format ? "OA":"BE", framesz, encoded_data_len);
|
||||
|
||||
return SWITCH_TRUE;
|
||||
|
@ -276,8 +277,11 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
|||
* bandwidth-efficient operation is employed."
|
||||
*
|
||||
*/
|
||||
switch_clear_flag(context, AMR_OPT_OCTET_ALIGN);
|
||||
|
||||
if (!globals.force_oa) {
|
||||
switch_clear_flag(context, AMR_OPT_OCTET_ALIGN);
|
||||
} else {
|
||||
switch_set_flag(context, AMR_OPT_OCTET_ALIGN);
|
||||
}
|
||||
if (codec->fmtp_in) {
|
||||
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
for (x = 0; x < argc; x++) {
|
||||
|
@ -452,7 +456,7 @@ static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
|||
}
|
||||
|
||||
if (globals.debug) {
|
||||
switch_amr_info(shift_buf, *encoded_data_len, switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, "AMR encoder");
|
||||
switch_amr_info(codec, shift_buf, *encoded_data_len, switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, "AMR encoder");
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -479,7 +483,7 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
|||
}
|
||||
|
||||
if (globals.debug) {
|
||||
switch_amr_info(buf, encoded_data_len, switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, "AMR decoder");
|
||||
switch_amr_info(codec, buf, encoded_data_len, switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, "AMR decoder");
|
||||
}
|
||||
|
||||
if (switch_test_flag(context, AMR_OPT_OCTET_ALIGN)) {
|
||||
|
@ -643,6 +647,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
|
|||
if (!strcasecmp(var, "adjust-bitrate")) {
|
||||
globals.adjust_bitrate = (switch_byte_t) atoi(val);
|
||||
}
|
||||
if (!strcasecmp(var, "force-oa")) {
|
||||
globals.force_oa = (switch_byte_t) atoi(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue