* @param parser the structure to parse
* @return a candidate element
* @throws Exception
*/
protected JingleTransportCandidate parseCandidate(XmlPullParser parser) throws Exception {
ICECandidate mt = new ICECandidate();
String channel = parser.getAttributeValue("", "channel");
String generation = parser.getAttributeValue("", "generation");
String ip = parser.getAttributeValue("", "ip");
String name = parser.getAttributeValue("", "name");
String network = parser.getAttributeValue("", "network");
String username = parser.getAttributeValue("", "username");
String password = parser.getAttributeValue("", "password");
String port = parser.getAttributeValue("", "port");
String preference = parser.getAttributeValue("", "preference");
String proto = parser.getAttributeValue("", "proto");
String type = parser.getAttributeValue("", "type");
if (channel != null) {
mt.setChannel(new TransportCandidate.Channel(channel));
}
if (generation != null) {
try {
mt.setGeneration(Integer.parseInt(generation));
}
catch (Exception e) {
}
}
if (ip != null) {
mt.setIp(ip);
}
else {
return null;
}
if (name != null) {
mt.setName(name);
}
if (network != null) {
try {
mt.setNetwork(Integer.parseInt(network));
}
catch (Exception e) {
}
}
if (username != null) {
mt.setUsername(username);
}
if (password != null) {
mt.setPassword(password);
}
if (port != null) {
try {
mt.setPort(Integer.parseInt(port));
}
catch (Exception e) {
}
}
if (preference != null) {
try {
mt.setPreference(Integer.parseInt(preference));
}
catch (Exception e) {
}
}
if (proto != null) {
mt.setProto(new TransportCandidate.Protocol(proto));
}
if (type != null) {
mt.setType(ICECandidate.Type.valueOf(type));
}
return new JingleTransport.Ice.Candidate(mt);
}