use of org.jivesoftware.smackx.jingleold.packet.JingleTransport.JingleTransportCandidate in project Smack by igniterealtime.
the class JingleTransportProvider method parse.
/**
* Parse a iq/jingle/transport element.
*
* @param parser the structure to parse
* @return a transport element.
* @throws IOException
* @throws XmlPullParserException
* @throws SmackException
*/
@Override
public JingleTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
boolean done = false;
JingleTransport trans = getInstance();
while (!done) {
int eventType = parser.next();
String name = parser.getName();
if (eventType == XmlPullParser.START_TAG) {
if (name.equals(JingleTransportCandidate.NODENAME)) {
JingleTransportCandidate jtc = parseCandidate(parser);
if (jtc != null)
trans.addCandidate(jtc);
} else {
throw new SmackException("Unknown tag \"" + name + "\" in transport element.");
}
} else if (eventType == XmlPullParser.END_TAG) {
if (name.equals(JingleTransport.NODENAME)) {
done = true;
}
}
}
return trans;
}
use of org.jivesoftware.smackx.jingleold.packet.JingleTransport.JingleTransportCandidate in project Smack by igniterealtime.
the class TransportNegotiator method obtainCandidatesList.
/**
* Parse the list of transport candidates from a Jingle packet.
*
* @param jingle The input jingle packet
*/
private List<TransportCandidate> obtainCandidatesList(Jingle jingle) {
List<TransportCandidate> result = new ArrayList<>();
if (jingle != null) {
// Get the list of candidates from the packet
for (JingleContent jingleContent : jingle.getContentsList()) {
if (jingleContent.getName().equals(parentNegotiator.getName())) {
for (JingleTransport jingleTransport : jingleContent.getJingleTransportsList()) {
for (JingleTransportCandidate jingleTransportCandidate : jingleTransport.getCandidatesList()) {
TransportCandidate transCand = jingleTransportCandidate.getMediaTransport();
result.add(transCand);
}
}
}
}
}
return result;
}
Aggregations