Current default sample Android pjsip pjsua2 sample app sends very poor video quality and I wish to improve this to atleast HD quality. I have tried using the below methods, but it keep on showing very low video quality. How can I improve outgoing video quality? This sample app is able to receive up to 355 * 288 video quality from other sip video calls, but it sends a very poor video quality.
Currently I have tried to achieve HD video by updating the below values from the MediaFormatvideo file, just before making outgoing call. And it doesnt help at all to improve outgoing video. Am I updating those attributes at the wrong places?
Currently it sending video quality below 192 * 144 and doesnt accept above 352 * 288 video quality. How can I update it to support atleast 1280*720 video quality?
MediaFormatVideo mf=new MediaFormatVideo();
mf.setFpsNum(30);
mf.setFpsDenum(1);
mf.setAvgBps(512000);
mf.setMaxBps(1024000);
mf.setHeight(720);
mf.setWidth(1280);
I am updating those setting as below:
MyCall call = new MyCall(account, -1);
CallOpParam prm = new CallOpParam(true);
AccountVideoConfig avc=new AccountVideoConfig();
MediaFormatVideo mf=new MediaFormatVideo();
Log.e("javan-video",String.valueOf(avc.getAutoShowIncoming()));
Log.e("javan-videofps",String.valueOf(mf.getFpsNum()));
mf.setFpsNum(30);
mf.setFpsDenum(1);
mf.setAvgBps(512000);
mf.setMaxBps(1024000);
mf.setHeight(720);
mf.setWidth(1280);
Log.e("javan-videofps",String.valueOf(mf.getFpsNum()));
try {
call.makeCall("sip:"+dialno+"@peoplefone.ch", prm);
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setSpeakerphoneOn(true);
// startRinging();
} catch (Exception e) {
call.delete();
return;
}
currentCall = call;
showCallActivity();
}
I have found documentation, and based my implementation on that, but I couldn't improve the video quality.
Framerate
Specify number of frames processed per second.
For encoding direction, configured via pjmedia_vid_codec_param.enc_fmt.det.vid.fps, e.g:
/* Sending @30fps */
param.enc_fmt.det.vid.fps.num = 30;
param.enc_fmt.det.vid.fps.denum = 1;
Note:
that there is a possibility that the value will be adjusted to follow remote capability. For example, if remote signals that maximum framerate supported is 10fps and locally the encoding direction framerate is set to 30fps, then 10fps will be used.
limitation: if preview is enabled before call is established, capture device will opened using default framerate of the device, and subsequent calls that use that device will use this framerate regardless of the configured encoding framerate that is set above. Currently the only solution is to disable preview before establishing media and re-enable it once the video media is established.
For decoding direction, two steps are needed:
pjmedia_vid_codec_param.dec_fmt.det.vid.fps should be set to the highest value expected for incoming video framerate.
signalling to remote, configured via codec specific SDP format parameter (fmtp): pjmedia_vid_codec_param.dec_fmtp.
H263-1998, maximum framerate is specified per size/resolution basis, check here for more info.
/* 3000/(1.001*2) fps for CIF */
param.dec_fmtp.param[m].name = pj_str("CIF");
param.dec_fmtp.param[m].val = pj_str("2");
/* 3000/(1.001*1) fps for QCIF */
param.dec_fmtp.param[n].name = pj_str("QCIF");
param.dec_fmtp.param[n].val = pj_str("1");
H264, similar to size/resolution, the framerate is implicitly specified in H264 level (check the standard specification or this) and the H264 level is signalled via H264 SDP fmtp profile-level-id, e.g:
/* Can receive up to 1280×720 @30fps */
param.dec_fmtp.param[n].name = pj_str("profile-level-id");
param.dec_fmtp.param[n].val = pj_str("xxxx1f");
Bitrate
Specify bandwidth requirement for video payloads stream delivery.
This is configurable via pjmedia_vid_codec_param.enc_fmt.det.vid.avg_bps and pjmedia_vid_codec_param.enc_fmt.det.vid.max_bps, e.g:
/* Bitrate range preferred: 512-1024kbps */
param.enc_fmt.det.vid.avg_bps = 512000;
param.enc_fmt.det.vid.max_bps = 1024000;
Notes:
This setting is applicable for encoding and decoding direction, currently there is no way to set asymmetric bitrate. By decoding direction, actually it just means that this setting will be queried when generating bandwidth info for local SDP (see next point).
The bitrate setting of all codecs will be enumerated and the highest value will be signalled in bandwidth info in local SDP (see ticket #1244).
There is a possibility that the encoding bitrate will be adjusted to follow remote bitrate setting, i.e: read from SDP bandwidth info (b=TIAS line) in remote SDP. For example, if remote signals that maximum bitrate is 128kbps and locally the bitrate is set to 512kbps, then 128kbps will be used.
If codec specific bitrate setting signalling (via SDP fmtp) is desired, e.g: MaxBR for H263, application should put the SDP fmtp manually, for example:
/* H263 specific maximum bitrate 512kbps */
param.dec_fmtp.param[n].name = pj_str("MaxBR");
param.dec_fmtp.param[n].val = pj_str("5120"); /* = max_bps / 100 */
Documentation link : enter link description here
From: "0525512904" <sip:0525512904@95.128.80.93>;tag=1609930889511
I: To: <sip:90761330096@95.128.80.5>;tag=c6ce5331-3a35-44c8-bb80-23b6ec664085
I: CSeq: 1 INVITE
I: Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
I: Contact: <sip:90761330096@146.4.49.20:45483;transport=TLS;ob>
I: Supported: replaces, 100rel, timer, norefersub
I: Content-Type: application/sdp
I: Content-Length: 580
I: v=0
I: o=- 3818919690 3818919691 IN IP4 192.168.3.135
I: s=pjmedia
I: b=AS:352
I: t=0 0
I: a=X-nat:0
I: m=audio 4012 RTP/AVP 96 120
I: c=IN IP4 192.168.3.135
I: b=TIAS:64000
I: a=rtcp:4031 IN IP4 192.168.3.135
I: a=sendrecv
I: a=rtpmap:96 speex/16000
I: a=rtpmap:120 telephone-event/16000
I: a=fmtp:120 0-16
I: a=ssrc:1510027056 cname:365aaa4f448493db
I: m=video 4013 RTP/AVP 97
I: c=IN IP4 192.168.3.135
I: b=TIAS:256000
I: a=rtcp:4033 IN IP4 192.168.3.135
I: a=sendrecv
I: a=rtpmap:97 H264/90000
I: a=fmtp:97 profile-level-id=42e01e; packetization-mode=1
I: a=ssrc:1146236185 cname:365aaa4f448493db
I: a=rtcp-fb:* nack pli
I: --end msg--
E: ringing call
Complete log link sip call complete log