public class JingleManager extends Object implements JingleSessionListener
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) {
e.printStackTrace();
}
}
});
Thread.sleep(15000);
} catch (Exception e) {
e.printStackTrace();
}
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) {
e.printStackTrace();
}
| Constructor and Description |
|---|
JingleManager(XMPPConnection connection,
List<JingleMediaManager> jingleMediaManagers)
Default constructor with a defined XMPPConnection, Transport Resolver and a Media Manager
If a fully implemented JingleMediaSession is entered, JingleManager manage Jingle signalling and jmf
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCreationListener(CreatedJingleSessionListener createdJingleSessionListener)
Adds a CreatedJingleSessionListener.
|
void |
addJingleSessionRequestListener(JingleSessionRequestListener jingleSessionRequestListener)
Add a Jingle session request listenerJingle to listen to incoming session
requests.
|
JingleSession |
createIncomingJingleSession(JingleSessionRequest request)
When the session request is acceptable, this method should be invoked.
|
JingleSession |
createOutgoingJingleSession(String responder)
Creates an Jingle session to start a communication with another user.
|
void |
disconnectAllSessions()
Disconnect all Jingle Sessions
|
List<JingleMediaManager> |
getMediaManagers()
Get the Media Managers of this Jingle Manager
|
JingleSession |
getSession(String jid)
Get a session with the informed JID.
|
static boolean |
isServiceEnabled(XMPPConnection connection)
Returns true if the Jingle support is enabled for the given connection.
|
static boolean |
isServiceEnabled(XMPPConnection connection,
String userID)
Returns true if the specified user handles Jingle messages.
|
void |
removeCreationListener(CreatedJingleSessionListener createdJingleSessionListener)
Removes a CreatedJingleSessionListener.
|
void |
removeJingleSessionRequestListener(JingleSessionRequestListener jingleSessionRequestListener)
Removes a Jingle session listenerJingle.
|
void |
sessionClosed(String reason,
JingleSession jingleSession)
Notification that the session was closed normally.
|
void |
sessionClosedOnError(XMPPException e,
JingleSession jingleSession)
Notification that the session was closed due to an exception.
|
void |
sessionDeclined(String reason,
JingleSession jingleSession)
Notification that the session was declined.
|
void |
sessionEstablished(PayloadType pt,
TransportCandidate rc,
TransportCandidate lc,
JingleSession jingleSession)
Notification that the session has been established.
|
void |
sessionMediaReceived(JingleSession jingleSession,
String participant)
Notification that the Media has arrived for this session.
|
void |
sessionRedirected(String redirection,
JingleSession jingleSession)
Notification that the session was redirected.
|
static void |
setJingleServiceEnabled()
Setup the jingle system to let the remote clients know we support Jingle.
|
void |
setMediaManagers(List<JingleMediaManager> jingleMediaManagers)
Set the Media Managers of this Jingle Manager
|
static void |
setServiceEnabled(XMPPConnection connection,
boolean enabled)
Enables or disables the Jingle support on a given connection.
|
void |
triggerSessionCreated(JingleSession jingleSession)
Trigger CreatedJingleSessionListeners that a session was created.
|
public JingleManager(XMPPConnection connection, List<JingleMediaManager> jingleMediaManagers) throws XMPPException, SmackException
connection - XMPP XMPPConnection to be usedjingleMediaManagers - an implemeted JingleMediaManager to be used.SmackExceptionXMPPExceptionpublic static void setJingleServiceEnabled()
public static void setServiceEnabled(XMPPConnection connection, boolean enabled)
connection - the connection where the service will be enabled or
disabledenabled - indicates if the service will be enabled or disabledpublic static boolean isServiceEnabled(XMPPConnection connection)
connection - the connection to look for Jingle supportpublic static boolean isServiceEnabled(XMPPConnection connection, String userID) throws XMPPException, SmackException
connection - the connection to use to perform the service discoveryuserID - the user to check. A fully qualified xmpp ID, e.g.
jdoe@example.comSmackException - if there was no response from the server.XMPPExceptionpublic List<JingleMediaManager> getMediaManagers()
public void setMediaManagers(List<JingleMediaManager> jingleMediaManagers)
jingleMediaManagers - JingleMediaManager to be used for open, close, start and stop jmf streamingspublic void addJingleSessionRequestListener(JingleSessionRequestListener jingleSessionRequestListener)
jingleSessionRequestListener - an implemented JingleSessionRequestListenerremoveJingleSessionRequestListener(JingleSessionRequestListener),
JingleListenerpublic void removeJingleSessionRequestListener(JingleSessionRequestListener jingleSessionRequestListener)
jingleSessionRequestListener - The jingle session jingleSessionRequestListener to be removedaddJingleSessionRequestListener(JingleSessionRequestListener),
JingleListenerpublic void addCreationListener(CreatedJingleSessionListener createdJingleSessionListener)
createdJingleSessionListener - public void removeCreationListener(CreatedJingleSessionListener createdJingleSessionListener)
createdJingleSessionListener - public void triggerSessionCreated(JingleSession jingleSession)
jingleSession - public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession)
JingleSessionListenersessionEstablished in interface JingleSessionListenerpt - the Payload tyep to userc - the remote candidate to use for connecting to the remote
service.lc - the local candidate where we must listen for connectionsjingleSession - Session that called the methodpublic void sessionDeclined(String reason, JingleSession jingleSession)
JingleSessionListenersessionDeclined in interface JingleSessionListenerreason - the reason (if any).jingleSession - Session that called the methodpublic void sessionRedirected(String redirection, JingleSession jingleSession)
JingleSessionListenersessionRedirected in interface JingleSessionListenerjingleSession - session that called the methodpublic void sessionClosed(String reason, JingleSession jingleSession)
JingleSessionListenersessionClosed in interface JingleSessionListenerreason - the reason (if any).jingleSession - Session that called the methodpublic void sessionClosedOnError(XMPPException e, JingleSession jingleSession)
JingleSessionListenersessionClosedOnError in interface JingleSessionListenere - the exception.jingleSession - session that called the methodpublic void sessionMediaReceived(JingleSession jingleSession, String participant)
JingleSessionListenersessionMediaReceived in interface JingleSessionListenerjingleSession - session that called the methodparticipant - description of the participantpublic void disconnectAllSessions()
public JingleSession createOutgoingJingleSession(String responder) throws XMPPException
responder - the fully qualified jabber ID with resource of the other
user.XMPPExceptionpublic JingleSession createIncomingJingleSession(JingleSessionRequest request) throws XMPPException
request - the remote request that is being accepted.XMPPExceptionpublic JingleSession getSession(String jid)
jid -