]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Do not allow native RTP bridging if packetization of media streams differs.
authorMark Michelson <mmichelson@digium.com>
Tue, 12 Feb 2013 20:16:24 +0000 (20:16 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 12 Feb 2013 20:16:24 +0000 (20:16 +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

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

main/rtp_engine.c

index 04905358cbf3ed9caa49c5270a5f8a035591f016..b2adb0de4a4e577372497c18a07b32b4c190d145 100644 (file)
@@ -1273,6 +1273,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
        enum ast_rtp_dtmf_mode dmode;
        format_t codec0 = 0, codec1 = 0;
        int unlock_chans = 1;
+       int read_ptime0, read_ptime1, write_ptime0, write_ptime1;
 
        /* Lock both channels so we can look for the glue that binds them together */
        ast_channel_lock(c0);
@@ -1352,6 +1353,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, c0->rawreadformat)).cur_ms;
+       read_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, c1->rawreadformat)).cur_ms;
+       write_ptime0 = (ast_codec_pref_getsize(&instance0->codecs.pref, c0->rawwriteformat)).cur_ms;
+       write_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, c1->rawwriteformat)).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;