Opus Audio codec with pjsip not working on android

TM
Tailor, Mayur
Fri, Aug 4, 2017 5:52 AM

Hi,

I have applied opus codec in my android app with pjsip.

below are the steps, please correct me if i am doing wrong:-

  1. build openh264 lib

  2. build opus using *https://trac.pjsip.org/repos/ticket/1904
    https://trac.pjsip.org/repos/ticket/1904 *ticket which create libopus.so

  3. build pjsip using openh264 and upus using ./configure-android
    --use-ndk-cflags --with-opus=[absolute-path-to]/opus-dev-lib
    *--with-openh264=/Users/me/openh264/android
    *command which works currectly.

now i put all 3 .so files(open264.so, opus.so and pjsua2.so) into android
project.

add following code in android to set opus code.

try {
CodecInfoVector codecs = ep.codecEnum();
String str =  codecs.size() + "";
if (codecs == null || codecs.size() == 0) {
Log.v(TAG, "CodecInfoVector size " + str);
}

for(int i = 0; i < codecs.size(); i++) {
    CodecInfo codecInfo = codecs.get(i);
    if(codecInfo.getCodecId().contains("opus")) {
        short maxPriority = 255;
        codecInfo.setPriority(maxPriority);

        ep.codecSetPriority(codecInfo.getCodecId(), maxPriority);
    }
    String id = codecInfo.getCodecId();
    long p = codecInfo.getPriority();

    Log.v(TAG, "CodecId->" + id);
    Log.v(TAG, "CodecPriority->" + p);
}
CodecInfoVector codecs2 = ep.codecEnum();
String newCodecId = codecs2.get(0).getCodecId();
Log.v(TAG, "NewCodecId" + newCodecId);

} catch (Exception exc) {
Log.e(TAG, "Error while CodecInfoVector", exc);
}

Logcat

08-04 10:55:44.853 21214-21214/: CodecId->speex/16000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->130
08-04 10:55:44.853 21214-21214/: CodecId->speex/8000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->129
08-04 10:55:44.853 21214-21214/: CodecId->speex/32000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->iLBC/8000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->GSM/8000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->PCMU/8000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->PCMA/8000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->G722/16000/1
08-04 10:55:44.853 21214-21214/: CodecPriority->128
08-04 10:55:44.853 21214-21214/: CodecId->opus/48000/2
08-04 10:55:44.853 21214-21214/: CodecPriority->255
08-04 10:55:44.853 21214-21214/: NewCodecIdopus/48000/2

my astrisk server version is 13.

audio output on android loudspeaker is same as without setting upus audio
codec.

I am not able to find out reason please help

Regards
Mayur Tailor

--


DISCLAIMER:This e-mail and any attachment(s) transmitted with it are
intended solely for the use of the intended recipient(s) and may contain
confidential and privileged information. If you are not the named
addressee, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete it from your system. Any views or opinions
expressed are solely those of the sender and do not necessarily represent
those of Pratham Software or its affiliates or group companies, unless
sender does so with due authority from Pratham Software. Electronic
Correspondence cannot be guaranteed to be secure, timely or error free.
This is subject to change without notice and is intended only for
employees, Licensees and/or affiliates. We do not take responsibility for
acting on time-sensitive instructions sent by email. Any form of
reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail and attachments, if any,
and/or any action taken in reliance of this e-mail, without the prior
written consent of the sender is strictly prohibited. The recipient should
check this e-mail and attachment(s), if any, for the presence of viruses
and/or defects. Pratham Software accepts no liability for any damage caused
by any virus and/or defects transmitted by this email.

Hi, I have applied opus codec in my android app with pjsip. below are the steps, please correct me if i am doing wrong:- 1) build openh264 lib 2) build opus using *https://trac.pjsip.org/repos/ticket/1904 <https://trac.pjsip.org/repos/ticket/1904> *ticket which create *libopus.so* 3) build pjsip using openh264 and upus using ./configure-android --use-ndk-cflags --with-opus=[absolute-path-to]/opus-dev-lib *--with-openh264=/Users/me/openh264/android *command which works currectly. now i put all 3 .so files(open264.so, opus.so and pjsua2.so) into android project. add following code in android to set opus code. try { CodecInfoVector codecs = ep.codecEnum(); String str = codecs.size() + ""; if (codecs == null || codecs.size() == 0) { Log.v(TAG, "CodecInfoVector size " + str); } for(int i = 0; i < codecs.size(); i++) { CodecInfo codecInfo = codecs.get(i); if(codecInfo.getCodecId().contains("opus")) { short maxPriority = 255; codecInfo.setPriority(maxPriority); ep.codecSetPriority(codecInfo.getCodecId(), maxPriority); } String id = codecInfo.getCodecId(); long p = codecInfo.getPriority(); Log.v(TAG, "CodecId->" + id); Log.v(TAG, "CodecPriority->" + p); } CodecInfoVector codecs2 = ep.codecEnum(); String newCodecId = codecs2.get(0).getCodecId(); Log.v(TAG, "NewCodecId" + newCodecId); } catch (Exception exc) { Log.e(TAG, "Error while CodecInfoVector", exc); } *Logcat* 08-04 10:55:44.853 21214-21214/: CodecId->speex/16000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->130 08-04 10:55:44.853 21214-21214/: CodecId->speex/8000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->129 08-04 10:55:44.853 21214-21214/: CodecId->speex/32000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->iLBC/8000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->GSM/8000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->PCMU/8000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->PCMA/8000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->G722/16000/1 08-04 10:55:44.853 21214-21214/: CodecPriority->128 08-04 10:55:44.853 21214-21214/: CodecId->opus/48000/2 08-04 10:55:44.853 21214-21214/: CodecPriority->255 08-04 10:55:44.853 21214-21214/: NewCodecIdopus/48000/2 *my astrisk server version is 13.* audio output on android loudspeaker is same as without setting *upus* audio codec. *I am not able to find out reason please help* Regards Mayur Tailor -- ------------------------------ *DISCLAIMER:This e-mail and any attachment(s) transmitted with it are intended solely for the use of the intended recipient(s) and may contain confidential and privileged information. If you are not the named addressee, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete it from your system. Any views or opinions expressed are solely those of the sender and do not necessarily represent those of Pratham Software or its affiliates or group companies, unless sender does so with due authority from Pratham Software. Electronic Correspondence cannot be guaranteed to be secure, timely or error free. This is subject to change without notice and is intended only for employees, Licensees and/or affiliates. We do not take responsibility for acting on time-sensitive instructions sent by email. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail and attachments, if any, and/or any action taken in reliance of this e-mail, without the prior written consent of the sender is strictly prohibited. The recipient should check this e-mail and attachment(s), if any, for the presence of viruses and/or defects. Pratham Software accepts no liability for any damage caused by any virus and/or defects transmitted by this email.*