Ajout de programme qui peuvent s'echanger des donnees jingle et negocier une
session
--- a/build.xml Sat Feb 28 02:46:02 2009 +0100
+++ b/build.xml Sat Feb 28 02:55:32 2009 +0100
@@ -292,8 +292,7 @@
<target name="clean"
description="Delete old build and dist directories">
- <echo message="on deletet ${outdir-classes}" />
- <delete verbose="true" dir="${outdir}"/>
+ <delete verbose="false" dir="${outdir}"/>
</target>
Binary file libs/smack.jar has changed
Binary file libs/smackx-debug.jar has changed
Binary file libs/smackx-jingle.jar has changed
Binary file libs/smackx.jar has changed
--- a/src/com/beem/project/beem/Beem.java Sat Feb 28 02:46:02 2009 +0100
+++ b/src/com/beem/project/beem/Beem.java Sat Feb 28 02:55:32 2009 +0100
@@ -3,13 +3,14 @@
import android.app.Activity;
import android.os.Bundle;
-public class Beem extends Activity
-{
- /** Called when the activity is first created. */
+public class Beem extends Activity {
+
+ /** Called when the activity is first created.
+ * @param savedInstanceState toto
+ */
@Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/Caller.java Sat Feb 28 02:55:32 2009 +0100
@@ -0,0 +1,128 @@
+package com.beem.project.beem.jingle;
+import java.util.ArrayList;
+import java.util.List;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smackx.jingle.JingleManager;
+import org.jivesoftware.smackx.jingle.JingleSession;
+import org.jivesoftware.smackx.jingle.listeners.JingleSessionListener;
+import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
+import org.jivesoftware.smackx.jingle.media.PayloadType;
+import org.jivesoftware.smackx.jingle.nat.BasicTransportManager;
+import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+
+/**
+ * @author darisk
+ *
+ */
+public class Caller {
+
+ private XMPPConnection con;
+ private String login;
+ private String password;
+ private JingleManager jingleManager;
+ private List<JingleMediaManager> mediaManagers;
+ private JingleSession out;
+
+ public Caller(final String login, final String pass, String server) {
+ if (server == null || server.equals(""))
+ server = "localhost";
+ XMPPConnection.DEBUG_ENABLED = true;
+ this.login = login;
+ this.password = pass;
+ ConnectionConfiguration conf = new ConnectionConfiguration(server);
+ conf.setRosterLoadedAtLogin(false);
+
+ con = new XMPPConnection(conf);
+ try {
+ con.connect();
+ con.login(this.login, this.password, "Caller");
+ initialize();
+ } catch (XMPPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void call(final String destinataire) {
+ try {
+ out = jingleManager.createOutgoingJingleSession(destinataire);
+ // TODO configure out avec addMediaSession et addNegociator
+ out.addListener(new JingleSessionListener() {
+
+ @Override
+ public void sessionRedirected(final String redirection,
+ final JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void sessionMediaReceived(final JingleSession jingleSession,
+ final String participant) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void sessionEstablished(final PayloadType pt,
+ final TransportCandidate remoteCandidate,
+ final TransportCandidate localCandidate,
+ final JingleSession jingleSession) {
+ System.out.println("Session established");
+ }
+
+ @Override
+ public void sessionDeclined(final String reason,
+ final JingleSession jingleSession) {
+ System.out.println("Session " + jingleSession.getResponder()
+ + "declined because " + reason);
+ }
+
+ @Override
+ public void sessionClosedOnError(final XMPPException e,
+ final JingleSession jingleSession) {
+ System.out.println("Session " + jingleSession.getResponder() + " closed on error");
+
+ }
+
+ @Override
+ public void sessionClosed(final String reason,
+ final JingleSession jingleSession) {
+ System.out.println("Session " + jingleSession.getResponder()
+ + "closed because " + reason);
+ }
+ });
+ out.startOutgoing();
+
+
+ } catch (XMPPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private void initialize() {
+ mediaManagers = new ArrayList<JingleMediaManager>();
+ mediaManagers.add(new SenderMediaManager(new BasicTransportManager()));
+ JingleManager.setJingleServiceEnabled();
+ jingleManager = new JingleManager(con, mediaManagers);
+
+ }
+
+ /**
+ * @param args Program args
+ * @throws InterruptedException exception
+ */
+ public static void main(final String[] args) throws InterruptedException {
+ if (args.length < 4) {
+ System.err.println("Not enough parameters");
+ System.err.println("Usage : Caller user password server jidtocall");
+ }
+ // String dest ="test2@nowhere/Receiver";
+ Caller test = new Caller(args[1], args[2], args[3]);
+ test.call(args[4]);
+ Thread.sleep(60000);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/Receiver.java Sat Feb 28 02:55:32 2009 +0100
@@ -0,0 +1,125 @@
+package com.beem.project.beem.jingle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smackx.jingle.JingleManager;
+import org.jivesoftware.smackx.jingle.JingleSession;
+import org.jivesoftware.smackx.jingle.JingleSessionRequest;
+import org.jivesoftware.smackx.jingle.listeners.JingleSessionListener;
+import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
+import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
+import org.jivesoftware.smackx.jingle.media.PayloadType;
+import org.jivesoftware.smackx.jingle.nat.BasicTransportManager;
+import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+
+
+public class Receiver {
+
+ private XMPPConnection con;
+ private JingleManager jingleManager;
+ private List<JingleMediaManager> mediaManagers;
+ private JingleSession in;
+
+ public Receiver(String username, String pass) {
+// XMPPConnection.DEBUG_ENABLED = true;
+ ConnectionConfiguration conf = new ConnectionConfiguration("localhost");
+ conf.setRosterLoadedAtLogin(false);
+ con = new XMPPConnection(conf);
+ try {
+ con.connect();
+ con.login(username, pass, "Receiver");
+ initialize();
+
+ } catch (XMPPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void initialize()
+ {
+ mediaManagers = new ArrayList<JingleMediaManager>();
+ mediaManagers.add(new SenderMediaManager(new BasicTransportManager()));
+ JingleManager.setJingleServiceEnabled();
+ jingleManager = new JingleManager(con, mediaManagers);
+ jingleManager.addJingleSessionRequestListener(new JingleSessionRequestListener() {
+
+ @Override
+ public void sessionRequested(JingleSessionRequest request) {
+ System.out.println("Jingle Session request from "+request.getFrom());
+ try {
+ in = request.accept();
+ // TODO configure in
+ in.addListener(new JingleSessionListener() {
+
+ @Override
+ public void sessionRedirected(String redirection,
+ JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void sessionMediaReceived(JingleSession jingleSession,
+ String participant) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void sessionEstablished(PayloadType pt,
+ TransportCandidate remoteCandidate,
+ TransportCandidate localCandidate, JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ System.out.println("Session established");
+ }
+
+ @Override
+ public void sessionDeclined(String reason, JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ System.out.println("Session "+ jingleSession.getResponder() +"declined because "+ reason);
+ }
+
+ @Override
+ public void sessionClosedOnError(XMPPException e,
+ JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ System.out.println("Session "+ jingleSession.getResponder() + " closed");
+
+ }
+
+ @Override
+ public void sessionClosed(String reason, JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ System.out.println("Session "+ jingleSession.getResponder() +"closedd because "+ reason);
+ }
+ });
+ in.startIncoming();
+ } catch (XMPPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+
+ }
+
+ /**
+ * @param args
+ * @throws InterruptedException
+ * @throws InterruptedException
+ */
+ public static void main(String[] args) throws InterruptedException {
+ // TODO Auto-generated method stub
+ Receiver rec = new Receiver("test2", "test2");
+ System.out.println("Receiver initialized");
+
+ Thread.sleep(60000);
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/ReceiverMediaManager.java Sat Feb 28 02:55:32 2009 +0100
@@ -0,0 +1,53 @@
+package com.beem.project.beem.jingle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jivesoftware.smackx.jingle.JingleSession;
+import org.jivesoftware.smackx.jingle.SmackLogger;
+import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
+import org.jivesoftware.smackx.jingle.media.JingleMediaSession;
+import org.jivesoftware.smackx.jingle.media.PayloadType;
+import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaSession;
+import org.jivesoftware.smackx.jingle.nat.JingleTransportManager;
+import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+
+public class ReceiverMediaManager extends JingleMediaManager {
+
+ private static final SmackLogger LOGGER = SmackLogger.getLogger(ReceiverMediaManager.class);
+
+ public static final String MEDIA_NAME = "69Test";
+
+ private List<PayloadType> payloads;
+
+ public ReceiverMediaManager(JingleTransportManager transportManager) {
+ super(transportManager);
+ // TODO Auto-generated constructor stub
+ setupPayloads();
+ LOGGER.info("A TestMedia Manager is created");
+ }
+
+ @Override
+ public JingleMediaSession createMediaSession(PayloadType payloadType,
+ TransportCandidate remote, TransportCandidate local,
+ JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ return new TestMediaSession(payloadType, remote, local, null, jingleSession);
+ }
+
+ @Override
+ public List<PayloadType> getPayloads() {
+ // TODO Auto-generated method stub
+ return payloads;
+ }
+
+ private void setupPayloads() {
+ payloads = new ArrayList<PayloadType>();
+ payloads.add(new PayloadType.Audio(42, "Test"));
+ payloads.add(new PayloadType.Audio(69, "Test2"));
+ }
+
+ public String getName() {
+ return MEDIA_NAME;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/SenderMediaManager.java Sat Feb 28 02:55:32 2009 +0100
@@ -0,0 +1,51 @@
+package com.beem.project.beem.jingle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jivesoftware.smackx.jingle.JingleSession;
+import org.jivesoftware.smackx.jingle.SmackLogger;
+import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
+import org.jivesoftware.smackx.jingle.media.JingleMediaSession;
+import org.jivesoftware.smackx.jingle.media.PayloadType;
+import org.jivesoftware.smackx.jingle.nat.JingleTransportManager;
+import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+
+public class SenderMediaManager extends JingleMediaManager {
+
+ private static final SmackLogger LOGGER = SmackLogger.getLogger(SenderMediaManager.class);
+
+ public static final String MEDIA_NAME = "42Test";
+
+ private List<PayloadType> payloads;
+
+ public SenderMediaManager(JingleTransportManager transportManager) {
+ super(transportManager);
+ // TODO Auto-generated constructor stub
+ setupPayloads();
+ LOGGER.info("A TestMedia Manager is created");
+ }
+
+ @Override
+ public JingleMediaSession createMediaSession(PayloadType payloadType,
+ TransportCandidate remote, TransportCandidate local,
+ JingleSession jingleSession) {
+ // TODO Auto-generated method stub
+ return new SenderMediaSession(payloadType, remote, local, null, jingleSession);
+ }
+
+ @Override
+ public List<PayloadType> getPayloads() {
+ return payloads;
+ }
+
+ private void setupPayloads() {
+ payloads = new ArrayList<PayloadType>();
+ payloads.add(new PayloadType.Audio(42, "Test"));
+ }
+
+ @Override
+ public String getName() {
+ return MEDIA_NAME;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/SenderMediaSession.java Sat Feb 28 02:55:32 2009 +0100
@@ -0,0 +1,101 @@
+/**
+ *
+ */
+package com.beem.project.beem.jingle;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.jivesoftware.smackx.jingle.JingleSession;
+import org.jivesoftware.smackx.jingle.SmackLogger;
+import org.jivesoftware.smackx.jingle.media.JingleMediaSession;
+import org.jivesoftware.smackx.jingle.media.PayloadType;
+import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+
+/**
+ * @author darisk
+ *
+ */
+public class SenderMediaSession extends JingleMediaSession {
+
+ private static final SmackLogger LOGGER = SmackLogger.getLogger(SenderMediaSession.class);
+ private InputStream is;
+ private static final String filename = "/tmp/test.jpg";
+
+ /**
+ * @param payloadType
+ * @param remote
+ * @param local
+ * @param mediaLocator
+ * @param jingleSession
+ */
+ public SenderMediaSession(PayloadType payloadType, TransportCandidate remote,
+ TransportCandidate local, String mediaLocator,
+ JingleSession jingleSession) {
+ super(payloadType, remote, local, mediaLocator, jingleSession);
+ initialize();
+ LOGGER.info("Demarrage d'une session avec local: "+ local +" #remote: "+remote );
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#initialize()
+ */
+ @Override
+ public void initialize() {
+ // TODO Auto-generated method stub
+ try {
+ is = new BufferedInputStream(new FileInputStream(filename));
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#setTrasmit(boolean)
+ */
+ @Override
+ public void setTrasmit(boolean active) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#startReceive()
+ */
+ @Override
+ public void startReceive() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#startTrasmit()
+ */
+ @Override
+ public void startTrasmit() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#stopReceive()
+ */
+ @Override
+ public void stopReceive() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#stopTrasmit()
+ */
+ @Override
+ public void stopTrasmit() {
+ // TODO Auto-generated method stub
+
+ }
+
+}