Fixes an issue in the allocation of ports which causes a portion of a user-specified port range to be utilized. Reported by Emil Ivov.

fix-message-formatting
Lyubomir Marinov 12 years ago
parent 979d99145e
commit 4d0b635908

@ -42,7 +42,8 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>>
* Initialized by {@link #initializePortNumbers()}.
* </p>
*/
private static PortTracker defaultPortTracker = new PortTracker(5000, 6000);
private static final PortTracker defaultPortTracker
= new PortTracker(5000, 6000);
/**
* The port tracker that we should use when binding video media streams.
@ -51,25 +52,25 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>>
* necessary properties are set.
* </p>
*/
private static PortTracker videoPortTracker = null;
private static PortTracker videoPortTracker;
/**
* The port tracker that we should use when binding data channels.
* <p>
* Potentially initialized by {@link #initializePortNumbers()} if the
* necessary properties are set
* necessary properties are set.
* </p>
*/
private static PortTracker dataChannelPortTracker = null;
private static PortTracker dataPortTracker;
/**
* The port tracker that we should use when binding data media streams.
* <p>
* Potentially initialized by {@link #initializePortNumbers()} if the
* necessary properties are set
* necessary properties are set.
* </p>
*/
private static PortTracker audioPortTracker = null;
private static PortTracker audioPortTracker;
/**
* RTP audio DSCP configuration property name.
@ -281,70 +282,72 @@ protected StreamConnector createStreamConnector(MediaType mediaType)
}
/**
* (Re)Sets the all the port allocators to reflect current values specified
* in the <tt>ConfigurationService</tt>. Calling this method may very well
* result in creating new port allocators or destroying existing ones.
* Tries to set the ranges of the <tt>PortTracker</tt>s (e.g. default,
* audio, video, data channel) to the values specified in the
* <tt>ConfigurationService</tt>.
*/
protected static void initializePortNumbers()
protected synchronized static void initializePortNumbers()
{
//try the default tracker first
ConfigurationService cfg
= ProtocolMediaActivator.getConfigurationService();
String minPortNumberStr
String minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_MEDIA_PORT_NUMBER_PROPERTY_NAME);
String maxPortNumberStr
String maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_MEDIA_PORT_NUMBER_PROPERTY_NAME);
//try to send the specified range. If there's no specified range in
//configuration, we'll just leave the tracker as it is: [5000 to 6000]
defaultPortTracker.tryRange(minPortNumberStr, maxPortNumberStr);
//Try the specified range; otherwise, leave the tracker as it is:
//[5000, 6000].
defaultPortTracker.tryRange(minPort, maxPort);
//try the VIDEO tracker
minPortNumberStr
minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_VIDEO_PORT_NUMBER_PROPERTY_NAME);
maxPortNumberStr
maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_VIDEO_PORT_NUMBER_PROPERTY_NAME);
//try to send the specified range. If there's no specified range in
//configuration, we'll just leave this tracker to null
videoPortTracker
= PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
//Try the specified range; otherwise, leave the tracker to null.
if (videoPortTracker == null)
videoPortTracker = PortTracker.createTracker(minPort, maxPort);
else
videoPortTracker.tryRange(minPort, maxPort);
//try the AUDIO tracker
minPortNumberStr
minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_AUDIO_PORT_NUMBER_PROPERTY_NAME);
maxPortNumberStr
maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_AUDIO_PORT_NUMBER_PROPERTY_NAME);
//try to send the specified range. If there's no specified range in
//configuration, we'll just leave this tracker to null
audioPortTracker
= PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
//Try the specified range; otherwise, leave the tracker to null.
if (audioPortTracker == null)
audioPortTracker = PortTracker.createTracker(minPort, maxPort);
else
audioPortTracker.tryRange(minPort, maxPort);
//try the DATA CHANNEL tracker
minPortNumberStr
minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_DATA_CHANNEL_PORT_NUMBER_PROPERTY_NAME);
maxPortNumberStr
maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_DATA_CHANNEL_PORT_NUMBER_PROPERTY_NAME);
//try to send the specified range. If there's no specified range in
//configuration, we'll just leave this tracker to null
dataChannelPortTracker
= PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
//Try the specified range; otherwise, leave the tracker to null.
if (dataPortTracker == null)
dataPortTracker = PortTracker.createTracker(minPort, maxPort);
else
dataPortTracker.tryRange(minPort, maxPort);
}
/**
@ -594,11 +597,13 @@ protected static PortTracker getPortTracker(MediaType mediaType)
case AUDIO:
if (audioPortTracker != null)
return audioPortTracker;
break;
else
break;
case VIDEO:
if (videoPortTracker != null)
return videoPortTracker;
break;
else
break;
}
return defaultPortTracker;

Loading…
Cancel
Save