1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-06 05:01:12 +01:00

More Refactoring

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7311 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Thiago Camargo 2007-02-27 13:23:21 +00:00 committed by thiago
parent 9e4be21775
commit 79b19ce620
10 changed files with 186 additions and 125 deletions

View file

@ -51,6 +51,8 @@ import java.util.List;
* portB ---> portA
* <p/>
* <i>Transmit and Receive are interdependents. To receive you MUST trasmit. </i>
*
* @author Thiago Camargo
*/
public class AudioChannel {

View file

@ -24,7 +24,9 @@ import org.jivesoftware.smackx.jingle.media.PayloadType;
import javax.media.format.AudioFormat;
/**
* Audio Format Ttils.
* Audio Format Utils.
*
* @author Thiago Camargo
*/
public class AudioFormatUtils {

View file

@ -36,11 +36,15 @@ import java.net.ServerSocket;
* But you could also use in any VOIP application.
* For better NAT Traversal support this implementation don´t support only receive or only transmit.
* To receive you MUST transmit. So the only implemented and functionally methods are startTransmit() and stopTransmit()
*
* @author Thiago Camargo
*
*/
public class AudioMediaSession extends JingleMediaSession {
private AudioFormat format;
private AudioChannel audioChannel;
private String locator = "javasound://";
/**
* Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates
@ -50,8 +54,23 @@ public class AudioMediaSession extends JingleMediaSession {
* @param local The local information. The candidate that will receive the jmf
*/
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local) {
final TransportCandidate local) {
this(payloadType, remote, local, "javasound://");
}
/**
* Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates
*
* @param payloadType Payload of the jmf
* @param remote The remote information. The candidate that the jmf will be sent to.
* @param local The local information. The candidate that will receive the jmf
*/
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local, String locator) {
super(payloadType, remote, local);
if (locator != null && !locator.equals(""))
this.locator = locator;
initialize();
}
/**
@ -72,14 +91,15 @@ public class AudioMediaSession extends JingleMediaSession {
System.out.println(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort);
} else {
}
else {
ip = this.getRemote().getIp();
localIp = this.getLocal().getLocalIp();
localPort = this.getLocal().getPort();
remotePort = this.getRemote().getPort();
}
audioChannel = new AudioChannel(new MediaLocator("dsound://"), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()));
audioChannel = new AudioChannel(new MediaLocator(locator), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()));
}
/**

View file

@ -1,4 +1,4 @@
package org.jivesoftware.jingleaudio.jmf; /**
/**
* $RCSfile$
* $Revision: $
* $Date: 08/11/2006
@ -18,6 +18,8 @@ package org.jivesoftware.jingleaudio.jmf; /**
* limitations under the License.
*/
package org.jivesoftware.jingleaudio.jmf;
import javax.media.*;
import javax.media.protocol.DataSource;
import javax.media.rtp.*;
@ -25,6 +27,8 @@ import javax.media.rtp.event.*;
/**
* This class implements receive methods and listeners to be used in AudioChannel
*
* @author Thiago Camargo
*/
public class AudioReceiver implements ReceiveStreamListener, SessionListener,
ControllerListener {

View file

@ -32,7 +32,9 @@ import java.io.IOException;
/**
* Implements a jingleMediaManager using JMF based API.
* It supports GSM and G723 codecs.
* <i>This API only currently works on windows.</i>
* <i>This API only currently works on windows and Mac.</i>
*
* @author Thiago Camargo
*/
public class JmfMediaManager extends JingleMediaManager {

View file

@ -1,3 +1,23 @@
/**
* $RCSfile$
* $Revision: $
* $Date: 25/12/2006
* <p/>
* Copyright 2003-2006 Jive Software.
* <p/>
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.jingleaudio.jspeex;
import mil.jfcom.cie.media.session.MediaSession;
@ -19,23 +39,14 @@ import java.net.ServerSocket;
import java.security.GeneralSecurityException;
/**
* $RCSfile$
* $Revision: $
* $Date: 25/12/2006
* This Class implements a complete JingleMediaSession.
* It sould be used to transmit and receive audio captured from the Mic.
* This Class should be automaticly controlled by JingleSession.
* But you could also use in any VOIP application.
* For better NAT Traversal support this implementation don´t support only receive or only transmit.
* To receive you MUST transmit. So the only implemented and functionally methods are startTransmit() and stopTransmit()
*
* Copyright 2003-2006 Jive Software.
*
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* @author Thiago Camargo
*/
public class AudioMediaSession extends JingleMediaSession implements MediaSessionListener {
@ -77,8 +88,9 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
* @param local The local information. The candidate that will receive the jmf
*/
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local) {
final TransportCandidate local) {
super(payloadType, remote, local);
initialize();
}
/**
@ -99,7 +111,8 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
System.out.println(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort);
} else {
}
else {
ip = this.getRemote().getIp();
localIp = this.getLocal().getLocalIp();
localPort = this.getLocal().getPort();
@ -108,13 +121,17 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
try {
mediaSession = createSession(localIp, localPort, ip, remotePort, this, 2, false, true);
} catch (NoProcessorException e) {
}
catch (NoProcessorException e) {
e.printStackTrace();
} catch (UnsupportedFormatException e) {
}
catch (UnsupportedFormatException e) {
e.printStackTrace();
} catch (IOException e) {
}
catch (IOException e) {
e.printStackTrace();
} catch (GeneralSecurityException e) {
}
catch (GeneralSecurityException e) {
e.printStackTrace();
}
}
@ -126,7 +143,8 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
try {
System.out.println("start");
mediaSession.start(true);
} catch (IOException e) {
}
catch (IOException e) {
e.printStackTrace();
}
}

View file

@ -1,14 +1,3 @@
package org.jivesoftware.jingleaudio.jspeex;
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.TransportCandidate;
import org.jivesoftware.jingleaudio.JMFInit;
import java.io.File;
import java.io.IOException;
/**
* $RCSfile$
* $Revision: $
@ -28,6 +17,24 @@ import java.io.IOException;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.jingleaudio.jspeex;
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.TransportCandidate;
import org.jivesoftware.jingleaudio.JMFInit;
import java.io.File;
import java.io.IOException;
/**
* Implements a jingleMediaManager using JMF based API and JSpeex.
* It supports Speex codec.
* <i>This API only currently works on windows.</i>
*
* @author Thiago Camargo
*/
public class SpeexMediaManager extends JingleMediaManager {
public SpeexMediaManager() {