[jitsi~svn:10183] Updates FMJ to r11. This revision uses an adaptive jitter buffer (for aud

bgrozev at java.net bgrozev at java.net
Fri Dec 14 17:11:54 CET 2012


Project:    jitsi
Repository: svn
Revision:   10183
Author:     bgrozev
Date:       2012-12-14 16:11:51 UTC
Link:       

Log Message:
------------
Updates FMJ to r11. This revision uses an adaptive jitter buffer (for audio streams), which changes size according to the number of packets arriving too late. Passes the net.java.sip.communicator.impl.neomedia.adaptive_jitter_buffer.* properties to the FMJ Registry. Changes the mechanism through which the number of discarded packets is obtained in MediaStreamStatsImpl, now using a FMJ controls. Shows more information about discarded packets and the adaptive jitter buffer in the "call info" window.


Revisions:
----------
10183


Modified Paths:
---------------
trunk/lib/installer-exclude/libjitsi.jar
libjitsi/src/org/jitsi/impl/neomedia/MediaServiceImpl.java
libjitsi/src/org/jitsi/service/neomedia/MediaStreamStats.java
trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
trunk/resources/languages/resources.properties
libjitsi/src/org/jitsi/impl/neomedia/MediaStreamStatsImpl.java
libjitsi/lib/fmj.jar
trunk/lib/installer-exclude/fmj.jar


Diffs:
------
Index: trunk/lib/installer-exclude/fmj.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/lib/installer-exclude/libjitsi.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java
===================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java	(revision 10182)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/call/CallInfoFrame.java	(revision 10183)
@@ -601,9 +601,26 @@
                  String.valueOf((int)mediaStreamStats.getPercentDiscarded()
                          + "%")));
         stringBuffer.append(getLineString(
-                resources.getI18NString("service.gui.callinfo.DISCARDED_TOTAL"),
-                String.valueOf(mediaStreamStats.getNbDiscarded())));
+            resources.getI18NString("service.gui.callinfo.DISCARDED_TOTAL"),
+            String.valueOf(mediaStreamStats.getNbDiscarded())
+                + " (" + mediaStreamStats.getNbDiscardedLate() + " late, "
+                + mediaStreamStats.getNbDiscardedFull() + " full, "
+                + mediaStreamStats.getNbDiscardedShrink() + " shrink, "
+                + mediaStreamStats.getNbDiscardedReset() + " reset)"));
 
+        stringBuffer.append(getLineString(
+                resources.getI18NString(
+                    "service.gui.callinfo.ADAPTIVE_JITTER_BUFFER"),
+                    mediaStreamStats.isAdaptiveBufferEnabled()
+                            ? "enabled" : "disabled"));
+        stringBuffer.append(getLineString(
+                resources.getI18NString(
+                        "service.gui.callinfo.JITTER_BUFFER_DELAY"),
+                "~" + mediaStreamStats.getJitterBufferDelayMs()
+                + "ms; currently in queue: "
+                + mediaStreamStats.getPacketQueueCountPackets() + "/"
+                + mediaStreamStats.getPacketQueueSize() + " packets"));
+
         long rttMs = mediaStreamStats.getRttMs();
         if(rttMs != -1)
         {
Index: trunk/resources/languages/resources.properties
===================================================================
--- trunk/resources/languages/resources.properties	(revision 10182)
+++ trunk/resources/languages/resources.properties	(revision 10183)
@@ -594,7 +594,9 @@
 service.gui.callinfo.HARVESTS=harvests)
 service.gui.callinfo.DECODED_WITH_FEC=Packets decoded with FEC
 service.gui.callinfo.DISCARDED_PERCENT=Packets currently being discarded
-service.gui.callinfo.DISCARDED_TOTAL=Total number of discarded packets
+service.gui.callinfo.DISCARDED_TOTAL=Number of discarded packets
+service.gui.callinfo.ADAPTIVE_JITTER_BUFFER=Adaptive jitter buffer
+service.gui.callinfo.JITTER_BUFFER_DELAY=Jitter buffer
 
 service.gui.ALWAYS_TRUST=Always trust this certificate
 service.gui.CERT_DIALOG_TITLE=Verify Certificate
Index: libjitsi/lib/fmj.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: libjitsi/src/org/jitsi/service/neomedia/MediaStreamStats.java
===================================================================
--- libjitsi/src/org/jitsi/service/neomedia/MediaStreamStats.java	(revision 10182)
+++ libjitsi/src/org/jitsi/service/neomedia/MediaStreamStats.java	(revision 10183)
@@ -168,4 +168,79 @@
      */
     public double getPercentDiscarded();
 
+    /**
+     * Checks whether there is an adaptive jitter buffer enabled for at least
+     * one of the <tt>ReceiveStream</tt>s of the <tt>MediaStreamImpl</tt>.
+     *
+     * @return <tt>true</tt> if there is an adaptive jitter buffer enabled for
+     * at least one of the <tt>ReceiveStream</tt>s of the
+     * <tt>MediaStreamImpl</tt>. Otherwise, <tt>false</tt>
+     */
+    public boolean isAdaptiveBufferEnabled();
+
+    /**
+     * Returns the delay in number of packets introduced by the jitter buffer.
+     *
+     * @return the delay in number of packets introduced by the jitter buffer
+     */
+    public int getJitterBufferDelayPackets();
+
+    /**
+     * Returns the delay in milliseconds introduced by the jitter buffer.
+     *
+     * @return the delay in milliseconds introduces by the jitter buffer
+     */
+    public int getJitterBufferDelayMs();
+
+    /**
+     * Returns the number of packets discarded since the beginning of the
+     * session, because the packet queue was reset.
+     *
+     * @return the number of packets discarded since the beginning of the
+     * session, because the packet queue was reset.
+     */
+    public int getNbDiscardedReset();
+
+    /**
+     * Returns the number of packets discarded since the beginning of the
+     * session, because they were late.
+     *
+     * @return the number of packets discarded since the beginning of the
+     * session, because they were late.
+     */
+    public int getNbDiscardedLate();
+
+    /**
+     * Returns the number of packets discarded since the beginning of the
+     * session, while the packet queue was shrinking.
+     *
+     * @return the number of packets discarded since the beginning of the
+     * session, while the packet queue was shrinking.
+     */
+    public int getNbDiscardedShrink();
+
+    /**
+     * Returns the number of packets discarded since the beginning of the
+     * session, because the packet queue was full.
+     *
+     * @return the number of packets discarded since the beginning of the
+     * session, because the packet queue was full.
+     */
+    public int getNbDiscardedFull();
+
+    /**
+     * Returns the current size of the packet queue.
+     *
+     * @return the current size of the packet queue.
+     */
+    public int getPacketQueueSize();
+
+    /**
+     * Returns the number of packets currently in the packet queue.
+     *
+     * @return the number of packets currently in the packet queue.
+     */
+    public int getPacketQueueCountPackets();
+
+
 }
Index: libjitsi/src/org/jitsi/impl/neomedia/MediaServiceImpl.java
===================================================================
--- libjitsi/src/org/jitsi/impl/neomedia/MediaServiceImpl.java	(revision 10182)
+++ libjitsi/src/org/jitsi/impl/neomedia/MediaServiceImpl.java	(revision 10183)
@@ -1603,6 +1603,15 @@
             }
         }
 
+        ConfigurationService cfg = LibJitsi.getConfigurationService();
+        for(String prop : cfg.getPropertyNamesByPrefix("net.java.sip."
+                + "communicator.impl.neomedia.adaptive_jitter_buffer", true))
+        {
+            String suffix
+                    = prop.substring(prop.lastIndexOf(".") + 1 ,prop.length());
+            Registry.set("adaptive_jitter_buffer_" + suffix, cfg.getString(prop));
+        }
+
         FMJPlugInConfiguration.registerCustomPackages();
         FMJPlugInConfiguration.registerCustomCodecs();
     }
Index: libjitsi/src/org/jitsi/impl/neomedia/MediaStreamStatsImpl.java
===================================================================
--- libjitsi/src/org/jitsi/impl/neomedia/MediaStreamStatsImpl.java	(revision 10182)
+++ libjitsi/src/org/jitsi/impl/neomedia/MediaStreamStatsImpl.java	(revision 10183)
@@ -8,8 +8,11 @@
 
 import java.awt.*;
 import java.net.*;
+import java.util.*;
 
 import javax.media.format.*;
+import javax.media.control.*;
+import javax.media.protocol.*;
 import javax.media.rtp.*;
 
 import net.sf.fmj.media.rtp.*;
@@ -19,6 +22,7 @@
 import org.jitsi.service.neomedia.control.*;
 import org.jitsi.service.neomedia.format.*;
 import org.jitsi.util.*;
+import org.relaxng.datatype.DatatypeStreamingValidator;
 
 /**
  * Class used to compute stats concerning a MediaStream.
@@ -692,7 +696,7 @@
     }
 
     /**
-     * Returns the number of Protocol Data Units (PDU) discarded by the
+     * Returns the total number of Protocol Data Units (PDU) discarded by the
      * FMJ packet queue since the beginning of the session. It's the sum over
      * all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt>
      *
@@ -701,25 +705,72 @@
     public long getNbDiscarded()
     {
         int nbDiscarded = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            nbDiscarded =+ pqc.getDiscarded();
+        return nbDiscarded;
+    }
 
-        if (mediaStreamImpl.isStarted())
-        {
-            MediaDeviceSession devSession = mediaStreamImpl.getDeviceSession();
+    /**
+     * Returns the number of Protocol Data Units (PDU) discarded by the
+     * FMJ packet queue since the beginning of the session due to shrinking.
+     * It's the sum over all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt>
+     *
+     * @return the number of discarded packets due to shrinking.
+     */
+    public int getNbDiscardedShrink()
+    {
+        int nbDiscardedShrink = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            nbDiscardedShrink =+ pqc.getDiscardedShrink();
+        return nbDiscardedShrink;
+    }
 
-            if (devSession != null)
-            {
-                for(ReceiveStream receiveStream
-                        : devSession.getReceiveStreams())
-                {
-                    nbDiscarded
-                        += receiveStream.getSourceReceptionStats().getPDUDrop();
-                }
-            }
-        }
-        return nbDiscarded;
+    /**
+     * Returns the number of Protocol Data Units (PDU) discarded by the
+     * FMJ packet queue since the beginning of the session because it was full.
+     * It's the sum over all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt>
+     *
+     * @return the number of discarded packets because it was full.
+     */
+    public int getNbDiscardedFull()
+    {
+        int nbDiscardedFull = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            nbDiscardedFull =+ pqc.getDiscardedFull();
+        return nbDiscardedFull;
     }
 
     /**
+     * Returns the number of Protocol Data Units (PDU) discarded by the
+     * FMJ packet queue since the beginning of the session because they were late.
+     * It's the sum over all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt>
+     *
+     * @return the number of discarded packets because they were late.
+     */
+    public int getNbDiscardedLate()
+    {
+        int nbDiscardedLate = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            nbDiscardedLate =+ pqc.getDiscardedLate();
+        return nbDiscardedLate;
+    }
+
+    /**
+     * Returns the number of Protocol Data Units (PDU) discarded by the
+     * FMJ packet queue since the beginning of the session during resets.
+     * It's the sum over all <tt>ReceiveStream</tt>s of the <tt>MediaStream</tt>
+     *
+     * @return the number of discarded packets during resets.
+     */
+    public int getNbDiscardedReset()
+    {
+        int nbDiscardedReset = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            nbDiscardedReset =+ pqc.getDiscardedReset();
+        return nbDiscardedReset;
+    }
+
+    /**
      * Returns the number of sent/received bytes since the beginning of the
      * session.
      *
@@ -899,4 +950,113 @@
         // Saves the last update number download lost value.
         this.nbDiscarded += newNbDiscarded;
     }
+
+    public boolean isAdaptiveBufferEnabled()
+    {
+        for(PacketQueueControl pcq : getPacketQueueControls())
+            if(pcq.isAdaptiveBufferEnabled())
+                return true;
+        return false;
+    }
+
+    /**
+     * Returns the delay in number of packets introduced by the jitter buffer.
+     * Since there might be multiple <tt>ReceiveStreams</tt>, returns the
+     * biggest delay found in any of them.
+     *
+     * @return the delay in number of packets introduced by the jitter buffer
+     */
+    public int getJitterBufferDelayPackets()
+    {
+        int delay = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            if(pqc.getCurrentDelayPackets() > delay)
+                delay = pqc.getCurrentDelayPackets();
+
+        return delay;
+    }
+
+    /**
+     * Returns the delay in milliseconds introduced by the jitter buffer.
+     * Since there might be multiple <tt>ReceiveStreams</tt>, returns the
+     * biggest delay found in any of them.
+     *
+     * @return the delay in milliseconds introduces by the jitter buffer
+     */
+    public int getJitterBufferDelayMs()
+    {
+        int delay = 0;
+        for(PacketQueueControl pqc : getPacketQueueControls())
+          if(pqc.getCurrentDelayMs() > delay)
+              delay = pqc.getCurrentDelayMs();
+        return delay;
+    }
+
+    /**
+     * Returns the size of the first <tt>PacketQueueControl</tt> found via
+     * <tt>getPacketQueueControls</tt>.
+     *
+     * @return the size of the first <tt>PacketQueueControl</tt> found via
+     * <tt>getPacketQueueControls</tt>.
+     */
+    public int getPacketQueueSize()
+    {
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            return pqc.getCurrentSizePackets();
+        return 0;
+    }
+
+    /**
+     * Returns the number of packets in the first <tt>PacketQueueControl</tt>
+     * found via <tt>getPacketQueueControls</tt>.
+     *
+     * @return the number of packets in the first <tt>PacketQueueControl</tt>
+     * found via <tt>getPacketQueueControls</tt>.
+     */
+    public int getPacketQueueCountPackets()
+    {
+        for(PacketQueueControl pqc : getPacketQueueControls())
+            return pqc.getCurrentPacketCount();
+        return 0;
+    }
+
+    /**
+     * Returns the set of <tt>PacketQueueControls</tt> found for all the
+     * <tt>DataSource</tt>s of all the <tt>ReceiveStream</tt>s. The set contains
+     * only non-null elements.
+     *
+     * @return the set of <tt>PacketQueueControls</tt> found for all the
+     * <tt>DataSource</tt>s of all the <tt>ReceiveStream</tt>s. The set contains
+     * only non-null elements.
+     */
+    private Set<PacketQueueControl> getPacketQueueControls()
+    {
+        Set<PacketQueueControl> set = new TreeSet<PacketQueueControl>();
+        if (mediaStreamImpl.isStarted())
+        {
+            MediaDeviceSession devSession = mediaStreamImpl.getDeviceSession();
+            if (devSession != null)
+            {
+                for(ReceiveStream receiveStream
+                        : devSession.getReceiveStreams())
+                {
+                    DataSource ds = receiveStream.getDataSource();
+                    if(ds instanceof net.sf.fmj.media.protocol.rtp.DataSource)
+                    {
+                        for (PushBufferStream pbs :
+                                ((net.sf.fmj.media.protocol.rtp.DataSource)ds)
+                                        .getStreams())
+                        {
+                            PacketQueueControl pqc = (PacketQueueControl)
+                                    pbs.getControl(
+                                            PacketQueueControl.class.getName());
+                            if(pqc != null)
+                                set.add(pqc);
+                        }
+                    }
+                }
+            }
+        }
+        return set;
+    }
 }







More information about the commits mailing list