]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_pjsip_sdp_rtp: Fix MOH transitions
authorTorrey Searle <torrey@voxbone.com>
Mon, 24 Feb 2020 15:00:08 +0000 (16:00 +0100)
committerSean Bright <sean.bright@gmail.com>
Thu, 27 Feb 2020 20:20:37 +0000 (14:20 -0600)
Update the state of remote_hold immediately on receipt of remote
SDP so that the information is available when building the SDP
answer

ASTERISK-28754 #close

Change-Id: I7026032a807e9c95081cb8f060400b05deb4836f

include/asterisk/res_pjsip_session.h
res/res_pjsip_sdp_rtp.c

index 38df3fd1658f1cf3d84fc9d44d225374ef56f51d..27d669fa159ca63b87148e24d8577bea4d6f78c0 100644 (file)
@@ -89,6 +89,8 @@ struct ast_sip_session_media {
        unsigned int remote_rtcp_mux:1;
        /*! \brief Does remote support ice */
        unsigned int remote_ice:1;
+       /*! \brief Stream is held by remote side changed during this negotiation*/
+       unsigned int remotely_held_changed:1;
        /*! \brief Stream type this session media handles */
        char stream_type[1];
 };
index 391a65ef051e66a3b3850f5a33612466df713048..15245f2247577e0a7ce5cc1078ac0e7c4285afe7 100644 (file)
@@ -1066,6 +1066,20 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct
        /* If ICE support is enabled find all the needed attributes */
        check_ice_support(session, session_media, stream);
 
+       /* Check if incomming SDP is changing the remotely held state */
+       if (ast_sockaddr_isnull(addrs) ||
+               ast_sockaddr_is_any(addrs) ||
+               pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL) ||
+               pjmedia_sdp_media_find_attr2(stream, "inactive", NULL)) {
+               if (!session_media->remotely_held) {
+                       session_media->remotely_held = 1;
+                       session_media->remotely_held_changed = 1;
+               }
+       } else if (session_media->remotely_held) {
+               session_media->remotely_held = 0;
+               session_media->remotely_held_changed = 1;
+       }
+
        if (set_caps(session, session_media, stream)) {
                return 0;
        }
@@ -1484,22 +1498,19 @@ static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct a
                return 1;
        }
 
-       if (ast_sockaddr_isnull(addrs) ||
-               ast_sockaddr_is_any(addrs) ||
-               pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL) ||
-               pjmedia_sdp_media_find_attr2(remote_stream, "inactive", NULL)) {
-               if (!session_media->remotely_held) {
+       if (session_media->remotely_held_changed) {
+               if (session_media->remotely_held) {
                        /* The remote side has put us on hold */
                        ast_queue_hold(session->channel, session->endpoint->mohsuggest);
                        ast_rtp_instance_stop(session_media->rtp);
                        ast_queue_frame(session->channel, &ast_null_frame);
-                       session_media->remotely_held = 1;
+                       session_media->remotely_held_changed = 0;
+               } else {
+                       /* The remote side has taken us off hold */
+                       ast_queue_unhold(session->channel);
+                       ast_queue_frame(session->channel, &ast_null_frame);
+                       session_media->remotely_held_changed = 0;
                }
-       } else if (session_media->remotely_held) {
-               /* The remote side has taken us off hold */
-               ast_queue_unhold(session->channel);
-               ast_queue_frame(session->channel, &ast_null_frame);
-               session_media->remotely_held = 0;
        } else if ((pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE)
                && (session->inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
                ast_queue_control(session->channel, AST_CONTROL_UPDATE_RTP_PEER);