public class NetworkAddressManagerServiceImpl extends java.lang.Object implements NetworkAddressManagerService
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BIND_RETRIES_PROPERTY_NAME
The name of the property containing the number of binds that we should
should execute in case a port is already bound to (each retry would be on
a new random port).
|
static int |
DEFAULT_STUN_SERVER_PORT
Default STUN server port.
|
(package private) java.net.DatagramSocket |
localHostFinderSocket
The socket that we use for dummy connections during selection of a local
address that has to be used when communicating with a specific location.
|
static java.lang.String |
STUN_SRV_NAME
The service name to use when discovering STUN servers through DNS using
SRV requests as per RFC 5389.
|
static java.lang.String |
TURN_SRV_NAME
The service name to use when discovering TURN servers through DNS using
SRV requests as per RFC 5766.
|
BIND_RETRIES_DEFAULT_VALUE
Constructor and Description |
---|
NetworkAddressManagerServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Adds new NetworkConfigurationChangeListener which will
be informed for network configuration changes.
|
java.net.DatagramSocket |
createDatagramSocket(java.net.InetAddress laddr,
int preferredPort,
int minPort,
int maxPort)
Creates a DatagramSocket and binds it to the specified
localAddress and a port in the range specified by the
minPort and maxPort parameters.
|
org.ice4j.ice.Agent |
createIceAgent()
Creates and returns an ICE agent that a protocol could use for the
negotiation of media transport addresses.
|
org.ice4j.ice.IceMediaStream |
createIceStream(int numComponents,
int portBase,
java.lang.String streamName,
org.ice4j.ice.Agent agent)
Creates an IceMediaStrean and adds to it one or two
components, which also implies running the currently installed
harvesters.
|
org.ice4j.ice.IceMediaStream |
createIceStream(int rtpPort,
java.lang.String streamName,
org.ice4j.ice.Agent agent)
Creates an IceMediaStrean and adds to it an RTP and and RTCP
component, which also implies running the currently installed
harvesters so that they would.
|
org.ice4j.ice.harvest.StunCandidateHarvester |
discoverStunServer(java.lang.String domainName,
byte[] userName,
byte[] password)
Tries to discover a TURN or a STUN server for the specified
domainName.
|
byte[] |
getHardwareAddress(java.net.NetworkInterface iface)
Returns the hardware address (i.e.
|
java.net.InetAddress |
getLocalHost(java.net.InetAddress intendedDestination)
Returns an InetAddress instance that represents the localhost, and that
a socket can bind upon or distribute to peers as a contact address.
|
java.net.InetSocketAddress |
getPublicAddressFor(java.net.InetAddress dst,
int port)
Tries to obtain an for the specified port.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a bound property is changed.
|
void |
removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Remove NetworkConfigurationChangeListener.
|
void |
start()
Initializes this network address manager service implementation.
|
void |
stop()
Kills all threads/processes launched by this thread (if any) and
prepares it for shutdown.
|
java.net.DatagramSocket localHostFinderSocket
public static final java.lang.String BIND_RETRIES_PROPERTY_NAME
public static final int DEFAULT_STUN_SERVER_PORT
public static final java.lang.String TURN_SRV_NAME
public static final java.lang.String STUN_SRV_NAME
public void start()
public void stop()
public java.net.InetAddress getLocalHost(java.net.InetAddress intendedDestination)
getLocalHost
in interface NetworkAddressManagerService
intendedDestination
- the destination that we'd like to use the
localhost address with.public byte[] getHardwareAddress(java.net.NetworkInterface iface)
getHardwareAddress
in interface NetworkAddressManagerService
iface
- the NetworkInterfacepublic java.net.InetSocketAddress getPublicAddressFor(java.net.InetAddress dst, int port) throws java.io.IOException, java.net.BindException
getPublicAddressFor
in interface NetworkAddressManagerService
dst
- the destination that we'd like to use this address with.port
- the port whose mapping we are interested in.java.io.IOException
- if an error occurs while creating the socket.java.net.BindException
- if the port is already in use.public void propertyChange(java.beans.PropertyChangeEvent evt)
evt
- A PropertyChangeEvent object describing the event source
and the property that has changed.public java.net.DatagramSocket createDatagramSocket(java.net.InetAddress laddr, int preferredPort, int minPort, int maxPort) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
createDatagramSocket
in interface NetworkAddressManagerService
laddr
- the address that we'd like to bind the socket on.preferredPort
- the port number that we should try to bind to first.minPort
- the port number where we should first try to bind before
moving to the next one (i.e. minPort + 1)maxPort
- the maximum port number where we should try binding
before giving up and throwinG an exception.java.lang.IllegalArgumentException
- if either minPort or
maxPort is not a valid port number or if minPort >
maxPort.java.io.IOException
- if an error occurs while the underlying resolver lib
is using sockets.java.net.BindException
- if we couldn't find a free port between
minPort and maxPort before reaching the maximum allowed
number of retries.public void addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
addNetworkConfigurationChangeListener
in interface NetworkAddressManagerService
listener
- the listener.public void removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
removeNetworkConfigurationChangeListener
in interface NetworkAddressManagerService
listener
- the listener.public org.ice4j.ice.Agent createIceAgent()
createIceAgent
in interface NetworkAddressManagerService
public org.ice4j.ice.harvest.StunCandidateHarvester discoverStunServer(java.lang.String domainName, byte[] userName, byte[] password)
discoverStunServer
in interface NetworkAddressManagerService
domainName
- the domain name that we are trying to discover a
TURN server for.userName
- the name of the user we'd like to use when connecting to
a TURN server (we won't be using credentials in case we only have a STUN
server).password
- the password that we'd like to try when connecting to
a TURN server (we won't be using credentials in case we only have a STUN
server).StunCandidateHarvester
corresponding to the TURN or
STUN server we discovered or null if there were no such records
for the specified domainNamepublic org.ice4j.ice.IceMediaStream createIceStream(int rtpPort, java.lang.String streamName, org.ice4j.ice.Agent agent) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
createIceStream
in interface NetworkAddressManagerService
rtpPort
- the port that we should try to bind the RTP component on
(the RTCP one would automatically go to rtpPort + 1)streamName
- the name of the stream to createagent
- the Agent that should create the stream.java.lang.IllegalArgumentException
- if rtpPort is not a valid port
number.java.io.IOException
- if an error occurs while the underlying resolver
is using sockets.java.net.BindException
- if we couldn't find a free port between within the
default number of retries.public org.ice4j.ice.IceMediaStream createIceStream(int numComponents, int portBase, java.lang.String streamName, org.ice4j.ice.Agent agent) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
createIceStream
in interface NetworkAddressManagerService
portBase
- the port that we should try to bind first component on
(the second one would automatically go to portBase + 1)streamName
- the name of the stream to createagent
- the Agent that should create the stream.java.lang.IllegalArgumentException
- if portBase is not a valid port
number. If numComponents is neither 1 nor 2.java.io.IOException
- if an error occurs while the underlying resolver
is using sockets.java.net.BindException
- if we couldn't find a free port between within the
default number of retries.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.