[Asterisk-code-review] res pjsip.c: Register PJMEDIA error code decoder. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Fri Jul 1 11:16:12 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: res_pjsip.c: Register PJMEDIA error code decoder.
......................................................................


res_pjsip.c: Register PJMEDIA error code decoder.

Registering the PJMEDIA error codes allows errors found when parsing an
incoming SDP to be easier to figure out.

"Missing SDP rtpmap for dynamic payload type (PJMEDIA_SDP_EMISSINGRTPMAP)"
is much easier to understand than "Unknown error 220030".

ASTERISK-25772

Change-Id: I44b2dcea656fedd7593171be9e845880a2c70ca0
---
M res/res_pjsip.c
1 file changed, 20 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index bbaf778..5df2603 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -24,6 +24,7 @@
 #include <pjsip/sip_transaction.h>
 #include <pj/timer.h>
 #include <pjlib.h>
+#include <pjmedia/errno.h>
 
 #include "asterisk/res_pjsip.h"
 #include "res_pjsip/include/res_pjsip_private.h"
@@ -4252,6 +4253,19 @@
 	return AST_MODULE_LOAD_DECLINE;
 }
 
+/*
+ * This is a place holder function to ensure that pjmedia_strerr() is at
+ * least directly referenced by this module to ensure that the loader
+ * linker will link to the function.  If a module only indirectly
+ * references a function from another module, such as a callback parameter
+ * to a function, the loader linker has been known to miss the link.
+ */
+void never_called_res_pjsip(void);
+void never_called_res_pjsip(void)
+{
+	pjmedia_strerror(0, NULL, 0);
+}
+
 static int load_module(void)
 {
 	struct ast_threadpool_options options;
@@ -4267,6 +4281,12 @@
 		goto error;
 	}
 
+	/* Register PJMEDIA error codes for SDP parsing errors */
+	if (pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, pjmedia_strerror)
+		!= PJ_SUCCESS) {
+		ast_log(LOG_WARNING, "Failed to register pjmedia error codes.  Codes will not be decoded.\n");
+	}
+
 	if (ast_sip_initialize_system()) {
 		ast_log(LOG_ERROR, "Failed to initialize SIP 'system' configuration section. Aborting load\n");
 		goto error;

-- 
To view, visit https://gerrit.asterisk.org/3128
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I44b2dcea656fedd7593171be9e845880a2c70ca0
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list