javaandroidsippjsua2videocall

How to improve quality video for pjsua2 (pjsip) for android


when working with video calls in android pjsua2 encountered the fact that the video is not rendered and pixels appear when the frame is changed

enter image description here

How to fix this problem. I am using this code to assign parameters to a codec.

codecParam.setEncFmt(
                setCodecParams(
                    codecParam.getEncFmt(), // MediaFormatVideo
                    30, // fpsNum
                    1, // fpsDenum
                    2048000, //AvgBps
                    10192000 // MaxBps
                )
  );


public MediaFormatVideo setCodecParams(
        MediaFormatVideo mediaFormatVideo,
        int fps,
        int fpsDeNum,
        int avgBps,
        int maxBps
    ) {
        mediaFormatVideo.setFpsNum(fps);
        mediaFormatVideo.setFpsDenum(fpsDeNum);
        if (avgBps > 0) {
            mediaFormatVideo.setAvgBps(avgBps);
        }
        if (maxBps > 0) {
            mediaFormatVideo.setMaxBps(maxBps);
        }
        mediaFormatVideo.setWidth(240);
        mediaFormatVideo.setHeight(320);


        return mediaFormatVideo;
    }

Solution

  • I found the answer. For best quality We need set decFmtp for codec param:

    Set profile-level-id value for codec:

    val codecFmtpVector = codecParam.decFmtp
    for (i in codecFmtpVector.indices) {
         if ("profile-level-id" == codecFmtpVector[i].name) {
                 codecFmtpVector[i].setVal("42e01f")
                 break
         }
    }
    codecParam.decFmtp = codecFmtpVector