summaryrefslogtreecommitdiff
path: root/pjmedia/src
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/src
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/src')
-rw-r--r--pjmedia/src/pjmedia/endpoint.c32
-rw-r--r--pjmedia/src/pjmedia/errno.c21
-rw-r--r--pjmedia/src/pjmedia/sdp.c4
3 files changed, 42 insertions, 15 deletions
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),