debut de l'audit de mon code
authornikita@mapiproxy
Tue, 25 Aug 2009 03:42:58 +0200
changeset 355 b11d01c264a3
parent 354 62b942273625
child 356 e46f634c629c
debut de l'audit de mon code
src/com/beem/project/beem/jingle/JingleService.java
src/com/beem/project/beem/jingle/MicroRTPReceiver.java
src/com/beem/project/beem/jingle/MicroRTPTransmitter.java
src/com/beem/project/beem/jingle/RTPMediaManager.java
src/com/beem/project/beem/jingle/RTPMediaSession.java
src/com/beem/project/beem/jingle/RTPReceiver.java
src/com/beem/project/beem/jingle/RTPTransmitter.java
src/com/beem/project/beem/jingle/package-info.java
--- a/src/com/beem/project/beem/jingle/JingleService.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java	Tue Aug 25 03:42:58 2009 +0200
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package com.beem.project.beem.jingle;
 
@@ -19,30 +19,42 @@
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
 /**
+ * Beem Jingle Service, manage jingle call.
  * @author nikita
- *
  */
 public class JingleService {
-    private JingleManager            mJingleManager;
+    private JingleManager mJingleManager;
     private List<JingleMediaManager> mMediaManagers;
-    private JingleSession            mIn;
-    private JingleSession            mOut;
+    private JingleSession mIn;
+    private JingleSession mOut;
 
-    public JingleService(XMPPConnection xmppConnection) {
+    /**
+     * JingleService constructor.
+     * @param xmppConnection a valid XMPPConnection
+     */
+    public JingleService(final XMPPConnection xmppConnection) {
 	BasicTransportManager bt = new BasicTransportManager();
 
 	mMediaManagers = new ArrayList<JingleMediaManager>();
 	mMediaManagers.add(new RTPMediaManager(bt));
     }
 
+    /**
+     * finish to construct the instance.
+     * @param conn the xmppConnection used with constructor
+     */
     public void initWhenConntected(XMPPConnection conn) {
 	mJingleManager = new JingleManager(conn, mMediaManagers);
 	mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
     }
 
-    public void call(final String destinataire) {
+    /**
+     * begin a jingle call.
+     * @param receiver the call receiver
+     */
+    public void call(final String receiver) {
 	try {
-	    mOut = mJingleManager.createOutgoingJingleSession(destinataire);
+	    mOut = mJingleManager.createOutgoingJingleSession(receiver);
 	    // TODO configure out avec addMediaSession et addNegociator
 	    mOut.addListener(new BeemJingleCallerSessionListener());
 	    mOut.startOutgoing();
@@ -53,63 +65,75 @@
     }
 
     /*
-    private void receiveData(String ip, int port) throws IOException {
-	Socket s = null;
-	try {
-	    s = new Socket(ip, port);
-	    System.out.println("Waiting data");
-	    InputStream in = s.getInputStream();
-	    int a;
-	    while ((a = in.read()) != -1) {
-		System.out.println("Received " + a);
-	    }
-	    System.out.println("End receiving data");
-	} finally {
-	    if (s != null)
-		s.close();
+     * private void receiveData(String ip, int port) throws IOException { Socket s = null; try { s = new Socket(ip,
+     * port); System.out.println("Waiting data"); InputStream in = s.getInputStream(); int a; while ((a = in.read()) !=
+     * -1) { System.out.println("Received " + a); } System.out.println("End receiving data"); } finally { if (s != null)
+     * s.close(); } }
+     */
+    /**
+     * Listen on receiver session events.
+     * @author nikita
+     */
+    private class BeemJingleReceiverSessionListener implements JingleSessionListener {
+
+	/**
+	 * constructor.
+	 */
+	public BeemJingleReceiverSessionListener() {
+	    super();
+	    // TODO Auto-generated constructor stub
 	}
-    }*/
-    
-    private class BeemJingleReceiverSessionListener implements JingleSessionListener {
-	 @Override
-	    public void sessionClosed(String reason, JingleSession jingleSession) {
-		System.out.println("Session " + jingleSession.getResponder() + "closedd because " + reason);
-	    }
+
+	@Override
+	public void sessionClosed(String reason, JingleSession jingleSession) {
+	    System.out.println("Session " + jingleSession.getResponder() + "closedd 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 sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
+	    // TODO Auto-generated method stub
+	    System.out.println("Session " + jingleSession.getResponder() + " closed");
 
-	    @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 sessionDeclined(String reason, JingleSession jingleSession) {
+	    // TODO Auto-generated method stub
+	    System.out.println("Session " + jingleSession.getResponder() + "declined because " + reason);
+	}
 
-	    @Override
-	    public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate,
-		TransportCandidate localCandidate, JingleSession jingleSession) {
-		System.out.println("Session established");
-		System.out.println("Je recois sur " + remoteCandidate.getIp() + ":"
-		+ remoteCandidate.getPort());
-		RTPReceiver rtpReceiver = new MicroRTPReceiver(remoteCandidate.getPort());
-	    }
+	@Override
+	public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate,
+	    TransportCandidate localCandidate, JingleSession jingleSession) {
+	    System.out.println("Session established");
+	    System.out.println("Je recois sur " + remoteCandidate.getIp() + ":" + remoteCandidate.getPort());
+	    RTPReceiver rtpReceiver = new MicroRTPReceiver(remoteCandidate.getPort());
+	}
 
-	    @Override
-	    public void sessionMediaReceived(JingleSession jingleSession, String participant) {
-		System.out.println("Session Media received from " + participant);
-	    }
+	@Override
+	public void sessionMediaReceived(JingleSession jingleSession, String participant) {
+	    System.out.println("Session Media received from " + participant);
+	}
 
-	    @Override
-	    public void sessionRedirected(String redirection, JingleSession jingleSession) {
-	    }
+	@Override
+	public void sessionRedirected(String redirection, JingleSession jingleSession) {
+	}
     }
 
+    /**
+     * Listen on caller session events.
+     * @author nikita
+     */
     private class BeemJingleCallerSessionListener implements JingleSessionListener {
+
+	/**
+	 * constructor.
+	 */
+	public BeemJingleCallerSessionListener() {
+	    super();
+	    // TODO Auto-generated constructor stub
+	}
+
 	@Override
 	public void sessionClosed(final String reason, final JingleSession jingleSession) {
 	    System.out.println("Session " + jingleSession.getResponder() + "closed because " + reason);
@@ -135,7 +159,6 @@
 	    int port = localCandidate.getPort();
 	    System.out.println("Session established waiting connection on " + ip + ":" + port);
 
-
 	    RTPTransmitter transm = new MicroRTPTransmitter(ip, port);
 
 	    transm.run();
@@ -162,7 +185,19 @@
 	}
     }
 
+    /**
+     * Listen for a Jingle session request.
+     * @author nikita
+     */
     private class BeemJingleSessionRequestListener implements JingleSessionRequestListener {
+
+	/**
+	 * Constructor.
+	 */
+	public BeemJingleSessionRequestListener() {
+	    super();
+	}
+
 	@Override
 	public void sessionRequested(JingleSessionRequest request) {
 	    System.out.println("Jingle Session request from " + request.getFrom());
--- a/src/com/beem/project/beem/jingle/MicroRTPReceiver.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/MicroRTPReceiver.java	Tue Aug 25 03:42:58 2009 +0200
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package com.beem.project.beem.jingle;
 
@@ -9,8 +9,8 @@
 import android.util.Log;
 
 /**
+ * 
  * @author nikita
- *
  */
 public class MicroRTPReceiver extends RTPReceiver {
 
@@ -20,7 +20,8 @@
 	super(rtpPort);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
      * @see org.jlibrtp.jlibrtp.RTPAppIntf#receiveData(org.jlibrtp.jlibrtp.DataFrame, org.jlibrtp.jlibrtp.Participant)
      */
     @Override
--- a/src/com/beem/project/beem/jingle/MicroRTPTransmitter.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/MicroRTPTransmitter.java	Tue Aug 25 03:42:58 2009 +0200
@@ -9,7 +9,6 @@
 
 /**
  * @author nikita
- *
  */
 public class MicroRTPTransmitter extends RTPTransmitter {
 
@@ -19,21 +18,23 @@
 
     @Override
     void start() {
-	AudioRecord audRec = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, 8000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT) );
-	byte [] audioData = new byte[1024];
+	AudioRecord audRec = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, 8000,
+	    AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, AudioRecord.getMinBufferSize(8000,
+		AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT));
+	byte[] audioData = new byte[1024];
 	int byteReaded = 0;
 	while (!mKillme) {
 	    byteReaded = audRec.read(audioData, byteReaded, 1024);
 	    System.out.println("readed " + byteReaded);
 	    mRtpSession.sendData(audioData);
 	}
-	
+
 	try {
 	    Thread.sleep(200);
 	} catch (Exception e) {
 	}
 	this.mRtpSession.endSession();
-	
+
     }
 
 }
--- a/src/com/beem/project/beem/jingle/RTPMediaManager.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPMediaManager.java	Tue Aug 25 03:42:58 2009 +0200
@@ -11,13 +11,17 @@
 import org.jivesoftware.smackx.jingle.nat.JingleTransportManager;
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
+/**
+ * RTPMediaManager, gere les payloads et renvoie une session RTP
+ * @author nikita
+ */
 public class RTPMediaManager extends JingleMediaManager {
 
-    private static final SmackLogger LOGGER     = SmackLogger.getLogger(RTPMediaManager.class);
+    private static final SmackLogger LOGGER = SmackLogger.getLogger(RTPMediaManager.class);
 
-    public static final String       MEDIA_NAME = "RTP_BIDON";
+    public static final String MEDIA_NAME = "RTP_BIDON";
 
-    private List<PayloadType>        mPayloads;
+    private List<PayloadType> mPayloads;
 
     public RTPMediaManager(JingleTransportManager transportManager) {
 	super(transportManager);
@@ -28,7 +32,7 @@
 
     @Override
     public JingleMediaSession createMediaSession(PayloadType payloadType, TransportCandidate remote,
-	    TransportCandidate local, JingleSession jingleSession) {
+	TransportCandidate local, JingleSession jingleSession) {
 	// TODO Auto-generated method stub
 	return new RTPMediaSession(payloadType, remote, local, null, jingleSession);
     }
--- a/src/com/beem/project/beem/jingle/RTPMediaSession.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPMediaSession.java	Tue Aug 25 03:42:58 2009 +0200
@@ -13,8 +13,8 @@
  */
 public class RTPMediaSession extends JingleMediaSession {
 
-    private RTPTransmitter           mTransmitter;
-    private RTPReceiver              mReceiver;
+    private RTPTransmitter mTransmitter;
+    private RTPReceiver mReceiver;
 
     /**
      * @param payloadType
--- a/src/com/beem/project/beem/jingle/RTPReceiver.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPReceiver.java	Tue Aug 25 03:42:58 2009 +0200
@@ -11,10 +11,9 @@
 
 public class RTPReceiver implements Runnable, RTPAppIntf {
 
-    RTPSession                       mRtpSession = null;
-    byte[]                           mAbData     = null;
-    private boolean                  mKillme     = false;
-
+    RTPSession mRtpSession = null;
+    byte[] mAbData = null;
+    private boolean mKillme = false;
 
     public RTPReceiver(int rtpPort) {
 	DatagramSocket rtpSocket = null;
@@ -94,6 +93,6 @@
     @Override
     public void userEvent(int arg0, Participant[] arg1) {
 	// TODO Auto-generated method stub
-	
+
     }
 }
--- a/src/com/beem/project/beem/jingle/RTPTransmitter.java	Tue Aug 25 02:54:23 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPTransmitter.java	Tue Aug 25 03:42:58 2009 +0200
@@ -10,8 +10,8 @@
 import org.jlibrtp.jlibrtp.RTPSession;
 
 public abstract class RTPTransmitter implements Runnable, RTPAppIntf {
-    protected RTPSession               mRtpSession = null;
-    protected boolean                  mKillme     = false;
+    protected RTPSession mRtpSession = null;
+    protected boolean mKillme = false;
 
     public RTPTransmitter(String remoteIP, int port) {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/package-info.java	Tue Aug 25 03:42:58 2009 +0200
@@ -0,0 +1,4 @@
+/**
+ * This package contains the class used by the Beem Jingle process.
+ */
+package com.beem.project.beem.jingle;