pjsip pjsua2 샘플 Android 앱의 비디오 품질을 어떻게 향상시킬 수 있습니까?

Dec 22 2020

현재 기본 샘플 Android pjsip pjsua2 샘플 앱은 매우 나쁜 비디오 품질을 전송하며 최소한 Hd 품질로 개선하고자합니다. 아래 방법을 사용해 보았지만 계속해서 매우 낮은 화질을 보여줍니다. 나가는 비디오 품질을 개선하려면 어떻게해야합니까? 이 샘플 앱은 다른 한 모금 영상 통화에서 최대 355 * 288 영상 품질을 수신 할 수 있지만 매우 낮은 영상 품질을 전송합니다. 현재 나는 발신 전화를 걸기 직전에 MediaFormatvideo 파일에서 아래 값을 업데이트하여 HD 비디오를 얻으려고했습니다. 그리고 그것은 나가는 비디오를 개선하는 데 전혀 도움이되지 않습니다. 잘못된 위치에서 해당 속성을 업데이트하고 있습니까?

현재 192 * 144 미만의 비디오 품질을 전송하고 352 * 288 이상의 비디오 품질을 허용하지 않습니다. 최소 1280 * 720 비디오 품질을 지원하도록 업데이트하려면 어떻게해야합니까?

    MediaFormatVideo mf=new MediaFormatVideo();
    mf.setFpsNum(30);
    mf.setFpsDenum(1);
    mf.setAvgBps(512000);
    mf.setMaxBps(1024000);
    mf.setHeight(720);
    mf.setWidth(1280);

나는 그 설정을 아래와 같이 업데이트하고있다.

   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();
}

문서를 찾았고 .. 구현하려고했지만 비디오 품질을 향상시킬 수 없었습니다.

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 */

문서 링크 : 여기에 링크 설명 입력

 From: "0525512904" <sip:[email protected]>;tag=1609930889511
I: To: <sip:[email protected]>;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:[email protected]: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

완전한 로그 링크 모금 통화 완전한 로그

답변

ShanePowell Jan 07 2021 at 03:22

아직 주어진 정보로는 질문에 답할 수 없습니다.

SDP는 SIP 프로토콜 의 페이로드 유형으로 사용됩니다 .

(일부) SIP 로그에서 확인할 수 있습니다.

Content-Type: application/sdp

SDP 는 제안 / 응답 프로토콜입니다.

불완전한 로그 캡처를 감안할 때 SIP INVITE (전체 sip 메시지를 제공하지 않은 것으로 가정)를 제공 했으므로 SDP 프로 코톨 만 제공했습니다. 따라서 제안과 답변을 모두 제공하는 데 필요한 완전한 그림을 얻으십시오.

또한 비디오 인코더 / 디코더 설정 주변에 다른 PJSIP 로깅도 포함하는 것이 좋습니다.

귀하의 제안에서 다음과 같이 말합니다.

m=video 4013 RTP/AVP 97

매개 변수를 사용하여 비디오를 보내거나받을 수 있다는 의미입니다.

a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=42e01e; packetization-mode=1

즉, 90000 (즉, 90kHz)의 샘플 속도로 H264를 송수신 할 수 있습니다.

H264 매개 변수 설정은 다음과 같습니다. a = fmtp : 97 profile-level-id = 42e01e; 패킷 화 모드 = 1

그래서...

profile-level-id=42e01e

https://tools.ietf.org/html/rfc6184

  profile-level-id:
     A base16 [7] (hexadecimal) representation of the following
     three bytes in the sequence parameter set NAL unit is specified
     in [1]: 1) profile_idc, 2) a byte herein referred to as
     profile-iop, composed of the values of constraint_set0_flag,
     constraint_set1_flag, constraint_set2_flag,
     constraint_set3_flag, constraint_set4_flag,
     constraint_set5_flag, and reserved_zero_2bits in bit-
     significance order, starting from the most-significant bit, and
     3) level_idc.  Note that reserved_zero_2bits is required to be
     equal to 0 in [1], but other values for it may be specified in
     the future by ITU-T or ISO/IEC.

profile_idc : 0x42 (66) profile-iop : 0xE0 (이진 11100000) level_idc : 0x1E (30)

https://en.wikipedia.org/wiki/Advanced_Video_Coding

profile_idc : 66

Baseline Profile (BP, 66) 주로 추가 데이터 손실 견고성이 필요한 저비용 애플리케이션에 사용되는이 프로필은 일부 화상 회의 및 모바일 애플리케이션에 사용됩니다. 이 프로필에는 Constrained Baseline Profile에서 지원되는 모든 기능과 손실 견고성 (또는 저 지연 멀티 포인트 비디오 스트림 합성과 같은 다른 목적)에 사용할 수있는 세 가지 추가 기능이 포함됩니다. 이 프로필의 중요성은 2009 년 Constrained Baseline Profile의 정의 이후 다소 희미 해졌습니다. 모든 Constrained Baseline Profile 비트 스트림은 두 프로필이 동일한 프로필 식별자 코드 값을 공유하기 때문에 Baseline Profile 비트 스트림으로 간주됩니다.

profile-iop : 바이너리 11100000

이것은 다음을 의미합니다.

constraint_set0_flag=1 (Constrained Baseline profile)
constraint_set1_flag=1
constraint_set2_flag=1

이 두 값 IDC 및 제약 플래그는 디코더가 지원할 수있는 항목을 기반으로 비디오 인코더를 설정하는 데 사용됩니다.

레벨 : 30 즉 3.0

Level: 3.0 Maximum decoding speed (macroblocks/s): 40,500 Maximum
frame size (macroblocks): 1,620 Maximum video bit rate for video
coding layer (VCL): 10,000 Examples for high resolution @ highest
frame rate (maximum stored frames): 
  352×[email protected] (12) 
  352×[email protected] (10) 
  720×[email protected] (6) 
  720×[email protected] (5)

프로필 수준은 비디오 해상도를 지정하지 않고 최대 프레임 크기 / 비트 전송률을 수동으로 지정합니다. 이러한 구성에 "적합"할 수있는 해상도 / 프레임 속도의 모든 조합이 유효합니다. 이것은 resoulation / framerates 목록이 유효한 것으로 나열되는 곳입니다.

따라서 720x480 @ 30fps 또는 720x576 @ 25fps는 레벨 3.0 프로필을 전송하는 데 유효합니다.

제안이 상대방에게 말하는 것은 다음과 같습니다.

  1. 이 쪽은 제한된 기준 프로필 H264 인코딩 스트림 만 디코딩 할 수 있습니다.
  2. 이 쪽은 최대 레벨 3.0 비트 레이트 (예 : 위의 해상도 / fps 콤보 목록)까지만 디코딩 할 수 있습니다.

이 제안은 장치가 상대방에게 무엇을 보낼 것인지를 알려주지 않습니다. 이것은 상대방이 디코딩 할 수 있다고 말하는 것과 결합 된 로컬 설정에 따라 달라집니다.

PJSIP는 SDP ANSWER를 기반으로 전송되는 내용을 파악하기 위해 설정 및 지원되는 제공 디코딩 (인코더 설정에 대한 PJSIP 로그를 볼 수있는 이유)을 기반으로 전송할 수있는 최상의 해상도 / fps를 "선택"합니다. 제공됨).

동영상이 대칭 일 필요는 없습니다. 즉, 카메라 / 화면 H / W에 따라 전송할 수있는 것과 다른 해상도를 표시 할 수 있습니다.

이는 또한 스트리밍 중에 동적으로 변경되는 해상도 (예 : RTCP 보고서의 네트워크 대역폭 변경에 따라 세로 / 가로 반전 또는 해상도 증가 / 감소)와 같은 사항을 고려하지 않습니다. 이를 조사하는 유일한 방법은 H264 스트림을 캡처하고 디코딩하여 수행중인 작업을 이해하는 것입니다. PJSIP 로그에서도 알려줄 수 있습니다.

최신 정보

pjsip 로깅 출력을 보면 INVITE의 SDP 제안과 200 OK의 대답을 모두 볼 수 있습니다.

I: 11:13:36.176           pjsua_core.c  .RX 1119 bytes Response msg 200/INVITE/cseq=22580 (rdata0x6f73203b18) from TLS 95.128.80.3:5061:
I: SIP/2.0 200 OK
I: To: <sip:[email protected]>;tag=61c5c92f
I: Via: SIP/2.0/TLS 146.4.49.20:49305;received=146.4.49.20;rport=49305;branch=z9hG4bKPjdad60ffa-6072-4c6d-8eb1-4a32ab26443a;alias
I: Record-Route: <sip:95.128.80.5;r2=on;lr=on;did=e8.cc62>,<sip:95.128.80.3:5061;transport=tls;r2=on;lr=on;did=e8.cc62>
I: CSeq: 22580 INVITE
I: Call-ID: 0e7676b2-1ca2-48b2-9696-f7e6dc7e1ec9
I: From: <sip:[email protected]>;tag=0b4094bb-b47e-4132-960c-ac564015efa0
I: Content-Type: application/sdp
I: Contact: <sip:[email protected]:5060;alias=95.128.80.93~5060~1>
I: Content-Length: 535
I: v=0
I: o=- 3819003211 3819003212 IN IP4 95.128.80.5
I: s=pjmedia
I: b=AS:352
I: t=0 0
I: a=X-nat:0
I: m=audio 20918 RTP/AVP 96 120
I: c=IN IP4 95.128.80.5
I: b=TIAS:64000
I: a=rtpmap:96 speex/16000
I: a=rtpmap:120 telephone-event/16000
I: a=fmtp:120 0-16
I: a=ssrc:1254727526 cname:496ca0741b8de59f
I: a=sendrecv
I: a=rtcp:20919
I: m=video 20956 RTP/AVP 97
I: c=IN IP4 95.128.80.5
I: b=TIAS:256000
I: a=rtpmap:97 H264/90000
I: a=fmtp:97 profile-level-id=42e01e; packetization-mode=1
I: a=ssrc:977888024 cname:496ca0741b8de59f
I: a=rtcp-fb:* nack pli
I: a=sendrecv
I: a=rtcp:20957
I: --end msg--

답변에서 오퍼와 동일한 H264 매개 변수로 응답했음을 알 수 있습니다.

I: m=video 20956 RTP/AVP 97
...
I: a=rtpmap:97 H264/90000
I: a=fmtp:97 profile-level-id=42e01e; packetization-mode=1

따라서 최대 H264 레벨 3.0 비트 레이트를 허용합니다.

캡처 장치 (카메라)의 초기화를 보면 다음 로그가 표시됩니다.

I: 11:13:36.270             vid_port.c  .........Opening device OpenGL renderer [OpenGL] for render: format=I420, size=352x288 @15:1 fps

이것은 안드로이드 전면 카메라가 352x288 @ 15fps의 해상도로 열렸 음을 의미합니다.

나는 이것이 당신이 말하는 비디오 품질의 원인이라고 생각합니다.

pjsip의 소스 코드를 보면 지원되는 매개 변수가있는 카메라가 열거됩니다.

지원되는 캡처 해상도 크기는 전송할 수있는 "허용 된"해상도 크기에 따라 축소 된 기본 캡처 해상도 크기에 의해 결정됩니다.

허용되는 크기가 352x288 @ 15보다 크므로 전면 카메라의 Andriod 기본 캡처 해상도 만 352x288 @ 15라고 가정 할 수 있습니다.

전면 카메라 대신 후면 카메라를 사용하여 게터 솔루션이나 더 나은 전면 카메라가있는 다른 Andriod 장치가 있는지 확인할 수 있습니다.

PjSip은 android.hardware.Camera API를 사용하여 카메라 장치에 액세스하고 사용합니다. pjsip이 카메라 장치를 사용하는 방법에 대한 자세한 내용은 PjCameraInfo 및 PjCamera 를 참조하십시오 .