]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_sdp_rtp: implement hold state handling on moh_passthrough
authorTorrey Searle <torrey@voxbone.com>
Wed, 12 Feb 2020 16:05:11 +0000 (17:05 +0100)
committerTorrey Searle <torrey@voxbone.com>
Mon, 17 Feb 2020 07:35:26 +0000 (08:35 +0100)
When moh_passthrough is used, asterisk is only generating invites
of type sendonly and sendrecv instead of taking fully into account
the on hold state of the local and remote parties

ASTERISK-28738 #close

Change-Id: Iaaad9fbc033cb14803d433b8a4071bc337047761

res/res_pjsip_sdp_rtp.c

index 36b60444d355d025e77c5695010f5fe192a160e0..391a65ef051e66a3b3850f5a33612466df713048 100644 (file)
@@ -1188,6 +1188,8 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
        static const pj_str_t STR_IP6 = { "IP6", 3};
        static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
        static const pj_str_t STR_SENDONLY = { "sendonly", 8 };
+       static const pj_str_t STR_INACTIVE = { "inactive", 8 };
+       static const pj_str_t STR_RECVONLY = { "recvonly", 8 };
        pjmedia_sdp_media *media;
        const char *hostip = NULL;
        struct ast_sockaddr addr;
@@ -1371,9 +1373,20 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
                media->attr[media->attr_count++] = attr;
        }
 
-       /* Add the sendrecv attribute - we purposely don't keep track because pjmedia-sdp will automatically change our offer for us */
        attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
-       attr->name = !session_media->locally_held ? STR_SENDRECV : STR_SENDONLY;
+       if (session_media->locally_held) {
+               if (session_media->remotely_held) {
+                       attr->name = STR_INACTIVE; /* To place on hold a recvonly stream, send inactive */
+               } else {
+                       attr->name = STR_SENDONLY; /* Send sendonly to initate a local hold */
+               }
+       } else {
+               if (session_media->remotely_held) {
+                       attr->name = STR_RECVONLY; /* Remote has sent sendonly, reply recvonly */
+               } else {
+                       attr->name = STR_SENDRECV; /* No hold in either direction */
+               }
+       }
        media->attr[media->attr_count++] = attr;
 
        /* If we've got rtcp-mux enabled, add it unless we received an offer without it */