aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Ivov <emcho@jitsi.org>2009-11-05 20:34:21 +0000
committerEmil Ivov <emcho@jitsi.org>2009-11-05 20:34:21 +0000
commit730c90c7981f4a6db2f0c67f15dbf97079f0d48c (patch)
tree555d6649f5df0e59603d9d24a03c10d7e7eee991
parent39d3a191e22b7e98fa2845364cc709814b06d999 (diff)
downloadjitsi-730c90c7981f4a6db2f0c67f15dbf97079f0d48c.zip
jitsi-730c90c7981f4a6db2f0c67f15dbf97079f0d48c.tar.gz
jitsi-730c90c7981f4a6db2f0c67f15dbf97079f0d48c.tar.bz2
Migrates SIP over to neomedia. (Work in progress). Debugging SDP generation
-rw-r--r--src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java2
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandler.java91
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java33
-rw-r--r--src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java8
-rw-r--r--src/net/java/sip/communicator/service/neomedia/MediaDirection.java30
5 files changed, 118 insertions, 46 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
index 83cc33a..d0ab0ad 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java
@@ -781,7 +781,7 @@ public class NetworkAddressManagerServiceImpl
+ ") and maxPort (" + maxPort + ")");
}
- ConfigurationService config = NeomediaActivator
+ ConfigurationService config = NetaddrActivator
.getConfigurationService();
int bindRetries = config.getInt(BIND_RETRIES_PROPERTY_NAME,
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandler.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandler.java
index 2a90f73..b065084 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandler.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandler.java
@@ -56,12 +56,14 @@ public class CallPeerMediaHandler
/**
* Determines whether or not streaming local video is currently enabled.
*/
- private boolean localVideoTransmissionEnabled = false;
+ private MediaDirection videoDirectionUserPreference
+ = MediaDirection.RECVONLY;
/**
* Determines whether or not streaming local audio is currently enabled.
*/
- private boolean localAudioTransmissionEnabled = true;
+ private MediaDirection audioDirectionUserPreference
+ = MediaDirection.SENDRECV;
/**
* The minimum port number that we'd like our RTP sockets to bind upon.
@@ -111,25 +113,18 @@ public class CallPeerMediaHandler
}
/**
- * The method creates . The
- * resources (address and port) allocated for the <tt>callPeer</tt>
- * should be kept by the media service implementation until the originating
- * <tt>callPeer</tt> enters the DISCONNECTED state. Subsequent sdp
- * offers/answers requested for the <tt>Call</tt> that the original
- * <tt>callPeer</tt> belonged to MUST receive the same IP/port couple
- * as the first one in order to allow for conferencing. The associated port
- * will be released once the call has ended.
+ * Specifies whether this media handler should be allowed to transmit
+ * local video.
*
- * @return a new SDP description String advertising all params of
- * <tt>callSession</tt>.
+ * @param enabled <tt>true</tt> if the media handler should transmit local
+ * video and <tt>false</tt> otherwise.
*/
- public synchronized String createSdpOffer()
+ public void setLocalVideoTransmissionEnabled(boolean enabled)
{
- SessionDescription sess = SdpUtils.createSessionDescription(
-
- peer.getProtocolProvider().getAccountID().getUserID());
-
- return sess.toString();
+ if (enabled)
+ videoDirectionUserPreference = MediaDirection.SENDRECV;
+ else
+ videoDirectionUserPreference = MediaDirection.RECVONLY;
}
/**
@@ -141,7 +136,22 @@ public class CallPeerMediaHandler
*/
public boolean isLocalVideoTransmissionEnabled()
{
- return localVideoTransmissionEnabled;
+ return videoDirectionUserPreference.allowsSending();
+ }
+
+ /**
+ * Specifies whether this media handler should be allowed to transmit
+ * local audio.
+ *
+ * @param enabled <tt>true</tt> if the media handler should transmit local
+ * audio and <tt>false</tt> otherwise.
+ */
+ public void setLocalAudioTransmissionEnabled(boolean enabled)
+ {
+ if(enabled)
+ audioDirectionUserPreference = MediaDirection.SENDRECV;
+ else
+ audioDirectionUserPreference = MediaDirection.RECVONLY;
}
/**
@@ -153,7 +163,7 @@ public class CallPeerMediaHandler
*/
public boolean isLocalAudioTransmissionEnabled()
{
- return localAudioTransmissionEnabled;
+ return audioDirectionUserPreference.allowsSending();
}
/**
@@ -175,14 +185,40 @@ public class CallPeerMediaHandler
MediaService mediaService = SipActivator.getMediaService();
//media connectors.
- StreamConnector audioConn = createStreamConnector();
- StreamConnector videoConn = createStreamConnector();
+ audioStreamConnector = createStreamConnector();
+ videoStreamConnector = createStreamConnector();
+
+ //Audio Media Description
+ Vector<MediaDescription> mediaDescs = new Vector<MediaDescription>();
- //devices
MediaDevice aDev = mediaService.getDefaultDevice(MediaType.AUDIO);
+ MediaDirection audioDirection
+ = aDev.getDirection().and(audioDirectionUserPreference);
+
+ if(audioDirection != MediaDirection.INACTIVE);
+ {
+ mediaDescs.add(createMediaDescription(
+ aDev, this.audioStreamConnector, audioDirection));
+ }
+
+
MediaDevice vDev = mediaService.getDefaultDevice(MediaType.VIDEO);
+ MediaDirection videoDirection
+ = vDev.getDirection().and(videoDirectionUserPreference);
+
+ if(videoDirection != MediaDirection.INACTIVE);
+ {
+ mediaDescs.add(createMediaDescription(
+ vDev, this.videoStreamConnector, videoDirection));
+ }
+
+ String userName = peer.getProtocolProvider().getAccountID().getUserID();
+ SessionDescription sDes = SdpUtils.createSessionDescription(
+ videoStreamConnector.getDataSocket().getLocalAddress(),
+ userName, mediaDescs);
+ System.out.println(sDes.toString());
}
@@ -200,18 +236,15 @@ public class CallPeerMediaHandler
* @throws OperationFailedException
*/
private MediaDescription createMediaDescription(MediaDevice dev,
- StreamConnector connector
- )
+ StreamConnector connector,
+ MediaDirection direction)
throws OperationFailedException
{
List<MediaFormat> formats = dev.getSupportedFormats();
-
-
-
return SdpUtils.createMediaDescription(
- formats, connector, dev.getDirection(), dynamicPayloadTypes);
+ formats, connector, direction, dynamicPayloadTypes);
}
private void initFormats(Iterator<MediaFormat> fmtsIter)
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
index e7dd050..5ead4cf 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
@@ -54,7 +54,7 @@ public class SdpUtils
public static SessionDescription createSessionDescription(
InetAddress localAddress)
{
- return createSessionDescription(localAddress, null);
+ return createSessionDescription(localAddress, null, null);
}
/**
@@ -66,12 +66,17 @@ public class SdpUtils
* address that we'd like to use when talking to the remote party.
* @param userName the user name to use in the origin parameter or
* <tt>null</tt> in case we'd like to use a default.
+ * @param mediaDescriptions a <tt>Vector</tt> containing the list of
+ * <tt>MediaDescription</tt>s that we'd like to advertise (leave
+ * <tt>null</tt> if you'd like to add these later).
*
* @return an empty instance of a <tt>SessionDescription</tt> with
* preinitialized <tt>s</tt>, <tt>v</tt>, and <tt>t</tt> parameters.
*/
public static SessionDescription createSessionDescription(
- InetAddress localAddress, String userName)
+ InetAddress localAddress,
+ String userName,
+ Vector<MediaDescription> mediaDescriptions)
{
SessionDescription sessDescr = null;
@@ -118,6 +123,9 @@ public class SdpUtils
sessDescr.setConnection(c);
+ if ( mediaDescriptions != null)
+ sessDescr.setMediaDescriptions(mediaDescriptions);
+
return sessDescr;
}
catch (SdpException exc)
@@ -202,7 +210,7 @@ public class SdpUtils
try
{
fmtp = findPayloadTypeSpecificAttribute(
- mediaDesc.getAttributes(false), SdpConstants.FMTP, pt);
+ mediaDesc.getAttributes(false), "fmtp", pt);
}
catch (SdpException exc)
{
@@ -319,9 +327,8 @@ public class SdpUtils
//now create the format.
MediaFormat format = SipActivator.getMediaService().getFormatFactory()
- //.createMediaFormat(payloadType, encoding, clockRate,
- // numChannels, fmtParamsMap);
- .createMediaFormat(encoding, clockRate, fmtParamsMap);
+ .createMediaFormat(payloadType, encoding, clockRate,
+ numChannels, fmtParamsMap);
return format;
}
@@ -775,7 +782,8 @@ public class SdpUtils
MediaType mediaType = null;
// a=sendonly|sendrecv|recvonly|inactive
- mediaAttributes.add(createDirectionAttribute(direction));
+ if( direction != MediaDirection.SENDRECV)
+ mediaAttributes.add(createDirectionAttribute(direction));
for (int i = 0; i < payloadTypesArray.length; i++)
{
@@ -783,7 +791,7 @@ public class SdpUtils
MediaType fmtMediaType = format.getMediaType();
// determine whether we are dealing with audio or video.
- if (mediaType != null)
+ if (mediaType == null)
{
mediaType = fmtMediaType;
}
@@ -819,15 +827,18 @@ public class SdpUtils
Attribute rtpmap = sdpFactory.createAttribute(SdpConstants.RTPMAP,
payloadType + " " + format.getEncoding() + "/"
- + format.getClockRate() + numChannelsStr);
+ + format.getClockRateString() + numChannelsStr);
mediaAttributes.add(rtpmap);
// a=fmtp:
- Attribute fmtp = sdpFactory.createAttribute(SdpConstants.FMTP,
+ if( format.getFormatParameters().size() > 0)
+ {
+ Attribute fmtp = sdpFactory.createAttribute("fmtp",
payloadType + " " + encodeFmtp(format));
- mediaAttributes.add(fmtp);
+ mediaAttributes.add(fmtp);
+ }
payloadTypesArray[i] = payloadType;
}
diff --git a/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java b/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java
index 69526e7..19d5a72 100644
--- a/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java
+++ b/src/net/java/sip/communicator/service/neomedia/DefaultStreamConnector.java
@@ -172,14 +172,14 @@ public class DefaultStreamConnector
* Initializes a new <tt>DefaultStreamConnector</tt> instance which is to
* represent a specific pair of control and data <tt>DatagramSocket</tt>s.
*
- * @param controlSocket the <tt>DatagramSocket</tt> to be used for control
- * data (e.g. RTCP) traffic
* @param dataSocket the <tt>DatagramSocket</tt> to be used for data (e.g.
* RTP) traffic
+ * @param controlSocket the <tt>DatagramSocket</tt> to be used for control
+ * data (e.g. RTCP) traffic
*/
public DefaultStreamConnector(
- DatagramSocket controlSocket,
- DatagramSocket dataSocket)
+ DatagramSocket dataSocket,
+ DatagramSocket controlSocket)
{
this.controlSocket = controlSocket;
this.dataSocket = dataSocket;
diff --git a/src/net/java/sip/communicator/service/neomedia/MediaDirection.java b/src/net/java/sip/communicator/service/neomedia/MediaDirection.java
index 79736fd..575b7ee 100644
--- a/src/net/java/sip/communicator/service/neomedia/MediaDirection.java
+++ b/src/net/java/sip/communicator/service/neomedia/MediaDirection.java
@@ -122,7 +122,7 @@ public enum MediaDirection
* @return the new <tt>MediaDirection</tt> obtained after applying the
* <tt>direction</tt> constraint to this <tt>MediaDirection</tt>.
*/
- private MediaDirection and(MediaDirection direction)
+ public MediaDirection and(MediaDirection direction)
{
if (this == SENDRECV)
{
@@ -238,4 +238,32 @@ public enum MediaDirection
{
return this.and(remotePartyDir.getReverseDirection());
}
+
+ /**
+ * Determines whether the directions specified by this
+ * <tt>MediaDirection</tt> instance allow for outgoing (i.e. sending)
+ * streams or in other words whether this is a <tt>SENDONLY</tt> or a
+ * <tt>SENDRECV</tt> instance
+ *
+ * @return <tt>true</tt> if this <tt>MediaDirection</tt> instance includes
+ * the possibility of sending and <tt>false</tt> otherwise.
+ */
+ public boolean allowsSending()
+ {
+ return this == SENDONLY || this == SENDRECV;
+ }
+
+ /**
+ * Determines whether the directions specified by this
+ * <tt>MediaDirection</tt> instance allow for incoming (i.e. receiving)
+ * streams or in other words whether this is a <tt>RECVONLY</tt> or a
+ * <tt>SENDRECV</tt> instance
+ *
+ * @return <tt>true</tt> if this <tt>MediaDirection</tt> instance includes
+ * the possibility of receiving and <tt>false</tt> otherwise.
+ */
+ public boolean allowsReceiving()
+ {
+ return this == RECVONLY || this == SENDRECV;
+ }
}