I'll try to be brief.
I wish to create communication between 2 java apps (that will later be transported to android) without passing through a server. As such, I have spent weeks looking around, and after a lot of work I found stun and ice4j. The best explanation of how to use ice4j I found here, and it pretty much showed me what I need to do to add stun servers to an agent (I don't really know what an agent is, just that it manages my communications with STUN and TURN), through this code:
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ice4j.Transport;
import org.ice4j.TransportAddress;
import org.ice4j.ice.Agent;
import org.ice4j.ice.IceMediaStream;
import org.ice4j.ice.harvest.StunCandidateHarvester;
public class ice4jTesting {
public static void main(String[] args) {
Agent agent = new Agent();
String[] hostnames = new String[] {"jitsi.org", "numb.viagenie.ca", "stun.ekiga.net"};
for(String hostname: hostnames) {
try {
TransportAddress address;
address = new TransportAddress(InetAddress.getByName(hostname), 3478, Transport.UDP);
agent.addCandidateHarvester(new StunCandidateHarvester(address));
} catch (UnknownHostException ex) {
Logger.getLogger(SimpleStun.class.getName()).log(Level.SEVERE, null, ex);
}
}
IceMediaStream stream = agent.createMediaStream("audio");
int port = 5000;
try {
agent.createComponent(stream, Transport.UDP, port, port, port+100);
// The three last arguments are: preferredPort, minPort, maxPort
} catch (IllegalArgumentException | IOException ex) {
Logger.getLogger(SimpleStun.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
however, after this the tutorial utilizes SDPUtils
, a class that is in the source code of ice4j I found on github, to recieve the SDP information from the agent. However I got ice4j.jar from the central maven repository, and added it to my netbeans regular project (I did this because I am not very familiar with maven, and just wanted a regular library on my regular project). This jar library does not have the SDPUtils
class, and since I don't really understand enough of this code to fix it myself, I was wondering if any of you could help me either fix the code above, or show me an example of how to answer the question on the title.
However, unless you can either do what I said in the last sentence, or point me to some sample code, your help will most likely not be useful, since I am mentally incapable of understanding the theory behind this completely because of the many concepts I do not know.
I have until the end of this week to figure this out, and if I don't I'm pretty screwed. So please, if you can or know someone that can help, I would extremely appreciate it.
Thanks for reading it so far and trying to help :)