Changes between Version 4 and Version 5 of Ticket #1941
- Timestamp:
- Oct 12, 2016 12:37:18 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #1941 – Description
v4 v5 20 20 21 21 == !CallKit support == 22 !CallKit requires the call audio to start only when audio session has been activated, thus it's recommended that you use PJSIP with no sound device (by calling {{{pjsua_set_no_snd_dev()}}}) and open the sound device only when necessary (by calling {{{pjsua_set_snd_dev())}}}. Below is an example on how to integrate !CallKit with PJSIP, with the delegate functions taken from [https://developer.apple.com/library/content/samplecode/Speakerbox/Listings/Speakerbox_ProviderDelegate_swift.html#//apple_ref/doc/uid/TP40017290-Speakerbox_ProviderDelegate_swift-DontLinkElementID_23 Speakerbox] sample app provided by Apple. 22 [https://developer.apple.com/reference/callkit 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: 23 1. Starting PJSIP with no sound device (by calling {{{pjsua_set_no_snd_dev()}}} after startup). 24 2. Close the sound device when unused, also with the same API ({{{pjsua_set_no_snd_dev()}}}). 25 3. Upon audio session activation, open the sound device with the API {{{pjsua_set_snd_dev()}}}. 26 27 Below is an example on how to integrate !CallKit with PJSIP, with the delegate functions taken from [https://developer.apple.com/library/content/samplecode/Speakerbox/Listings/Speakerbox_ProviderDelegate_swift.html#//apple_ref/doc/uid/TP40017290-Speakerbox_ProviderDelegate_swift-DontLinkElementID_23 Speakerbox] sample app provided by Apple. 23 28 24 29 To make outgoing call: 25 30 {{{ 26 31 func provider(_ provider: CXProvider, perform action: CXStartCallAction) { 27 /* 1. Provide your own implementation to configure 32 /* 1. We must not start call audio here, and can only do so 33 * once the audio session has been activated by the system 34 * after having its priority elevated. So, make sure that the sound 35 * device is closed at this point. 36 */ 37 38 /* 2. Provide your own implementation to configure 28 39 * the audio session here. 29 40 */ 30 41 configureAudioSession() 31 42 32 /* 2. Set pjsua_set_no_snd_dev() before making call with 33 * pjsua_call_make_call() since we must not start 34 * call audio here, and can only do so once the audio session 35 * has been activated by the system after having its priority 36 * elevated. 37 */ 38 39 /* 3. Use pjsua's on_call_state() callback to report significant 43 /* 3. Make call with pjsua_call_make_call(). 44 * Then use pjsua's on_call_state() callback to report significant 40 45 * events in the call's lifecycle, by calling iOS API 41 46 * CXProvider.reportOutgoingCall(with: startedConnectingAt:) and … … 43 48 */ 44 49 45 /* 4. If step ( 2) above returns PJ_SUCCESS, call action.fulfill(),50 /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(), 46 51 * otherwise call action.fail(). 47 52 */ … … 52 57 {{{ 53 58 func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { 54 /* 1. Provide your own implementation to configure 59 /* 1. We must not start call audio here, and can only do so 60 * once the audio session has been activated by the system 61 * after having its priority elevated. So, make sure that the sound 62 * device is closed at this point. 63 */ 64 65 /* 2. Provide your own implementation to configure 55 66 * the audio session here. 56 67 */ 57 68 configureAudioSession() 58 69 59 /* 2. We must not start call audio here, so if sound device is 60 * active, you need to call pjsua_set_no_snd_dev() first, 61 * before proceeding with pjsua_call_answer(). 70 /* 3. Answer the call with pjsua_call_answer(). 71 */ 62 72 63 /* 3. Signal to the system that the action has been successfully64 * performed.73 /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(), 74 * otherwise call action.fail(). 65 75 */ 66 action.fulfill()67 76 } 68 77 }}}