Changes between Version 3 and Version 4 of Ticket #1941


Ignore:
Timestamp:
Oct 11, 2016 1:07:22 AM (8 years ago)
Author:
ming
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1941 – Description

    v3 v4  
    2020 
    2121== !CallKit support == 
    22 a. AVAudioSession handling[[br]] Application needs to handle its own audio session management according to [https://developer.apple.com/reference/callkit?language=objc Apple's doc]. 
     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. 
    2323 
    24 {{{#!comment 
    25 b. !AudioUnit restart 
     24To make outgoing call: 
     25{{{ 
     26    func provider(_ provider: CXProvider, perform action: CXStartCallAction) { 
     27        /* 1. Provide your own implementation to configure 
     28         *    the audio session here. 
     29         */ 
     30        configureAudioSession() 
     31 
     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 
     40         *    events in the call's lifecycle, by calling iOS API 
     41         *    CXProvider.reportOutgoingCall(with: startedConnectingAt:) and 
     42         *    CXProvider.reportOutgoingCall(with: ConnectedAt:) 
     43         */ 
     44          
     45        /* 4. If step (2) above returns PJ_SUCCESS, call action.fulfill(), 
     46         *    otherwise call action.fail(). 
     47         */ 
     48    } 
     49}}} 
     50 
     51To handle incoming call: 
     52{{{ 
     53    func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { 
     54        /* 1. Provide your own implementation to configure 
     55         *    the audio session here. 
     56         */ 
     57        configureAudioSession() 
     58 
     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(). 
     62 
     63        /* 3. Signal to the system that the action has been successfully 
     64         *    performed. 
     65         */ 
     66        action.fulfill() 
     67    } 
     68}}} 
     69 
     70To start sound device: 
     71{{{ 
     72    func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) { 
     73        /* Start call audio media, now that the audio session has been 
     74         * activated after having its priority boosted. 
     75         * 
     76         * Call pjsua API pjsua_set_snd_dev() here. 
     77         */ 
     78    } 
    2679}}} 
    2780