]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9613: mod_amr: fix AMR mode bitmap ("mode-set" param in remote fmtp)
authorDragos Oancea <droancea@yahoo.com>
Wed, 5 Oct 2016 09:36:23 +0000 (05:36 -0400)
committerDragos Oancea <droancea@yahoo.com>
Wed, 5 Oct 2016 10:31:49 +0000 (06:31 -0400)
src/mod/codecs/mod_amr/mod_amr.c

index b8aeb1635c666846f38c28542feed9fe633624c4..11d75617a22b2325ce5a0548b0c70035f100b8b6 100644 (file)
@@ -275,8 +275,12 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
                        }
                }
 
+               /*init to default if there's no "mode-set" param */
+               context->enc_mode = globals.default_bitrate;
+               /* choose the highest mode (bitrate) for high audio quality from fmtp "mode-set" param */
+               /* Note: mode-set = 0 is a valid mode */
                if (context->enc_modes) {
-                       for (i = 7; i > -1; i++) {
+                       for (i = 7; i > -1; i--) {
                                if (context->enc_modes & (1 << i)) {
                                        context->enc_mode = (switch_byte_t) i;
                                        break;
@@ -284,15 +288,10 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
                        }
                }
 
-               if (!context->enc_mode) {
-                       context->enc_mode = globals.default_bitrate;
-               }
-
                switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0,
                                                context->enc_mode);
                codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
 
-               context->enc_mode = AMR_DEFAULT_BITRATE;
                context->encoder_state = NULL;
                context->decoder_state = NULL;