Allows finer control over the generation of synchronization source (SSRC) identifiers.

cusax-fix 4921
Lyubomir Marinov 12 years ago
parent 22e5ff0a90
commit 527cee16b9

@ -21,7 +21,7 @@
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/easymock-3.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar" sourcepath="/fmj"/>
<classpathentry kind="lib" path="lib/installer-exclude/forms-1.2.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-meta-1.0.jar"/>

Binary file not shown.

@ -1498,8 +1498,8 @@ protected void initialize(String screenname,
// in case of modified account, we clear list of supported features
// and every state change listeners, otherwise we can have two
// OperationSet for same feature and it can causes problem (i.e.
// two OperationSetBasicTelephony can launch two ICE negociations
// (with different ufrag/passwd) and peer will failed call. And
// two OperationSetBasicTelephony can launch two ICE negotiations
// (with different ufrag/pwd) and peer will failed call. And
// by the way user will see two dialog for answering/refusing the
// call
supportedFeatures.clear();
@ -1547,7 +1547,7 @@ protected void initialize(String screenname,
InfoRetreiver infoRetreiver = new InfoRetreiver(this, screenname);
//initialize the presence operationset
//initialize the presence OperationSet
OperationSetPersistentPresenceJabberImpl persistentPresence =
new OperationSetPersistentPresenceJabberImpl(this, infoRetreiver);
@ -1695,18 +1695,6 @@ protected void initialize(String screenname,
ColibriConferenceIQ.ELEMENT_NAME,
ColibriConferenceIQ.NAMESPACE,
new ColibriIQProvider());
providerManager.addExtensionProvider(
PayloadTypePacketExtension.ELEMENT_NAME,
ColibriConferenceIQ.NAMESPACE,
new DefaultPacketExtensionProvider<
PayloadTypePacketExtension>(
PayloadTypePacketExtension.class));
providerManager.addExtensionProvider(
ParameterPacketExtension.ELEMENT_NAME,
ColibriConferenceIQ.NAMESPACE,
new DefaultPacketExtensionProvider<
ParameterPacketExtension>(
ParameterPacketExtension.class));
providerManager.addExtensionProvider(
ConferenceDescriptionPacketExtension.ELEMENT_NAME,

@ -297,6 +297,9 @@ public static class Channel
@Deprecated
public static final String RTCP_PORT_ATTR_NAME = "rtcpport";
public static final String RTP_LEVEL_RELAY_TYPE_ATTR_NAME
= "rtp-level-relay-type";
/**
* The XML name of the <tt>rtpport</tt> attribute of a <tt>channel</tt>
* of a <tt>content</tt> of a <tt>conference</tt> IQ which represents
@ -364,6 +367,14 @@ public static class Channel
@Deprecated
private int rtcpPort;
/**
* The type of RTP-level relay (in the terms specified by RFC 3550
* &quot;RTP: A Transport Protocol for Real-Time Applications&quot; in
* section 2.3 &quot;Mixers and Translators&quot;) used for this
* <tt>Channel</tt>.
*/
private RTPLevelRelayType rtpLevelRelayType;
/**
* The RTP port of the <tt>channel</tt> represented by this instance.
*
@ -373,6 +384,12 @@ public static class Channel
@Deprecated
private int rtpPort;
/**
* The <tt>SourcePacketExtension</tt>s of this channel.
*/
private final List<SourcePacketExtension> sources
= new LinkedList<SourcePacketExtension>();
/**
* The list of (RTP) SSRCs which have been seen/received on this
* <tt>Channel</tt> by now. These may exclude SSRCs which are no longer
@ -415,6 +432,23 @@ public boolean addPayloadType(PayloadTypePacketExtension payloadType)
: payloadTypes.add(payloadType);
}
/**
* Adds a <tt>SourcePacketExtension</tt> to the list of sources of this
* channel.
*
* @param source the <tt>SourcePacketExtension</tt> to add to the list
* of sources of this channel
* @return <tt>true</tt> if the list of sources of this channel changed
* as a result of the execution of the method; otherwise, <tt>false</tt>
*/
public synchronized boolean addSource(SourcePacketExtension source)
{
if (source == null)
throw new NullPointerException("source");
return sources.contains(source) ? false : sources.add(source);
}
/**
* Adds a specific (RTP) SSRC to the list of SSRCs seen/received on this
* <tt>Channel</tt>. Invoked by the Jitsi Videobridge server, not its
@ -522,6 +556,19 @@ public int getRTCPPort()
return rtcpPort;
}
/**
* Gets the type of RTP-level relay (in the terms specified by RFC 3550
* &quot;RTP: A Transport Protocol for Real-Time Applications&quot; in
* section 2.3 &quot;Mixers and Translators&quot;) used for this
* <tt>Channel</tt>.
*
* @return the type of RTP-level relay used for this <tt>Channel</tt>
*/
public RTPLevelRelayType getRTPLevelRelayType()
{
return rtpLevelRelayType;
}
/**
* Gets the port which has been allocated to this <tt>channel</tt> for
* the purposes of transmitting RTP packets.
@ -538,6 +585,18 @@ public int getRTPPort()
return rtpPort;
}
/**
* Gets the list of <tt>SourcePacketExtensions</tt>s which represent the
* sources of this channel.
*
* @return a <tt>List</tt> of <tt>SourcePacketExtension</tt>s which
* represent the sources of this channel
*/
public synchronized List<SourcePacketExtension> getSources()
{
return new ArrayList<SourcePacketExtension>(sources);
}
/**
* Gets (a copy of) the list of (RTP) SSRCs seen/received on this
* <tt>Channel</tt>.
@ -586,6 +645,20 @@ public boolean removePayloadType(PayloadTypePacketExtension payloadType)
return payloadTypes.remove(payloadType);
}
/**
* Removes a <tt>SourcePacketExtension</tt> from the list of sources of
* this channel.
*
* @param source the <tt>SourcePacketExtension</tt> to remove from the
* list of sources of this channel
* @return <tt>true</tt> if the list of sources of this channel changed
* as a result of the execution of the method; otherwise, <tt>false</tt>
*/
public synchronized boolean removeSource(SourcePacketExtension source)
{
return sources.remove(source);
}
/**
* Removes a specific (RTP) SSRC from the list of SSRCs seen/received on
* this <tt>Channel</tt>. Invoked by the Jitsi Videobridge server, not
@ -722,6 +795,32 @@ public void setRTCPPort(int rtcpPort)
this.rtcpPort = rtcpPort;
}
/**
* Sets the type of RTP-level relay (in the terms specified by RFC 3550
* &quot;RTP: A Transport Protocol for Real-Time Applications&quot; in
* section 2.3 &quot;Mixers and Translators&quot;) used for this
* <tt>Channel</tt>.
*
* @param s the type of RTP-level relay used for this <tt>Channel</tt>
*/
public void setRTPLevelRelayType(RTPLevelRelayType rtpLevelRelayType)
{
this.rtpLevelRelayType = rtpLevelRelayType;
}
/**
* Sets the type of RTP-level relay (in the terms specified by RFC 3550
* &quot;RTP: A Transport Protocol for Real-Time Applications&quot; in
* section 2.3 &quot;Mixers and Translators&quot;) used for this
* <tt>Channel</tt>.
*
* @param s the type of RTP-level relay used for this <tt>Channel</tt>
*/
public void setRTPLevelRelayType(String s)
{
setRTPLevelRelayType(RTPLevelRelayType.parseRTPLevelRelayType(s));
}
/**
* Sets the port which has been allocated to this <tt>channel</tt> for
* the purposes of transmitting RTP packets.
@ -827,6 +926,15 @@ public void toXML(StringBuilder xml)
.append(rtcpPort).append('\'');
}
// rtpLevelRelayType
RTPLevelRelayType rtpLevelRelayType = getRTPLevelRelayType();
if (rtpLevelRelayType != null)
{
xml.append(' ').append(RTP_LEVEL_RELAY_TYPE_ATTR_NAME)
.append("='").append(rtpLevelRelayType).append('\'');
}
// rtpPort
int rtpPort = getRTPPort();
@ -837,13 +945,15 @@ public void toXML(StringBuilder xml)
}
List<PayloadTypePacketExtension> payloadTypes = getPayloadTypes();
boolean hasPayloadTypes = (payloadTypes.size() != 0);
boolean hasPayloadTypes = !payloadTypes.isEmpty();
List<SourcePacketExtension> sources = getSources();
boolean hasSources = !sources.isEmpty();
long[] ssrcs = getSSRCs();
boolean hasSSRCs = (ssrcs.length != 0);
IceUdpTransportPacketExtension transport = getTransport();
boolean hasTransport = (transport != null);
if (hasPayloadTypes || hasSSRCs || hasTransport)
if (hasPayloadTypes || hasSources || hasSSRCs || hasTransport)
{
xml.append('>');
if (hasPayloadTypes)
@ -851,6 +961,11 @@ public void toXML(StringBuilder xml)
for (PayloadTypePacketExtension payloadType : payloadTypes)
xml.append(payloadType.toXML());
}
if (hasSources)
{
for (SourcePacketExtension source : sources)
xml.append(source.toXML());
}
if (hasSSRCs)
{
for (long ssrc : ssrcs)

@ -6,6 +6,7 @@
*/
package net.java.sip.communicator.impl.protocol.jabber.extensions.colibri;
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*;
import org.jitsi.service.neomedia.*;
@ -23,6 +24,36 @@
public class ColibriIQProvider
implements IQProvider
{
/** Initializes a new <tt>ColibriIQProvider</tt> instance. */
public ColibriIQProvider()
{
ProviderManager providerManager = ProviderManager.getInstance();
providerManager.addExtensionProvider(
PayloadTypePacketExtension.ELEMENT_NAME,
ColibriConferenceIQ.NAMESPACE,
new DefaultPacketExtensionProvider<PayloadTypePacketExtension>(
PayloadTypePacketExtension.class));
providerManager.addExtensionProvider(
SourcePacketExtension.ELEMENT_NAME,
SourcePacketExtension.NAMESPACE,
new DefaultPacketExtensionProvider<SourcePacketExtension>(
SourcePacketExtension.class));
PacketExtensionProvider parameterProvider
= new DefaultPacketExtensionProvider<ParameterPacketExtension>(
ParameterPacketExtension.class);
providerManager.addExtensionProvider(
ParameterPacketExtension.ELEMENT_NAME,
ColibriConferenceIQ.NAMESPACE,
parameterProvider);
providerManager.addExtensionProvider(
ParameterPacketExtension.ELEMENT_NAME,
SourcePacketExtension.NAMESPACE,
parameterProvider);
}
private void addChildExtension(
ColibriConferenceIQ.Channel channel,
PacketExtension childExtension)
@ -218,6 +249,19 @@ else if (ColibriConferenceIQ.Content.ELEMENT_NAME.equals(
if ((rtcpPort != null) && (rtcpPort.length() != 0))
channel.setRTCPPort(Integer.parseInt(rtcpPort));
// rtpLevelRelayType
String rtpLevelRelayType
= parser.getAttributeValue(
"",
ColibriConferenceIQ.Channel
.RTP_LEVEL_RELAY_TYPE_ATTR_NAME);
if ((rtpLevelRelayType != null)
&& (rtpLevelRelayType.length() != 0))
{
channel.setRTPLevelRelayType(rtpLevelRelayType);
}
// rtpPort
String rtpPort
= parser.getAttributeValue(
@ -252,7 +296,16 @@ else if (channel != null)
String peName = null;
String peNamespace = null;
if (PayloadTypePacketExtension.ELEMENT_NAME.equals(
if (IceUdpTransportPacketExtension.ELEMENT_NAME
.equals(name)
&& IceUdpTransportPacketExtension.NAMESPACE
.equals(parser.getNamespace()))
{
peName = name;
peNamespace
= IceUdpTransportPacketExtension.NAMESPACE;
}
else if (PayloadTypePacketExtension.ELEMENT_NAME.equals(
name))
{
/*
@ -263,15 +316,6 @@ else if (channel != null)
peName = name;
peNamespace = namespace;
}
else if (IceUdpTransportPacketExtension.ELEMENT_NAME
.equals(name)
&& IceUdpTransportPacketExtension.NAMESPACE
.equals(parser.getNamespace()))
{
peName = name;
peNamespace
= IceUdpTransportPacketExtension.NAMESPACE;
}
else if (RawUdpTransportPacketExtension.ELEMENT_NAME
.equals(name)
&& RawUdpTransportPacketExtension.NAMESPACE
@ -281,6 +325,13 @@ else if (RawUdpTransportPacketExtension.ELEMENT_NAME
peNamespace
= RawUdpTransportPacketExtension.NAMESPACE;
}
else if (SourcePacketExtension.ELEMENT_NAME.equals(name)
&& SourcePacketExtension.NAMESPACE.equals(
parser.getNamespace()))
{
peName = name;
peNamespace = SourcePacketExtension.NAMESPACE;
}
if (peName == null)
{
@ -315,6 +366,18 @@ else if (RawUdpTransportPacketExtension.ELEMENT_NAME
return iq;
}
/**
* Parses using a specific <tt>XmlPullParser</tt> and ignores XML content
* presuming that the specified <tt>parser</tt> is currently at the start
* tag of an element with a specific name and throwing away until the end
* tag with the specified name is encountered.
*
* @param parser the <tt>XmlPullParser</tt> which parses the XML content
* @param name the name of the element at the start tag of which the
* specified <tt>parser</tt> is presumed to currently be and until the end
* tag of which XML content is to be thrown away
* @throws Exception if an errors occurs while parsing the XML content
*/
private void throwAway(XmlPullParser parser, String name)
throws Exception
{

@ -0,0 +1,59 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.jabber.extensions.colibri;
/**
* Defines the RTP-level relay types as specified by RFC 3550 "RTP: A Transport
* Protocol for Real-Time Applications" in section 2.3 "Mixers and Translators".
*
* @author Lyubomir Marinov
*/
public enum RTPLevelRelayType
{
/**
* The type of RTP-level relay which performs content mixing on the received
* media. In order to mix the received content, the relay will usually
* decode the received RTP and RTCP packets into raw media and will
* subsequently generate new RTP and RTCP packets to send the new media
* which represents the mix of the received content.
*/
MIXER,
/**
* The type of RTP-level relay which does not perform content mixing on the
* received media and rather forwards the received RTP and RTCP packets. The
* relay will usually not decode the received RTP and RTCP into raw media.
*/
TRANSLATOR;
public static RTPLevelRelayType parseRTPLevelRelayType(String s)
{
for (RTPLevelRelayType value : RTPLevelRelayType.values())
{
if (s.equals(value.toString()))
return value;
}
throw new IllegalArgumentException(s);
}
/**
* {@inheritDoc}
*/
@Override
public String toString()
{
switch (this)
{
case MIXER:
return "mixer";
case TRANSLATOR:
return "translator";
default:
return super.toString();
}
}
}

@ -0,0 +1,95 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.jabber.extensions.colibri;
import java.util.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*;
/**
* Implements <tt>AbstractPacketExtension</tt> for the <tt>source</tt> element
* defined by <a href="http://hancke.name/jabber/jingle-sources">
* Source-Specific Media Attributes in Jingle</a>.
*
* @author Lyubomir Marinov
*/
public class SourcePacketExtension
extends AbstractPacketExtension
{
/**
* The XML name of the <tt>setup</tt> element defined by Source-Specific
* Media Attributes in Jingle.
*/
public static final String ELEMENT_NAME = "source";
/**
* The XML namespace of the <tt>setup</tt> element defined by
* Source-Specific Media Attributes in Jingle.
*/
public static final String NAMESPACE = "urn:xmpp:jingle:apps:rtp:ssma:0";
/**
* The XML name of the <tt>setup</tt> element's attribute which corresponds
* to the <tt>ssrc</tt> media attribute in SDP.
*/
private static final String SSRC_ATTR_NAME = "ssrc";
/** Initializes a new <tt>SourcePacketExtension</tt> instance. */
public SourcePacketExtension()
{
super(NAMESPACE, ELEMENT_NAME);
}
/**
* Adds a specific parameter (as defined by Source-Specific Media Attributes
* in Jingle) to this source.
*
* @param parameter the <tt>ParameterPacketExtension</tt> to add to this
* source
*/
public void addParameter(ParameterPacketExtension parameter)
{
addChildExtension(parameter);
}
/**
* Gets the parameters (as defined by Source-Specific Media Attributes in
* Jingle) of this source.
*
* @return the <tt>ParameterPacketExtension</tt>s of this source
*/
public List<ParameterPacketExtension> getParameters()
{
return getChildExtensionsOfType(ParameterPacketExtension.class);
}
/**
* Gets the synchronization source (SSRC) ID of this source.
*
* @return the synchronization source (SSRC) ID of this source
*/
public long getSSRC()
{
String s = getAttributeAsString(SSRC_ATTR_NAME);
return (s == null) ? -1 : Long.parseLong(s);
}
/**
* Sets the synchronization source (SSRC) ID of this source.
*
* @param ssrc the synchronization source (SSRC) ID to be set on this source
*/
public void setSSRC(long ssrc)
{
if (ssrc == -1)
removeAttribute(SSRC_ATTR_NAME);
else
setAttribute(SSRC_ATTR_NAME, Long.toString(ssrc));
}
}

@ -9,35 +9,70 @@
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
/**
* Implements <tt>AbstractPacketExtension</tt> for the <tt>fingerprint</tt>
* element defined by XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*
* @author Lyubomir Marinov
*/
public class DtlsFingerprintPacketExtension
extends AbstractPacketExtension
{
/**
* The XML name of the <tt>fingerprint</tt> element defined by XEP-0320: Use
* of DTLS-SRTP in Jingle Sessions.
*/
public static final String ELEMENT_NAME = "fingerprint";
/**
* The XML name of the <tt>fingerprint</tt> element's attribute which
* specifies the hash function utilized to calculate the fingerprint.
*/
private static final String HASH_ATTR_NAME = "hash";
/**
* The XML namespace of the <tt>fingerprint</tt> element defined by
* XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*/
public static final String NAMESPACE = "urn:xmpp:jingle:apps:dtls:0";
/**
* The <tt>required</tt> attribute has been removed in version 0.2 of
* XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*/
private static final String REQUIRED_ATTR_NAME = "required";
/** Initializes a new <tt>DtlsFingerprintPacketExtension</tt> instance. */
public DtlsFingerprintPacketExtension()
{
super(NAMESPACE, ELEMENT_NAME);
}
/**
* Gets the fingerprint carried/represented by this instance.
*
* @return the fingerprint carried/represented by this instance
*/
public String getFingerprint()
{
return getText();
}
/**
* Gets the hash function utilized to calculate the fingerprint
* carried/represented by this instance.
*
* @return the hash function utilized to calculate the fingerprint
* carried/represented by this instance
*/
public String getHash()
{
return getAttributeAsString(HASH_ATTR_NAME);
}
/**
* The <tt>required</tt> attribute has been removed in version 0.2 of
* XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*/
public boolean getRequired()
{
String attr = getAttributeAsString(REQUIRED_ATTR_NAME);
@ -45,16 +80,33 @@ public boolean getRequired()
return (attr == null) ? false : Boolean.parseBoolean(attr);
}
/**
* Sets the fingerprint to be carried/represented by this instance.
*
* @param fingerprint the fingerprint to be carried/represented by this
* instance
*/
public void setFingerprint(String fingerprint)
{
setText(fingerprint);
}
/**
* Sets the hash function utilized to calculate the fingerprint
* carried/represented by this instance.
*
* @param hash the hash function utilized to calculate the fingerprint
* carried/represented by this instance
*/
public void setHash(String hash)
{
setAttribute(HASH_ATTR_NAME, hash);
}
/**
* The <tt>required</tt> attribute has been removed in version 0.2 of
* XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*/
public void setRequired(boolean required)
{
setAttribute(REQUIRED_ATTR_NAME, Boolean.valueOf(required));

@ -10,7 +10,6 @@
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
/**
* Represents the <tt>payload-type</tt> elements described in XEP-0167.
*
@ -204,7 +203,7 @@ public void addParameter(ParameterPacketExtension parameter)
{
//parameters are the only extensions we can have so let's use
//super's list.
super.addChildExtension(parameter);
addChildExtension(parameter);
}
/**
@ -214,9 +213,8 @@ public void addParameter(ParameterPacketExtension parameter)
* @return a <b>reference</b> to the the list of parameters currently
* registered for this payload type.
*/
@SuppressWarnings("unchecked") // nothing we could do here.
public List<ParameterPacketExtension> getParameters()
{
return (List<ParameterPacketExtension>)super.getChildExtensions();
return getChildExtensionsOfType(ParameterPacketExtension.class);
}
}

Loading…
Cancel
Save