use of org.jivesoftware.smackx.jingleold.nat.BridgedTransportManager in project Spark by igniterealtime.
the class JinglePlugin method initialize.
public void initialize() {
// Add Jingle to discovered items list.
SparkManager.addFeature(JINGLE_NAMESPACE);
final LocalPreferences localPref = SettingsManager.getLocalPreferences();
// If there is a server entered in spark.properties use it as fallback
if (!localPref.getStunFallbackHost().equals("")) {
fallbackStunEnabled = true;
}
// Get the default port
stunPort = localPref.getStunFallbackPort();
// Set Jingle Enabled
JingleManager.setJingleServiceEnabled();
JingleManager.setServiceEnabled(SparkManager.getConnection(), true);
// Add to PhoneManager
PhoneManager.getInstance().addPhone(this);
// Adds a tab handler.
SparkManager.getChatManager().addSparkTabHandler(new JingleTabHandler());
final SwingWorker jingleLoadingThread = new SwingWorker() {
public Object construct() {
if (fallbackStunEnabled) {
stunServer = localPref.getStunFallbackHost();
readyToConnect = true;
}
try {
if (STUN.serviceAvailable(SparkManager.getConnection())) {
STUN stun = STUN.getSTUNServer(SparkManager.getConnection());
if (stun != null) {
List<STUN.StunServerAddress> servers = stun.getServers();
if (servers.size() > 0) {
stunServer = servers.get(0).getServer();
stunPort = Integer.parseInt(servers.get(0).getPort());
readyToConnect = true;
}
}
}
if (readyToConnect) {
JingleTransportManager transportManager = new ICETransportManager(SparkManager.getConnection(), stunServer, stunPort);
List<JingleMediaManager> mediaManagers = new ArrayList<>();
// Get the Locator from the Settings
String locator = SettingsManager.getLocalPreferences().getAudioDevice();
mediaManagers.add(new JmfMediaManager(locator, transportManager));
mediaManagers.add(new SpeexMediaManager(transportManager));
// mediaManagers.add(new ScreenShareMediaManager(transportManager));
jingleManager = new JingleManager(SparkManager.getConnection(), mediaManagers);
if (transportManager instanceof BridgedTransportManager) {
jingleManager.addCreationListener((BridgedTransportManager) transportManager);
} else if (transportManager instanceof ICETransportManager) {
jingleManager.addCreationListener((ICETransportManager) transportManager);
}
}
} catch (XMPPException | SmackException e) {
Log.error("Unable to initialize", e);
}
return true;
}
public void finished() {
addListeners();
}
};
jingleLoadingThread.start();
// Add Presence listener for better service discovery.
addPresenceListener();
SparkManager.getConnection().addConnectionListener(this);
}
Aggregations