Force using just OPUS codec in Linphone Android

你说的曾经没有我的故事 提交于 2019-12-11 03:24:11

问题


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);

回答1:


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.



来源:https://stackoverflow.com/questions/31635522/force-using-just-opus-codec-in-linphone-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!