1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 04:28:00 +01:00

Merge branch 'jingleS5B' into jingle2

This commit is contained in:
vanitasvitae 2017-06-18 12:32:08 +02:00
commit d0701f8fd1
3 changed files with 57 additions and 55 deletions

View file

@ -41,6 +41,7 @@ public class JingleS5BTransport extends JingleContentTransport {
protected JingleS5BTransport(List<JingleContentTransportCandidate> candidates, List<JingleContentTransportInfo> infos, String streamId, String dstAddr, Bytestream.Mode mode) {
super(candidates, infos);
StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty.");
this.streamId = streamId;
this.dstAddr = dstAddr;
this.mode = mode;
@ -137,7 +138,6 @@ public class JingleS5BTransport extends JingleContentTransport {
}
public JingleS5BTransport build() {
StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty.");
return new JingleS5BTransport(candidates, infos, streamId, dstAddr, mode);
}
}

View file

@ -50,6 +50,14 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
private final Type type;
public JingleS5BTransportCandidate(String candidateId, String host, Jid jid, int port, int priority, Type type) {
Objects.requireNonNull(candidateId);
Objects.requireNonNull(host);
Objects.requireNonNull(jid);
if (priority < 0) {
throw new IllegalArgumentException("Priority MUST be present and NOT less than 0.");
}
this.cid = candidateId;
this.host = host;
this.jid = jid;
@ -59,12 +67,7 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
}
public JingleS5BTransportCandidate(Bytestream.StreamHost streamHost, int priority) {
this.cid = StringUtils.randomString(24);
this.host = streamHost.getAddress();
this.jid = streamHost.getJID();
this.port = streamHost.getPort();
this.priority = priority;
this.type = Type.proxy;
this(StringUtils.randomString(24), streamHost.getAddress(), streamHost.getJID(), streamHost.getPort(), priority, Type.proxy);
}
public enum Type {
@ -191,12 +194,6 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
}
public JingleS5BTransportCandidate build() {
Objects.requireNonNull(cid);
Objects.requireNonNull(host);
Objects.requireNonNull(jid);
if (priority < 0) {
throw new IllegalArgumentException("Priority MUST be present and NOT less than 0.");
}
return new JingleS5BTransportCandidate(cid, host, jid, port, priority, type);
}
}

View file

@ -56,58 +56,63 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider<J
}
JingleS5BTransportCandidate.Builder cb;
while (true) {
outerloop: while (true) {
int tag = parser.nextTag();
String name = parser.getName();
if (tag == START_TAG) {
switch (name) {
switch (tag) {
case START_TAG: {
switch (name) {
case JingleS5BTransportCandidate.ELEMENT:
cb = JingleS5BTransportCandidate.getBuilder();
cb.setCandidateId(parser.getAttributeValue(null, ATTR_CID));
cb.setHost(parser.getAttributeValue(null, ATTR_HOST));
cb.setJid(parser.getAttributeValue(null, ATTR_JID));
cb.setPriority(Integer.parseInt(parser.getAttributeValue(null, ATTR_PRIORITY)));
case JingleS5BTransportCandidate.ELEMENT:
cb = JingleS5BTransportCandidate.getBuilder();
cb.setCandidateId(parser.getAttributeValue(null, ATTR_CID));
cb.setHost(parser.getAttributeValue(null, ATTR_HOST));
cb.setJid(parser.getAttributeValue(null, ATTR_JID));
cb.setPriority(Integer.parseInt(parser.getAttributeValue(null, ATTR_PRIORITY)));
String portString = parser.getAttributeValue(null, ATTR_PORT);
if (portString != null) {
cb.setPort(Integer.parseInt(portString));
String portString = parser.getAttributeValue(null, ATTR_PORT);
if (portString != null) {
cb.setPort(Integer.parseInt(portString));
}
String typeString = parser.getAttributeValue(null, ATTR_TYPE);
if (typeString != null) {
cb.setType(JingleS5BTransportCandidate.Type.fromString(typeString));
}
builder.addTransportCandidate(cb.build());
break;
case JingleS5BTransportInfo.CandidateActivated.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateActivated(
parser.getAttributeValue(null,
JingleS5BTransportInfo.CandidateActivated.ATTR_CID)));
break;
case JingleS5BTransportInfo.CandidateUsed.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateUsed(
parser.getAttributeValue(null,
JingleS5BTransportInfo.CandidateUsed.ATTR_CID)));
break;
case JingleS5BTransportInfo.CandidateError.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateError());
break;
case JingleS5BTransportInfo.ProxyError.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.ProxyError());
break;
}
}
break;
String typeString = parser.getAttributeValue(null, ATTR_TYPE);
if (typeString != null) {
cb.setType(JingleS5BTransportCandidate.Type.fromString(typeString));
case END_TAG: {
switch (name) {
case JingleContentTransport.ELEMENT:
break outerloop;
}
builder.addTransportCandidate(cb.build());
break;
case JingleS5BTransportInfo.CandidateActivated.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateActivated(
parser.getAttributeValue(null,
JingleS5BTransportInfo.CandidateActivated.ATTR_CID)));
break;
case JingleS5BTransportInfo.CandidateUsed.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateUsed(
parser.getAttributeValue(null,
JingleS5BTransportInfo.CandidateUsed.ATTR_CID)));
break;
case JingleS5BTransportInfo.CandidateError.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.CandidateError());
break;
case JingleS5BTransportInfo.ProxyError.ELEMENT:
builder.addTransportInfo(JingleS5BTransportInfo.ProxyError());
break;
}
}
if (tag == END_TAG && name.equals(JingleContentTransport.ELEMENT)) {
break;
}
}
return builder.build();
}
}