]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Do not allow native RTP bridging if packetization of media streams differs.
authorMatthew Jordan <mjordan@digium.com>
Thu, 14 Feb 2013 15:08:15 +0000 (15:08 +0000)
committerMatthew Jordan <mjordan@digium.com>
Thu, 14 Feb 2013 15:08:15 +0000 (15:08 +0000)
The RTP engine will no longer allow for local and remote native RTP bridges
if packetization of streams differs. Allowing native bridging in this scenario
has been known to cause FAX failures.

(closes ASTERISK-20650)
Reported by: Maciej Krajewski
Patches:
ASTERISK-20659.patch uploaded by Mark Michelson (License #5049)

Review: https://reviewboard.asterisk.org/r/2319
........

Merged revisions 381281 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 381306 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/11.2@381401 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/rtp_engine.c

index 4e2669088919704b1deae77fead3bec09bcfd17b..a64db0f2aa7e662a2ff2f35f0afa4fa9b024ac1f 100644 (file)
@@ -1460,6 +1460,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
        struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
        struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
        int unlock_chans = 1;
+       int read_ptime0, read_ptime1, write_ptime0, write_ptime1;
 
        if (!cap0 || !cap1) {
                unlock_chans = 0;
@@ -1568,6 +1569,18 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
                goto done;
        }
 
+       read_ptime0 = (ast_codec_pref_getsize(&instance0->codecs.pref, ast_channel_rawreadformat(c0))).cur_ms;
+       read_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, ast_channel_rawreadformat(c1))).cur_ms;
+       write_ptime0 = (ast_codec_pref_getsize(&instance0->codecs.pref, ast_channel_rawwriteformat(c0))).cur_ms;
+       write_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, ast_channel_rawwriteformat(c1))).cur_ms;
+
+       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);
+               res = AST_BRIDGE_FAILED_NOWARN;
+               goto done;
+       }
+
        instance0->glue = glue0;
        instance1->glue = glue1;
        instance0->chan = c0;