From 03885f4e4db3ac4c1e60c1ee25747e291c03d541 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 31 Jan 2023 13:23:04 -0500 Subject: [PATCH] MT#56521 hunt for usable packet_stream In order to rewrite certain session-level SDP lines, we need to reference a packet_stream which contains the correct information. But we cannot simply rely on the first media section having a usable packet stream, as the first media section could have been rejected. Iterate media sections until we find a usable one. Change-Id: I36594e80981fc0645a7747399bd9951fbc2e5676 --- daemon/sdp.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/daemon/sdp.c b/daemon/sdp.c index 47cdad54a..12c8da51c 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2687,15 +2687,21 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu err = "no matching session media"; if (!m) goto error; - call_media = m->data; - err = "mismatched session media index"; - if (call_media->index != media_index) - goto error; - err = "no matching session media stream"; - rtp_ps_link = call_media->streams.head; - if (!rtp_ps_link) + + // look for first usable (non-rejected, non-empty) packet stream + // from any media to determine session-level attributes, if any + ps = NULL; + for (GList *mc = m; mc; mc = mc->next) { + call_media = mc->data; + if (!call_media->streams.head) + continue; + ps = call_media->streams.head->data; + break; + } + + err = "no usable session media stream"; + if (!ps) goto error; - ps = rtp_ps_link->data; err = "error while processing o= line"; if (!monologue->sdp_username)