From 6f1b71970d4f519b7c99ece3bf099e18dc2cdd9a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 16 Mar 2021 15:52:51 +0100 Subject: [PATCH] parse extmap-allow-mixed --- .../conversations/xmpp/jingle/RtpContentMap.java | 6 +++--- .../xmpp/jingle/SessionDescription.java | 15 ++++++++++----- .../xmpp/jingle/stanzas/RtpDescription.java | 12 +++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpContentMap.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpContentMap.java index 38935d8fb..3e02cc29b 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpContentMap.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpContentMap.java @@ -40,7 +40,7 @@ public class RtpContentMap { } public static RtpContentMap of(final JinglePacket jinglePacket) { - final Map contents = DescriptionTransport.of(jinglePacket.getJingleContents()); + final Map contents = DescriptionTransport.of(jinglePacket.getJingleContents()); if (isOmemoVerified(contents)) { return new OmemoVerifiedRtpContentMap(jinglePacket.getGroup(), contents); } else { @@ -53,7 +53,7 @@ public class RtpContentMap { if (values.size() == 0) { return false; } - for(final DescriptionTransport descriptionTransport : values) { + for (final DescriptionTransport descriptionTransport : values) { if (descriptionTransport.transport instanceof OmemoVerifiedIceUdpTransportInfo) { continue; } @@ -174,7 +174,7 @@ public class RtpContentMap { } public static DescriptionTransport of(final SessionDescription sessionDescription, final SessionDescription.Media media) { - final RtpDescription rtpDescription = RtpDescription.of(media); + final RtpDescription rtpDescription = RtpDescription.of(sessionDescription, media); final IceUdpTransportInfo transportInfo = IceUdpTransportInfo.of(sessionDescription, media); return new DescriptionTransport(rtpDescription, transportInfo); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java index 8f0b0d4fe..39031c4a9 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java @@ -198,10 +198,10 @@ public class SessionDescription { checkNoWhitespace(type, "feedback negotiation type must not contain whitespace"); mediaAttributes.put("rtcp-fb", "* " + type + (Strings.isNullOrEmpty(subtype) ? "" : " " + subtype)); } - for (RtpDescription.FeedbackNegotiationTrrInt feedbackNegotiationTrrInt : description.feedbackNegotiationTrrInts()) { + for (final RtpDescription.FeedbackNegotiationTrrInt feedbackNegotiationTrrInt : description.feedbackNegotiationTrrInts()) { mediaAttributes.put("rtcp-fb", "* trr-int " + feedbackNegotiationTrrInt.getValue()); } - for (RtpDescription.RtpHeaderExtension extension : description.getHeaderExtensions()) { + for (final RtpDescription.RtpHeaderExtension extension : description.getHeaderExtensions()) { final String id = extension.getId(); final String uri = extension.getUri(); if (Strings.isNullOrEmpty(id)) { @@ -214,7 +214,12 @@ public class SessionDescription { checkNoWhitespace(uri, "feedback negotiation uri must not contain whitespace"); mediaAttributes.put("extmap", id + " " + uri); } - for (RtpDescription.SourceGroup sourceGroup : description.getSourceGroups()) { + + if (description.hasChild("extmap-allow-mixed", Namespace.JINGLE_RTP_HEADER_EXTENSIONS)) { + mediaAttributes.put("extmap-allow-mixed", ""); + } + + for (final RtpDescription.SourceGroup sourceGroup : description.getSourceGroups()) { final String semantics = sourceGroup.getSemantics(); final List groups = sourceGroup.getSsrcs(); if (Strings.isNullOrEmpty(semantics)) { @@ -226,8 +231,8 @@ public class SessionDescription { } mediaAttributes.put("ssrc-group", String.format("%s %s", semantics, Joiner.on(' ').join(groups))); } - for (RtpDescription.Source source : description.getSources()) { - for (RtpDescription.Source.Parameter parameter : source.getParameters()) { + for (final RtpDescription.Source source : description.getSources()) { + for (final RtpDescription.Source.Parameter parameter : source.getParameters()) { final String id = source.getSsrcId(); final String parameterName = parameter.getParameterName(); final String parameterValue = parameter.getParameterValue(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java index 9a1630f80..650c26bef 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/RtpDescription.java @@ -6,11 +6,14 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; @@ -530,11 +533,15 @@ public class RtpDescription extends GenericDescription { } } - public static RtpDescription of(final SessionDescription.Media media) { + public static RtpDescription of(final SessionDescription sessionDescription, final SessionDescription.Media media) { final RtpDescription rtpDescription = new RtpDescription(media.media); final Map> parameterMap = new HashMap<>(); final ArrayListMultimap feedbackNegotiationMap = ArrayListMultimap.create(); final ArrayListMultimap sourceParameterMap = ArrayListMultimap.create(); + final Set attributes = Sets.newHashSet(Iterables.concat( + sessionDescription.attributes.keySet(), + media.attributes.keySet() + )); for (final String rtcpFb : media.attributes.get("rtcp-fb")) { final String[] parts = rtcpFb.split(" "); if (parts.length >= 2) { @@ -581,6 +588,9 @@ public class RtpDescription extends GenericDescription { rtpDescription.addChild(extension); } } + if (attributes.contains("extmap-allow-mixed")) { + rtpDescription.addChild("extmap-allow-mixed", Namespace.JINGLE_RTP_HEADER_EXTENSIONS); + } for (final String ssrcGroup : media.attributes.get("ssrc-group")) { final String[] parts = ssrcGroup.split(" "); if (parts.length >= 2) {