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
Related
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"
I'm developing a web application integrating Vidyo and I need to record video calls. I followed the documentation guide and installed a Media Bridge Docker image in my server. I don't face problems on connecting with the media bridge, but effectively it doesn't record video nor audio. The output .flv file shows only a 10 seconds black screen with display names of the call particpants.
My configuration file is:
width=1280
height=720
fps=30
kbps=2000
layout=1
maxParticipants=8
overlay=1
videoCodec=H264
audioCodec=AAC
maxCallDuration=180
presentationAllowed=1
presWidth=1280
presHeight=720
presFps=5
presKbps=300
destination="flv:/opt/vidyo/recordingTest.flv"
resourceId="test_recording"
token=<TOKEN HERE>
host="prod.vidyo.io"
mediaPorts="50000-50100"
publicIp="127.0.0.1"
log=debug
And the errors in the output log file are:
[1050]: LmiAudioProcessing ERROR [System thread] LmiAudioProcessing.c:1208 LmiAudioProcessingSetVoiceProcessing scip_xmpp_audio_processing audio processing: special voice processing should be set to off prior to setting voice processing off.
[1050]: LmiAudioProcessing ERROR [System thread] LmiAudioProcessing.c:1219 LmiAudioProcessingSetVoiceProcessing scip_xmpp_audio_processing audio processing: unable to set voice processing off.
[1050]: LmiTransport ERROR [System thread] LmiTcpTransport.c:1435 LmiTcpTransportConstructAddressFromString Error resolving address roni.eng.vidyo.com:443: UnknownHost
[1050]: LmiSignaling ERROR [System thread] LmiStackConnection.c:36 LmiStackConnectionConstructOutbound Could not create connection to ed3df5eef18e3b0d
[1050]: XmppGateway ERROR [System thread] xmpp.c:1010 makeXmppCall failed: LmiUserLogin
[1050]: leg ERROR [System thread] leg.c:845 legStart epMakeCall failed. protocol: xmpp dest: room:demoRoom~token:<TOKEN>~server:roni.eng.vidyo.com config: addOverlay:on~caFile:/opt/vidyo/conf/openssl/certs/ca-certificates.crt~dropCall:on
[1050]: gwCall ERROR [System thread] call.c:1744 main failed: legStart 0
[126]: LmiAudioProcessing ERROR [System thread] LmiAudioProcessing.c:1208 LmiAudioProcessingSetVoiceProcessing scip_xmpp_audio_processing audio processing: special voice processing should be set to off prior to setting voice processing off.
[126]: LmiAudioProcessing ERROR [System thread] LmiAudioProcessing.c:1219 LmiAudioProcessingSetVoiceProcessing scip_xmpp_audio_processing audio processing: unable to set voice processing off.
[126]: writer ERROR [System thread] writer.c:876 writerUpdateStats failed: Assign audio stats
[126]: rtmp ERROR [System thread] rtmp.c:662 endpointGetStats failed: Update stats
[126]: leg ERROR [System thread] leg.c:1567 legGetStats failed: epGetStats failed
[126]: ScipXmppCommon ERROR xmpp scip_xmpp_common.c:269 sxcRemoteSourceAdded We already have video remote source - skip this one
[126]: LmiRtp ERROR xmpp LmiRtpSessionInline.h:294 LmiRtpSessionGetActiveRtpDestination 3LI/IGh+pOy/zbUmmgAa conn 1: Can't get active RTP destination from stopped session
[126]: LmiRtp ERROR xmpp LmiRtpSessionInline.h:294 LmiRtpSessionGetActiveRtpDestination 3LI/IGh+pOy/zbUmmgAa conn 2: Can't get active RTP destination from stopped session
[126]: XmppGateway ERROR xmpp xmpp.c:586 selectedParticipantListChanged failed: selected_participants_do_show_selected_n
[126]: leg ERROR videoRenderer leg.c:388 epCaptureVideo leg: xmpp get video frame failed
[126]: gwCall ERROR gw-tp-1 call.c:1472 peerCallEndTask legEndCall failed
In case if this helps you try this, this worked for me.You don't need SIP configuration
#main video/audio settings
width=1280
height=720
fps=30
kbps=2000
layout=1
maxParticipants=8
overlay=1
videoCodec=H264
audioCodec=PCM
maxCallDuration=180 # duration in minutes
#Presentation settings
presentationAllowed=1 #0 - ignore presentations 1 - replace main video with presentation
presWidth=1280
presHeight=720
presFps=5
presKbps=300
destination="flv:/opt/vidyo/<call_id>.flv"
#vidyo.io connection info
resourceId="<room_id>"
token="<call_token>"
host="prod.vidyo.io"
I have added pjsip VoIP functionality to my iOS App recently. Using pjsip offers no problem while the App is active, I can both receive and make Calls without issues.
But I seem to have a Problem with the sound devices in the background. The first call I receive from the background works fine, I get sound and I can close it normally.
The problem is after the first call I get no sound what so ever when I accept a call from the Background. The same happens if I make or receive a call while the App is active and then go to the background and receive a call.
When I close the app, the first Call from the background works normally again.
I have no idea what could cause that.
I have tried to manually close all calls via CallManager and I call a CXEndCallAction when the Server Side terminates the call, to get CallKit to close properly.
I'd be happy to post specific code passages, but currently, I have no clue where the problem could lie...
UPDATE:
I have figured out that the pjsip coreaudio initializes differently the second time.
Now the Question is, how do I reset CoreAudio in pjsip properly?
Successful Call Init:
11:03:01.615 tsx0x1030710a8 .....State changed from Trying to
Proceeding, event=TX_MSG
11:03:01.615 dlg0x1030840a8 ......Transaction tsx0x1030710a8 state changed to Proceeding
2019-02-13 11:03:01.615745+0100 VarioCallCTI[11928:2820452] Incoming call from "Matthias" <sip:238#80.80.245.33>
11:03:01.618 pjsua_aud.c ..Set sound device: capture=0, playback=0
11:03:01.618 pjsua_aud.c !Set sound device: capture=0, playback=0
11:03:01.619 pjsua_aud.c !...Opening sound device PCM#16000/1/20ms
11:03:01.619 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.808024+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>)
11:03:01.851 pjsua_aud.c ...Opening sound device PCM#44100/1/20ms
11:03:01.851 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.859854+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 44100 Hz, Int16> inf< 1 ch, 44100 Hz, Int16>)
11:03:01.860 pjsua_aud.c ...Opening sound device PCM#48000/1/20ms
11:03:01.860 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.867061+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 48000 Hz, Int16> inf< 1 ch, 48000 Hz, Int16>)
11:03:01.867 pjsua_aud.c ...Opening sound device PCM#32000/1/20ms
11:03:01.867 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.874321+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 32000 Hz, Int16> inf< 1 ch, 32000 Hz, Int16>)
11:03:01.875 pjsua_aud.c ...Opening sound device PCM#16000/1/20ms
11:03:01.875 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.881126+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>)
11:03:01.881 pjsua_aud.c ...Opening sound device PCM#8000/1/20ms
11:03:01.881 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.888214+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 8000 Hz, Int16> inf< 1 ch, 8000 Hz, Int16>)
11:03:01.888 pjsua_aud.c ...Unable to open sound device: Unknown error -560117684 [status=-560117684]
Error in Setting of Audio Devices - IncomingCall
TESTPRINT FOR NOTIFICATION INFO: eingehender anruf von 238
TESTPRINT FOR NOTIFICATION INFO: 238
Unsuccessful Call Init:
11:03:49.840 tsx0x103064ea8 .....State changed from Trying to Proceeding, event=TX_MSG
11:03:49.840 dlg0x1030906a8 ......Transaction tsx0x103064ea8 state changed to Proceeding
2019-02-13 11:03:49.841013+0100 VarioCallCTI[11928:2820906] Incoming call from "Matthias" <sip:238#80.80.245.33>
11:03:49.842 pjsua_aud.c ..Set sound device: capture=0, playback=0
11:03:49.842 pjsua_aud.c ...Opening sound device PCM#16000/1/20ms
11:03:49.842 coreaudio_dev. ....Using VoiceProcessingIO audio unit
11:03:49.847 pjsua_aud.c !Set sound device: capture=0, playback=0
2019-02-13 11:03:50.276837+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
2019-02-13 11:03:50.277597+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2019-02-13 11:03:50.292488+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2019-02-13 11:03:50.293379+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
11:03:50.383 coreaudio_dev. !....core audio stream started
Setting of Audio Devices Successfull - IncomingCall
TESTPRINT FOR NOTIFICATION INFO: eingehender anruf von 238
TESTPRINT FOR NOTIFICATION INFO: 238
I have figured out how to solve the Problem.
Since the PJSIP Library Init caused the coreAudio to initialize before the priority bump required by iOS was fully finished, I had to open CallKit and register at the PJSIP Server inside the CallKit - ProviderDelegate
func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool = false, completion: ((NSError?) -> Void)?) {
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: handle)
update.hasVideo = hasVideo
//MARK: Final Working Solution
print("Starting PJSIP after PUSH")
pjsipfunctions.init().registersip(mainUser.sipData["User"], mainUser.sipData["Password"], mainUser.sipData["Server"])
provider.reportNewIncomingCall(with: uuid, update: update) { error in
if error == nil {
let call = Call(uuid: uuid, handle: handle)
self.callManager.add(call: call)
userTerminatedCall = false
}
completion?(error as? NSError)
}
}
}
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.
Someone could tell me why this happen?
iOS10, iPhone5s, VOIP Siphon pjsip2.5.5.
These issue was not appear every time,it came sometimes when you want to make call or answer call (add at:20161226).
Error opening sound device:
14:06:03.137742 pjsua_aud.c ....Set sound device: capture=-1, playback=-2
14:06:03.137775 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#16000/1/20ms
14:06:03.137837 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.147404 acquire_call enter,call_id:2
14:06:03.233365 level:4,msg:14:06:03.233 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#44100/1/20ms
14:06:03.233488 level:4,msg:14:06:03.233 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.263379 AVAudioSessionRouteChangeNotification ..changeReason..3
14:06:03.439201 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#48000/1/20ms
14:06:03.444813 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.518592 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#32000/1/20ms
14:06:03.518731 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.587808 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#16000/1/20ms
14:06:03.587936 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.659660 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#8000/1/20ms
14:06:03.659837 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.734433 pjsua_aud.c .....Unable to open sound device: Unknown OpenSSL error 503317117 [status=506637]
14:06:03.734512 pjsua_aud.c ....Error opening sound device: Unknown OpenSSL error 503317117 [status=506637]
14:06:03.734534 pjsua_aud.c ...Conf connect: 0 --> 2
14:06:03.734555 pjsua_aud.c ....Set sound device: capture=-1, playback=-2
14:06:03.734586 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#16000/1/20ms
14:06:03.734651 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.799718 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#44100/1/20ms
14:06:03.799847 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.868825 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#48000/1/20ms
14:06:03.869031 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:03.936294 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#32000/1/20ms
14:06:03.936423 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:04.006834 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#16000/1/20ms
14:06:04.006962 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:04.075150 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#8000/1/20ms
14:06:04.075288 coreaudio_dev. ......Using VoiceProcessingIO audio unit
14:06:04.144082 pjsua_aud.c .....Unable to open sound device: Unknown OpenSSL error 503317117 [status=506637]
14:06:04.144165 pjsua_aud.c ....Error opening sound device: Unknown OpenSSL error 503317117 [status=506637]
14:06:04.144186 pjsua_conf_connect:pjsua_conf_connect_value 506637 ret 506637
today(2016-12-16),I get the same bug,but the error number is different(iphone5 ios10.1.1 siphone pjsip2.5.5)
316-981188544 2016-12-16 10:52:29.160553 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#44100/1/20ms
316-981188544 2016-12-16 10:52:29.160689 coreaudio_dev. ......Using VoiceProcessingIO audio unit
316-981188544 2016-12-16 10:52:29.167254 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#48000/1/20ms
316-981188544 2016-12-16 10:52:29.167391 coreaudio_dev. ......Using VoiceProcessingIO audio unit
316-981188544 2016-12-16 10:52:29.172857 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#32000/1/20ms
316-981188544 2016-12-16 10:52:29.172994 coreaudio_dev. ......Using VoiceProcessingIO audio unit
316-981188544 2016-12-16 10:52:29.178400 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#16000/1/20ms
316-981188544 2016-12-16 10:52:29.178539 coreaudio_dev. ......Using VoiceProcessingIO audio unit
316-981188544 2016-12-16 10:52:29.184486 pjsua_aud.c .....Opening sound device (speaker + mic) PCM#8000/1/20ms
316-981188544 2016-12-16 10:52:29.184631 coreaudio_dev. ......Using VoiceProcessingIO audio unit
316-981188544 2016-12-16 10:52:29.195032 pjsua_aud.c .....Unable to open sound device: Unknown error -1701297535 [status=-1701297535]
316-981188544 2016-12-16 10:52:29.195105 pjsua_aud.c ....Error opening sound device: Unknown error -1701297535 [status=-1701297535]
Step 1: At first open info.plist file in your xcode project in Supporting Files Folder and click "+" in Information property list.
Step 2: Select and Add Privacy - Microphone Usage Description in the list.
Step 3: Add the value Microphone in the Privacy - Microphone Usage Description.
Now Compile and run your project.
At last,I fix this bug with IOS's CallKit,take a look at this website: https://trac.pjsip.org/repos/ticket/1941
Details: CallKit framework allows apps to use the native phone UI to receive incoming calls and make outgoing calls. In order to achieve this, CallKit requires the call audio to start only when audio session has been activated, thus it's recommended that when using PJSIP, you open the sound device only when necessary. It can be done by:
Starting PJSIP with no sound device (by calling pjsua_set_no_snd_dev() after startup). Close the sound device when unused, also with the same API (pjsua_set_no_snd_dev()). Upon audio session activation, open the sound device with the API pjsua_set_snd_dev(). Below is an example on how to integrate CallKit with PJSIP, with the delegate functions taken from ​Speakerbox sample app provided by Apple.
To make outgoing call:
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
/* 1. We must not start call audio here, and can only do so
* once the audio session has been activated by the system
* after having its priority elevated. So, make sure that the sound
* device is closed at this point.
*/
/* 2. Provide your own implementation to configure
* the audio session here.
*/
configureAudioSession()
/* 3. Make call with pjsua_call_make_call().
* Then use pjsua's on_call_state() callback to report significant
* events in the call's lifecycle, by calling iOS API
* CXProvider.reportOutgoingCall(with: startedConnectingAt:) and
* CXProvider.reportOutgoingCall(with: ConnectedAt:)
*/
/* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
* otherwise call action.fail().
*/
}
To handle incoming call:
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
/* 1. We must not start call audio here, and can only do so
* once the audio session has been activated by the system
* after having its priority elevated. So, make sure that the sound
* device is closed at this point.
*/
/* 2. Provide your own implementation to configure
* the audio session here.
*/
configureAudioSession()
/* 3. Answer the call with pjsua_call_answer().
*/
/* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
* otherwise call action.fail().
*/
}
To start sound device:
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
/* Start call audio media, now that the audio session has been
* activated after having its priority boosted.
*
* Call pjsua API pjsua_set_snd_dev() here.
*/
}
My issue was that, when I played a sound on incoming calls I set the AudioSession caterogry Playback like:
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
I changed it to Play and record:
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
and it worked after that. So if you somewhere in your code set the audio session to playback, change it to play and record.
#Altanai
func setAudioSessionActive(active: Bool) -> Bool{
let sessionInterface = AVAudioSession.sharedInstance()
do{
try sessionInterface.setActive(active)
if(active){
if(sessionInterface.category != AVAudioSessionCategoryPlayAndRecord){
try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord)
}
if(sessionInterface.mode != AVAudioSessionModeVoiceChat){
try sessionInterface.setMode(AVAudioSessionModeVoiceChat)
}
}
return true
}
catch let error{
return false
}
}
func configureAudioSession(){
let sessionInterface = AVAudioSession.sharedInstance()
do{
if(sessionInterface.responds(to: #selector(AVAudioSession.setCategory(_:with:)))){
try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
}
else{
try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord)
}
try sessionInterface.setMode(AVAudioSessionModeVoiceChat)
}
catch let error{
NSLog("SipManager - configureAudioSession error: \(error)")
}
}