Changes between Version 4 and Version 5 of Ticket #1941


Ignore:
Timestamp:
10/11/16 19:37:18 (20 months ago)
Author:
ming
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1941 – Description

    v4 v5  
    2020 
    2121== !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: 
     231. Starting PJSIP with no sound device (by calling {{{pjsua_set_no_snd_dev()}}} after startup). 
     242. Close the sound device when unused, also with the same API ({{{pjsua_set_no_snd_dev()}}}). 
     253. Upon audio session activation, open the sound device with the API {{{pjsua_set_snd_dev()}}}. 
     26 
     27Below 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. 
    2328 
    2429To make outgoing call: 
    2530{{{ 
    2631    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 
    2839         *    the audio session here. 
    2940         */ 
    3041        configureAudioSession() 
    3142 
    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 
    4045         *    events in the call's lifecycle, by calling iOS API 
    4146         *    CXProvider.reportOutgoingCall(with: startedConnectingAt:) and 
     
    4348         */ 
    4449          
    45         /* 4. If step (2) above returns PJ_SUCCESS, call action.fulfill(), 
     50        /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(), 
    4651         *    otherwise call action.fail(). 
    4752         */ 
     
    5257{{{ 
    5358    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 
    5566         *    the audio session here. 
    5667         */ 
    5768        configureAudioSession() 
    5869 
    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         */ 
    6272 
    63         /* 3. Signal to the system that the action has been successfully 
    64          *    performed. 
     73        /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(), 
     74         *    otherwise call action.fail(). 
    6575         */ 
    66         action.fulfill() 
    6776    } 
    6877}}}