Adds support for XEP-0339 source groups in ColibriConferenceIQ and ColibriIQProvider.

fix-message-formatting
George Politis 11 years ago
parent 25ff1e12ca
commit a12207caeb

@ -898,6 +898,11 @@ public static class Channel
private final List<SourcePacketExtension> sources
= new LinkedList<SourcePacketExtension>();
/**
* The <tt>SourceGroupPacketExtension</tt>s of this channel.
*/
private List<SourceGroupPacketExtension> sourceGroups;
/**
* 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
@ -956,6 +961,29 @@ public synchronized boolean addSource(SourcePacketExtension source)
return sources.contains(source) ? false : sources.add(source);
}
/**
* Adds a <tt>SourceGroupPacketExtension</tt> to the list of source
* groups of this channel.
*
* @param sourceGroup 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 addSourceGroup(
SourceGroupPacketExtension sourceGroup)
{
if (sourceGroup == null)
throw new NullPointerException("sourceGroup");
if (sourceGroups == null)
sourceGroups = new LinkedList<SourceGroupPacketExtension>();
return sourceGroups.contains(sourceGroup)
? false : sourceGroups.add(sourceGroup);
}
/**
* 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
@ -1104,6 +1132,19 @@ public synchronized List<SourcePacketExtension> getSources()
return new ArrayList<SourcePacketExtension>(sources);
}
/**
* Gets the list of <tt>SourceGroupPacketExtensions</tt>s which
* represent the source groups of this channel.
*
* @return a <tt>List</tt> of <tt>SourceGroupPacketExtension</tt>s which
* represent the source groups of this channel
*/
public synchronized List<SourceGroupPacketExtension> getSourceGroups()
{
return (sourceGroups == null) ? null
: new ArrayList<SourceGroupPacketExtension>(sourceGroups);
}
/**
* Gets (a copy of) the list of (RTP) SSRCs seen/received on this
* <tt>Channel</tt>.
@ -1407,6 +1448,7 @@ protected void printContent(StringBuilder xml)
{
List<PayloadTypePacketExtension> payloadTypes = getPayloadTypes();
List<SourcePacketExtension> sources = getSources();
List<SourceGroupPacketExtension> souceGroups = getSourceGroups();
int[] ssrcs = getSSRCs();
for (PayloadTypePacketExtension payloadType : payloadTypes)
@ -1415,6 +1457,10 @@ protected void printContent(StringBuilder xml)
for (SourcePacketExtension source : sources)
xml.append(source.toXML());
if (souceGroups != null && souceGroups.size() != 0)
for (SourceGroupPacketExtension sourceGroup : souceGroups)
xml.append(sourceGroup.toXML());
for (int i = 0; i < ssrcs.length; i++)
{
xml.append('<').append(SSRC_ELEMENT_NAME).append('>')

@ -40,6 +40,11 @@ public ColibriIQProvider()
SourcePacketExtension.NAMESPACE,
new DefaultPacketExtensionProvider<SourcePacketExtension>(
SourcePacketExtension.class));
providerManager.addExtensionProvider(
SourceGroupPacketExtension.ELEMENT_NAME,
SourceGroupPacketExtension.NAMESPACE,
new DefaultPacketExtensionProvider<SourceGroupPacketExtension>(
SourceGroupPacketExtension.class));
PacketExtensionProvider parameterProvider
= new DefaultPacketExtensionProvider<ParameterPacketExtension>(
@ -84,6 +89,13 @@ else if (childExtension instanceof IceUdpTransportPacketExtension)
channel.setTransport(transport);
}
else if (childExtension instanceof SourceGroupPacketExtension)
{
SourceGroupPacketExtension sourceGroup
= (SourceGroupPacketExtension)childExtension;
channel.addSourceGroup(sourceGroup);
}
}
private void addChildExtension(
@ -538,7 +550,14 @@ else if (SourcePacketExtension.ELEMENT_NAME.equals(name)
peName = name;
peNamespace = SourcePacketExtension.NAMESPACE;
}
else if (SourceGroupPacketExtension.ELEMENT_NAME
.equals(name)
&& SourceGroupPacketExtension.NAMESPACE
.equals(parser.getNamespace()))
{
peName = name;
peNamespace = SourceGroupPacketExtension.NAMESPACE;
}
if (peName == null)
{
throwAway(parser, name);

@ -0,0 +1,66 @@
/*
* 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.jingle;
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.colibri.*;
import java.util.*;
/**
* Represents <tt>ssrc-group</tt> elements described in XEP-0339.
*
* Created by gp on 07/08/14.
*/
public class SourceGroupPacketExtension
extends AbstractPacketExtension
{
/**
* The name of the "ssrc-group" element.
*/
public static final String ELEMENT_NAME = "ssrc-group";
/**
* The namespace for the "ssrc-group" element.
*/
public static final String NAMESPACE = "urn:xmpp:jingle:apps:rtp:ssma:0";
/**
* The name of the payload <tt>id</tt> SDP argument.
*/
public static final String SEMANTICS_ATTR_NAME = "semantics";
/**
* Creates a new {@link SourceGroupPacketExtension} instance with the proper
* element name and namespace.
*/
public SourceGroupPacketExtension()
{
super(NAMESPACE, ELEMENT_NAME);
}
/**
* Gets the semantics of this source group.
*
* @return the semantics of this source group.
*/
public String getSemantics()
{
return getAttributeAsString(SEMANTICS_ATTR_NAME);
}
/**
* Gets the sources of this source group.
*
* @return the sources of this source group.
*/
public List<SourcePacketExtension> getSources()
{
return getChildExtensionsOfType(SourcePacketExtension.class);
}
}
Loading…
Cancel
Save