Redturbo
Redturbo

Reputation: 1613

Force using just OPUS codec in Linphone Android

How can I force to use just Opus Codec in linphone ? Is there a setting in LinphoneManager.java, or somewhere else (like in LinphoneCore) to change codec setting ?

I found this code in LinphoneManager.java :

enableDisableAudioCodec("speex", 32000, 1, false);
enableDisableAudioCodec("speex", 16000, 1, false);
enableDisableAudioCodec("speex", 8000, 1, true);
enableDisableAudioCodec("iLBC", 8000, 1, false);
enableDisableAudioCodec("G722", 8000, 1, false);
enableDisableAudioCodec("G729", 8000, 1, false);
enableDisableAudioCodec("AMR", 8000, 1, false);
enableDisableAudioCodec("AMR-WB", 16000, 1, false);
enableDisableAudioCodec("SILK", 8000, 1, true);

can I Just delete that code and just put this :

enableDisableAudioCodec("OPUS", 8000, 1, true);

Upvotes: 2

Views: 2304

Answers (1)

MrReboot
MrReboot

Reputation: 263

You can use a function like this:

private void enableJustOneAudioCodec(String codecName) {
    for (PayloadType pt : LinphoneManager.getLc().getAudioCodecs()) {
        try {
            if (pt.getMime().equals(codecName)) {
                LinphoneManager.getLc().enablePayloadType(pt, true);
            } else {
                LinphoneManager.getLc().enablePayloadType(pt, false);
            }
        } catch (LinphoneCoreException ex) {
            Log.w(ex,"Unable to modify status for codec " + pt.getMime());
        }
    }
}

And then:

enableJustOneAudioCodec("OPUS")

You can also enable OPUS in linphonerc file:

[audio_codec_0]

mime=OPUS
rate=8000
enabled=1

but you must explicitly disable the other codecs.

Upvotes: 2

Related Questions