7

I am trying to change the priority of codecs used in pjsip android.
I am able to get the codecs priority but after changing the codecs priority,it is not reflecting back.

if( ep != null)
        {
            try {
                CodecInfoVector codecInfoVector = ep.codecEnum();
                if(!codecInfoVector.isEmpty()){
                    System.out.println("Codecs Enabled!!");
                    System.out.println("Number of codecs enabled now: "+codecInfoVector.size());
                    for(int i=0;i<codecInfoVector.size();i++)
                    {
                        CodecInfo codecInfo = codecInfoVector.get(i);
                        String codecId = codecInfo.getCodecId();
                        short codecPriority = 128;//use higher number for making preferred codec first.
                        short disableCodecPriority = 0;//use 0 to disable codec in sdp
                        System.out.println("Codec info now is: "+ codecId);
                        switch(codecId)
                        {
                            case "PCMA/8000/1":
                                if(Dialer_Properties.enablePCMA)
                                    codecInfo.codecSetPriority("PCMA/8000",codecPriority);
                                else
                                    codecInfo.codecSetPriority("PCMA/8000",disableCodecPriority);
                                break;
                            case "PCMU/8000/1":
                                if(Dialer_Properties.enablePCMU)
                                    codecInfo.codecSetPriority("PCMU/8000",codecPriority);
                                else
                                    codecInfo.codecSetPriority("PCMU/8000",disableCodecPriority);
                                break;
                            case "G729/8000/1":
                                if(Dialer_Properties.enableG729)
                                    codecInfo.codecSetPriority("G729/8000",codecPriority);
                                else
                                    codecInfo.codecSetPriority("G729/8000",disableCodecPriority);
                                break;
                        }

                        System.out.println("Codec Priority now is: "+codecInfo.getPriority());
                    }

                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }


How to fix this issue??

Jeeva
  • 1,791
  • 2
  • 23
  • 42

1 Answers1

2

After changing the priority,i did not update the codecInfoVector with updated values.
As a result the values was not reflected.

PJSIP provides a method in endpoint java class.
After updating the particular code,i could the see the updated priority codecs in SDP.

ep.codecSetPriority("PCMA/8000",codecPriority);

where ep is endpoint instance object.

Jeeva
  • 1,791
  • 2
  • 23
  • 42
  • How to update codecInfoVector after setting codec priority ? – Himadri Jun 20 '19 at 07:14
  • @Himadri i used endpoint instance to set codec priority which helped to update the codecInfoVector before i used codecinfo only so it was not reflected – Jeeva Jun 20 '19 at 08:48
  • I also doing the same. used endpoint instance to set codec priority and found that codec priority not applied – Himadri Jun 20 '19 at 09:56
  • @Himadri bro then please post your code and ask it as separate question – Jeeva Jun 20 '19 at 09:57