Changeset 1710


Ignore:
Timestamp:
Jan 18, 2008 8:14:17 PM (16 years ago)
Author:
nanang
Message:

Ticket #452:
Updated errno.h & .c to accomodate SRTP Transport & libsrtp error code

Location:
pjproject/branches/users/nanang/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h

    r1700 r1710  
    4343 */ 
    4444#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE) 
     45#define PJMEDIA_ERRNO_END         (PJMEDIA_ERRNO_START + PJ_ERRNO_SPACE_SIZE - 1) 
    4546 
    4647 
     
    4849 * Mapping from PortAudio error codes to pjmedia error space. 
    4950 */ 
    50 #define PJMEDIA_PORTAUDIO_ERRNO_START (PJMEDIA_ERRNO_START+PJ_ERRNO_SPACE_SIZE-1000) 
    51  
     51#define PJMEDIA_PORTAUDIO_ERRNO_START (PJMEDIA_ERRNO_END-10000) 
     52#define PJMEDIA_PORTAUDIO_ERRNO_END   (PJMEDIA_PORTAUDIO_ERRNO_START + 10000 -1) 
    5253/** 
    5354 * Convert PortAudio error code to PJMEDIA error code. 
    54  */ 
    55 #define PJMEDIA_ERRNO_FROM_PORTAUDIO(err)   (err+PJMEDIA_PORTAUDIO_ERRNO_START) 
     55 * PortAudio error code range: 0 >= err >= -10000 
     56 */ 
     57#define PJMEDIA_ERRNO_FROM_PORTAUDIO(err)   ((int)PJMEDIA_PORTAUDIO_ERRNO_START-err) 
     58 
     59 
     60/** 
     61 * Mapping from LibSRTP error codes to pjmedia error space. 
     62 */ 
     63#define PJMEDIA_LIBSRTP_ERRNO_START (PJMEDIA_ERRNO_END-10200) 
     64#define PJMEDIA_LIBSRTP_ERRNO_END   (PJMEDIA_LIBSRTP_ERRNO_START + 200 - 1) 
     65/** 
     66 * Convert LibSRTP error code to PJMEDIA error code. 
     67 * LibSRTP error code range: 0 <= err < 200 
     68 */ 
     69#define PJMEDIA_ERRNO_FROM_LIBSRTP(err)   (PJMEDIA_LIBSRTP_ERRNO_START+err) 
    5670 
    5771 
     
    532546/** 
    533547 * @hideinitializer 
     548 * SRTP crypto-suite name not match the offerer tag. 
     549 */ 
     550#define PJMEDIA_SRTP_ECRYPTONOTMATCH (PJMEDIA_ERRNO_START+220)   /* 220220 */ 
     551/** 
     552 * @hideinitializer 
     553 * Invalid SRTP key length for specific crypto. 
     554 */ 
     555#define PJMEDIA_SRTP_EINKEYLEN      (PJMEDIA_ERRNO_START+221)    /* 220221 */ 
     556/** 
     557 * @hideinitializer 
     558 * Unsupported SRTP crypto-suite. 
     559 */ 
     560#define PJMEDIA_SRTP_ENOTSUPCRYPTO  (PJMEDIA_ERRNO_START+222)    /* 220222 */ 
     561/** 
     562 * @hideinitializer 
     563 * SRTP SDP contains ambigue answer. 
     564 */ 
     565#define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+223)    /* 220223 */ 
     566/** 
     567 * @hideinitializer 
     568 * Duplicated crypto tag. 
     569 */ 
     570#define PJMEDIA_SRTP_ESDPDUPCRYPTOTAG (PJMEDIA_ERRNO_START+224)  /* 220224 */ 
     571/** 
     572 * @hideinitializer 
     573 * Invalid crypto attribute. 
     574 */ 
     575#define PJMEDIA_SRTP_ESDPINCRYPTO   (PJMEDIA_ERRNO_START+225)    /* 220225 */ 
     576/** 
     577 * @hideinitializer 
     578 * Invalid crypto tag. 
     579 */ 
     580#define PJMEDIA_SRTP_ESDPINCRYPTOTAG (PJMEDIA_ERRNO_START+226)   /* 220226 */ 
     581/** 
     582 * @hideinitializer 
     583 * Invalid SDP media transport for SRTP. 
     584 */ 
     585#define PJMEDIA_SRTP_ESDPINTRANSPORT (PJMEDIA_ERRNO_START+227)   /* 220227 */ 
     586/** 
     587 * @hideinitializer 
     588 * SRTP crypto attribute required in SDP. 
     589 */ 
     590#define PJMEDIA_SRTP_ESDPREQCRYPTO  (PJMEDIA_ERRNO_START+228)    /* 220228 */ 
     591/** 
     592 * @hideinitializer 
    534593 * Secure transport required in SDP media descriptor. 
    535594 */ 
    536 #define PJMEDIA_SRTP_ESDPREQSECTP   (PJMEDIA_ERRNO_START+220)    /* 220220 */ 
    537 /** 
    538  * @hideinitializer 
    539  * SDP contains ambigue answer. 
    540  */ 
    541 #define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+221)    /* 220221 */ 
    542  
     595#define PJMEDIA_SRTP_ESDPREQSECTP   (PJMEDIA_ERRNO_START+229)    /* 220229 */ 
    543596 
    544597 
  • pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c

    r1700 r1710  
    2424#endif 
    2525 
     26#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 
     27    pj_str_t srtp_transport_getliberrstr(int err); 
     28#endif 
    2629 
    2730 
     
    144147 
    145148    /* SRTP transport errors: */ 
    146     PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP,   "Secure transport required in SDP media descriptor" ), 
    147     PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPAMBIGUEANS, "SDP contains ambigue answer" ), 
    148      
     149    PJ_BUILD_ERR( PJMEDIA_SRTP_ECRYPTONOTMATCH, "SRTP crypto-suite name not match the offerer tag" ), 
     150    PJ_BUILD_ERR( PJMEDIA_SRTP_EINKEYLEN,       "Invalid SRTP key length for specific crypto" ), 
     151    PJ_BUILD_ERR( PJMEDIA_SRTP_ENOTSUPCRYPTO,   "Unsupported SRTP crypto-suite" ), 
     152    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPAMBIGUEANS,  "SRTP SDP contains ambigue answer" ), 
     153    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPDUPCRYPTOTAG,"Duplicated SRTP crypto tag" ), 
     154    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINCRYPTO,    "Invalid SRTP crypto attribute" ), 
     155    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINCRYPTOTAG, "Invalid SRTP crypto tag" ), 
     156    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINTRANSPORT, "Invalid SDP media transport for SRTP" ), 
     157    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQCRYPTO,   "SRTP crypto attribute required in SDP" ), 
     158    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP,    "Secure transport required in SDP media descriptor" ) 
    149159}; 
    150160 
     
    165175    /* See if the error comes from PortAudio. */ 
    166176#if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_PORTAUDIO_SOUND 
    167     if (statcode >= PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized) && 
    168         statcode <  PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized + 10000)) 
     177    if (statcode >= PJMEDIA_PORTAUDIO_ERRNO_START && 
     178        statcode <= PJMEDIA_PORTAUDIO_ERRNO_END) 
    169179    { 
    170180 
    171         int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0); 
     181        //int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0); 
     182        int pa_err = PJMEDIA_PORTAUDIO_ERRNO_START - statcode; 
    172183        pj_str_t msg; 
    173184         
     
    181192    } else  
    182193#endif  /* PJMEDIA_SOUND_IMPLEMENTATION */ 
     194 
     195#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 
     196    /* LIBSRTP error */ 
     197    if (statcode >= PJMEDIA_LIBSRTP_ERRNO_START && 
     198        statcode <  PJMEDIA_LIBSRTP_ERRNO_END) 
     199    { 
     200        int err = statcode - PJMEDIA_PORTAUDIO_ERRNO_START; 
     201        pj_str_t msg; 
     202         
     203        msg = srtp_transport_getliberrstr(err); 
     204 
     205        errstr.ptr = buf; 
     206        pj_strncpy_with_null(&errstr, &msg, bufsize); 
     207        return errstr; 
     208     
     209    } else 
     210#endif 
     211     
     212    /* PJMEDIA error */ 
    183213    if (statcode >= PJMEDIA_ERRNO_START &&  
    184                statcode < PJMEDIA_ERRNO_START + PJ_ERRNO_SPACE_SIZE) 
     214               statcode < PJMEDIA_ERRNO_END) 
    185215    { 
    186216        /* Find the error in the table. 
     
    217247 
    218248        }  
    219     } 
    220  
     249    }  
    221250#endif  /* PJ_HAS_ERROR_STRING */ 
    222251 
Note: See TracChangeset for help on using the changeset viewer.