24 | | {{{#!comment |
25 | | b. !AudioUnit restart |
| 24 | To 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 | |
| 51 | To 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 | |
| 70 | To 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 | } |