Ignore:
Timestamp:
Jun 3, 2010 10:41:32 AM (14 years ago)
Author:
nanang
Message:

Re #1089:

  • Added a feature in dialog to store and retrieve remote capabilities dug from the remote messages.
  • Added few APIs in dialog to query and update remote capabilities, also added an API in pjsua_call to query whether a capability is supported by remote.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_dialog.h

    r3068 r3196  
    9191 
    9292/** 
     93 * Dialog capability status. 
     94 */ 
     95typedef enum pjsip_dialog_cap_status 
     96{ 
     97    /** Capability is unsupported. */ 
     98    PJSIP_DIALOG_CAP_UNSUPPORTED    = 0, 
     99 
     100    /** Capability is supported */ 
     101    PJSIP_DIALOG_CAP_SUPPORTED      = 1, 
     102 
     103    /**  
     104     *  Unknown capability status. This is usually because we lack the  
     105     *  capability info which is retrieved from capability header specified 
     106     *  in the dialog messages. 
     107     */ 
     108    PJSIP_DIALOG_CAP_UNKNOWN        = 2 
     109} pjsip_dialog_cap_status; 
     110 
     111 
     112/** 
    93113 * This structure describes the dialog structure. Application MUST NOT 
    94114 * try to SET the values here directly, but instead it MUST use the 
     
    128148    pjsip_dlg_party     local;      /**< Local party info.                  */ 
    129149    pjsip_dlg_party     remote;     /**< Remote party info.                 */ 
     150    pjsip_hdr           rem_cap_hdr;/**< List of remote capability header.  */ 
    130151    pjsip_role_e        role;       /**< Initial role.                      */ 
    131152    pj_bool_t           uac_has_2xx;/**< UAC has received 2xx response?     */ 
     
    613634 
    614635/** 
     636 * Check if remote peer have the specified capability as published 
     637 * in the dialog messages from remote peer. 
     638 * 
     639 * Notes: 
     640 * - The capability \a token lookup will apply exact match, but not  
     641 *   case-sensitive, for example: <tt>"text/html"</tt> will not match  
     642 *   <tt>"text / html"</tt> (notice the spaces). 
     643 * 
     644 * @param dlg       The dialog. 
     645 * @param htype     The header type to be checked, which value may be: 
     646 *                  - PJSIP_H_ACCEPT 
     647 *                  - PJSIP_H_ALLOW 
     648 *                  - PJSIP_H_SUPPORTED 
     649 * @param hname     If htype specifies PJSIP_H_OTHER, then the header name 
     650 *                  must be supplied in this argument. Otherwise the value 
     651 *                  must be set to NULL. 
     652 * @param token     The capability token to check. For example, if \a htype 
     653 *                  is PJSIP_H_ALLOW, then \a token specifies the method 
     654 *                  names; if \a htype is PJSIP_H_SUPPORTED, then \a token 
     655 *                  specifies the extension names such as "100rel". 
     656 * 
     657 * @return          PJSIP_DIALOG_CAP_SUPPORTED if the specified capability 
     658 *                  is explicitly supported, see @pjsip_dialog_cap_status 
     659 *                  for more info. 
     660 */ 
     661PJ_DECL(pjsip_dialog_cap_status) pjsip_dlg_remote_has_cap( 
     662                                                    pjsip_dialog *dlg, 
     663                                                    int htype, 
     664                                                    const pj_str_t *hname, 
     665                                                    const pj_str_t *token); 
     666 
     667/** 
     668 * Get the specified capability header from the remote capability headers 
     669 * stored in the dialog. 
     670 * 
     671 * @param dlg       The dialog. 
     672 * @param htype     The header type to be retrieved, which value may be: 
     673 *                  - PJSIP_H_ACCEPT 
     674 *                  - PJSIP_H_ALLOW 
     675 *                  - PJSIP_H_SUPPORTED 
     676 * @param hname     If htype specifies PJSIP_H_OTHER, then the header name 
     677 *                  must be supplied in this argument. Otherwise the value 
     678 *                  must be set to NULL. 
     679 * 
     680 * @return          The appropriate header, or NULL if the header is not 
     681 *                  available. 
     682 */ 
     683PJ_DECL(const pjsip_hdr*) pjsip_dlg_get_remote_cap_hdr(pjsip_dialog *dlg, 
     684                                                       int htype, 
     685                                                       const pj_str_t *hname); 
     686 
     687/** 
     688 * Set remote capability from a SIP header containing array of capability  
     689 * tags/values. 
     690 * 
     691 * @param dlg       The dialog. 
     692 * @param cap_hdr   The SIP header. 
     693 * 
     694 * @return          PJ_SUCCESS when successful, otherwise the appropriate 
     695 *                  error code will be returned. 
     696 */ 
     697PJ_DECL(pj_status_t) pjsip_dlg_set_remote_cap_hdr( 
     698                                    pjsip_dialog *dlg, 
     699                                    const pjsip_generic_array_hdr *cap_hdr); 
     700 
     701/** 
     702 * Remove a remote capability header. 
     703 * 
     704 * @param dlg       The dialog. 
     705 * @param htype     The header type to be removed, which value may be: 
     706 *                  - PJSIP_H_ACCEPT 
     707 *                  - PJSIP_H_ALLOW 
     708 *                  - PJSIP_H_SUPPORTED 
     709 * @param hname     If htype specifies PJSIP_H_OTHER, then the header name 
     710 *                  must be supplied in this argument. Otherwise the value 
     711 *                  must be set to NULL. 
     712 * 
     713 * @return          PJ_SUCCESS when successful, otherwise the appropriate 
     714 *                  error code will be returned. 
     715 */ 
     716PJ_DECL(pj_status_t) pjsip_dlg_remove_remote_cap_hdr(pjsip_dialog *dlg, 
     717                                                     int htype, 
     718                                                     const pj_str_t *hname); 
     719 
     720/** 
     721 * Update remote capabilities from a received message. The header types 
     722 * to be updated from the message will only be \a PJSIP_H_ACCEPT,  
     723 * \a PJSIP_H_ALLOW, and \a PJSIP_H_SUPPORTED. 
     724 * 
     725 * @param dlg       The dialog. 
     726 * @param msg       The received message. 
     727 * @param strict    If this is set to PJ_TRUE, any header types missing 
     728 *                  from the message will cause removal of existing 
     729 *                  header types in the capability list. Otherwise, the  
     730 *                  capability list will not be modified when any header 
     731 *                  type is missing. 
     732 * 
     733 * @return          PJ_SUCCESS when successful, otherwise the appropriate 
     734 *                  error code will be returned. 
     735 */ 
     736PJ_DECL(pj_status_t) pjsip_dlg_update_remote_cap(pjsip_dialog *dlg, 
     737                                                 const pjsip_msg *msg, 
     738                                                 pj_bool_t strict); 
     739 
     740 
     741 
     742/** 
    615743 * @} 
    616744 */ 
Note: See TracChangeset for help on using the changeset viewer.