Cherry
Cherry

Reputation: 719

PJSIP Video Call: No video... only blank window is appearing in iOS?

I am trying to add a video call feature in my iOS application using pjsip 2.7.1. I have followed the steps mentioned in this link https://trac.pjsip.org/repos/wiki/Video_Users_Guide

if (pjsua_vid_win_get_info(i, &wi) == PJ_SUCCESS) {

        dispatch_async(dispatch_get_main_queue(), ^{

            UIView* videoView = (__bridge UIView *)wi.hwnd.info.ios.window;                    
                /* Resize it to fit width */
                videoView.bounds = CGRectMake(0, 0, 375,667);
                /* Center it horizontally */
                videoView.center = CGPointMake(375/2.0, 667/2.0);

                NSLog(@"*******  Native Window Called  ******** ");
}

When I make a video call everything seems fine, I didn't find any issues in the logs.

2018-11-01 11:16:11.980945+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.980 pjsua_media.c .....Call 0: updating media..

2018-11-01 11:16:11.981282+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.981 pjsua_media.c .......Media stream call00:0 is destroyed

2018-11-01 11:16:11.981801+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.981 pjsua_aud.c ......Audio channel update..

2018-11-01 11:16:11.982020+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.981 strm0x14c817228 .......VAD temporarily disabled

2018-11-01 11:16:11.983647+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.983 strm0x14c817228 .......Encoder stream started

2018-11-01 11:16:11.994218+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.994 strm0x14c817228 .......Decoder stream started

2018-11-01 11:16:11.995006+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.994 pjsua_media.c ......Audio updated, stream #0: PCMU (sendrecv)

2018-11-01 11:16:11.995355+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.995 pjsua_media.c .......Media stream call00:1 is destroyed

2018-11-01 11:16:11.995506+0400 SwiftVoiceCallingApp[730:49599] 11:16:11.995 pjsua_vid.c ......Video channel update..

2018-11-01 11:16:12.021673+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.021 vstenc0x14c813e28 .......Encoder stream started

2018-11-01 11:16:12.022508+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.022 vstdec0x14c813e28 .......Decoder stream started

2018-11-01 11:16:12.023527+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.023 pjsua_vid.c .......Setting up RX..

2018-11-01 11:16:12.024107+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.024 pjsua_vid.c ........Creating video window: type=stream, cap_id=-1, rend_id=0

2018-11-01 11:16:12.024864+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.024 vid_port.c .........Opening device OpenGL renderer [OpenGL] for render: format=I420, size=656x656 @22:1 fps

2018-11-01 11:16:12.153215+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 ios_opengl_dev.c .........iOS OpenGL ES renderer successfully created

2018-11-01 11:16:12.153426+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 vid_port.c .........Device OpenGL renderer [OpenGL] opened: format=BGRA, size=656x656 @22:1 fps

2018-11-01 11:16:12.153551+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 pjsua_vid.c .........stream window id 0 created for cap_dev=-1 rend_dev=0

2018-11-01 11:16:12.153590+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 pjsua_vid.c .........Window 0 created

2018-11-01 11:16:12.153629+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 ios_opengl_dev.c ........Starting ios opengl stream

2018-11-01 11:16:12.153758+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 pjsua_vid.c .......Setting up TX..

2018-11-01 11:16:12.153805+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.153 pjsua_vid.c ........Creating video window: type=preview, cap_id=2, rend_id=0

2018-11-01 11:16:12.155163+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.155 vid_port.c .........Opening device Front Camera [AVF] for capture: format=I420, size=352x288 @15:1 fps

2018-11-01 11:16:12.175070+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.175 vid_port.c .........Device Front Camera [AVF] opened: format=I420, size=352x288 @15:1 fps

2018-11-01 11:16:12.179564+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.179 darwin_dev.m .........Native preview initialized

2018-11-01 11:16:12.179708+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.179 pjsua_vid.c .........Preview window id 1 created for cap_dev 2, using built-in preview!

2018-11-01 11:16:12.179743+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.179 pjsua_vid.c .........Window 1 created

2018-11-01 11:16:12.179818+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.179 darwin_dev.m ........Starting Darwin video stream

2018-11-01 11:16:12.560349+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.560 pjsua_media.c ......Video updated, stream #1: H264 (sendrecv)

2018-11-01 11:16:12.560565+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.560 pjsua_aud.c .....Conf connect: 2 --> 0

2018-11-01 11:16:12.560631+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.560 conference.c ......Port 2 (sip:[email protected]) transmitting to port 0 (iPhone IO device)

2018-11-01 11:16:12.560680+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.560 pjsua_aud.c .....Conf connect: 0 --> 2

2018-11-01 11:16:12.560729+0400 SwiftVoiceCallingApp[730:49599] 11:16:12.560 conference.c ......Port 0 (iPhone IO device) transmitting to port 2 (sip:[email protected])

2018-11-01 11:16:12.560765+0400 SwiftVoiceCallingApp[730:49599] windows id : 0

2018-11-01 11:16:12.560806+0400 SwiftVoiceCallingApp[730:49599] media id : 1

2018-11-01 11:16:12.560841+0400 SwiftVoiceCallingApp[730:49599] 1. PJSUA_CALL_MEDIA_ACTIVE

2018-11-01 11:16:12.594432+0400 SwiftVoiceCallingApp[730:49349] ******* Native Window Called ********

After Hangup:

2018-11-01 11:16:32.181814+0400 SwiftVoiceCallingApp[730:49599] Outgoing Call status Id is: 200

2018-11-01 11:16:32.187486+0400 SwiftVoiceCallingApp[730:49599] 11:16:32.187 pjsua_media.c ......Call 0: deinitializing media..

2018-11-01 11:16:32.203479+0400 SwiftVoiceCallingApp[730:49599] 11:16:32.203 pjsua_media.c ........Media stream call00:0 is destroyed

2018-11-01 11:16:32.204868+0400 SwiftVoiceCallingApp[730:49599] 11:16:32.204 pjsua_vid.c ........Stopping video stream..

2018-11-01 11:16:32.232410+0400 SwiftVoiceCallingApp[730:49599] 11:16:32.232 darwin_dev.m .........Stopping Darwin video stream

However, I didn't find any video inside my UIView.

 UIView* videoView = (__bridge UIView *)wi.hwnd.info.ios.window;

I just added this videoView as a subview to my ViewController's view

 self.view.addSubView:videoView

I feel above videoView already has Video stream. Am I missing anything else?

Upvotes: 1

Views: 1359

Answers (1)

Nazrul Islam
Nazrul Islam

Reputation: 768

You need to enable video auto show and video transmit while adding account pjsua_acc_add by default its disable.

acc_cfg.vid_in_auto_show = PJ_TRUE;

acc_cfg.vid_out_auto_transmit = PJ_TRUE;

Then use below method to show video preview,

int vid_idx;
pjsua_vid_win_id wid;

vid_idx = pjsua_call_get_vid_stream_idx(*call_id);
if (vid_idx >= 0) {
    pjsua_call_info ci;

    pjsua_call_get_info(*call_id, &ci);
    wid = ci.media[vid_idx].stream.vid.win_in;

    if (wid >= 0) {

        pjsua_vid_win_info wi;
        pj_status_t myStatus;
        myStatus = pjsua_vid_win_get_info(wid, &wi);

        if (myStatus == PJ_SUCCESS) {
            UIView *view = (__bridge UIView *)wi.hwnd.info.ios.window;
        }

    }
}

Happy to help you :)

Upvotes: 2

Related Questions