Class JingleManager

  • All Implemented Interfaces:
    JingleListener, JingleSessionListener

    public class JingleManager
    extends Object
    implements JingleSessionListener
    Jingle is a session establishment protocol defined in (XEP-0166). It defines a framework for negotiating and managing out-of-band ( data that is send and receive through other connection than XMPP connection) data sessions over XMPP. With this protocol you can setup VOIP Calls, Video Streaming, File transfers and whatever out-of-band session based transmission.

    To create a Jingle Session you need a Transport method and a Payload type.

    A transport method is how it will transmit and receive network packets. Transport MUST have one or more candidates. A transport candidate is an IP Address with a defined port, that other party must send data to.

    A supported payload type, is the data encoding format that the jmf will be transmitted. For instance an Audio Payload "GSM".

    A Jingle session negotiates a payload type and a pair of transport candidates. Which means that when a Jingle Session is established you will have two defined transport candidates with addresses and a defined Payload type. In other words, you will have two IP address with their respective ports, and a Codec type defined.

    The JingleManager is a facade built upon Jabber Jingle (XEP-166) to allow the use of Jingle. This implementation allows the user to simply use this class for setting the Jingle parameters, create and receive Jingle Sessions.

    In order to use the Jingle, the user must provide a TransportManager that will handle the resolution of potential IP addresses that can be used to transport the streaming (jmf). This TransportManager can be initialized with several default resolvers, including a fixed solver that can be used when the address and port are know in advance. This API have ready to use Transport Managers, for instance: BasicTransportManager, STUNTransportManager, BridgedTransportManager.

    You should also specify a JingleMediaManager if you want that JingleManager assume Media control Using a JingleMediaManager implementation is the easier way to implement a Jingle Application.

    Otherwise before creating an outgoing connection, the user must create jingle session listeners that will be called when different events happen. The most important event is sessionEstablished(), that will be called when all the negotiations are finished, providing the payload type for the transmission as well as the remote and local addresses and ports for the communication. See JingleSessionListener for a complete list of events that can be observed.

    This is an example of how to use the JingleManager: This example implements a Jingle VOIP Call between two users.
                                   To wait for an Incoming Jingle Session:
                                   try {
                                               // Connect to an XMPP Server
                                               XMPPConnection x1 = new XMPPTCPConnection("xmpp.com");
                                               x1.connect();
                                               x1.login("juliet", "juliet");
                                               // Create a JingleManager using a BasicResolver
                                               final JingleManager jm1 = new JingleManager(
                                                       x1, new BasicTransportManager());
                                               // Create a JingleMediaManager. In this case using Jingle Audio Media API
                                               JingleMediaManager jingleMediaManager = new AudioMediaManager();
                                               // Set the JingleMediaManager
                                               jm1.setMediaManager(jingleMediaManager);
                                               // Listen for incoming calls
                                               jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
                                                   public void sessionRequested(JingleSessionRequest request) {
                                                       try {
                                                          // Accept the call
                                                          IncomingJingleSession session = request.accept();
                                                           // Start the call
                                                           session.start();
                                                       } catch (XMPPException e) {
                                                           LOGGER.log(Level.WARNING, "exception", e);
                                                       }
                                                   }
                                               });
                                           Thread.sleep(15000);
                                           } catch (Exception e) {
                                               LOGGER.log(Level.WARNING, "exception", e);
                                           }
                                   To create an Outgoing Jingle Session:
                                         try {
                                               // Connect to an XMPP Server
                                               XMPPConnection x0 = new XMPPTCPConnection("xmpp.com");
                                               x0.connect();
                                               x0.login("romeo", "romeo");
                                               // Create a JingleManager using a BasicResolver
                                               final JingleManager jm0 = new JingleManager(
                                                       x0, new BasicTransportManager());
                                               // Create a JingleMediaManager. In this case using Jingle Audio Media API
                                               JingleMediaManager jingleMediaManager = new AudioMediaManager(); // Using Jingle Media API
                                               // Set the JingleMediaManager
                                               jm0.setMediaManager(jingleMediaManager);
                                               // Create a new Jingle Call with a full JID
                                               OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("juliet@xmpp.com/Smack");
                                               // Start the call
                                               js0.start();
                                               Thread.sleep(10000);
                                               js0.terminate();
                                               Thread.sleep(3000);
                                           } catch (Exception e) {
                                               LOGGER.log(Level.WARNING, "exception", e);
                                           }
                                   
    See Also:
    JingleListener, TransportResolver, JingleSession, JingleSession, JingleMediaManager, , STUNTransportManager, BridgedTransportManager, TransportResolver, BridgedResolver, ICEResolver, STUNResolver and BasicResolver.