[Asterisk-code-review] res_pjsip_sdp_rtp: Send topology changed after hold/unhold. (asterisk[16])
Maximilian Fridrich
asteriskteam at digium.com
Thu May 19 09:41:41 CDT 2022
Maximilian Fridrich has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18571 )
Change subject: res_pjsip_sdp_rtp: Send topology changed after hold/unhold.
......................................................................
res_pjsip_sdp_rtp: Send topology changed after hold/unhold.
When a pjsip channel with more than one stream is set on hold/unhold,
the hold indication only handles the default audio stream. Other stream
topologies might have changed simultaneously, so after the (un)hold
frame is queued an additional frame of type
AST_CONTROL_STREAM_TOPOLOGY_CHANGED is queued. This ensures that
TOPOLOGY_CHANGED with the correct topology of all streams is indicated
after hold/unhold is indicated.
ASTERISK-30051
Change-Id: I04f1110565fd05fea565f5539b534b54549d4f71
---
M res/res_pjsip_sdp_rtp.c
1 file changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/71/18571/1
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 3b2e299..d821535 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -2001,8 +2001,11 @@
RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
struct pjmedia_sdp_media *remote_stream = remote->media[index];
enum ast_media_type media_type = session_media->type;
+ struct ast_stream_topology *top = NULL;
+ struct ast_stream *stream;
char host[NI_MAXHOST];
int res;
+ int i;
struct ast_sip_session_media *session_media_transport;
if (!session->channel) {
@@ -2097,16 +2100,43 @@
set_session_media_remotely_held(session_media, session, remote_stream, asterisk_stream, addrs);
if (session_media->remotely_held_changed) {
+ struct ast_frame f = { .frametype = AST_FRAME_NULL };
+ if (ast_stream_topology_get_count(session->pending_media_state->topology) > 1) {
+ /* If there is more than just the audio stream, we need to make sure to also queue
+ * a topoology_change update. Otherwise the hold indication could overwrite the
+ * topology of the other streams.
+ */
+ top = ast_stream_topology_clone(session->pending_media_state->topology);
+ for (i = 0; i < ast_stream_topology_get_count(top); ++i) {
+ stream = ast_stream_topology_get_stream(top, i);
+ if (ast_stream_get_state(stream) == AST_STREAM_STATE_RECVONLY) {
+ ast_stream_set_state(stream, AST_STREAM_STATE_SENDONLY);
+ } else if (ast_stream_get_state(stream) == AST_STREAM_STATE_SENDONLY) {
+ ast_stream_set_state(stream, AST_STREAM_STATE_RECVONLY);
+ }
+ }
+ f.frametype = AST_FRAME_CONTROL;
+ f.subclass.integer = AST_CONTROL_STREAM_TOPOLOGY_CHANGED,
+ f.data.ptr = (void *)top;
+ }
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);
+ if (f.frametype != AST_FRAME_NULL && top != NULL) {
+ ast_queue_frame(session->channel, &f);
+ ast_stream_topology_free(top);
+ }
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);
+ if (f.frametype != AST_FRAME_NULL && top != NULL) {
+ ast_queue_frame(session->channel, &f);
+ ast_stream_topology_free(top);
+ }
session_media->remotely_held_changed = 0;
}
} else if ((pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE)
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18571
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I04f1110565fd05fea565f5539b534b54549d4f71
Gerrit-Change-Number: 18571
Gerrit-PatchSet: 1
Gerrit-Owner: Maximilian Fridrich <m.fridrich at commend.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220519/5ce61f6a/attachment.html>
More information about the asterisk-code-review
mailing list