Browse Source

MT#63317 set correct output media w bundle

Change-Id: I8e4e2514a6f779d9fcedfe1593b228d336cf5c2a
rfuchs/dtls-ice
Richard Fuchs 3 months ago
parent
commit
cc48a89c41
4 changed files with 54 additions and 11 deletions
  1. +37
    -0
      daemon/call.c
  2. +4
    -5
      daemon/media_socket.c
  3. +2
    -1
      include/media_socket.h
  4. +11
    -5
      t/auto-daemon-tests-bundle.pl

+ 37
- 0
daemon/call.c View File

@ -1287,6 +1287,7 @@ void free_sink_handler(struct sink_handler *sh) {
void __add_sink_handler(sink_handler_q *q, struct packet_stream *sink, const struct sink_attrs *attrs) {
struct sink_handler *sh = g_new0(__typeof(*sh), 1);
sh->sink = sink;
sh->bundle_sink = sink;
if (attrs)
sh->attrs = *attrs;
t_queue_push_tail(q, sh);
@ -3451,6 +3452,40 @@ static void monologue_bundle_set_fds(struct call_monologue *ml) {
}
}
// reset/assign handler sinks
__attribute__((nonnull(1)))
static void monologue_bundle_set_sink_handlers(sink_handler_q *q) {
for (__auto_type l = q->head; l; l = l->next) {
__auto_type sh = l->data;
__auto_type sink = sh->sink;
__auto_type media = sink->media;
__auto_type bundle = media->bundle;
if (!bundle)
continue;
__auto_type ps = get_media_component(bundle, sink->component);
if (ps)
sh->bundle_sink = ps;
else
ilog(LOG_WARN, "No matching bundle stream for component #%u found", sink->component);
}
}
// reset/assign handler sinks
__attribute__((nonnull(1)))
static void monologue_bundle_set_sinks(struct call_monologue *ml) {
for (unsigned int i = 0; i < ml->medias->len; i++) {
__auto_type media = ml->medias->pdata[i];
if (!media)
continue;
for (__auto_type l = media->streams.head; l; l = l->next) {
__auto_type ps = l->data;
monologue_bundle_set_sink_handlers(&ps->rtp_sinks);
monologue_bundle_set_sink_handlers(&ps->rtcp_sinks);
monologue_bundle_set_sink_handlers(&ps->rtp_mirrors);
}
}
}
__attribute__((nonnull(1, 2)))
static void monologue_bundle_accept(struct call_monologue *ml, sdp_ng_flags *flags) {
if (!ML_ISSET(ml, BUNDLE))
@ -3742,6 +3777,8 @@ int monologue_offer_answer(struct call_monologue *monologues[2], sdp_streams_q *
monologue_bundle_accept(sender_ml, flags);
monologue_bundle_set_fds(receiver_ml);
monologue_bundle_set_sinks(sender_ml);
monologue_bundle_set_sinks(receiver_ml);
// set ipv4/ipv6/mixed media stats
if (flags->opmode == OP_OFFER || flags->opmode == OP_ANSWER) {


+ 4
- 5
daemon/media_socket.c View File

@ -2844,11 +2844,10 @@ static void media_packet_set_streams(struct packet_handler_ctx *phc) {
// out_srtp is set to point to the SRTP context to use
static void media_packet_rtcp_mux(struct packet_handler_ctx *phc, struct sink_handler *sh) {
phc->out_srtp = sh->sink;
if (phc->rtcp && sh->sink->rtcp_sibling)
phc->out_srtp = sh->sink->rtcp_sibling; // use RTCP SRTP context
phc->mp.media_out = sh->sink->media;
phc->out_srtp = sh->bundle_sink;
if (phc->rtcp && phc->out_srtp->rtcp_sibling)
phc->out_srtp = phc->out_srtp->rtcp_sibling; // use RTCP SRTP context
}
@ -3573,7 +3572,7 @@ static int stream_packet(struct packet_handler_ctx *phc) {
for (__auto_type sh_link = phc->sinks->head; sh_link; sh_link = sh_link->next) {
struct sink_handler *sh = sh_link->data;
struct packet_stream *sink = sh->sink;
struct packet_stream *sink = sh->bundle_sink;
// this sets rtcp, in_srtp, out_srtp, media_out, and sink
media_packet_rtcp_mux(phc, sh);


+ 2
- 1
include/media_socket.h View File

@ -269,7 +269,8 @@ struct rtpext_printer {
* only the sink_handler objects (and the packet_stream objects they are related to) are used.
*/
struct sink_handler {
struct packet_stream *sink;
struct packet_stream *sink; // part of the appropriate output media
struct packet_stream *bundle_sink; // from the bundle head media
const struct streamhandler *handler;
struct sink_attrs attrs;
const struct rtpext_printer *rtpext;


+ 11
- 5
t/auto-daemon-tests-bundle.pl View File

@ -429,8 +429,8 @@ snd($sock_b, $port_d, rtp(105, 3000, 4000, 0x6321, "\x33" x 800));
rcv($sock_d, $port_b, rtpm(105, 3000, 4000, 0x6321, "\x33" x 800));
snd($sock_d, $port_b, rtp(105, 7000, 9000, 0x8741, "\x22" x 800));
rcv($sock_b, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800)); # XXX wrong port
rcv_no($sock_a);
rcv($sock_a, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800));
rcv_no($sock_b);
# mix up bundle ports
@ -1073,12 +1073,14 @@ rcv($sock_c, $port_a, rtpm(0, 2000, 6000, 0x1234, "\x44" x 160, [[1, 'a']]));
snd($sock_c, $port_a, rtp(0, 6000, 8000, 0x5678, "\x77" x 160));
rcv($sock_a, $port_c, rtpm(0, 6000, 8000, 0x5678, "\x77" x 160, [[1, 'a']]));
rcv_no($sock_b);
snd($sock_a, $port_d, rtp(105, 3000, 4000, 0x6321, "\x33" x 800));
rcv($sock_d, $port_b, rtpm(105, 3000, 4000, 0x6321, "\x33" x 800));
snd($sock_d, $port_b, rtp(105, 7000, 9000, 0x8741, "\x22" x 800));
rcv($sock_b, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']])); # XXX wrong socket
rcv($sock_a, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']]));
rcv_no($sock_b);
# mix up bundle ports
@ -1197,12 +1199,14 @@ rcv($sock_c, $port_a, rtpm(0, 2000, 6000, 0x1234, "\x44" x 160));
snd($sock_c, $port_a, rtp(0, 6000, 8000, 0x5678, "\x77" x 160));
rcv($sock_a, $port_c, rtpm(0, 6000, 8000, 0x5678, "\x77" x 160, [[1, 'a']]));
rcv_no($sock_b);
snd($sock_a, $port_d, rtp(105, 3000, 4000, 0x6321, "\x33" x 800));
rcv($sock_d, $port_b, rtpm(105, 3000, 4000, 0x6321, "\x33" x 800));
snd($sock_d, $port_b, rtp(105, 7000, 9000, 0x8741, "\x22" x 800));
rcv($sock_b, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']])); # XXX wrong socket
rcv($sock_a, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']]));
rcv_no($sock_b);
# mix up bundle ports
@ -1351,12 +1355,14 @@ rcv($sock_c, $port_a, rtpm(0, 2000, 6000, 0x1234, "\x44" x 160));
snd($sock_c, $port_a, rtp(0, 6000, 8000, 0x5678, "\x77" x 160));
rcv($sock_a, $port_c, rtpm(0, 6000, 8000, 0x5678, "\x77" x 160, [[1, 'a']]));
rcv_no($sock_b);
snd($sock_a, $port_d, rtp(105, 3000, 4000, 0x6321, "\x33" x 800));
rcv($sock_d, $port_b, rtpm(105, 3000, 4000, 0x6321, "\x33" x 800));
snd($sock_d, $port_b, rtp(105, 7000, 9000, 0x8741, "\x22" x 800));
rcv($sock_b, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']])); # XXX wrong socket
rcv($sock_a, $port_d, rtpm(105, 7000, 9000, 0x8741, "\x22" x 800, [[1, 'v']]));
rcv_no($sock_b);
# mix up bundle ports


Loading…
Cancel
Save