diff options
Diffstat (limited to 'pjmedia/src/pjmedia/errno.c')
-rw-r--r-- | pjmedia/src/pjmedia/errno.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/pjmedia/src/pjmedia/errno.c b/pjmedia/src/pjmedia/errno.c index 300cbd44..f8e39328 100644 --- a/pjmedia/src/pjmedia/errno.c +++ b/pjmedia/src/pjmedia/errno.c @@ -23,6 +23,9 @@ # include <portaudio.h> #endif +#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) + const char* get_libsrtp_errstr(int err); +#endif /* PJMEDIA's own error codes/messages @@ -141,6 +144,21 @@ static const struct PJ_BUILD_ERR( PJMEDIA_ENOSNDPLAY, "No suitable sound playback device" ), PJ_BUILD_ERR( PJMEDIA_ESNDINDEVID, "Invalid sound device ID" ), PJ_BUILD_ERR( PJMEDIA_ESNDINSAMPLEFMT, "Invalid sample format for sound device" ), + +#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) + /* SRTP transport errors: */ + PJ_BUILD_ERR( PJMEDIA_SRTP_ECRYPTONOTMATCH, "SRTP crypto-suite name not match the offerer tag" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_EINKEYLEN, "Invalid SRTP key length for specific crypto" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ENOTSUPCRYPTO, "Unsupported SRTP crypto-suite" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPAMBIGUEANS, "SRTP SDP contains ambigue answer" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPDUPCRYPTOTAG,"Duplicated SRTP crypto tag" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINCRYPTO, "Invalid SRTP crypto attribute" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINCRYPTOTAG, "Invalid SRTP crypto tag" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPINTRANSPORT, "Invalid SDP media transport for SRTP" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQCRYPTO, "SRTP crypto attribute required" ), + PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP, "Secure transport required in SDP media descriptor" ) +#endif + }; #endif /* PJ_HAS_ERROR_STRING */ @@ -159,11 +177,12 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode, /* See if the error comes from PortAudio. */ #if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_PORTAUDIO_SOUND - if (statcode >= PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized) && - statcode < PJMEDIA_ERRNO_FROM_PORTAUDIO(paNotInitialized + 10000)) + if (statcode >= PJMEDIA_PORTAUDIO_ERRNO_START && + statcode <= PJMEDIA_PORTAUDIO_ERRNO_END) { - int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0); + //int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0); + int pa_err = PJMEDIA_PORTAUDIO_ERRNO_START - statcode; pj_str_t msg; msg.ptr = (char*)Pa_GetErrorText(pa_err); @@ -175,8 +194,26 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode, } else #endif /* PJMEDIA_SOUND_IMPLEMENTATION */ + +#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) + /* LIBSRTP error */ + if (statcode >= PJMEDIA_LIBSRTP_ERRNO_START && + statcode < PJMEDIA_LIBSRTP_ERRNO_END) + { + int err = statcode - PJMEDIA_PORTAUDIO_ERRNO_START; + pj_str_t msg; + + msg = pj_str((char*)get_libsrtp_errstr(err)); + + pj_strncpy_with_null(&errstr, &msg, bufsize); + return errstr; + + } else +#endif + + /* PJMEDIA error */ if (statcode >= PJMEDIA_ERRNO_START && - statcode < PJMEDIA_ERRNO_START + PJ_ERRNO_SPACE_SIZE) + statcode < PJMEDIA_ERRNO_END) { /* Find the error in the table. * Use binary search! @@ -211,8 +248,7 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode, return errstr; } - } - + } #endif /* PJ_HAS_ERROR_STRING */ /* Error not found. */ |