Index: /pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h
===================================================================
--- /pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h	(revision 1709)
+++ /pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h	(revision 1710)
@@ -43,4 +43,5 @@
  */
 #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
+#define PJMEDIA_ERRNO_END         (PJMEDIA_ERRNO_START + PJ_ERRNO_SPACE_SIZE - 1)
 
 
@@ -48,10 +49,23 @@
  * Mapping from PortAudio error codes to pjmedia error space.
  */
-#define PJMEDIA_PORTAUDIO_ERRNO_START (PJMEDIA_ERRNO_START+PJ_ERRNO_SPACE_SIZE-1000)
-
+#define PJMEDIA_PORTAUDIO_ERRNO_START (PJMEDIA_ERRNO_END-10000)
+#define PJMEDIA_PORTAUDIO_ERRNO_END   (PJMEDIA_PORTAUDIO_ERRNO_START + 10000 -1)
 /**
  * Convert PortAudio error code to PJMEDIA error code.
- */
-#define PJMEDIA_ERRNO_FROM_PORTAUDIO(err)   (err+PJMEDIA_PORTAUDIO_ERRNO_START)
+ * PortAudio error code range: 0 >= err >= -10000
+ */
+#define PJMEDIA_ERRNO_FROM_PORTAUDIO(err)   ((int)PJMEDIA_PORTAUDIO_ERRNO_START-err)
+
+
+/**
+ * Mapping from LibSRTP error codes to pjmedia error space.
+ */
+#define PJMEDIA_LIBSRTP_ERRNO_START (PJMEDIA_ERRNO_END-10200)
+#define PJMEDIA_LIBSRTP_ERRNO_END   (PJMEDIA_LIBSRTP_ERRNO_START + 200 - 1)
+/**
+ * Convert LibSRTP error code to PJMEDIA error code.
+ * LibSRTP error code range: 0 <= err < 200
+ */
+#define PJMEDIA_ERRNO_FROM_LIBSRTP(err)   (PJMEDIA_LIBSRTP_ERRNO_START+err)
 
 
@@ -532,13 +546,52 @@
 /**
  * @hideinitializer
+ * SRTP crypto-suite name not match the offerer tag.
+ */
+#define PJMEDIA_SRTP_ECRYPTONOTMATCH (PJMEDIA_ERRNO_START+220)   /* 220220 */
+/**
+ * @hideinitializer
+ * Invalid SRTP key length for specific crypto.
+ */
+#define PJMEDIA_SRTP_EINKEYLEN	    (PJMEDIA_ERRNO_START+221)    /* 220221 */
+/**
+ * @hideinitializer
+ * Unsupported SRTP crypto-suite.
+ */
+#define PJMEDIA_SRTP_ENOTSUPCRYPTO  (PJMEDIA_ERRNO_START+222)    /* 220222 */
+/**
+ * @hideinitializer
+ * SRTP SDP contains ambigue answer.
+ */
+#define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+223)    /* 220223 */
+/**
+ * @hideinitializer
+ * Duplicated crypto tag.
+ */
+#define PJMEDIA_SRTP_ESDPDUPCRYPTOTAG (PJMEDIA_ERRNO_START+224)  /* 220224 */
+/**
+ * @hideinitializer
+ * Invalid crypto attribute.
+ */
+#define PJMEDIA_SRTP_ESDPINCRYPTO   (PJMEDIA_ERRNO_START+225)    /* 220225 */
+/**
+ * @hideinitializer
+ * Invalid crypto tag.
+ */
+#define PJMEDIA_SRTP_ESDPINCRYPTOTAG (PJMEDIA_ERRNO_START+226)   /* 220226 */
+/**
+ * @hideinitializer
+ * Invalid SDP media transport for SRTP.
+ */
+#define PJMEDIA_SRTP_ESDPINTRANSPORT (PJMEDIA_ERRNO_START+227)   /* 220227 */
+/**
+ * @hideinitializer
+ * SRTP crypto attribute required in SDP.
+ */
+#define PJMEDIA_SRTP_ESDPREQCRYPTO  (PJMEDIA_ERRNO_START+228)    /* 220228 */
+/**
+ * @hideinitializer
  * Secure transport required in SDP media descriptor.
  */
-#define PJMEDIA_SRTP_ESDPREQSECTP   (PJMEDIA_ERRNO_START+220)    /* 220220 */
-/**
- * @hideinitializer
- * SDP contains ambigue answer.
- */
-#define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+221)    /* 220221 */
-
+#define PJMEDIA_SRTP_ESDPREQSECTP   (PJMEDIA_ERRNO_START+229)    /* 220229 */
 
 
Index: /pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c
===================================================================
--- /pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c	(revision 1709)
+++ /pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c	(revision 1710)
@@ -24,4 +24,7 @@
 #endif
 
+#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
+    pj_str_t srtp_transport_getliberrstr(int err);
+#endif
 
 
@@ -144,7 +147,14 @@
 
     /* SRTP transport errors: */
-    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP,   "Secure transport required in SDP media descriptor" ),
-    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPAMBIGUEANS, "SDP contains ambigue answer" ),
-    
+    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 in SDP" ),
+    PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP,    "Secure transport required in SDP media descriptor" )
 };
 
@@ -165,9 +175,10 @@
     /* 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;
 	
@@ -181,6 +192,25 @@
     } 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 = srtp_transport_getliberrstr(err);
+
+	errstr.ptr = buf;
+	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.
@@ -217,6 +247,5 @@
 
 	} 
-    }
-
+    } 
 #endif	/* PJ_HAS_ERROR_STRING */
 
