1

I am implementing SIP Video Call using Pjsip library.

My view is successfully transmitted to other person but what I want is to display my camera view in my screen(Something like WhatsApp).

I found that Pjsip is using camera to transmit view. How can I display my Camera View in a SurfaceView using Pjsip library(as I can not use multiple instances of Camera)?

I have already tried this using the following code:

fun updateVideoPreview(holder: SurfaceHolder) {
if (SipManager.getInstance()?.activeCalls?.get(callId) != null &&
        SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoWindow != null &&
        SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoPreview != null) {
    if (videoPreviewActive) {
        val vidWH = VideoWindowHandle()
        vidWH.handle?.setWindow(holder.surface)
        val vidPrevParam = VideoPreviewOpParam()
        vidPrevParam.window = vidWH
        vidPrevParam.show = true
        try {
            SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoPreview?.start(vidPrevParam)
        } catch (e: Exception) {
            println(e)
        }
    } else {
        try {
            SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoPreview?.stop()
        } catch (e: Exception) {
            println(e)
        }
    }
}

}

When I executed this code what I found is the preview that is transmitted to other side(mirror effect) but what I want is my own view.

Can anyone help me with this?

Aanal Shah
  • 1,946
  • 2
  • 20
  • 30

1 Answers1

0

I did this: - Replaced SurfaceView with TextureView and

if (isFrontCamera) {
    val matrix = Matrix()
    matrix.setScale(-1.0f, 1.0f)
    matrix.postTranslate(width.toFloat(), 0.0f)
    surfacePreviewCapture.setTransform(matrix)
}

It worked for me. Hope it help others.

Aanal Shah
  • 1,946
  • 2
  • 20
  • 30
  • Yes. But not accurate @SonPham – Aanal Shah Feb 11 '20 at 06:16
  • I have problem when start and stop start transmit media, sometimes my app freeze when changed state. – Son Pham Feb 11 '20 at 06:26
  • How can i contact with you? (Skype or Messager) – Son Pham Feb 11 '20 at 06:47
  • Can you share some pjmedia_video_format_detail @Aanal Mehta. This is my config cp.enc_fmt.det.vid.size.w = 720; cp.enc_fmt.det.vid.size.h = 1280; cp.enc_fmt.det.vid.avg_bps = 500*1000; cp.enc_fmt.det.vid.max_bps = 1024*2*1000; cp.enc_fmt.det.vid.fps.num = 30; cp.enc_fmt.det.vid.fps.denum = 1; – Son Pham Feb 14 '20 at 03:06
  • Aanal Mehta can you help me – Son Pham Mar 20 '20 at 05:02
  • 1
    @SonPham Here is my Video Codec format /*Set Video Codecs*/ val param = ep?.getVideoCodecParam("H264") val encFormatVideo = param?.encFmt val decFormatVideo = param?.decFmt encFormatVideo?.height = 320 encFormatVideo?.width = 240 decFormatVideo?.height = 320 decFormatVideo?.width = 240 param?.encFmt = encFormatVideo param?.decFmt = decFormatVideo ep?.setVideoCodecParam("H264", param) – Aanal Shah Mar 20 '20 at 05:58