[Asterisk-code-review] chan_pjsip: Ignore RTP that we haven't negotiated (asterisk[13])
Sean Bright
asteriskteam at digium.com
Fri Dec 27 09:23:03 CST 2019
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13503 )
Change subject: chan_pjsip: Ignore RTP that we haven't negotiated
......................................................................
chan_pjsip: Ignore RTP that we haven't negotiated
If chan_pjsip receives an RTP packet whose payload differs from the
channel's native format, and asymmetric_rtp_codec is disabled (the
default), Asterisk will switch the channel's native format to match
that of the incoming packet without regard to the negotiated payloads.
We now keep track of the formats that have been negotiated and check
before switching payloads which results in these packets being dropped
instead of causing the session to terminate.
ASTERISK-28139 #close
Reported by: Paul Brooks
Change-Id: Icc3b85cee1772026cee5dc1b68459bf9431c14a3
---
M channels/chan_pjsip.c
M include/asterisk/res_pjsip_session.h
M res/res_pjsip_sdp_rtp.c
M res/res_pjsip_session.c
4 files changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/13503/1
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 33abe03..c4281c3 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -771,7 +771,8 @@
* raw read format BEFORE the native format check
*/
if (!session->endpoint->asymmetric_rtp_codec &&
- ast_format_cmp(ast_channel_rawwriteformat(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ ast_format_cmp(ast_channel_rawwriteformat(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL &&
+ ast_format_cap_iscompatible_format(session->joint_caps, f->subclass.format) == AST_FORMAT_CMP_EQUAL) {
struct ast_format_cap *caps;
/* For maximum compatibility we ensure that the formats match that of the received media */
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 9ae1883..676a335 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -143,6 +143,8 @@
struct ast_party_id id;
/*! Requested capabilities */
struct ast_format_cap *req_caps;
+ /*! Joint capabilities */
+ struct ast_format_cap *joint_caps;
/*! Optional DSP, used only for inband DTMF/Fax-CNG detection if configured */
struct ast_dsp *dsp;
/*! Whether the termination of the session should be deferred */
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 98e9819..78c19aa 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -401,6 +401,8 @@
return -1;
}
+ ast_format_cap_append_from_cap(session->joint_caps, joint, media_type);
+
ast_rtp_codecs_payloads_copy(&codecs, ast_rtp_instance_get_codecs(session_media->rtp),
session_media->rtp);
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index bbdb8d1..b61b0fd 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1351,6 +1351,7 @@
ao2_cleanup(session->aor);
ao2_cleanup(session->contact);
ao2_cleanup(session->req_caps);
+ ao2_cleanup(session->joint_caps);
ao2_cleanup(session->direct_media_cap);
ast_dsp_free(session->dsp);
@@ -1433,6 +1434,10 @@
if (!session->req_caps) {
return NULL;
}
+ session->joint_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!session->joint_caps) {
+ return NULL;
+ }
session->datastores = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
DATASTORE_BUCKETS, datastore_hash, NULL, datastore_cmp);
if (!session->datastores) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13503
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Icc3b85cee1772026cee5dc1b68459bf9431c14a3
Gerrit-Change-Number: 13503
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191227/0bda4a69/attachment-0001.html>
More information about the asterisk-code-review
mailing list