| 26 | |
| 27 | == Configuring Multiple Targets == |
| 28 | |
| 29 | Both call redirection and multiple call targets are done with the same function below: |
| 30 | |
| 31 | {{{ |
| 32 | PJ_DECL(pj_status_t) pjsua_call_manage_target(pjsua_call_id call_id, |
| 33 | const pj_str_t *target, |
| 34 | pjsip_status_code tgt_code, |
| 35 | const pj_str_t *referer, |
| 36 | float qvalue, |
| 37 | const pjsua_msg_data *msg_data); |
| 38 | }}} |
| 39 | |
| 40 | The parameters of the function are as follows: |
| 41 | |
| 42 | * ''call_id'': the call ID of an outgoing call which status is not disconnected yet. |
| 43 | * ''target'': target URI. |
| 44 | * ''tgt_code'': operation to be applied to the target: |
| 45 | - value 100-199: the target will be added, but it will not be called until it's code is set to 2xx. |
| 46 | - value 200-299: the target will be added and called as soon as possible. |
| 47 | - value 300-699: the target will be removed from the list, if it's present. |
| 48 | * ''referer'': Optionally specify the URI of the referer, that is the URI of the original target which returned redirection response containing this target. This referer URI is used to calculate the priority of this new target. If referer is not used, the target priority will be calculated from the qvalue parameter instead. |
| 49 | * ''qvalue'': Priority value, from 0 to 1. Target with lower priority number will be called first. If application specify zero, then this target will be selected first for the next call, and if 1, this target will be called last. |
| 50 | * ''msg_data'': Optional list of headers etc to be added to outgoing call to this target. |
| 51 | |
| 52 | |
| 53 | Please see the function documentation for details. |
| 54 | |
| 55 | For call redirection, there is new callback in {{{pjsua_callback}}} to notify application about redirection response from callee: |
| 56 | |
| 57 | {{{ |
| 58 | void (*on_call_redirected)(pjsua_call_id call_id, |
| 59 | unsigned target_cnt, |
| 60 | const pj_str_t target[], |
| 61 | pjsip_event *e); |
| 62 | }}} |
| 63 | |
| 64 | For SIP redirection, application would have to implement {{{on_call_redirected()}}} callback above, and call {{{pjsua_call_manage_target()}}} for each target that it wants the call to follow. |
| 65 | |
| 66 | For configuring alternate target to outgoing call without waiting for 3xx response, application can simply add the target with {{{pjsua_call_manage_target()}}} immediately after making the call |