Exemplo n.º 1
0
    static void test_sequence_buffer32()
    {
        Log("test_sequence_buffer32");
        const int Size   = 256;
        var       buffer = new SequenceBuffer32 <TestPacketData32>(Size);

        for (int i = 0; i < Size; ++i)
        {
            TestPacketData entry;
            entry.sequence = 0;
            IsTrue(buffer.Exists((uint)i) == false);
            IsTrue(buffer.Available((uint)i) == true);
            IsTrue(buffer.Get((uint)i) == -1);
        }

        for (int i = 0; i <= Size * 4; ++i)
        {
            int index = buffer.Insert((uint)i);
            IsTrue(index != -1);
            IsTrue(buffer.id == i + 1);
            buffer.entries[index].sequence = (uint)i;
        }

        for (int i = 0; i <= Size; ++i)
        {
            int index = buffer.Insert((uint)i); //note: outside bounds!
            IsTrue(index == -1);
        }

        uint sequence = Size * 4;

        for (int i = 0; i < Size; ++i)
        {
            int index = buffer.Get(sequence);
            IsTrue(index >= 0);
            IsTrue(index < Size);
            IsTrue(buffer.entries[index].sequence == sequence);
            sequence--;
        }

        buffer.Reset();
        IsTrue(buffer.id == 0);

        for (int i = 0; i < Size; ++i)
        {
            IsTrue(buffer.Exists((uint)i) == false);
            IsTrue(buffer.Available((uint)i) == true);
            IsTrue(buffer.Get((uint)i) == -1);
        }
    }
    public JitterBufferEntry GetEntry(uint frame)
    {
        int id = buffer.Get(frame);

        if (id == -1)
        {
            return(null);
        }

        return(buffer.entries[id]);
    }