summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/bridge_native_rtp.c81
-rw-r--r--channels/chan_rtp.c7
-rw-r--r--channels/pjsip/dialplan_functions.c62
-rw-r--r--main/acl.c36
-rw-r--r--res/res_pjsip_refer.c3
-rw-r--r--res/res_pjsip_session.c6
-rw-r--r--res/res_rtp_asterisk.c28
-rw-r--r--third-party/pjproject/Makefile13
-rw-r--r--third-party/pjproject/patches/config_site.h4
9 files changed, 145 insertions, 95 deletions
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index 7eacc9d8c..a106d2d5f 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -270,7 +270,6 @@ static struct ast_frame *native_rtp_framehook(struct ast_channel *chan, struct a
}
bridge = ast_channel_get_bridge(chan);
-
if (bridge) {
/* native_rtp_bridge_start/stop are not being called from bridging
core so we need to lock the bridge prior to calling these functions
@@ -312,26 +311,21 @@ static int native_rtp_bridge_capable(struct ast_channel *chan)
return !ast_channel_has_hook_requiring_audio(chan);
}
-static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
+static int native_rtp_bridge_compatible_check(struct ast_bridge *bridge, struct ast_bridge_channel *bc0, struct ast_bridge_channel *bc1)
{
- struct ast_bridge_channel *bc0 = AST_LIST_FIRST(&bridge->channels);
- struct ast_bridge_channel *bc1 = AST_LIST_LAST(&bridge->channels);
enum ast_rtp_glue_result native_type;
- struct ast_rtp_glue *glue0, *glue1;
+ struct ast_rtp_glue *glue0;
+ struct ast_rtp_glue *glue1;
RAII_VAR(struct ast_rtp_instance *, instance0, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, vinstance0, NULL, ao2_cleanup);
RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
RAII_VAR(struct ast_format_cap *, cap0, NULL, ao2_cleanup);
RAII_VAR(struct ast_format_cap *, cap1, NULL, ao2_cleanup);
- int read_ptime0, read_ptime1, write_ptime0, write_ptime1;
-
- /* We require two channels before even considering native bridging */
- if (bridge->num_channels != 2) {
- ast_debug(1, "Bridge '%s' can not use native RTP bridge as two channels are required\n",
- bridge->uniqueid);
- return 0;
- }
+ int read_ptime0;
+ int read_ptime1;
+ int write_ptime0;
+ int write_ptime1;
if (!native_rtp_bridge_capable(bc0->chan)) {
ast_debug(1, "Bridge '%s' can not use native RTP bridge as channel '%s' has features which prevent it\n",
@@ -345,29 +339,34 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
return 0;
}
- if ((native_type = native_rtp_bridge_get(bc0->chan, bc1->chan, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1))
- == AST_RTP_GLUE_RESULT_FORBID) {
+ native_type = native_rtp_bridge_get(bc0->chan, bc1->chan, &glue0, &glue1,
+ &instance0, &instance1, &vinstance0, &vinstance1);
+ if (native_type == AST_RTP_GLUE_RESULT_FORBID) {
ast_debug(1, "Bridge '%s' can not use native RTP bridge as it was forbidden while getting details\n",
bridge->uniqueid);
return 0;
}
- if (ao2_container_count(bc0->features->dtmf_hooks) && ast_rtp_instance_dtmf_mode_get(instance0)) {
+ if (ao2_container_count(bc0->features->dtmf_hooks)
+ && ast_rtp_instance_dtmf_mode_get(instance0)) {
ast_debug(1, "Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
bridge->uniqueid, ast_channel_name(bc0->chan));
return 0;
}
- if (ao2_container_count(bc1->features->dtmf_hooks) && ast_rtp_instance_dtmf_mode_get(instance1)) {
+ if (ao2_container_count(bc1->features->dtmf_hooks)
+ && ast_rtp_instance_dtmf_mode_get(instance1)) {
ast_debug(1, "Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
bridge->uniqueid, ast_channel_name(bc1->chan));
return 0;
}
- if ((native_type == AST_RTP_GLUE_RESULT_LOCAL) && ((ast_rtp_instance_get_engine(instance0)->local_bridge !=
- ast_rtp_instance_get_engine(instance1)->local_bridge) ||
- (ast_rtp_instance_get_engine(instance0)->dtmf_compatible &&
- !ast_rtp_instance_get_engine(instance0)->dtmf_compatible(bc0->chan, instance0, bc1->chan, instance1)))) {
+ if (native_type == AST_RTP_GLUE_RESULT_LOCAL
+ && (ast_rtp_instance_get_engine(instance0)->local_bridge
+ != ast_rtp_instance_get_engine(instance1)->local_bridge
+ || (ast_rtp_instance_get_engine(instance0)->dtmf_compatible
+ && !ast_rtp_instance_get_engine(instance0)->dtmf_compatible(bc0->chan,
+ instance0, bc1->chan, instance1)))) {
ast_debug(1, "Bridge '%s' can not use local native RTP bridge as local bridge or DTMF is not compatible\n",
bridge->uniqueid);
return 0;
@@ -386,11 +385,16 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
if (glue1->get_codec) {
glue1->get_codec(bc1->chan, cap1);
}
- if (ast_format_cap_count(cap0) != 0 && ast_format_cap_count(cap1) != 0 && !ast_format_cap_iscompatible(cap0, cap1)) {
+ if (ast_format_cap_count(cap0) != 0
+ && ast_format_cap_count(cap1) != 0
+ && !ast_format_cap_iscompatible(cap0, cap1)) {
struct ast_str *codec_buf0 = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
struct ast_str *codec_buf1 = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
- ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n",
- ast_format_cap_get_names(cap0, &codec_buf0), ast_format_cap_get_names(cap1, &codec_buf1));
+
+ ast_debug(1, "Bridge '%s': Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n",
+ bridge->uniqueid,
+ ast_format_cap_get_names(cap0, &codec_buf0),
+ ast_format_cap_get_names(cap1, &codec_buf1));
return 0;
}
@@ -400,14 +404,39 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
write_ptime1 = ast_format_cap_get_format_framing(cap1, ast_channel_rawwriteformat(bc1->chan));
if (read_ptime0 != write_ptime1 || read_ptime1 != write_ptime0) {
- ast_debug(1, "Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n",
- read_ptime0, write_ptime1, read_ptime1, write_ptime0);
+ ast_debug(1, "Bridge '%s': Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n",
+ bridge->uniqueid,
+ read_ptime0, write_ptime1, read_ptime1, write_ptime0);
return 0;
}
return 1;
}
+static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
+{
+ struct ast_bridge_channel *bc0;
+ struct ast_bridge_channel *bc1;
+ int is_compatible;
+
+ /* We require two channels before even considering native bridging */
+ if (bridge->num_channels != 2) {
+ ast_debug(1, "Bridge '%s' can not use native RTP bridge as two channels are required\n",
+ bridge->uniqueid);
+ return 0;
+ }
+
+ bc0 = AST_LIST_FIRST(&bridge->channels);
+ bc1 = AST_LIST_LAST(&bridge->channels);
+
+ ast_channel_lock_both(bc0->chan, bc1->chan);
+ is_compatible = native_rtp_bridge_compatible_check(bridge, bc0, bc1);
+ ast_channel_unlock(bc0->chan);
+ ast_channel_unlock(bc1->chan);
+
+ return is_compatible;
+}
+
/*! \brief Helper function which adds frame hook to bridge channel */
static int native_rtp_bridge_framehook_attach(struct ast_bridge_channel *bridge_channel)
{
diff --git a/channels/chan_rtp.c b/channels/chan_rtp.c
index f1f4f05b9..d671706b2 100644
--- a/channels/chan_rtp.c
+++ b/channels/chan_rtp.c
@@ -316,7 +316,12 @@ static struct ast_channel *unicast_rtp_request(const char *type, struct ast_form
engine_name = S_COR(ast_test_flag(&opts, OPT_RTP_ENGINE),
opt_args[OPT_ARG_RTP_ENGINE], "asterisk");
- ast_ouraddrfor(&address, &local_address);
+ ast_sockaddr_copy(&local_address, &address);
+ if (ast_ouraddrfor(&address, &local_address)) {
+ ast_log(LOG_ERROR, "Could not get our address for sending media to '%s'\n",
+ args.destination);
+ goto failure;
+ }
instance = ast_rtp_instance_new(engine_name, NULL, &local_address, NULL);
if (!instance) {
ast_log(LOG_ERROR,
diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c
index ecf5105f8..719a0747c 100644
--- a/channels/pjsip/dialplan_functions.c
+++ b/channels/pjsip/dialplan_functions.c
@@ -722,7 +722,7 @@ static int channel_read_pjsip(struct ast_channel *chan, const char *type, const
/*! \brief Struct used to push function arguments to task processor */
struct pjsip_func_args {
- struct ast_channel *chan;
+ struct ast_sip_session *session;
const char *param;
const char *type;
const char *field;
@@ -737,49 +737,31 @@ static int read_pjsip(void *data)
struct pjsip_func_args *func_args = data;
if (!strcmp(func_args->param, "rtp")) {
- func_args->ret = channel_read_rtp(func_args->chan, func_args->type,
+ func_args->ret = channel_read_rtp(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
} else if (!strcmp(func_args->param, "rtcp")) {
- func_args->ret = channel_read_rtcp(func_args->chan, func_args->type,
+ func_args->ret = channel_read_rtcp(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
} else if (!strcmp(func_args->param, "endpoint")) {
- struct ast_sip_channel_pvt *pvt = ast_channel_tech_pvt(func_args->chan);
-
- if (!pvt) {
- ast_log(AST_LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(func_args->chan));
+ if (!func_args->session->endpoint) {
+ ast_log(AST_LOG_WARNING, "Channel %s has no endpoint!\n", ast_channel_name(func_args->session->channel));
return -1;
}
- if (!pvt->session || !pvt->session->endpoint) {
- ast_log(AST_LOG_WARNING, "Channel %s has no endpoint!\n", ast_channel_name(func_args->chan));
- return -1;
- }
- snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(pvt->session->endpoint));
+ snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->endpoint));
} else if (!strcmp(func_args->param, "contact")) {
- struct ast_sip_channel_pvt *pvt = ast_channel_tech_pvt(func_args->chan);
-
- if (!pvt) {
- ast_log(AST_LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(func_args->chan));
- return -1;
- }
- if (!pvt->session || !pvt->session->contact) {
+ if (!func_args->session->contact) {
return 0;
}
- snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(pvt->session->contact));
+ snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->contact));
} else if (!strcmp(func_args->param, "aor")) {
- struct ast_sip_channel_pvt *pvt = ast_channel_tech_pvt(func_args->chan);
-
- if (!pvt) {
- ast_log(AST_LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(func_args->chan));
- return -1;
- }
- if (!pvt->session || !pvt->session->aor) {
+ if (!func_args->session->aor) {
return 0;
}
- snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(pvt->session->aor));
+ snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->aor));
} else if (!strcmp(func_args->param, "pjsip")) {
- func_args->ret = channel_read_pjsip(func_args->chan, func_args->type,
+ func_args->ret = channel_read_pjsip(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
} else {
@@ -806,7 +788,6 @@ int pjsip_acf_channel_read(struct ast_channel *chan, const char *cmd, char *data
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
return -1;
}
- channel = ast_channel_tech_pvt(chan);
/* Check for zero arguments */
if (ast_strlen_zero(parse)) {
@@ -816,29 +797,44 @@ int pjsip_acf_channel_read(struct ast_channel *chan, const char *cmd, char *data
AST_STANDARD_APP_ARGS(args, parse);
+ ast_channel_lock(chan);
+
/* Sanity check */
if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
+ ast_channel_unlock(chan);
return 0;
}
+ channel = ast_channel_tech_pvt(chan);
if (!channel) {
- ast_log(AST_LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
+ ast_log(LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
+ ast_channel_unlock(chan);
return -1;
}
+ if (!channel->session) {
+ ast_log(LOG_WARNING, "Channel %s has no session\n", ast_channel_name(chan));
+ ast_channel_unlock(chan);
+ return -1;
+ }
+
+ func_args.session = ao2_bump(channel->session);
+ ast_channel_unlock(chan);
+
memset(buf, 0, len);
- func_args.chan = chan;
func_args.param = args.param;
func_args.type = args.type;
func_args.field = args.field;
func_args.buf = buf;
func_args.len = len;
- if (ast_sip_push_task_synchronous(channel->session->serializer, read_pjsip, &func_args)) {
+ if (ast_sip_push_task_synchronous(func_args.session->serializer, read_pjsip, &func_args)) {
ast_log(LOG_WARNING, "Unable to read properties of channel %s: failed to push task\n", ast_channel_name(chan));
+ ao2_ref(func_args.session, -1);
return -1;
}
+ ao2_ref(func_args.session, -1);
return func_args.ret;
}
diff --git a/main/acl.c b/main/acl.c
index 87776b33b..9820e8bef 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -914,40 +914,48 @@ int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
{
+ /*
+ * We must create the errno string before creating the address
+ * string because it could wipe out errno on the error return
+ * paths.
+ */
+ const char *sock_err;
int port;
int s;
+ /* Preserve our original address port */
port = ast_sockaddr_port(us);
- if ((s = socket(ast_sockaddr_is_ipv6(them) ? AF_INET6 : AF_INET,
- SOCK_DGRAM, 0)) < 0) {
- ast_log(LOG_ERROR, "Cannot create socket\n");
+ s = socket(ast_sockaddr_is_ipv6(them) ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ sock_err = ast_strdupa(strerror(errno));
+ ast_log(LOG_ERROR, "Cannot create socket to %s: %s\n",
+ ast_sockaddr_stringify_addr(them), sock_err);
return -1;
}
if (ast_connect(s, them)) {
- ast_log(LOG_WARNING, "Cannot connect\n");
+ sock_err = ast_strdupa(strerror(errno));
+ ast_log(LOG_WARNING, "Cannot connect to %s: %s\n",
+ ast_sockaddr_stringify_addr(them), sock_err);
close(s);
return -1;
}
if (ast_getsockname(s, us)) {
-
- ast_log(LOG_WARNING, "Cannot get socket name\n");
+ sock_err = ast_strdupa(strerror(errno));
+ ast_log(LOG_WARNING, "Cannot get socket name for connection to %s: %s\n",
+ ast_sockaddr_stringify_addr(them), sock_err);
close(s);
return -1;
}
close(s);
- {
- const char *them_addr = ast_strdupa(ast_sockaddr_stringify_addr(them));
- const char *us_addr = ast_strdupa(ast_sockaddr_stringify_addr(us));
-
- ast_debug(3, "For destination '%s', our source address is '%s'.\n",
- them_addr, us_addr);
- }
-
ast_sockaddr_set_port(us, port);
+ ast_debug(3, "For destination '%s', our source address is '%s'.\n",
+ ast_strdupa(ast_sockaddr_stringify_addr(them)),
+ ast_strdupa(ast_sockaddr_stringify_addr(us)));
+
return 0;
}
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 77b1a5438..d52a922fd 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -1007,6 +1007,7 @@ static int refer_incoming_refer_request(struct ast_sip_session *session, struct
int response;
static const pj_str_t str_refer_to = { "Refer-To", 8 };
+ static const pj_str_t str_refer_to_s = { "r", 1 };
static const pj_str_t str_replaces = { "Replaces", 8 };
if (!session->channel) {
@@ -1025,7 +1026,7 @@ static int refer_incoming_refer_request(struct ast_sip_session *session, struct
}
/* A Refer-To header is required */
- refer_to = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL);
+ refer_to = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &str_refer_to, &str_refer_to_s, NULL);
if (!refer_to) {
pjsip_dlg_respond(session->inv_session->dlg, rdata, 400, NULL, NULL, NULL);
ast_debug(3, "Received a REFER without Refer-To on channel '%s' from endpoint '%s'\n",
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 60850f04d..3c4f102f8 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1998,6 +1998,12 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
if (!strcmp(session->exten, pickupexten) ||
ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, NULL)) {
+ size_t size = pj_strlen(&sip_ruri->host) + 1;
+ char *domain = ast_alloca(size);
+
+ ast_copy_pj_str(domain, &sip_ruri->host, size);
+ pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);
+
return SIP_GET_DEST_EXTEN_FOUND;
}
/* XXX In reality, we'll likely have further options so that partial matches
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 1ae18fed3..2409e3aee 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -4915,9 +4915,11 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
ast_sockaddr_set_port(&rtp->rtcp->us,
ast_sockaddr_port(&rtp->rtcp->us) + 1);
+ ast_sockaddr_copy(&local_addr, &rtp->rtcp->us);
if (!ast_find_ourip(&local_addr, &rtp->rtcp->us, 0)) {
ast_sockaddr_set_port(&local_addr, ast_sockaddr_port(&rtp->rtcp->us));
} else {
+ /* Failed to get local address reset to use default. */
ast_sockaddr_copy(&local_addr, &rtp->rtcp->us);
}
@@ -5006,31 +5008,31 @@ static int ast_rtp_fd(struct ast_rtp_instance *instance, int rtcp)
static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr)
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
- struct ast_sockaddr local, us;
+ struct ast_sockaddr local;
+ ast_rtp_instance_get_local_address(instance, &local);
if (!ast_sockaddr_isnull(addr)) {
/* Update the local RTP address with what is being used */
- ast_ouraddrfor(addr, &us);
- ast_rtp_instance_get_local_address(instance, &local);
- ast_sockaddr_set_port(&us, ast_sockaddr_port(&local));
- ast_rtp_instance_set_local_address(instance, &us);
+ if (ast_ouraddrfor(addr, &local)) {
+ /* Failed to update our address so reuse old local address */
+ ast_rtp_instance_get_local_address(instance, &local);
+ } else {
+ ast_rtp_instance_set_local_address(instance, &local);
+ }
}
if (rtp->rtcp) {
ast_debug(1, "Setting RTCP address on RTP instance '%p'\n", instance);
ast_sockaddr_copy(&rtp->rtcp->them, addr);
if (!ast_sockaddr_isnull(addr)) {
- ast_sockaddr_set_port(&rtp->rtcp->them,
- ast_sockaddr_port(addr) + 1);
- }
+ ast_sockaddr_set_port(&rtp->rtcp->them, ast_sockaddr_port(addr) + 1);
- if (!ast_sockaddr_isnull(addr)) {
/* Update the local RTCP address with what is being used */
- ast_sockaddr_set_port(&us, ast_sockaddr_port(&local) + 1);
- ast_sockaddr_copy(&rtp->rtcp->us, &us);
+ ast_sockaddr_set_port(&local, ast_sockaddr_port(&local) + 1);
+ ast_sockaddr_copy(&rtp->rtcp->us, &local);
ast_free(rtp->rtcp->local_addr_str);
- rtp->rtcp->local_addr_str = ast_strdup(ast_sockaddr_stringify(&us));
+ rtp->rtcp->local_addr_str = ast_strdup(ast_sockaddr_stringify(&local));
}
}
@@ -5040,8 +5042,6 @@ static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct
rtp->strict_rtp_state = STRICT_RTP_LEARN;
rtp_learning_seq_init(&rtp->rtp_source_learn, rtp->seqno);
}
-
- return;
}
/*! \brief Write t140 redundacy frame
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index 645e7c4fb..2398ec428 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -63,11 +63,8 @@ ifeq ($(SPECIAL_TARGETS),)
endif
ifeq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),MALLOC_DEBUG)
CF += -DMALLOC_DEBUG
- MALLOC_DEBUG = yes
- $(apps): export LDFLAGS += -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
- $(apps): source/pjsip-apps/lib/libasterisk_malloc_debug.a
- source/pjsip-apps/src/python/_pjsua.so: LDFLAGS += -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
- source/pjsip-apps/src/python/_pjsua.so: source/pjsip-apps/lib/libasterisk_malloc_debug.a
+ MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a
+ MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
endif
ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
CF += -O3
@@ -190,14 +187,18 @@ source/pjsip-apps/lib/libasterisk_malloc_debug.a: source/pjsip-apps/lib/asterisk
$(CMD_PREFIX) ar qs $@ $< >/dev/null 2>&1
$(apps): APP = $(filter pj%,$(subst -, ,$(notdir $@)))
-$(apps): pjproject.symbols $(APP_THIRD_PARTY_LIB_FILES)
+$(apps): CFLAGS += -DPJ_LOG_MAX_LEVEL=2
+$(apps): LDFLAGS += $(MALLOC_DEBUG_LDFLAGS)
+$(apps): $(MALLOC_DEBUG_LIBS) pjproject.symbols $(APP_THIRD_PARTY_LIB_FILES)
$(ECHO_PREFIX) Compiling $(APP)
$(CMD_PREFIX) +$(MAKE) -C source/pjsip-apps/build $(filter pj%,$(subst -, ,$(notdir $@))) $(REALLY_QUIET)
+source/pjsip-apps/src/python/_pjsua.o: CFLAGS += -DPJ_LOG_MAX_LEVEL=2
source/pjsip-apps/src/python/_pjsua.o: source/pjsip-apps/src/python/_pjsua.c $(apps)
$(ECHO_PREFIX) Compiling python bindings
$(CMD_PREFIX) $(CC) -o $@ -c $< $(PYTHONDEV_INCLUDE) $(CFLAGS) $(PJ_CFLAGS)
+source/pjsip-apps/src/python/_pjsua.so: LDFLAGS += $(MALLOC_DEBUG_LDFLAGS)
source/pjsip-apps/src/python/_pjsua.so: source/pjsip-apps/src/python/_pjsua.o
$(ECHO_PREFIX) Linking python bindings $(@F)
$(CMD_PREFIX) gcc -shared -pthread -o $@ $< $(LDFLAGS) $(PJ_LDFLAGS) $(APP_LDLIBS) $(PYTHONDEV_LIB) $(REALLY_QUIET)
diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h
index f84adeb35..5e29cdb6a 100644
--- a/third-party/pjproject/patches/config_site.h
+++ b/third-party/pjproject/patches/config_site.h
@@ -34,7 +34,11 @@
#define PJ_SCANNER_USE_BITWISE 0
#define PJ_OS_HAS_CHECK_STACK 0
+
+#ifndef PJ_LOG_MAX_LEVEL
#define PJ_LOG_MAX_LEVEL 6
+#endif
+
#define PJ_ENABLE_EXTRA_CHECK 1
#define PJSIP_MAX_TSX_COUNT ((64*1024)-1)
#define PJSIP_MAX_DIALOG_COUNT ((64*1024)-1)