sdp to ice transport conversion
This commit is contained in:
parent
b44a3aeac6
commit
4d70855b4c
|
@ -91,7 +91,7 @@ public class RtpContentMap {
|
||||||
|
|
||||||
public static DescriptionTransport of(final SessionDescription sessionDescription, final SessionDescription.Media media) {
|
public static DescriptionTransport of(final SessionDescription sessionDescription, final SessionDescription.Media media) {
|
||||||
final RtpDescription rtpDescription = RtpDescription.of(media);
|
final RtpDescription rtpDescription = RtpDescription.of(media);
|
||||||
final IceUdpTransportInfo transportInfo = new IceUdpTransportInfo();
|
final IceUdpTransportInfo transportInfo = IceUdpTransportInfo.of(sessionDescription, media);
|
||||||
return new DescriptionTransport(rtpDescription, transportInfo);
|
return new DescriptionTransport(rtpDescription, transportInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
package eu.siacs.conversations.xmpp.jingle.stanzas;
|
package eu.siacs.conversations.xmpp.jingle.stanzas;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xml.Namespace;
|
import eu.siacs.conversations.xml.Namespace;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.SessionDescription;
|
||||||
|
|
||||||
public class IceUdpTransportInfo extends GenericTransportInfo {
|
public class IceUdpTransportInfo extends GenericTransportInfo {
|
||||||
|
|
||||||
public IceUdpTransportInfo() {
|
private IceUdpTransportInfo() {
|
||||||
super("transport", Namespace.JINGLE_TRANSPORT_ICE_UDP);
|
super("transport", Namespace.JINGLE_TRANSPORT_ICE_UDP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +41,24 @@ public class IceUdpTransportInfo extends GenericTransportInfo {
|
||||||
return transportInfo;
|
return transportInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IceUdpTransportInfo of(SessionDescription sessionDescription, SessionDescription.Media media) {
|
||||||
|
final String ufrag = Iterables.getFirst(media.attributes.get("ice-ufrag"), null);
|
||||||
|
final String pwd = Iterables.getFirst(media.attributes.get("ice-pwd"), null);
|
||||||
|
IceUdpTransportInfo iceUdpTransportInfo = new IceUdpTransportInfo();
|
||||||
|
if (ufrag != null) {
|
||||||
|
iceUdpTransportInfo.setAttribute("ufrag", ufrag);
|
||||||
|
}
|
||||||
|
if (pwd != null) {
|
||||||
|
iceUdpTransportInfo.setAttribute("pwd", pwd);
|
||||||
|
}
|
||||||
|
final Fingerprint fingerprint = Fingerprint.of(sessionDescription, media);
|
||||||
|
if (fingerprint != null) {
|
||||||
|
iceUdpTransportInfo.addChild(fingerprint);
|
||||||
|
}
|
||||||
|
return iceUdpTransportInfo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class Candidate extends Element {
|
public static class Candidate extends Element {
|
||||||
|
|
||||||
private Candidate() {
|
private Candidate() {
|
||||||
|
@ -136,5 +157,28 @@ public class IceUdpTransportInfo extends GenericTransportInfo {
|
||||||
fingerprint.setContent(element.getContent());
|
fingerprint.setContent(element.getContent());
|
||||||
return fingerprint;
|
return fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Fingerprint of(ArrayListMultimap<String, String> attributes) {
|
||||||
|
final String fingerprint = Iterables.getFirst(attributes.get("fingerprint"), null);
|
||||||
|
final String setup = Iterables.getFirst(attributes.get("setup"), null);
|
||||||
|
if (setup != null && fingerprint != null) {
|
||||||
|
final String[] fingerprintParts = fingerprint.split(" ", 2);
|
||||||
|
if (fingerprintParts.length == 2) {
|
||||||
|
final String hash = fingerprintParts[0];
|
||||||
|
final String actualFingerprint = fingerprintParts[1];
|
||||||
|
final Fingerprint element = new Fingerprint();
|
||||||
|
element.setAttribute("hash", hash);
|
||||||
|
element.setAttribute("setup", setup);
|
||||||
|
element.setContent(actualFingerprint);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Fingerprint of(final SessionDescription sessionDescription, final SessionDescription.Media media) {
|
||||||
|
final Fingerprint fingerprint = of(media.attributes);
|
||||||
|
return fingerprint == null ? of(sessionDescription.attributes) : fingerprint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue