<p>Maximilian Fridrich has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18571">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_sdp_rtp: Send topology changed after hold/unhold.<br><br>When a pjsip channel with more than one stream is set on hold/unhold,<br>the hold indication only handles the default audio stream. Other stream<br>topologies might have changed simultaneously, so after the (un)hold<br>frame is queued an additional frame of type<br>AST_CONTROL_STREAM_TOPOLOGY_CHANGED is queued. This ensures that<br>TOPOLOGY_CHANGED with the correct topology of all streams is indicated<br>after hold/unhold is indicated.<br><br>ASTERISK-30051<br><br>Change-Id: I04f1110565fd05fea565f5539b534b54549d4f71<br>---<br>M res/res_pjsip_sdp_rtp.c<br>1 file changed, 30 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/71/18571/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c</span><br><span>index 3b2e299..d821535 100644</span><br><span>--- a/res/res_pjsip_sdp_rtp.c</span><br><span>+++ b/res/res_pjsip_sdp_rtp.c</span><br><span>@@ -2001,8 +2001,11 @@</span><br><span> RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);</span><br><span> struct pjmedia_sdp_media *remote_stream = remote->media[index];</span><br><span> enum ast_media_type media_type = session_media->type;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_stream_topology *top = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_stream *stream;</span><br><span> char host[NI_MAXHOST];</span><br><span> int res;</span><br><span style="color: hsl(120, 100%, 40%);">+ int i;</span><br><span> struct ast_sip_session_media *session_media_transport;</span><br><span> </span><br><span> if (!session->channel) {</span><br><span>@@ -2097,16 +2100,43 @@</span><br><span> set_session_media_remotely_held(session_media, session, remote_stream, asterisk_stream, addrs);</span><br><span> </span><br><span> if (session_media->remotely_held_changed) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_frame f = { .frametype = AST_FRAME_NULL };</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_stream_topology_get_count(session->pending_media_state->topology) > 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If there is more than just the audio stream, we need to make sure to also queue</span><br><span style="color: hsl(120, 100%, 40%);">+ * a topoology_change update. Otherwise the hold indication could overwrite the</span><br><span style="color: hsl(120, 100%, 40%);">+ * topology of the other streams.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ top = ast_stream_topology_clone(session->pending_media_state->topology);</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 0; i < ast_stream_topology_get_count(top); ++i) {</span><br><span style="color: hsl(120, 100%, 40%);">+ stream = ast_stream_topology_get_stream(top, i);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_stream_get_state(stream) == AST_STREAM_STATE_RECVONLY) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_set_state(stream, AST_STREAM_STATE_SENDONLY);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (ast_stream_get_state(stream) == AST_STREAM_STATE_SENDONLY) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_set_state(stream, AST_STREAM_STATE_RECVONLY);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ f.frametype = AST_FRAME_CONTROL;</span><br><span style="color: hsl(120, 100%, 40%);">+ f.subclass.integer = AST_CONTROL_STREAM_TOPOLOGY_CHANGED,</span><br><span style="color: hsl(120, 100%, 40%);">+ f.data.ptr = (void *)top;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> if (session_media->remotely_held) {</span><br><span> /* The remote side has put us on hold */</span><br><span> ast_queue_hold(session->channel, session->endpoint->mohsuggest);</span><br><span> ast_rtp_instance_stop(session_media->rtp);</span><br><span> ast_queue_frame(session->channel, &ast_null_frame);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f.frametype != AST_FRAME_NULL && top != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_queue_frame(session->channel, &f);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_topology_free(top);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> session_media->remotely_held_changed = 0;</span><br><span> } else {</span><br><span> /* The remote side has taken us off hold */</span><br><span> ast_queue_unhold(session->channel);</span><br><span> ast_queue_frame(session->channel, &ast_null_frame);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f.frametype != AST_FRAME_NULL && top != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_queue_frame(session->channel, &f);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_topology_free(top);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> session_media->remotely_held_changed = 0;</span><br><span> }</span><br><span> } else if ((pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18571">change 18571</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18571"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I04f1110565fd05fea565f5539b534b54549d4f71 </div>
<div style="display:none"> Gerrit-Change-Number: 18571 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Maximilian Fridrich <m.fridrich@commend.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>