[Speex-dev] Problems with the Speex Jitter Buffer

Jean-Marc Valin jean-marc.valin at usherbrooke.ca
Thu Apr 19 23:43:49 PDT 2007


(Sorry about the delay -- currently attending ICASSP)
Hi,

Haven't looked at all the details, but what's clearly wrong is that you
need to put the *compressed* packets in the jitter buffer and decode
them only when you _get() them.

	Jean-Marc

David Feurle wrote:
> Hi,
> 
> I am using the JitterBuffer. Since there is not so much documentation I
> think I dont use it in a correct way. All the packets are recieved (I
> control the sequence numbers) but the JitterBuffer often tells me he has
> no packet. I am using it in the following way:
> 
> I am not sure if I use the ticks correctly but I think it can be set to
> 20(msec).
> It is set as a Member in my class and i pointed out where i use it so it
> is clear if i use it somewhere i better shouldnt.
> 
> - I initialize the JitterBuffer with ticks = 20 (saved in the variable
> m_Ticks)
> - My network thread repeadedly (every 20msec) calls AddPacket() which
> adds the packet to the buffer
>          320 bytes of audio data are set as the data
>          the timestamp is set to the sequence number of the packet times
> 20 (m_Ticks)
>          the span of the packet is set to 20 (the packet covers one tick
> entirely)
> - A thread which plays my Audio calls every 20msec the function GetSound()
> 
> As I said before the buffer just returns more or less the halve of the
> packets. But all the packets are added to the JitterBuffer.
> I posted some of the code i use in my email and i would be really
> thankfull if anybody could tell me where i am using the JitterBuffer wrong.
> 
> Many thanks in advance
> 
> David Feurle
> 
> 
> 
> Init()
> {
>    m_JitterBuffer = jitter_buffer_init(m_Ticks);
>    jitter_buffer_reset(m_JitterBuffer);
> }
> 
> Exit()
> {
>        jitter_buffer_destroy(m_JitterBuffer);
> }
> 
> void BeatJitterBuffer::AddPacket(Packet* packet)
> {
>    m_Mutex.Aquire();
>          char buff[320];
>        JitterBufferPacket p;
>        m_Decoder->DecompressPacket(packet, buff, 320);
>        p.data = buff;
>        p.len = 320;
>        p.timestamp = packet->SequenceNumber() * m_Ticks;
>        p.span = m_Ticks;
>        jitter_buffer_put(m_JitterBuffer, &p);
>    }
> 
>    m_Mutex.Release();
>    delete packet;
> }
> 
> void BeatJitterBuffer::GetSound(char* buffer, size_t maxLength)
> {
>    int ret;
> 
>    if (320 == maxLength)
>    {
>        JitterBufferPacket packet;
>        packet.data = buffer;
> 
>        m_Mutex.Aquire();
> 
>        ret = jitter_buffer_get(m_JitterBuffer, &packet, 0);
> 
>        if(ret != JITTER_BUFFER_OK)
>        {
>            ZeroMemory(packet.data, maxLength);
>         }
> 
>        jitter_buffer_tick(m_JitterBuffer);
>        jitter_buffer_update_delay(m_JitterBuffer, &packet, NULL);
>        m_Mutex.Release();
>    }
>    else
>    {
>        ZeroMemory(buffer, maxLength);
>    }
> }
> 
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
> 


More information about the Speex-dev mailing list