Changeset 2031


Ignore:
Timestamp:
Jun 19, 2008 1:54:21 PM (16 years ago)
Author:
bennylp
Message:

Added new API's in ICE stream transport to assist offer/answer negotiation: pj_ice_strans_has_sess(), pj_ice_strans_sess_is_running(), pj_ice_strans_sess_is_complete(), pj_ice_strans_get_running_comp_cnt(), pj_ice_strans_get_ufrag_pwd(), and PJNATH_EICEMISMATCH error code.

Location:
pjproject/trunk/pjnath
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/errno.h

    r1988 r2031  
    153153/** 
    154154 * @hideinitializer 
     155 * Default destination does not match any ICE candidates 
     156 */ 
     157#define PJNATH_EICEMISMATCH         (PJNATH_ERRNO_START+83) /* 370083 */ 
     158/** 
     159 * @hideinitializer 
    155160 * Invalid ICE component ID 
    156161 */ 
  • pjproject/trunk/pjnath/include/pjnath/ice_session.h

    r1988 r2031  
    511511{ 
    512512    /** 
    513      * The ICE agent is in controlled role. 
     513     * The role is unknown. 
    514514     */ 
    515515    PJ_ICE_SESS_ROLE_UNKNOWN, 
  • pjproject/trunk/pjnath/include/pjnath/ice_strans.h

    r1988 r2031  
    350350 
    351351/** 
     352 * Check if the ICE stream transport has the ICE session created. The 
     353 * ICE session is created with #pj_ice_strans_init_ice(). 
     354 * 
     355 * @param ice_st        The ICE stream transport. 
     356 * 
     357 * @return              PJ_TRUE if #pj_ice_strans_init_ice() has been 
     358 *                      called. 
     359 */ 
     360PJ_DECL(pj_bool_t) pj_ice_strans_has_sess(pj_ice_strans *ice_st); 
     361 
     362 
     363/** 
     364 * Check if ICE negotiation is still running. 
     365 * 
     366 * @param ice_st        The ICE stream transport. 
     367 * 
     368 * @return              PJ_TRUE if ICE session has been created and ICE  
     369 *                      negotiation negotiation is in progress. 
     370 */ 
     371PJ_DECL(pj_bool_t) pj_ice_strans_sess_is_running(pj_ice_strans *ice_st); 
     372 
     373 
     374/** 
     375 * Check if ICE negotiation has completed. 
     376 * 
     377 * @param ice_st        The ICE stream transport. 
     378 * 
     379 * @return              PJ_TRUE if ICE session has been created and the 
     380 *                      negotiation is complete. 
     381 */ 
     382PJ_DECL(pj_bool_t) pj_ice_strans_sess_is_complete(pj_ice_strans *ice_st); 
     383 
     384 
     385/** 
     386 * Get the current/running component count. If ICE negotiation has not 
     387 * been started, the number of components will be equal to the number 
     388 * when the ICE stream transport was created. Once negotiation been 
     389 * started, the number of components will be the lowest number of  
     390 * component between local and remote agents. 
     391 * 
     392 * @param ice_st        The ICE stream transport. 
     393 * 
     394 * @return              The running number of components. 
     395 */ 
     396PJ_DECL(unsigned) pj_ice_strans_get_running_comp_cnt(pj_ice_strans *ice_st); 
     397 
     398 
     399/** 
     400 * Get the ICE username fragment and password of the ICE session. The 
     401 * local username fragment and password can only be retrieved once ICE 
     402 * session has been created with #pj_ice_strans_init_ice(). The remote 
     403 * username fragment and password can only be retrieved once ICE session 
     404 * has been started with #pj_ice_strans_start_ice(). 
     405 * 
     406 * Note that the string returned by this function is only valid throughout 
     407 * the duration of the ICE session, and the application must not modify 
     408 * these strings. Once the ICE session has been stopped with 
     409 * #pj_ice_strans_stop_ice(), the pointer in the string will no longer be 
     410 * valid. 
     411 * 
     412 * @param ice_st        The ICE stream transport. 
     413 * @param loc_ufrag     Optional pointer to receive ICE username fragment 
     414 *                      of local endpoint from the ICE session. 
     415 * @param loc_pwd       Optional pointer to receive ICE password of local 
     416 *                      endpoint from the ICE session. 
     417 * @param rem_ufrag     Optional pointer to receive ICE username fragment 
     418 *                      of remote endpoint from the ICE session. 
     419 * @param rem_pwd       Optional pointer to receive ICE password of remote 
     420 *                      endpoint from the ICE session. 
     421 * 
     422 * @return              PJ_SUCCESS if the strings have been retrieved 
     423 *                      successfully. 
     424 */ 
     425PJ_DECL(pj_status_t) pj_ice_strans_get_ufrag_pwd(pj_ice_strans *ice_st, 
     426                                                 pj_str_t *loc_ufrag, 
     427                                                 pj_str_t *loc_pwd, 
     428                                                 pj_str_t *rem_ufrag, 
     429                                                 pj_str_t *rem_pwd); 
     430 
     431 
     432/** 
    352433 * Enumerate the local candidates for the specified component. 
    353434 * 
  • pjproject/trunk/pjnath/src/pjnath/errno.c

    r1988 r2031  
    5959    PJ_BUILD_ERR( PJNATH_EICEINPROGRESS,    "ICE check is in progress"), 
    6060    PJ_BUILD_ERR( PJNATH_EICEFAILED,        "All ICE checklists failed"), 
     61    PJ_BUILD_ERR( PJNATH_EICEMISMATCH,      "Default target doesn't match any ICE candidates"), 
    6162    PJ_BUILD_ERR( PJNATH_EICEINCOMPID,      "Invalid ICE component ID"), 
    6263    PJ_BUILD_ERR( PJNATH_EICEINCANDID,      "Invalid ICE candidate ID"), 
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r1988 r2031  
    701701 
    702702/* 
     703 * Check if the ICE stream transport has the ICE session created.  
     704 */ 
     705PJ_DEF(pj_bool_t) pj_ice_strans_has_sess(pj_ice_strans *ice_st) 
     706{ 
     707    PJ_ASSERT_RETURN(ice_st, PJ_FALSE); 
     708    return ice_st->ice != NULL; 
     709} 
     710 
     711/* 
     712 * Check if ICE negotiation is still running. 
     713 */ 
     714PJ_DEF(pj_bool_t) pj_ice_strans_sess_is_running(pj_ice_strans *ice_st) 
     715{ 
     716    return ice_st && ice_st->ice && ice_st->ice->rcand_cnt && 
     717           !pj_ice_strans_sess_is_complete(ice_st); 
     718} 
     719 
     720 
     721/* 
     722 * Check if ICE negotiation has completed. 
     723 */ 
     724PJ_DEF(pj_bool_t) pj_ice_strans_sess_is_complete(pj_ice_strans *ice_st) 
     725{ 
     726    return ice_st && ice_st->ice && ice_st->ice->is_complete; 
     727} 
     728 
     729 
     730/* 
     731 * Get the current/running component count. 
     732 */ 
     733PJ_DEF(unsigned) pj_ice_strans_get_running_comp_cnt(pj_ice_strans *ice_st) 
     734{ 
     735    PJ_ASSERT_RETURN(ice_st, PJ_EINVAL); 
     736 
     737    if (ice_st->ice && ice_st->ice->rcand_cnt) { 
     738        return (ice_st->comp_cnt < ice_st->ice->rcand_cnt) ? 
     739                    ice_st->comp_cnt : ice_st->ice->rcand_cnt; 
     740    } else { 
     741        return ice_st->comp_cnt; 
     742    } 
     743} 
     744 
     745 
     746/* 
     747 * Get the ICE username fragment and password of the ICE session. 
     748 */ 
     749PJ_DEF(pj_status_t) pj_ice_strans_get_ufrag_pwd( pj_ice_strans *ice_st, 
     750                                                 pj_str_t *loc_ufrag, 
     751                                                 pj_str_t *loc_pwd, 
     752                                                 pj_str_t *rem_ufrag, 
     753                                                 pj_str_t *rem_pwd) 
     754{ 
     755    PJ_ASSERT_RETURN(ice_st && ice_st->ice, PJ_EINVALIDOP); 
     756 
     757    if (loc_ufrag) *loc_ufrag = ice_st->ice->rx_ufrag; 
     758    if (loc_pwd) *loc_pwd = ice_st->ice->rx_pass; 
     759 
     760    if (rem_ufrag || rem_pwd) { 
     761        PJ_ASSERT_RETURN(ice_st->ice->rcand_cnt != 0, PJ_EINVALIDOP); 
     762        if (rem_ufrag) *rem_ufrag = ice_st->ice->tx_ufrag; 
     763        if (rem_pwd) *rem_pwd = ice_st->ice->tx_pass; 
     764    } 
     765 
     766    return PJ_SUCCESS; 
     767} 
     768 
     769/* 
    703770 * Enum candidates 
    704771 */ 
     
    709776{ 
    710777    unsigned i, cnt; 
    711     pj_ice_strans_comp *comp; 
    712  
    713     PJ_ASSERT_RETURN(ice_st && comp_id && comp_id <= ice_st->comp_cnt && 
    714                      count && cand, PJ_EINVAL); 
    715  
    716     comp = ice_st->comp[comp_id - 1]; 
    717     cnt = comp->cand_cnt; 
    718     cnt = (cnt > *count) ? *count : cnt; 
    719  
    720     for (i=0; i<cnt; ++i) { 
    721         pj_memcpy(&cand[i], &comp->cand_list[i], sizeof(pj_ice_sess_cand)); 
     778 
     779    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id &&  
     780                     comp_id <= ice_st->comp_cnt && count && cand, PJ_EINVAL); 
     781 
     782    cnt = 0; 
     783    for (i=0; i<ice_st->ice->lcand_cnt && cnt<*count; ++i) { 
     784        if (ice_st->ice->lcand[i].comp_id != comp_id) 
     785            continue; 
     786        pj_memcpy(&cand[cnt], &ice_st->ice->lcand[i], 
     787                  sizeof(pj_ice_sess_cand)); 
     788        ++cnt; 
    722789    } 
    723790 
Note: See TracChangeset for help on using the changeset viewer.