PJSIP : Video Call In Background - ios

I am working on PJSIP. Two ways Video and Audio call are working fine but the issue is when app is in background and I made a new Incoming call, The callKit is showing new incoming call and I picked up the call. Then app moves from background to foreground but video is not showing and audio is working at that time. If I made a call in foreground then video is showing at both end.
Please find below the logs :
15:48:19.251 ios_opengl_dev .......Failed to initialize iOS OpenGL because we are in background
15:48:19.251 vid_port.c .......Closing OpenGL renderer..
15:48:19.319 pjsua_vid.c .......Window 0: destroying..
15:48:19.319 pjsua_media.c ....pjsua_vid_channel_update() failed for call_id 0 media 1: video subsystem not initialized (PJMEDIA_EVID_INIT)
15:48:19.319 pjsua_media.c ....Error updating media call00:1: video subsystem not initialized (PJMEDIA_EVID_INIT)
15:48:19.319 pjsua_app.c ...Call 0 media 0 [type=audio], status is Active
15:48:19.319 pjsua_aud.c ...Conf connect: 3 --> 0
15:48:19.319 pjsua_app.c ....Turning sound device ON
15:48:19.319 conference.c ....Port 3 (sip:linchpin#192.168.1.7) transmitting to port 0 (Master/sound)
15:48:19.319 pjsua_aud.c ...Conf connect: 0 --> 3
15:48:19.319 conference.c ....Port 0 (Master/sound) transmitting to port 3 (sip:linchpin#192.168.1.7)
15:48:19.319 pjsua_app.c ...Call 0 media 1 [type=video], status is Error
15:48:19.319 pjsua_app.c ...Just rejected incoming video offer on call 0, use "vid call enable 1" or "vid call add" to enable video!

Add some delay in answering the call it will work as sometimes PJSIP is taking time to initiate the camera.

Related

App is getting crash on accepting incoming video call with PJSIP

App is getting hang after accepting incoming video call with PJSIP.
I have already answered call with 180 (Ringing state) and then accept call with code 200 but at that time my app is getting hang
Getting such logs:
2019-09-05 17:23:24.914108+0530 Codec name is Video Toolbox codec
2019-09-05 17:23:24.914226+0530 MTU VALUE for codec #0 is 1336
2019-09-05 17:23:24.914265+0530 FrameSize for codec #0 is w:1280 h:720
2019-09-05 17:23:24.914297+0530 FPS for codec #0 is 15/1
2019-09-05 17:23:24.914327+0530 BandWidth VALUE for codec #0 is avg:256000 max:256000
video available: 117:23:24.914 pjsua_call.c !Answering call 0: code=200
17:23:24.914 inv0x116850aa8 ..SDP negotiation done: Success
17:23:24.914 pjsua_media.c ...Call 0: updating media..
17:23:24.915 pjsua_media.c .....Media stream call00:0 is destroyed
17:23:24.915 pjsua_aud.c ....Audio channel update..
17:23:24.915 strm0x1169ef828 .....VAD temporarily disabled
17:23:24.917 strm0x1169ef828 .....Encoder stream started
17:23:24.917 strm0x1169ef828 .....Decoder stream started
17:23:24.920 pjsua_media.c ....Audio updated, stream #0: PCMU (sendrecv)
17:23:24.921 pjsua_media.c .....Media stream call00:1 is destroyed
17:23:24.921 pjsua_vid.c ....Video channel update..
17:23:25.011 vstenc0x1169f3428 .....Encoder stream started
17:23:25.011 vstdec0x1169f3428 .....Decoder stream started
17:23:25.011 pjsua_vid.c .....Setting up RX..
17:23:25.011 pjsua_vid.c ......Creating video window: type=stream, cap_id=-1, rend_id=0
17:23:25.011 vid_port.c .......Opening device OpenGL renderer [OpenGL] for render: format=I420, size=1280x720 #22:1 fps
17:23:25.237 ios_opengl_dev.c .......iOS OpenGL ES renderer successfully created
17:23:25.237 vid_port.c .......Device OpenGL renderer [OpenGL] opened: format=BGRA, size=1280x720 #22:1 fps
17:23:25.242 vid_conf.c .......Added port 0 (OpenGL renderer)
17:23:25.242 pjsua_vid.c .......stream window id 0 created for cap_dev=-1 rend_dev=0
17:23:25.242 pjsua_vid.c .......Window 0 created
17:23:25.246 vid_conf.c ......Added port 1 (vstdec0x1169f3428)
17:23:25.246 vid_conf.c ......Port 1 (vstdec0x1169f3428) transmitting to port 0 (OpenGL renderer)
17:23:25.246 ios_opengl_dev.c ......Starting ios opengl stream
17:23:25.249 pjsua_vid.c .....Setting up TX..
17:23:25.250 vid_conf.c ......Added port 2 (vstenc0x1169f3428)
17:23:25.250 pjsua_vid.c ......Creating video window: type=preview, cap_id=2, rend_id=0
17:23:25.250 vid_port.c .......Opening device Front Camera [AVF] for capture: format=I420, size=1280x720 #15:1 fps
17:23:25.332 vid_port.c .......Device Front Camera [AVF] opened: format=I420, size=1280x720 #15:1 fps
I have same problem with iOS platform. If you using pjsua_call_answer2, you could replace 180 (PJSIP_SC_RINGING) to 183 (PJSIP_SC_PROGRESS). It work fine with "out_auto_transmit = true"

Stop sound in AVAudioPlayer and shown AQDefaultDevice (173): skipping input stream Error Logs

I have used AVAudioPlayer and set the numberofloop to -1 because I want to play the audio in an infinite loop. At first it works well, but in the middle of playing sound track, I got the following error log continuously and my sound track was stopped.
2017-02-22 10:08:28.863041 TestBridgingHeader[1092:30476] [aqme] 255: AQDefaultDevice (173): skipping input stream 0 0 0x0
I am using two media players to get fade in fade out sound. I played these two media players using blocks:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{});
Why does my sound track stop and why does it show AQDefaultDevice error logs?
This is a bug in Xcode 8.
You can resolve it with these steps:
Select Product --> Scheme--> Edit Scheme.
Select Arguments.
Add OS_ACTIVITY_MODE setup "disable" to Environment Variables.

iOS: RTSP Stream in background

I'm developing an iOS app to play a RTSP Stream (with two tracks, one audio and one for video), and i'm using libVLC to do it.
Playing the video or only audio (adding the option "--no-video") works perfectly. If i start the player with only audio and then enter background the player keeps playing the stream.
The problem i'm having is that if i enter background when video is playing, i want to stop the video and start a new libVLC player with only audio. In that scenario i get this error message:
ERROR: [0x48e2000] >aurioc> 783: failed: '!int' (enable 2, outf< 2 ch, 48000 Hz, Float32, inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
[1973b5e4] audiounit_ios audio output error: failed to init AudioUnit (560557684)
[1973b5e4] audiounit_ios audio output error: opening AudioUnit output failed
[1973b5e4] core audio output error: module not functional
[17a27e74] core decoder error: failed to create audio output
The code in my appDelegate:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"applicationDidEnterBackground");
if(_playerController!=NULL){
[_playerController performSelector:#selector(goToBackground) withObject:nil afterDelay:1];
_playerController=NULL;
}
}
And in my uiViewController:
-(void)close:(BOOL)enterBackground
{
[_mediaPlayer stop];
NSArray* options = #[[NSString stringWithFormat:#"--no-video"]];
_mediaPlayer = [[VLCMediaPlayer alloc] initWithOptions:options];
_mediaPlayer.delegate = self;
_mediaPlayer.drawable = _videoView;
_mediaPlayer.media = [VLCMedia mediaWithURL:[NSURL URLWithString:url]];
[_mediaPlayer play];
}
Am i doing anything wrong?
yes, don't stop the video and start a new player. Just disable video decoding on the existing player and re-enable it once your app is in the foreground again. This is way more efficient, elegant and faster. Additionally, you won't run into this audio session locking issue.
How is VLC for iOS doing this? When the app is on the way to the background, we store the current video track's ID, which can be "1" but also something entirely else depending on the played stream, in a variable next to the media player object. Then, we we switch the media player's video track to "-1", which is the value for "off" in any case. Video decoding stops. Once the app moves to the foreground again, the media player's video track is set to the cached track ID again and video decoding starts again.

iOS - When starting a recording, the bluetooth device thinks I'm making a phone call

I have a recording app. I'm running into a problem that when I open my app and the phone is paired to a bluetooth device, as soon as I start recording, the bluetooth device thinks I'm starting a phone call. It makes an outgoing call sound, and displays on the screen "ON CALL" (always talking about the BT device), but no actual call is being made of course.
This is how I'm currently initializing my session:
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone
error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:AVAudioSessionCategoryOptionMixWithOthers |
AVAudioSessionCategoryOptionAllowBluetooth
error: nil];
I tried it on 2 different bluetooth devices and similar outcomes happen on the same. Both try to establish a phone call.
After looking at BlueTooth logs, I found some clue as to what it is doing:
12:24:07.185 A2DPClient.cpp:390 StopStreaming A2DP Notice Stopping A2DP audio streaming
12:24:07.186 A2DPClient.cpp:415 StopStreaming A2DP Notice Sending 'A2DP audio disconnected' event for device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.201 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable Handsfree Notice HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 2
12:24:07.203 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable Handsfree Notice HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 4
12:24:07.203 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable Handsfree Notice HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 1
12:24:07.203 HandsfreeGateway.cpp:699 createVisualVoicemai Handsfree Notice Setting up virtual call
12:24:07.205 AudioSendThread.cpp:91 run Audio Notice AudioSendThread stopping
12:24:07.207 HandsfreeGateway.cpp:1540 initiateScoConnectio Handsfree Notice Initiating SCO connection with delay of 20 milliseconds
12:24:07.207 HandsfreeGateway.cpp:3179 handleUpdateCallStat Handsfree Notice Updating call status for call(s): [ [#1: Outgoing to +XXXXXXXXXXXXX "My Number" (voicemail)] ]
12:24:07.207 HandsfreeGateway.cpp:1523 delayScoConnection Handsfree Notice Delaying SCO connection by 20 milliseconds
12:24:07.208 HandsfreeGateway.cpp:3183 handleUpdateCallStat Handsfree Notice callPresent: no, callState: 1, callSetup: outgoing, heldStatus: none, heldChanged: no, visualVoicemail: yes
12:24:07.208 HandsfreeGateway.cpp:2871 tellEveryOneAboutVVM Handsfree Notice Sending call setup "outgoing" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.208 HandsfreeGateway.cpp:2877 tellEveryOneAboutVVM Handsfree Notice Sending call status "call active" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.208 HandsfreeGateway.cpp:2760 operator() Handsfree Notice Sending call setup "none" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.229 HandsfreeGateway.cpp:1626 internalConnectAudio Handsfree Notice Making outgoing audio connection to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.457 HandsfreeGateway.cpp:1161 audioEvent Handsfree Notice Received audio connected event for device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.471 A2DPClient.cpp:1384 SuspendCfm A2DP Notice Successfully suspended stream to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:25:36.959 LeObserver.cpp:904 scanTimer Discovery Notice Session "wirelessproxd-central-35-1" is now at scan level 3
12:25:59.599 HandsfreeAudioPlugIn.cpp:1050 audioPauseNotificati Handsfree Notice HandsfreeGateway::audioPauseNotification
12:25:59.599 HandsfreeGateway.cpp:726 deleteVisualVoicemai Handsfree Notice Cleaning up virtual call
12:25:59.599 HandsfreeGateway.cpp:1567 internalDisconnectAu Handsfree Notice Disconnecting audio from device 00:19:B5:FE:05:9B "VW_RADIO_55"
What is that Setting up virtual call??? The only thing I'm doing in code at that point is
[self.audioRecorder record];
self.audioRecorder is an instance of AVAudioRecorder of course.
How can I prevent this?
Change your AVAudioSession options whenever you want to start recording and do not allow Bluetooth:
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone
error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error: nil];
[self.audioRecorder record];
Once finished the recording, on the delegate call of the AVAudioRecorder instance:
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
Set up back your AVAudioSession options to allow Bluetooth AVAudioSessionCategoryOptionAllowBluetooth this way the AVAudioSession will not assume the recording input should be handled as Voice Call from the connected BT device.

PJSIP error pjsua_call_media_init

I had compiled the code from this link, also I am able to successfully register a account on sip server. But when I make a sip call then it gives a trap error in pjsua_call_media_init.
I need help to understand the reason for error mentioned below.
--end msg--
14:51:34.422 pjsua_acc.c ....SIP outbound status for acc 0 is not active
14:51:34.422 pjsua_acc.c ....sip:ssssingh#sip.antisip.com: registration success, status=200 (OK), will re-register in 300 seconds
14:51:34.422 pjsua_acc.c ....Keep-alive timer started for acc 0, destination:91.121.81.212:5060, interval:15s
2013-07-04 14:51:34.423 GossipExample[1049:4603] Gossip: dispatchRegistrationState(0)
2013-07-04 14:51:46.651 GossipExample[1049:907] Gossip: ringbackWithSoundNamed: /var/mobile/Applications/1B440F28-7F74-46D5-A120-9C0B3C35AD65/GossipExample.app/ringtone.wav
14:51:46.653 pjsua_aud.c !Creating playlist with 1 file(s)..
14:51:46.655 wav_playlist.c .WAV playlist 'WAV playlist' created: samp.rate=44100, ch=2, bufsize=4KB
14:51:46.657 pjsua_aud.c .Playlist created, id=0, slot=1
14:51:47.708 pjsua_call.c Making call with acc #0 to sip:chakrit2#getonsip.com
14:51:47.710 pjsua_aud.c .Set sound device: capture=-1, playback=-2
14:51:47.711 pjsua_aud.c ..Opening sound device PCM#16000/1/20ms
14:51:47.712 coreaudio_dev. ...Using RemoteIO audio unit
14:51:48.013 coreaudio_dev. ...core audio stream started
14:51:48.021 pjsua_media.c .Call 0: initializing media..
After the above sequence of events there is a trap error, image is below

Resources