From 1d1908a032b3d078210ca41d3d1c17d1bf90cfdd Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 2 Apr 2007 11:30:14 +0000 Subject: ICE: work in progress git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1126 74dad513-b988-da41-8d7b-12977e46ad98 --- pjnath/include/pjnath/config.h | 15 ++++++++++++++ pjnath/include/pjnath/ice_session.h | 41 +++++++++++++++++++++++++------------ pjnath/include/pjnath/stun_auth.h | 2 ++ pjnath/include/pjnath/stun_msg.h | 4 ++++ pjnath/include/pjnath/types.h | 19 ++++++++++++++++- 5 files changed, 67 insertions(+), 14 deletions(-) (limited to 'pjnath/include') diff --git a/pjnath/include/pjnath/config.h b/pjnath/include/pjnath/config.h index 3bc5afaf..dec268f8 100644 --- a/pjnath/include/pjnath/config.h +++ b/pjnath/include/pjnath/config.h @@ -31,6 +31,21 @@ * @{ */ + +/* ************************************************************************** + * GENERAL + */ + +/** + * The log level for PJNATH error display. + * + * default 1 + */ +#ifndef PJNATH_ERROR_LEVEL +# define PJNATH_ERROR_LEVEL 1 +#endif + + /* ************************************************************************** * STUN CLIENT CONFIGURATION */ diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h index 929a4e82..36ad1b27 100644 --- a/pjnath/include/pjnath/ice_session.h +++ b/pjnath/include/pjnath/ice_session.h @@ -97,18 +97,6 @@ typedef enum pj_ice_cand_type } pj_ice_cand_type; -/** - * This enumeration describes the default preference for the ICE - * candidate types as described by ICE standard. - */ -enum pj_ice_type_pref -{ - PJ_ICE_HOST_PREF = 126, /**< Preference value for host. */ - PJ_ICE_SRFLX_PREF = 100, /**< Preference value for SRFLX. */ - PJ_ICE_PRFLX_PREF = 110, /**< Preference value for PRFLX */ - PJ_ICE_RELAYED_PREF = 0 /**< Preference value for relay */ -}; - /** Forward declaration for pj_ice_sess */ typedef struct pj_ice_sess pj_ice_sess; @@ -273,7 +261,7 @@ struct pj_ice_sess_check /** * Check priority. */ - pj_uint64_t prio; + pj_timestamp prio; /** * Connectivity check state. @@ -445,6 +433,7 @@ struct pj_ice_sess pj_mutex_t *mutex; /**< Mutex. */ pj_ice_sess_role role; /**< ICE role. */ pj_timestamp tie_breaker; /**< Tie breaker value */ + pj_uint8_t *prefs; /**< Type preference. */ pj_bool_t is_complete; /**< Complete? */ pj_status_t ice_status; /**< Error status. */ pj_ice_sess_cb cb; /**< Callback. */ @@ -565,6 +554,28 @@ PJ_DECL(pj_status_t) pj_ice_sess_change_role(pj_ice_sess *ice, pj_ice_sess_role new_role); +/** + * Assign a custom preference values for ICE candidate types. By assigning + * custom preference value, application can control the order of candidates + * to be checked first. The default preference settings is to use 126 for + * host candidates, 100 for server reflexive candidates, 110 for peer + * reflexive candidates, an 0 for relayed candidates. + * + * Note that this function must be called before any candidates are added + * to the ICE session. + * + * @param ice The ICE session. + * @param prefs Array of candidate preference value. The values are + * put in the array indexed by the candidate type as + * specified in pj_ice_cand_type. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pj_ice_sess_set_prefs(pj_ice_sess *ice, + const pj_uint8_t prefs[4]); + + + /** * Add a candidate to this ICE session. Application must add candidates for * each components ID before it can start pairing the candidates and @@ -595,6 +606,9 @@ PJ_DECL(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice, int addr_len, unsigned *p_cand_id); +#if 0 +/* Temporarily disabled to reduce size, since we don't need this yet */ + /** * Find default candidate for the specified component ID, using this * rule: @@ -612,6 +626,7 @@ PJ_DECL(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice, PJ_DECL(pj_status_t) pj_ice_sess_find_default_cand(pj_ice_sess *ice, unsigned comp_id, int *p_cand_id); +#endif /** * Pair the local and remote candidates to create check list. Application diff --git a/pjnath/include/pjnath/stun_auth.h b/pjnath/include/pjnath/stun_auth.h index 6914036d..539c8867 100644 --- a/pjnath/include/pjnath/stun_auth.h +++ b/pjnath/include/pjnath/stun_auth.h @@ -225,6 +225,8 @@ typedef struct pj_stun_auth_cred * in the message can be accepted. If this callback returns * PJ_FALSE, 438 (Stale Nonce) response will be created. * + * This callback is optional. + * * @param msg The STUN message where the nonce was received. * @param user_data The user data as specified in the credential. * @param realm The realm as specified in the message. diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h index 6c716a0c..f1544de3 100644 --- a/pjnath/include/pjnath/stun_msg.h +++ b/pjnath/include/pjnath/stun_msg.h @@ -1228,10 +1228,14 @@ PJ_DECL(pj_status_t) pj_stun_msg_decode(pj_pool_t *pool, * * @return The message string output. */ +#if PJ_LOG_MAX_LEVEL > 0 PJ_DECL(char*) pj_stun_msg_dump(const pj_stun_msg *msg, char *buffer, unsigned length, unsigned *printed_len); +#else +# define pj_stun_msg_dump(msg, buf, length, printed_len) "" +#endif /** diff --git a/pjnath/include/pjnath/types.h b/pjnath/include/pjnath/types.h index 72c326af..10544d22 100644 --- a/pjnath/include/pjnath/types.h +++ b/pjnath/include/pjnath/types.h @@ -37,11 +37,27 @@ PJ_BEGIN_DECL /** * Initialize pjnath library. * - * @return Initialization status. + * @return Initialization status. */ PJ_DECL(pj_status_t) pjnath_init(void); +/** + * Display error to the log. + * + * @param sender The sender name. + * @param title Title message. + * @param status The error status. + */ +#if PJNATH_ERROR_LEVEL <= PJ_LOG_MAX_LEVEL +PJ_DECL(void) pjnath_perror(const char *sender, const char *title, + pj_status_t status); +#else +# define pjnath_perror(sender, title, status) +#endif + + + PJ_END_DECL /** @@ -147,6 +163,7 @@ PJ_END_DECL * for different types of application, including but not limited to * the usage of ICE in SIP/SDP offer/answer. * + * * \subsection PJNATH_ICE_ARCH ICE Library Organization * * \image html ice-arch.jpg "ICE Architecture" -- cgit v1.2.3