#else
struct amrwb_context *context = NULL;
int encoding, decoding;
- int x, i, argc;
+ int x, i, argc, fmtptmp_pos;
char *argv[10];
char fmtptmp[128];
if (context->enc_modes) {
/* choose the highest mode (bitrate) for high audio quality. */
- for (i = 8; i > -1; i--) {
+ for (i = SWITCH_AMRWB_MODES-2; i > -1; i--) {
if (context->enc_modes & (1 << i)) {
context->enc_mode = (switch_byte_t) i;
break;
}
}
+
+ /* re-create mode-set */
+ fmtptmp_pos = switch_snprintf(fmtptmp, sizeof(fmtptmp), "mode-set=");
+ for (i = 0; SWITCH_AMRWB_MODES-1 > i; ++i) {
+ if (context->enc_modes & (1 << i)) {
+ fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, fmtptmp_pos > strlen("mode-set=") ? ",%d" : "%d", i);
+ }
+ }
+
+ } else {
+ /* use default mode-set */
+ fmtptmp_pos = switch_snprintf(fmtptmp, sizeof(fmtptmp), "mode-set=%d", context->enc_mode);
}
if (globals.adjust_bitrate) {
}
if (!globals.volte) {
- switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
- switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
+ fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d",
+ switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
} else {
- switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d; max-red=0; mode-change-capability=2",
- switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
+ fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d;max-red=0;mode-change-capability=2",
+ switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
}
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);