mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-01 01:35:59 +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:
parent
8ab9f55da4
commit
56dc8bd953
6 changed files with 82 additions and 35 deletions
|
@ -61,4 +61,5 @@ public abstract class JingleMediaManager {
|
|||
* @return
|
||||
*/
|
||||
public abstract JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,11 +23,11 @@ import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* <p/>
|
||||
* <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>
|
||||
*
|
||||
|
@ -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);
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||
public class JmfMediaManager extends JingleMediaManager {
|
||||
|
||||
private List<PayloadType> payloads = new ArrayList<PayloadType>();
|
||||
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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PayloadType> getPayloads() {
|
||||
return payloads;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs JMFInit the first time the application is started so that capture
|
||||
* devices are properly detected and initialized by JMF.
|
||||
|
|
Loading…
Reference in a new issue