]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: Fix ICE candidate nomination
authorThomas Guebels <tgu@escaux.com>
Mon, 19 Feb 2018 10:21:30 +0000 (11:21 +0100)
committerThomas Guebels <tgu@escaux.com>
Mon, 19 Feb 2018 10:31:38 +0000 (11:31 +0100)
If the ICE role is not set right away, we might have a role conflict
that stays undetected and ICE finishing with successful tests and no
candidate nominated. This was introduced by ASTERISK-27088.

To avoid this, we set the role as soon as before but only if the ICE
state permits it: still checking and not yet nominating candidates or
completed.

ASTERISK-27646

Change-Id: I5dbc69ad63cacbb067922850fbb113d479bd729c

res/res_rtp_asterisk.c

index 263dbff18b1e7495960fe2bc4f25b502eadd0b0f..76f5b09bb2eae44deb325fb194017212fe834049 100644 (file)
@@ -1011,6 +1011,15 @@ static void ast_rtp_ice_set_role(struct ast_rtp_instance *instance, enum ast_rtp
        }
 
        rtp->role = role;
+
+       if (!rtp->ice->real_ice->is_nominating && !rtp->ice->real_ice->is_complete) {
+               pj_thread_register_check();
+
+               pj_ice_sess_change_role(rtp->ice->real_ice, role == AST_RTP_ICE_ROLE_CONTROLLED ?
+                       PJ_ICE_SESS_ROLE_CONTROLLED : PJ_ICE_SESS_ROLE_CONTROLLING);
+       } else {
+               ast_debug(3, "Not setting ICE role because state is %s\n", rtp->ice->real_ice->is_nominating ? "nominating" : "complete" );
+       }
 }
 
 /*! \pre instance is locked */