Ignore:
Timestamp:
Nov 27, 2008 12:06:46 AM (15 years ago)
Author:
bennylp
Message:

Ticket #10: handle redirection response in the invite session

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h

    r2039 r2370  
    116116    void (*on_state_changed)(pjsip_inv_session *inv, pjsip_event *e); 
    117117 
    118  
    119118    /** 
    120119     * This callback is called when the invite usage module has created  
     
    214213     */ 
    215214    void (*on_send_ack)(pjsip_inv_session *inv, pjsip_rx_data *rdata); 
     215 
     216    /** 
     217     * This callback is called when the session is about to resend the  
     218     * INVITE request to the specified target, following the previously 
     219     * received redirection response. 
     220     * 
     221     * Application may accept the redirection to the specified target  
     222     * (the default behavior if this callback is implemented), reject  
     223     * this target only and make the session continue to try the next  
     224     * target in the list if such target exists, stop the whole 
     225     * redirection process altogether and cause the session to be 
     226     * disconnected, or defer the decision to ask for user confirmation. 
     227     * 
     228     * This callback is optional. If this callback is not implemented, 
     229     * the default behavior is to NOT follow the redirection response. 
     230     * 
     231     * @param inv       The invite session. 
     232     * @param target    The current target to be tried. 
     233     * @param cmd       Action to be performed for the target. Set this 
     234     *                  parameter to one of the value below: 
     235     *                  - PJSIP_REDIRECT_ACCEPT: immediately accept the 
     236     *                    redirection (default value). When set, the 
     237     *                    session will immediately resend INVITE request 
     238     *                    to the target. 
     239     *                  - PJSIP_REDIRECT_REJECT: immediately reject this 
     240     *                    target. The session will continue retrying with 
     241     *                    next target if present, or disconnect the call 
     242     *                    if there is no more target to try. 
     243     *                  - PJSIP_REDIRECT_STOP: stop the whole redirection 
     244     *                    process and immediately disconnect the call. The 
     245     *                    on_state_changed() callback will be called with 
     246     *                    PJSIP_INV_STATE_DISCONNECTED state immediately 
     247     *                    after this callback returns. 
     248     *                  - PJSIP_REDIRECT_PENDING: set to this value if 
     249     *                    no decision can be made immediately (for example 
     250     *                    to request confirmation from user). Application 
     251     *                    then MUST call #pjsip_inv_process_redirect() 
     252     *                    to either accept or reject the redirection upon 
     253     *                    getting user decision. 
     254     * @param e         The event that caused this callback to be called. 
     255     *                  This could be the receipt of 3xx response, or 
     256     *                  4xx/5xx response received for the INVITE sent to 
     257     *                  subsequent targets, or NULL if this callback is 
     258     *                  called from within #pjsip_inv_process_redirect() 
     259     *                  context. 
     260     */ 
     261    void (*on_redirected)(pjsip_inv_session *inv, const pjsip_uri *target, 
     262                          pjsip_redirect_op *cmd, const pjsip_event *e); 
    216263 
    217264} pjsip_inv_callback; 
     
    277324    pjmedia_sdp_neg     *neg;                       /**< Negotiator.        */ 
    278325    pjsip_transaction   *invite_tsx;                /**< 1st invite tsx.    */ 
     326    pjsip_tx_data       *invite_req;                /**< Saved invite req   */ 
    279327    pjsip_tx_data       *last_answer;               /**< Last INVITE resp.  */ 
    280328    pjsip_tx_data       *last_ack;                  /**< Last ACK request   */ 
     
    473521                                          int st_code, 
    474522                                          pj_bool_t notify ); 
     523 
     524 
     525/** 
     526 * Restart UAC session and prepare the session for a new initial INVITE. 
     527 * This function can be called for example when the application wants to 
     528 * follow redirection response with a new call reusing this session so 
     529 * that the new call will have the same Call-ID and From headers. After 
     530 * the session is restarted, application may create and send a new INVITE 
     531 * request. 
     532 * 
     533 * @param inv           The invite session. 
     534 * @param new_offer     Should be set to PJ_TRUE since the application will 
     535 *                      restart the session. 
     536 * 
     537 * @return              PJ_SUCCESS on successful operation. 
     538 */ 
     539PJ_DECL(pj_status_t) pjsip_inv_uac_restart(pjsip_inv_session *inv, 
     540                                           pj_bool_t new_offer); 
     541 
     542 
     543/** 
     544 * Accept or reject redirection response. Application MUST call this function 
     545 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_redirected()  
     546 * callback, to notify the invite session whether to accept or reject the 
     547 * redirection to the current target. Application can use the combination of 
     548 * PJSIP_REDIRECT_PENDING command in \a on_redirected() callback and this 
     549 * function to ask for user permission before redirecting the call. 
     550 * 
     551 * Note that if the application chooses to reject or stop redirection (by  
     552 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the 
     553 * session disconnection callback will be called before this function returns. 
     554 * And if the application rejects the target, the \a on_redirected() callback 
     555 * may also be called before this function returns if there is another target 
     556 * to try. 
     557 * 
     558 * @param inv           The invite session. 
     559 * @param cmd           Redirection operation. The semantic of this argument 
     560 *                      is similar to the description in the \a on_redirected() 
     561 *                      callback, except that the PJSIP_REDIRECT_PENDING is 
     562 *                      not accepted here. 
     563 * @param e             Should be set to NULL. 
     564 * 
     565 * @return              PJ_SUCCESS on successful operation. 
     566 */ 
     567PJ_DECL(pj_status_t) pjsip_inv_process_redirect(pjsip_inv_session *inv, 
     568                                                pjsip_redirect_op cmd, 
     569                                                pjsip_event *e); 
    475570 
    476571 
Note: See TracChangeset for help on using the changeset viewer.