Skip to content
Snippets Groups Projects
MediaStreamStatsImpl.java 33.6 KiB
Newer Older
    }

    /**
     * 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 HashSet<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;
    }