From 56dc8bd953a141ab3e16981495d33151ae44af3f Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Wed, 21 Mar 2007 13:49:44 +0000 Subject: [PATCH] Media Refactoring - Added Custom Media Locator Support git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7623 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jingle/media/JingleMediaManager.java | 3 +- .../jingle/media/JingleMediaSession.java | 35 +++++++++++++++--- .../mediaimpl/jmf/AudioMediaSession.java | 19 +--------- .../jingle/mediaimpl/jmf/JmfMediaManager.java | 37 +++++++++++++++++-- .../mediaimpl/jspeex/AudioMediaSession.java | 11 +++--- .../mediaimpl/jspeex/SpeexMediaManager.java | 12 +++++- 6 files changed, 82 insertions(+), 35 deletions(-) diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaManager.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaManager.java index ac80f39a6..738d0ca4e 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaManager.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaManager.java @@ -61,4 +61,5 @@ public abstract class JingleMediaManager { * @return */ public abstract JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local); -} \ No newline at end of file + + } \ No newline at end of file diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaSession.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaSession.java index 0bc631c0d..a905f3403 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaSession.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/media/JingleMediaSession.java @@ -23,11 +23,11 @@ import org.jivesoftware.smackx.jingle.nat.TransportCandidate; /** * Public Abstract Class provides a clear interface between Media Session and Jingle API. - * + *

* 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. * But provides an interface to let the user implements it using another API. For instance: JMF. - * + *

* The Class that implements this one, must have the support to transmit and receive the jmf. * This interface let the user choose his own jmf API. * @@ -41,19 +41,23 @@ public abstract class JingleMediaSession { private TransportCandidate local; // Remote Transport details private TransportCandidate remote; + // Media Locator + private String mediaLocator; /** * Creates a new JingleMediaSession Instance to handle Media methods. * - * @param payloadType Payload Type of the transmittion - * @param remote Remote accepted Transport Candidate - * @param local Local accepted Transport Candidate + * @param payloadType Payload Type of the transmittion + * @param remote Remote accepted Transport Candidate + * @param local Local accepted Transport Candidate + * @param mediaLocator Media Locator of the capture device */ public JingleMediaSession(PayloadType payloadType, TransportCandidate remote, - TransportCandidate local) { + TransportCandidate local, String mediaLocator) { this.local = local; this.remote = remote; this.payloadType = payloadType; + this.mediaLocator = mediaLocator; } /** @@ -83,6 +87,24 @@ public abstract class JingleMediaSession { 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. */ @@ -101,6 +123,7 @@ public abstract class JingleMediaSession { /** * Set transmit activity. If the active is true, the instance should trasmit. * If it is set to false, the instance should pause transmit. + * * @param active */ public abstract void setTrasmit(boolean active); diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioMediaSession.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioMediaSession.java index 1aa05db7b..ce765e53c 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioMediaSession.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioMediaSession.java @@ -41,19 +41,6 @@ import java.net.ServerSocket; public class AudioMediaSession extends JingleMediaSession { 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 @@ -65,9 +52,7 @@ public class AudioMediaSession extends JingleMediaSession { */ 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; + super(payloadType, remote, local, locator==null?"dsound://":locator); initialize(); } @@ -97,7 +82,7 @@ public class AudioMediaSession extends JingleMediaSession { 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())); } /** diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/JmfMediaManager.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/JmfMediaManager.java index 5ac6c91fe..d730dc542 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/JmfMediaManager.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/JmfMediaManager.java @@ -41,6 +41,7 @@ import java.util.ArrayList; public class JmfMediaManager extends JingleMediaManager { private List payloads = new ArrayList(); + private String mediaLocator = null; /** * Creates a Media Manager instance @@ -49,16 +50,26 @@ public class JmfMediaManager extends JingleMediaManager { setupPayloads(); } + /** + * Creates a Media Manager instance + * + * @param mediaLocator Media Locator + */ + public JmfMediaManager(String mediaLocator) { + this.mediaLocator = mediaLocator; + setupPayloads(); + } + /** * Returns a new jingleMediaSession * * @param payloadType payloadType - * @param remote remote Candidate - * @param local local Candidate - * @return JingleMediaSession + * @param remote remote Candidate + * @param local local Candidate + * @return JingleMediaSession */ 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 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 * devices are properly detected and initialized by JMF. diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/AudioMediaSession.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/AudioMediaSession.java index 0fa5aba2c..701e3e4fb 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/AudioMediaSession.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/AudioMediaSession.java @@ -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 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 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 locator media locator */ public AudioMediaSession(final PayloadType payloadType, final TransportCandidate remote, - final TransportCandidate local) { - super(payloadType, remote, local); + final TransportCandidate local, String locator) { + super(payloadType, remote, local, locator==null?"dsound://":locator); initialize(); } diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/SpeexMediaManager.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/SpeexMediaManager.java index bf6aae6d0..1c5b7dfe2 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/SpeexMediaManager.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jspeex/SpeexMediaManager.java @@ -46,8 +46,16 @@ public class SpeexMediaManager extends JingleMediaManager { 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) { - return new AudioMediaSession(payloadType, remote, local); + return new AudioMediaSession(payloadType, remote, local, null); } /** @@ -65,7 +73,7 @@ public class SpeexMediaManager extends JingleMediaManager { public List getPayloads() { return payloads; } - + /** * Runs JMFInit the first time the application is started so that capture * devices are properly detected and initialized by JMF.