AndroidGuy
AndroidGuy

Reputation: 23

How to pragmatically set a videoCodec to LinphoneCore in Android?

I am currently Developing a VoIP Android Application, and for VoIP support, I am using an Open source library Linphone.

Currently voice calling is happening, but video calling is not happening. After analyzing for a while, I came to know that by default when the app is loaded, the LinphoneCore library is using the H264 video codec.

But the VOIP Asterik server is configured with the VP8 video codec. I cannot change the video codec, which is configured in the server. Hence due to a codec mismatch, video data is not going.

So how can I set manually the video codec to VP8 from my app to LinphoneCore once the app is loaded?

Upvotes: 2

Views: 834

Answers (1)

Hasif Seyd
Hasif Seyd

Reputation: 1694

To set videoCodec to LinphoneCore, what you can do is , once your LinphoneCore is ready, you can just Retrieve the VideoCodec Payload that it supports and then set a particular payload and disable others as shown below in the code.

private void enableVp8Codec () {
    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
        PayloadType[] lPayLoadArr = lc.getVideoCodecs();
        for (final PayloadType pt : lPayLoadArr) {
            try {
                if (pt.getMime().equals("VP8")) {
                    lc.enablePayloadType(pt, true);
                } else {
                    lc.enablePayloadType(pt, false);
                }
            } catch (LinphoneCoreException e) {
                Log.e("tag",e.getMessage());
            }
        }
    }
}

This method you can probably call in onResume of your Activity

Upvotes: 2

Related Questions