From af991ee58f669214105e64efda7b022b3c81f5fc Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 8 Apr 2026 12:24:33 -0400 Subject: [PATCH] MT#55283 new "mix" flag Change-Id: I4d1dfa2a38533707e9c0f080377c880fc3b678a5 --- daemon/call.c | 22 +++++++++++++++++++--- daemon/call_interfaces.c | 4 ++++ docs/ng_control_protocol.md | 13 +++++++++++++ include/call_interfaces.h | 1 + 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 7b196ccd4..e739f2f47 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -4434,9 +4434,25 @@ static int monologue_subscribe_request1(struct call_media *src_media, struct cal if (ms) dst_media = ms->media; if (!dst_media) { - // new media needed - dst_media = call_get_media(dst_ml, &src_media->type, src_media->type_id, - NULL, false, dst_ml->medias->len + 1, mid_tracker_dst); + if (flags->mix) { + // find existing matching media + for (unsigned int i = 0; i < dst_ml->medias->len; i++) { + struct call_media *m = dst_ml->medias->pdata[i]; + if (!m) + continue; + if (m->type_id != src_media->type_id) + continue; + if (str_cmp_str(&m->type, &src_media->type)) + continue; + dst_media = m; + break; + } + } + if (!dst_media) { + // new media needed + dst_media = call_get_media(dst_ml, &src_media->type, src_media->type_id, + NULL, false, dst_ml->medias->len + 1, mid_tracker_dst); + } } /* subscribe dst_ml (subscriber) to src_ml, don't forget to carry the egress flag, if required */ diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 3b63d0b49..995b56718 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1218,6 +1218,10 @@ void call_ng_flags_flags(str *s, unsigned int idx, helper_arg arg) { case CSH_LOOKUP("rtcp mirror"): out->rtcp_mirror = true; break; + case CSH_LOOKUP("mix"): + case CSH_LOOKUP("mixed"): + out->mix = true; + break; case CSH_LOOKUP("NAT-wait"): case CSH_LOOKUP("nat-wait"): case CSH_LOOKUP("NAT wait"): diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index 500e9595f..9ad390818 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -1168,6 +1168,19 @@ Spaces in each string may be replaced by hyphens. this opens a security hole and potentially allows RTP streams to be hijacked, either partly or in whole. +* `mix` + + For a subscribe request to subscribe to multiple source medias (e.g. + subscribe to the audio of both parties to a regular call), instead of + producing one output media per source media (e.g. two output audio media), + produce one output media for each type of source media (e.g. just one + output audio media). All affected RTP flows will then be sent as part of + the same output media. + + Not that this doesn't enable actual audio mixing. The `audio player` + feature can be used to produce a single mixed output audio stream which + combines all audio input into one. + * `NAT-wait` Prevents forwarding media packets to the respective endpoint diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 22d502e9f..c344d0417 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -223,6 +223,7 @@ RTPE_NG_FLAGS_STR_CASE_HT_PARAMS bundle_strict:1, ice_reject:1, rtcp_mirror:1, + mix:1, trickle_ice:1, no_rtcp_attr:1, no_tls_id:1,