]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_pjsip: Don't change formats when frame of unsupported format is received. 04/904/3
authorJoshua Colp <jcolp@digium.com>
Thu, 16 Jul 2015 14:46:14 +0000 (11:46 -0300)
committerJoshua Colp <jcolp@digium.com>
Fri, 17 Jul 2015 17:35:40 +0000 (14:35 -0300)
Receipt of an RTP packet currently causes the formats on an PJSIP channel to
change to the format of the RTP packet. In some off-nominal cases it's possible
for this to be a format that has not been configured or negotiated. This change
makes it so only formats explicitly configured on the endpoint are allowed.

ASTERISK-25258 #close

Change-Id: If93d641fb6418a285928839300d7854cab8c1020

channels/chan_pjsip.c

index 2907d46b2df84e2298a45fa38fe82b2d97aace92..a297ca609d10eac53aa9e10b460d555d98cbc2b2 100644 (file)
@@ -627,7 +627,15 @@ static struct ast_frame *chan_pjsip_read(struct ast_channel *ast)
                return f;
        }
 
-       if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+
+       if (ast_format_cap_iscompatible_format(channel->session->endpoint->media.codecs, f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+               ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when endpoint '%s' is not configured for it\n",
+                       ast_format_get_name(f->subclass.format), ast_channel_name(ast),
+                       ast_sorcery_object_get_id(channel->session->endpoint));
+
+               ast_frfree(f);
+               return &ast_null_frame;
+       } else if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
                struct ast_format_cap *caps;
 
                ast_debug(1, "Oooh, format changed to %s\n", ast_format_get_name(f->subclass.format));