From 885ec0febec8217bd82fe2f0232475153194ebd0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 5 Apr 2020 17:31:48 +0200 Subject: [PATCH] a couple of bug fixes for SessionDescription.toString() --- .../xmpp/jingle/JingleRtpConnection.java | 14 ----------- .../xmpp/jingle/SessionDescription.java | 23 ++++++++++++------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index c82f8bcd3..ad2b9fdad 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -92,20 +92,6 @@ public class JingleRtpConnection extends AbstractJingleConnection { } private void processContents(final RtpContentMap contentMap) { - for (Map.Entry content : contentMap.contents.entrySet()) { - final RtpContentMap.DescriptionTransport descriptionTransport = content.getValue(); - final RtpDescription rtpDescription = descriptionTransport.description; - Log.d(Config.LOGTAG, "receive content with name " + content.getKey() + " and media=" + rtpDescription.getMedia()); - for (RtpDescription.PayloadType payloadType : rtpDescription.getPayloadTypes()) { - Log.d(Config.LOGTAG, "payload type: " + payloadType.toString()); - } - for (RtpDescription.RtpHeaderExtension extension : rtpDescription.getHeaderExtensions()) { - Log.d(Config.LOGTAG, "extension: " + extension.toString()); - } - final IceUdpTransportInfo iceUdpTransportInfo = descriptionTransport.transport; - Log.d(Config.LOGTAG, "transport: " + descriptionTransport.transport); - Log.d(Config.LOGTAG, "fingerprint " + iceUdpTransportInfo.getFingerprint()); - } setupWebRTC(); org.webrtc.SessionDescription sessionDescription = new org.webrtc.SessionDescription(org.webrtc.SessionDescription.Type.OFFER, SessionDescription.of(contentMap).toString()); Log.d(Config.LOGTAG, "debug print for sessionDescription:" + sessionDescription.description); 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 81f13307f..c205ab0d8 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java @@ -118,6 +118,8 @@ public class SessionDescription { if (currentMediaBuilder != null) { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); + } else { + sessionDescriptionBuilder.setAttributes(attributeMap); } sessionDescriptionBuilder.setMedia(mediaBuilder.build()); return sessionDescriptionBuilder.createSessionDescription(); @@ -130,12 +132,9 @@ public class SessionDescription { final Group group = contentMap.group; if (group != null) { attributeMap.put("group", group.getSemantics() + " " + Joiner.on(' ').join(group.getIdentificationTags())); - } else { - Log.d(Config.LOGTAG,"group was null"); } - //random additional attributes - + attributeMap.put("msid-semantic", " WMS my-media-stream"); for (Map.Entry entry : contentMap.contents.entrySet()) { final String name = entry.getKey(); @@ -172,6 +171,7 @@ public class SessionDescription { mediaAttributes.put("rtcp-fb", payloadType.getId() + " trr-int " + feedbackNegotiationTrrInt.getValue()); } } + for (RtpDescription.FeedbackNegotiation feedbackNegotiation : description.getFeedbackNegotiations()) { mediaAttributes.put("rtcp-fb", "* " + feedbackNegotiation.getType() + (Strings.isNullOrEmpty(feedbackNegotiation.getSubType()) ? "" : " " + feedbackNegotiation.getSubType())); } @@ -181,11 +181,18 @@ public class SessionDescription { for (RtpDescription.RtpHeaderExtension extension : description.getHeaderExtensions()) { mediaAttributes.put("extmap", extension.getId() + " " + extension.getUri()); } + for (RtpDescription.Source source : description.getSources()) { + for (RtpDescription.Source.Parameter parameter : source.getParameters()) { + mediaAttributes.put("ssrc", source.getSsrcId() + " " + parameter.getParameterName() + ":" + parameter.getParameterValue()); + } + } + mediaAttributes.put("mid", name); //random additional attributes - mediaAttributes.put("sendrecv",""); - mediaAttributes.put("rtcp-mux",""); + mediaAttributes.put("rtcp", "9 IN IP4 0.0.0.0"); + mediaAttributes.put("sendrecv", ""); + mediaAttributes.put("rtcp-mux", ""); final MediaBuilder mediaBuilder = new MediaBuilder(); mediaBuilder.setMedia(description.getMedia().toString().toLowerCase(Locale.ROOT)); @@ -227,8 +234,8 @@ public class SessionDescription { final StringBuilder s = new StringBuilder() .append("v=").append(version).append(LINE_DIVIDER) .append("o=- 8770656990916039506 2 IN IP4 127.0.0.1").append(LINE_DIVIDER) //what ever that means - .append("t=0 0").append(LINE_DIVIDER) - .append("s=").append(name).append(LINE_DIVIDER); + .append("s=").append(name).append(LINE_DIVIDER) + .append("t=0 0").append(LINE_DIVIDER); appendAttributes(s, attributes); for (Media media : this.media) { s.append("m=").append(media.media).append(' ').append(media.port).append(' ').append(media.protocol).append(' ').append(Joiner.on(' ').join(media.formats)).append(LINE_DIVIDER);