1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Media Refactoring - Added Custom Media Locator Support

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7623 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Thiago Camargo 2007-03-21 13:49:44 +00:00 committed by thiago
parent 8ab9f55da4
commit 56dc8bd953
6 changed files with 82 additions and 35 deletions

View file

@ -61,4 +61,5 @@ public abstract class JingleMediaManager {
* @return * @return
*/ */
public abstract JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local); public abstract JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local);
} }

View file

@ -23,11 +23,11 @@ import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
/** /**
* Public Abstract Class provides a clear interface between Media Session and Jingle API. * Public Abstract Class provides a clear interface between Media Session and Jingle API.
* * <p/>
* When a Jingle Session is fully stablished, we will have a Payload Type and two transport candidates defined for it. * When a Jingle Session is fully stablished, we will have a Payload Type and two transport candidates defined for it.
* Smack Jingle API don´t implement Media Transmit and Receive methods. * Smack Jingle API don´t implement Media Transmit and Receive methods.
* But provides an interface to let the user implements it using another API. For instance: JMF. * But provides an interface to let the user implements it using another API. For instance: JMF.
* * <p/>
* <i>The Class that implements this one, must have the support to transmit and receive the jmf.</i> * <i>The Class that implements this one, must have the support to transmit and receive the jmf.</i>
* <i>This interface let the user choose his own jmf API.</i> * <i>This interface let the user choose his own jmf API.</i>
* *
@ -41,6 +41,8 @@ public abstract class JingleMediaSession {
private TransportCandidate local; private TransportCandidate local;
// Remote Transport details // Remote Transport details
private TransportCandidate remote; private TransportCandidate remote;
// Media Locator
private String mediaLocator;
/** /**
* Creates a new JingleMediaSession Instance to handle Media methods. * Creates a new JingleMediaSession Instance to handle Media methods.
@ -48,12 +50,14 @@ public abstract class JingleMediaSession {
* @param payloadType Payload Type of the transmittion * @param payloadType Payload Type of the transmittion
* @param remote Remote accepted Transport Candidate * @param remote Remote accepted Transport Candidate
* @param local Local accepted Transport Candidate * @param local Local accepted Transport Candidate
* @param mediaLocator Media Locator of the capture device
*/ */
public JingleMediaSession(PayloadType payloadType, TransportCandidate remote, public JingleMediaSession(PayloadType payloadType, TransportCandidate remote,
TransportCandidate local) { TransportCandidate local, String mediaLocator) {
this.local = local; this.local = local;
this.remote = remote; this.remote = remote;
this.payloadType = payloadType; this.payloadType = payloadType;
this.mediaLocator = mediaLocator;
} }
/** /**
@ -83,6 +87,24 @@ public abstract class JingleMediaSession {
return remote; return remote;
} }
/**
* Return the media locator or null if not defined
*
* @return media locator
*/
public String getMediaLocator() {
return mediaLocator;
}
/**
* Set the media locator
*
* @param mediaLocator media locator or null to use default
*/
public void setMediaLocator(String mediaLocator) {
this.mediaLocator = mediaLocator;
}
/** /**
* Initialize the RTP Channel preparing to transmit and receive. * Initialize the RTP Channel preparing to transmit and receive.
*/ */
@ -101,6 +123,7 @@ public abstract class JingleMediaSession {
/** /**
* Set transmit activity. If the active is true, the instance should trasmit. * Set transmit activity. If the active is true, the instance should trasmit.
* If it is set to false, the instance should pause transmit. * If it is set to false, the instance should pause transmit.
*
* @param active * @param active
*/ */
public abstract void setTrasmit(boolean active); public abstract void setTrasmit(boolean active);

View file

@ -41,19 +41,6 @@ import java.net.ServerSocket;
public class AudioMediaSession extends JingleMediaSession { public class AudioMediaSession extends JingleMediaSession {
private AudioChannel audioChannel; private AudioChannel audioChannel;
private String locator = "dsound://";
/**
* 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) {
this(payloadType, remote, local, "dsound://");
}
/** /**
* Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates * Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates
@ -65,9 +52,7 @@ public class AudioMediaSession extends JingleMediaSession {
*/ */
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote, public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local, String locator) { final TransportCandidate local, String locator) {
super(payloadType, remote, local); super(payloadType, remote, local, locator==null?"dsound://":locator);
if (locator != null && !locator.equals(""))
this.locator = locator;
initialize(); initialize();
} }
@ -97,7 +82,7 @@ public class AudioMediaSession extends JingleMediaSession {
remotePort = this.getRemote().getPort(); remotePort = this.getRemote().getPort();
} }
audioChannel = new AudioChannel(new MediaLocator(locator), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType())); audioChannel = new AudioChannel(new MediaLocator(this.getMediaLocator()), localIp, ip, localPort, remotePort, AudioFormatUtils.getAudioFormat(this.getPayloadType()));
} }
/** /**

View file

@ -41,6 +41,7 @@ import java.util.ArrayList;
public class JmfMediaManager extends JingleMediaManager { public class JmfMediaManager extends JingleMediaManager {
private List<PayloadType> payloads = new ArrayList<PayloadType>(); private List<PayloadType> payloads = new ArrayList<PayloadType>();
private String mediaLocator = null;
/** /**
* Creates a Media Manager instance * Creates a Media Manager instance
@ -49,6 +50,16 @@ public class JmfMediaManager extends JingleMediaManager {
setupPayloads(); setupPayloads();
} }
/**
* Creates a Media Manager instance
*
* @param mediaLocator Media Locator
*/
public JmfMediaManager(String mediaLocator) {
this.mediaLocator = mediaLocator;
setupPayloads();
}
/** /**
* Returns a new jingleMediaSession * Returns a new jingleMediaSession
* *
@ -58,7 +69,7 @@ public class JmfMediaManager extends JingleMediaManager {
* @return JingleMediaSession * @return JingleMediaSession
*/ */
public JingleMediaSession createMediaSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) { public JingleMediaSession createMediaSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) {
return new AudioMediaSession(payloadType, remote, local); return new AudioMediaSession(payloadType, remote, local,mediaLocator);
} }
/** /**
@ -79,6 +90,24 @@ public class JmfMediaManager extends JingleMediaManager {
return payloads; return payloads;
} }
/**
* Return the media locator or null if not defined
*
* @return media locator
*/
public String getMediaLocator() {
return mediaLocator;
}
/**
* Set the media locator
*
* @param mediaLocator media locator or null to use default
*/
public void setMediaLocator(String mediaLocator) {
this.mediaLocator = mediaLocator;
}
/** /**
* Runs JMFInit the first time the application is started so that capture * Runs JMFInit the first time the application is started so that capture
* devices are properly detected and initialized by JMF. * devices are properly detected and initialized by JMF.

View file

@ -93,15 +93,16 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio
/** /**
* Creates a org.jivesoftware.jingleaudio.jmf.AudioMediaSession with defined payload type, remote and local candidates * Creates a org.jivesoftware.jingleaudio.jspeex.AudioMediaSession with defined payload type, remote and local candidates
* *
* @param payloadType Payload of the jmf * @param payloadType Payload of the jmf
* @param remote The remote information. The candidate that the jmf will be sent to. * @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 * @param local the local information. The candidate that will receive the jmf
* @param locator media locator
*/ */
public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote, public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote,
final TransportCandidate local) { final TransportCandidate local, String locator) {
super(payloadType, remote, local); super(payloadType, remote, local, locator==null?"dsound://":locator);
initialize(); initialize();
} }

View file

@ -46,8 +46,16 @@ public class SpeexMediaManager extends JingleMediaManager {
setupJMF(); setupJMF();
} }
/**
* Returns a new jingleMediaSession
*
* @param payloadType payloadType
* @param remote remote Candidate
* @param local local Candidate
* @return JingleMediaSession
*/
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) { public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) {
return new AudioMediaSession(payloadType, remote, local); return new AudioMediaSession(payloadType, remote, local, null);
} }
/** /**