Search in sources :

Example 1 with SpeexMediaManager

use of org.jivesoftware.smackx.jingleold.mediaimpl.jspeex.SpeexMediaManager 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);
}
Also used : JmfMediaManager(org.jivesoftware.smackx.jingleold.mediaimpl.jmf.JmfMediaManager) ICETransportManager(org.jivesoftware.smackx.jingleold.nat.ICETransportManager) JingleMediaManager(org.jivesoftware.smackx.jingleold.media.JingleMediaManager) SwingWorker(org.jivesoftware.spark.util.SwingWorker) JingleManager(org.jivesoftware.smackx.jingleold.JingleManager) SpeexMediaManager(org.jivesoftware.smackx.jingleold.mediaimpl.jspeex.SpeexMediaManager) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) STUN(org.jivesoftware.smackx.jingleold.nat.STUN) JingleTransportManager(org.jivesoftware.smackx.jingleold.nat.JingleTransportManager) BridgedTransportManager(org.jivesoftware.smackx.jingleold.nat.BridgedTransportManager)

Aggregations

JingleManager (org.jivesoftware.smackx.jingleold.JingleManager)1 JingleMediaManager (org.jivesoftware.smackx.jingleold.media.JingleMediaManager)1 JmfMediaManager (org.jivesoftware.smackx.jingleold.mediaimpl.jmf.JmfMediaManager)1 SpeexMediaManager (org.jivesoftware.smackx.jingleold.mediaimpl.jspeex.SpeexMediaManager)1 BridgedTransportManager (org.jivesoftware.smackx.jingleold.nat.BridgedTransportManager)1 ICETransportManager (org.jivesoftware.smackx.jingleold.nat.ICETransportManager)1 JingleTransportManager (org.jivesoftware.smackx.jingleold.nat.JingleTransportManager)1 STUN (org.jivesoftware.smackx.jingleold.nat.STUN)1 SwingWorker (org.jivesoftware.spark.util.SwingWorker)1 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)1