summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-09 00:13:40 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-09 00:13:40 +0000
commit1a7571f62112ae25317663cba5df39c8ff1690c7 (patch)
tree4bb56c9bc0d9a941ef274a2545c83a5243821465 /pjmedia
parent86871987528c71dfa0e666e663ed66f5eb776342 (diff)
Integration of pjmedia and pjsip error subsystem to pjlib
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@162 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/include/pjmedia.h4
-rw-r--r--pjmedia/include/pjmedia/errno.h19
-rw-r--r--pjmedia/include/pjmedia/session.h2
-rw-r--r--pjmedia/include/pjmedia/types.h3
-rw-r--r--pjmedia/src/pjmedia/endpoint.c32
-rw-r--r--pjmedia/src/pjmedia/errno.c21
-rw-r--r--pjmedia/src/pjmedia/sdp.c4
7 files changed, 47 insertions, 38 deletions
diff --git a/pjmedia/include/pjmedia.h b/pjmedia/include/pjmedia.h
index 7587b73e..2f160601 100644
--- a/pjmedia/include/pjmedia.h
+++ b/pjmedia/include/pjmedia.h
@@ -23,10 +23,10 @@
#include <pjmedia/errno.h>
#include <pjmedia/codec.h>
#include <pjmedia/jbuf.h>
-#include <pjmedia/mediamgr.h>
+#include <pjmedia/endpoint.h>
#include <pjmedia/rtcp.h>
#include <pjmedia/rtp.h>
-//#include <pjmedia/session.h>
+#include <pjmedia/session.h>
#include <pjmedia/sound.h>
#include <pjmedia/sdp.h>
#include <pjmedia/sdp_neg.h>
diff --git a/pjmedia/include/pjmedia/errno.h b/pjmedia/include/pjmedia/errno.h
index 8d1f6e14..d57a23b6 100644
--- a/pjmedia/include/pjmedia/errno.h
+++ b/pjmedia/include/pjmedia/errno.h
@@ -25,25 +25,6 @@ PJ_BEGIN_DECL
/**
- * Guidelines on error message length.
- */
-#define PJMEDIA_ERR_MSG_SIZE 64
-
-/**
- * Get error message for the specified error code.
- *
- * @param status The error code.
- * @param buffer The buffer where to put the error message.
- * @param bufsize Size of the buffer.
- *
- * @return The error message as NULL terminated string,
- * wrapped with pj_str_t.
- */
-PJ_DECL(pj_str_t) pjmedia_strerror( pj_status_t status, char *buffer,
- pj_size_t bufsize);
-
-
-/**
* Start of error code relative to PJ_ERRNO_START_USER.
*/
#define PJMEDIA_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
diff --git a/pjmedia/include/pjmedia/session.h b/pjmedia/include/pjmedia/session.h
index f6a9fc11..cbef4424 100644
--- a/pjmedia/include/pjmedia/session.h
+++ b/pjmedia/include/pjmedia/session.h
@@ -40,7 +40,7 @@ PJ_BEGIN_DECL
/**
* Create new session offering based on the local and remote SDP.
- * The session initially will be inactive.
+ * The session will start immediately.
*
* @param endpt The PJMEDIA endpoint instance.
* @param stream_cnt Maximum number of streams to be created. This
diff --git a/pjmedia/include/pjmedia/types.h b/pjmedia/include/pjmedia/types.h
index 6dd44bf7..726a33ec 100644
--- a/pjmedia/include/pjmedia/types.h
+++ b/pjmedia/include/pjmedia/types.h
@@ -133,8 +133,9 @@ typedef struct pjmedia_sock_info
{
pj_sock_t rtp_sock;
- pj_sock_t rtcp_sock;
pj_sockaddr_in rtp_addr_name;
+ pj_sock_t rtcp_sock;
+ pj_sockaddr_in rtcp_addr_name;
} pjmedia_sock_info;
diff --git a/pjmedia/src/pjmedia/endpoint.c b/pjmedia/src/pjmedia/endpoint.c
index 0100bd3f..e2524fd1 100644
--- a/pjmedia/src/pjmedia/endpoint.c
+++ b/pjmedia/src/pjmedia/endpoint.c
@@ -40,6 +40,32 @@ static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
PJ_DECL(pj_status_t) g711_init_factory (pjmedia_codec_factory *factory, pj_pool_t *pool);
PJ_DECL(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory);
+/* Flag to indicate whether pjmedia error subsystem has been registered
+ * to pjlib.
+ */
+static int error_subsys_registered;
+
+
+/**
+ * Defined in pjmedia/errno.c
+ *
+ * Get error message for the specified error code. Note that this
+ * function is only able to decode PJMEDIA specific error code.
+ * Application should use pj_strerror(), which should be able to
+ * decode all error codes belonging to all subsystems (e.g. pjlib,
+ * pjmedia, pjsip, etc).
+ *
+ * @param status The error code.
+ * @param buffer The buffer where to put the error message.
+ * @param bufsize Size of the buffer.
+ *
+ * @return The error message as NULL terminated string,
+ * wrapped with pj_str_t.
+ */
+PJ_DECL(pj_str_t) pjmedia_strerror( pj_status_t status, char *buffer,
+ pj_size_t bufsize);
+
+
/** Concrete declaration of media endpoint. */
struct pjmedia_endpt
@@ -65,6 +91,12 @@ PJ_DEF(pj_status_t) pjmedia_endpt_create(pj_pool_factory *pf,
pjmedia_codec_factory *factory;
pj_status_t status;
+ if (!error_subsys_registered) {
+ pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_strerror);
+ error_subsys_registered = 1;
+ }
+
PJ_ASSERT_RETURN(pf && p_endpt, PJ_EINVAL);
pool = pj_pool_create(pf, "med-ept", 512, 512, NULL);
diff --git a/pjmedia/src/pjmedia/errno.c b/pjmedia/src/pjmedia/errno.c
index aca50aef..f02ffa1c 100644
--- a/pjmedia/src/pjmedia/errno.c
+++ b/pjmedia/src/pjmedia/errno.c
@@ -132,20 +132,15 @@ PJ_DEF(pj_str_t) pjmedia_strerror( pj_status_t statcode,
pj_strncpy_with_null(&errstr, &msg, bufsize);
return errstr;
- } else {
- /* Error not found. */
- errstr.ptr = buf;
- errstr.slen = pj_snprintf(buf, bufsize,
- "Unknown error %d",
- statcode);
-
- return errstr;
- }
- }
- else {
- /* Not our code. Give it to PJLIB. */
- return pj_strerror(statcode, buf, bufsize);
+ }
}
+ /* Error not found. */
+ errstr.ptr = buf;
+ errstr.slen = pj_snprintf(buf, bufsize,
+ "Unknown error %d",
+ statcode);
+
+ return errstr;
}
diff --git a/pjmedia/src/pjmedia/sdp.c b/pjmedia/src/pjmedia/sdp.c
index edd83aa5..92f01251 100644
--- a/pjmedia/src/pjmedia/sdp.c
+++ b/pjmedia/src/pjmedia/sdp.c
@@ -989,8 +989,8 @@ PJ_DEF(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool,
}
PJ_CATCH(SYNTAX_ERROR) {
- char errmsg[PJMEDIA_ERR_MSG_SIZE];
- pjmedia_strerror(ctx.last_error, errmsg, sizeof(errmsg));
+ char errmsg[PJ_ERR_MSG_SIZE];
+ pj_strerror(ctx.last_error, errmsg, sizeof(errmsg));
PJ_LOG(4, (THIS_FILE, "Error parsing SDP in line %d col %d: %s",
scanner.line, pj_scan_get_col(&scanner),