[Speex-dev] Problems with the Speex Jitter Buffer

David Feurle feurle at bluehands.de
Thu Apr 19 23:57:45 PDT 2007


Thanks for your reply Jean-Marc!

this was what I had before.
But I decided to restructure it since the thread that plays the sound is 
a callback from the sound hardware, more or less an interrupt handler. 
For me it seems more reasonable to waste some memory for to save the 
decompressed Packet. While I write this I begin to think that it is 
possible I decompress Packets that are never used because they are too 
late. What is the reason why one should put the compressed Packet in the 
JitterBuffer?

       David
> (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