aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-11-26 20:25:29 +0200
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-11-26 20:25:29 +0200
commit5649188a00dfbb688cf3efdf6b9ae8e99e70c664 (patch)
tree1cf9f5ec8700f9867e9524bbc03d0b12cece2eba /src/net/java/sip/communicator/impl/protocol
parent64f9bee24de86b906d2c9465b58b73c84805d956 (diff)
downloadjitsi-5649188a00dfbb688cf3efdf6b9ae8e99e70c664.zip
jitsi-5649188a00dfbb688cf3efdf6b9ae8e99e70c664.tar.gz
jitsi-5649188a00dfbb688cf3efdf6b9ae8e99e70c664.tar.bz2
Fixes an issue which could cause Jitsi Videobridge to report synchronization source (SSRC) identifiers in text format as negative.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java55
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java37
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java18
3 files changed, 53 insertions, 57 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java
index ffa4ce0..314cd1e 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java
@@ -762,7 +762,7 @@ public class CallPeerMediaHandlerJabberImpl
@Override
public long getRemoteSSRC(MediaType mediaType)
{
- long[] ssrcs = getRemoteSSRCs(mediaType);
+ int[] ssrcs = getRemoteSSRCs(mediaType);
/*
* A peer (regardless of whether it is local or remote) may send
@@ -772,13 +772,8 @@ public class CallPeerMediaHandlerJabberImpl
* known in the list reported by the Jitsi Videobridge server is the
* last.
*/
- for (int i = ssrcs.length - 1; i >= 0; i--)
- {
- long ssrc = ssrcs[i];
-
- if (ssrc != SSRC_UNKNOWN)
- return ssrc;
- }
+ if (ssrcs.length != 0)
+ return 0xFFFFFFFFL & ssrcs[ssrcs.length - 1];
/*
* XXX In the case of Jitsi Videobridge, the super implementation of
@@ -803,11 +798,11 @@ public class CallPeerMediaHandlerJabberImpl
*
* @param mediaType the <tt>MediaType</tt> of the RTP streams the SSRCs of
* which are to be returned
- * @return an array of <tt>long</tt> values which represent the SSRCs of RTP
+ * @return an array of <tt>int</tt> values which represent the SSRCs of RTP
* streams with the specified <tt>mediaType</tt> known to be received by a
* <tt>MediaStream</tt> associated with this instance
*/
- public long[] getRemoteSSRCs(MediaType mediaType)
+ private int[] getRemoteSSRCs(MediaType mediaType)
{
/*
* If the Jitsi Videobridge server-side technology is utilized, a single
@@ -817,6 +812,7 @@ public class CallPeerMediaHandlerJabberImpl
* why the server will report them to the conference focus.
*/
ColibriConferenceIQ.Channel channel = getColibriChannel(mediaType);
+
if (channel != null)
return channel.getSSRCs();
@@ -830,7 +826,7 @@ public class CallPeerMediaHandlerJabberImpl
return
(ssrc == SSRC_UNKNOWN)
? ColibriConferenceIQ.NO_SSRCS
- : new long[] { ssrc };
+ : new int[] { (int) ssrc };
}
/**
@@ -1060,7 +1056,7 @@ public class CallPeerMediaHandlerJabberImpl
return Collections.emptyList();
else
{
- long[] remoteSSRCs = getRemoteSSRCs(MediaType.VIDEO);
+ int[] remoteSSRCs = getRemoteSSRCs(MediaType.VIDEO);
if (remoteSSRCs.length == 0)
return Collections.emptyList();
@@ -1070,16 +1066,15 @@ public class CallPeerMediaHandlerJabberImpl
List<Component> visualComponents
= new LinkedList<Component>();
- for (long remoteSSRC : remoteSSRCs)
+ for (int i = 0; i < remoteSSRCs.length; i++)
{
- if (remoteSSRC != -1)
- {
- Component visualComponent
- = videoStream.getVisualComponent(remoteSSRC);
+ int remoteSSRC = remoteSSRCs[i];
+ Component visualComponent
+ = videoStream.getVisualComponent(
+ 0xFFFFFFFFL & remoteSSRC);
- if (visualComponent != null)
- visualComponents.add(visualComponent);
- }
+ if (visualComponent != null)
+ visualComponents.add(visualComponent);
}
return visualComponents;
}
@@ -1376,25 +1371,11 @@ public class CallPeerMediaHandlerJabberImpl
if (src != null)
{
- long[] ssrcs = src.getSSRCs();
- long[] dstSsrcs = dst.getSSRCs();
+ int[] ssrcs = src.getSSRCs();
+ int[] dstSSRCs = dst.getSSRCs();
- if (!Arrays.equals(dstSsrcs, ssrcs))
- {
+ if (!Arrays.equals(dstSSRCs, ssrcs))
dst.setSSRCs(ssrcs);
- if(logger.isDebugEnabled())
- {
- logger.debug(
- "SSRCs changed for colibri "
- + mediaType.toString()
- + " channel "
- + dst.getID()
- + " from: "
- + Arrays.toString(dstSsrcs)
- + " to: "
- + Arrays.toString(ssrcs));
- }
- }
}
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java
index af5caaf..9a4f852 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java
@@ -43,11 +43,11 @@ public class ColibriConferenceIQ
= "http://jitsi.org/protocol/colibri";
/**
- * An array of <tt>long</tt>s which represents the lack of any (RTP) SSRCs
+ * An array of <tt>int</tt>s which represents the lack of any (RTP) SSRCs
* seen/received on a <tt>Channel</tt>. Explicitly defined to reduce
* unnecessary allocations.
*/
- public static final long[] NO_SSRCS = new long[0];
+ public static final int[] NO_SSRCS = new int[0];
/**
* The list of {@link Content}s included into this <tt>conference</tt> IQ.
@@ -395,7 +395,7 @@ public class ColibriConferenceIQ
* <tt>Channel</tt> by now. These may exclude SSRCs which are no longer
* active. Set by the Jitsi Videobridge server, not its clients.
*/
- private long[] ssrcs = NO_SSRCS;
+ private int[] ssrcs = NO_SSRCS;
private IceUdpTransportPacketExtension transport;
@@ -460,15 +460,15 @@ public class ColibriConferenceIQ
* <tt>Channel</tt> has been modified as part of the method call;
* otherwise, <tt>false</tt>
*/
- public synchronized boolean addSSRC(long ssrc)
+ public synchronized boolean addSSRC(int ssrc)
{
// contains
- for (long element : ssrcs)
- if (element == ssrc)
+ for (int i = 0; i < ssrcs.length; i++)
+ if (ssrcs[i] == ssrc)
return false;
// add
- long[] newSSRCs = new long[ssrcs.length + 1];
+ int[] newSSRCs = new int[ssrcs.length + 1];
System.arraycopy(ssrcs, 0, newSSRCs, 0, ssrcs.length);
newSSRCs[ssrcs.length] = ssrc;
@@ -483,9 +483,7 @@ public class ColibriConferenceIQ
*/
public MediaDirection getDirection()
{
- return direction == null
- ? MediaDirection.SENDRECV
- : direction;
+ return (direction == null) ? MediaDirection.SENDRECV : direction;
}
/**
@@ -601,10 +599,10 @@ public class ColibriConferenceIQ
* Gets (a copy of) the list of (RTP) SSRCs seen/received on this
* <tt>Channel</tt>.
*
- * @return an array of <tt>long</tt>s which represents (a copy of) the
+ * @return an array of <tt>int</tt>s which represents (a copy of) the
* list of (RTP) SSRCs seen/received on this <tt>Channel</tt>
*/
- public synchronized long[] getSSRCs()
+ public synchronized int[] getSSRCs()
{
return (ssrcs.length == 0) ? NO_SSRCS : ssrcs.clone();
}
@@ -670,7 +668,7 @@ public class ColibriConferenceIQ
* <tt>Channel</tt> has been modified as part of the method call;
* otherwise, <tt>false</tt>
*/
- public synchronized boolean removeSSRC(long ssrc)
+ public synchronized boolean removeSSRC(int ssrc)
{
if (ssrcs.length == 1)
{
@@ -688,7 +686,7 @@ public class ColibriConferenceIQ
{
if (ssrcs[i] == ssrc)
{
- long[] newSSRCs = new long[ssrcs.length - 1];
+ int[] newSSRCs = new int[ssrcs.length - 1];
if (i != 0)
System.arraycopy(ssrcs, 0, newSSRCs, 0, i);
@@ -843,7 +841,7 @@ public class ColibriConferenceIQ
* @param ssrcs the list of (RTP) SSRCs to be set as seen/received on
* this <tt>Channel</tt>
*/
- public void setSSRCs(long[] ssrcs)
+ public void setSSRCs(int[] ssrcs)
{
/*
* TODO Make sure that the SSRCs set on this instance do not contain
@@ -948,7 +946,7 @@ public class ColibriConferenceIQ
boolean hasPayloadTypes = !payloadTypes.isEmpty();
List<SourcePacketExtension> sources = getSources();
boolean hasSources = !sources.isEmpty();
- long[] ssrcs = getSSRCs();
+ int[] ssrcs = getSSRCs();
boolean hasSSRCs = (ssrcs.length != 0);
IceUdpTransportPacketExtension transport = getTransport();
boolean hasTransport = (transport != null);
@@ -968,11 +966,12 @@ public class ColibriConferenceIQ
}
if (hasSSRCs)
{
- for (long ssrc : ssrcs)
+ for (int i = 0; i < ssrcs.length; i++)
{
xml.append('<').append(SSRC_ELEMENT_NAME).append('>')
- .append(ssrc).append("</")
- .append(SSRC_ELEMENT_NAME).append('>');
+ .append(Long.toString(ssrcs[i] & 0xFFFFFFFFL))
+ .append("</").append(SSRC_ELEMENT_NAME)
+ .append('>');
}
}
if (hasTransport)
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java
index ea9a32d..7335dd5 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriIQProvider.java
@@ -168,7 +168,23 @@ public class ColibriIQProvider
else if (ColibriConferenceIQ.Channel.SSRC_ELEMENT_NAME
.equals(name))
{
- channel.addSSRC(Long.parseLong(ssrc.toString().trim()));
+ String s = ssrc.toString().trim();
+
+ if (s.length() != 0)
+ {
+ int i;
+
+ /*
+ * Legacy versions of Jitsi and Jitsi Videobridge
+ * may send a synchronization source (SSRC)
+ * identifier as a negative integer.
+ */
+ if (s.startsWith("-"))
+ i = Integer.parseInt(s);
+ else
+ i = (int) Long.parseLong(s);
+ channel.addSSRC(i);
+ }
ssrc = null;
}
else if (ColibriConferenceIQ.Content.ELEMENT_NAME.equals(