[Asterisk-code-review] chan_pjsip: Check audio frame when remote SSRC changes. (asterisk[13])
George Joseph
asteriskteam at digium.com
Tue Mar 10 11:59:04 CDT 2020
George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13846 )
Change subject: chan_pjsip: Check audio frame when remote SSRC changes.
......................................................................
chan_pjsip: Check audio frame when remote SSRC changes.
If the SSRC of a received RTP packet differed from the previous SSRC
an SSRC change control frame would be queued ahead of the media
frame. In the case of audio this would result in the format of the
audio frame not being checked, and if it differed or was not allowed
then it could cause the call to drop due to failure to set up a
translation path.
The chan_pjsip module will now no longer assume the first frame
will be the audio frame and instead goes through the complete list
to find it.
ASTERISK-28759
Change-Id: I6d854cc523f343e299a615636fc65bdbd5f809ec
---
M channels/chan_pjsip.c
1 file changed, 17 insertions(+), 10 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index c4281c3..0466fd3 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -731,6 +731,7 @@
struct ast_sip_session_media *media = NULL;
int rtcp = 0;
int fdno = ast_channel_fdno(ast);
+ struct ast_frame *cur;
switch (fdno) {
case 0:
@@ -759,7 +760,13 @@
ast_rtp_instance_set_last_rx(media->rtp, time(NULL));
- if (f->frametype != AST_FRAME_VOICE) {
+ for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
+ if (cur->frametype == AST_FRAME_VOICE) {
+ break;
+ }
+ }
+
+ if (!cur) {
return f;
}
@@ -771,36 +778,36 @@
* 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_cap_iscompatible_format(session->joint_caps, f->subclass.format) == AST_FORMAT_CMP_EQUAL) {
+ ast_format_cmp(ast_channel_rawwriteformat(ast), cur->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL &&
+ ast_format_cap_iscompatible_format(session->joint_caps, cur->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 */
ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when we're sending '%s', switching to match\n",
- ast_format_get_name(f->subclass.format), ast_channel_name(ast),
+ ast_format_get_name(cur->subclass.format), ast_channel_name(ast),
ast_format_get_name(ast_channel_rawwriteformat(ast)));
caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (caps) {
ast_format_cap_append_from_cap(caps, ast_channel_nativeformats(ast), AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_remove_by_type(caps, AST_MEDIA_TYPE_AUDIO);
- ast_format_cap_append(caps, f->subclass.format, 0);
+ ast_format_cap_append(caps, cur->subclass.format, 0);
ast_channel_nativeformats_set(ast, caps);
ao2_ref(caps, -1);
}
- ast_set_write_format_path(ast, ast_channel_writeformat(ast), f->subclass.format);
- ast_set_read_format_path(ast, ast_channel_readformat(ast), f->subclass.format);
+ ast_set_write_format_path(ast, ast_channel_writeformat(ast), cur->subclass.format);
+ ast_set_read_format_path(ast, ast_channel_readformat(ast), cur->subclass.format);
if (ast_channel_is_bridged(ast)) {
ast_channel_set_unbridged_nolock(ast, 1);
}
}
- if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), cur->subclass.format)
+ == AST_FORMAT_CMP_NOT_EQUAL) {
ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when it has not been negotiated\n",
- ast_format_get_name(f->subclass.format), ast_channel_name(ast));
-
+ ast_format_get_name(cur->subclass.format), ast_channel_name(ast));
ast_frfree(f);
return &ast_null_frame;
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13846
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I6d854cc523f343e299a615636fc65bdbd5f809ec
Gerrit-Change-Number: 13846
Gerrit-PatchSet: 8
Gerrit-Owner: Paulo Vicentini <paulo.vicentini at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200310/db4aa9b7/attachment-0001.html>
More information about the asterisk-code-review
mailing list