mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-12 08:01:08 +01:00
STUN fix and Media Tunning
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7610 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
cb2df91084
commit
9627fef139
9 changed files with 239 additions and 126 deletions
|
|
@ -42,7 +42,11 @@ public class BridgedTransportManager extends JingleTransportManager implements J
|
|||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
|
||||
// Return the correspondent resolver
|
||||
/**
|
||||
* Return the correspondent resolver
|
||||
* @param session correspondent Jingle Session
|
||||
* @return resolver
|
||||
*/
|
||||
protected TransportResolver createResolver(JingleSession session) {
|
||||
BridgedResolver bridgedResolver = new BridgedResolver(this.xmppConnection);
|
||||
return bridgedResolver;
|
||||
|
|
|
|||
|
|
@ -176,64 +176,65 @@ public class ICEResolver extends TransportResolver {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
// Get Public Candidate From XMPP Server
|
||||
|
||||
// Get Public Candidate From XMPP Server
|
||||
if (iceNegociator.getPublicCandidate() == null) {
|
||||
|
||||
if (iceNegociator.getPublicCandidate() == null) {
|
||||
String publicIp = RTPBridge.getPublicIP(connection);
|
||||
|
||||
String publicIp = RTPBridge.getPublicIP(connection);
|
||||
if (publicIp != null && !publicIp.equals("")) {
|
||||
|
||||
if (publicIp != null && !publicIp.equals("")) {
|
||||
Enumeration ifaces = null;
|
||||
|
||||
Enumeration ifaces = null;
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
}
|
||||
catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
}
|
||||
catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// If detect this address in local machine, don't use it.
|
||||
|
||||
// If detect this address in local machine, don't use it.
|
||||
boolean found = false;
|
||||
|
||||
boolean found = false;
|
||||
while (ifaces.hasMoreElements() && !false) {
|
||||
|
||||
while (ifaces.hasMoreElements() && !false) {
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
if (iaddress.getHostAddress().indexOf(publicIp) > -1) {
|
||||
found = true;
|
||||
break;
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
if (iaddress.getHostAddress().indexOf(publicIp) > -1) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
try {
|
||||
TransportCandidate publicCandidate = new ICECandidate(
|
||||
publicIp, 1, 0, String.valueOf(Math.abs(random.nextLong())), getFreePort(), "1", 0, "srflx");
|
||||
publicCandidate.setLocalIp(InetAddress.getLocalHost().getHostAddress());
|
||||
|
||||
if (!found) {
|
||||
try {
|
||||
publicCandidate.addCandidateEcho(session);
|
||||
TransportCandidate publicCandidate = new ICECandidate(
|
||||
publicIp, 1, 0, String.valueOf(Math.abs(random.nextLong())), getFreePort(), "1", 0, "srflx");
|
||||
publicCandidate.setLocalIp(InetAddress.getLocalHost().getHostAddress());
|
||||
|
||||
try {
|
||||
publicCandidate.addCandidateEcho(session);
|
||||
}
|
||||
catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
addCandidate(publicCandidate);
|
||||
}
|
||||
catch (SocketException e) {
|
||||
catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
addCandidate(publicCandidate);
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.setResolveEnd();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -512,6 +512,8 @@ public class RTPBridge extends IQ {
|
|||
// Cancel the collector.
|
||||
collector.cancel();
|
||||
|
||||
if(response == null) return null;
|
||||
|
||||
if (response.getIp() == null || response.getIp().equals("")) return null;
|
||||
|
||||
Enumeration ifaces = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue