[Speex-dev] speex with jitter buffer
nomprenom at gmail.com
Sun Jan 24 14:59:43 UTC 2021
I can't understand how to implement my encoder/decoder with the jitter
buffer. I hope someone can help me:
I have 2 threads.
Because I don't have yet the full environment (with the devices etc..),
- I'm reading from thread1,
- sending to the main thread,
- write to a jitter buff,
- from th2 : read from the jitter and play the data.
(Tomorrow, this is a device which will send the main thread the speex data
via RF - that's why I need to handle a jitter).
1) read 640 bytes from pcm (=40ms) (my settings are 8khz/16bits le)
2) encode to 40 bytes of speex
3) send to main thread 40 bytes of speex
1) speex_jitter_put(20 first bytes of speex, counter * 640) // timestamp =
0, 640, 1280, etc..
2) speex_jitter_put(20 last bytes of speex, 320 + counter * 640) //
timestamp = 320, 960, 1600, etc..
1) speex_jitter_get(buffer, NULL)
2) speex_jitter_get(buffer + 320, timestamp=320)
3) pcm_write(buffer, 640)
Actually I can't hear anything. I tried many things without success. It's
the most "stable" flow I found without seeing many warnings from the api
(underrun, negative buffer, etc..)
- in the main thread, I think speex_jitter_put always puts 20 ms, right ?
(I initialized the buffer with an audio sampling rate of 8khz)
- in the main thread, I don't know if it's ok to put directly 40ms of speex
or if I need to put 2 * 20ms with a different timestamp for the 2nd
- I don't know too well what the timestamp parameter is : is it a timestamp
in ms ? I use now, after searching on the net, "pcm units" (320 = 20 ms/
640 = 40ms)
- in thread 2, I can't pcm_write 320 only else I see many "underrun"
errors. I thought, at the beginning, to simply read from the jitter and
play (320) and to do this 2 times.
Any help will be appreciated.
On Mon, 18 Jan 2021 at 21:30, nomprenom <nomprenom at gmail.com> wrote:
> Thank you Tristan for your answer.
> For now I took jitter.c and .h from dsp and added them to the makefile of
> I also added speex_jitter_buffer.c and h from the sample into the lib.
> On Mon, 18 Jan 2021 at 20:30, Tristan Matthews <tmatth at videolan.org>
>> On Mon, Jan 18, 2021 at 12:29 PM nomprenom <nomprenom at gmail.com> wrote:
>> > Hi,
>> > I'd like to use the speex encode/decoder library with the speex jitter
>> > I took, first, the project "speex" from
>> > There is a nice sample in the directory speex_client/ which is using
>> speex_jitter_buffer.h which itself is using <speex/speex_jitter.h>
>> > I couldn't find this include file in the project.
>> > I checked in the project speexDSP and found it.
>> > I thought, maybe, speexDsp is the new "speex" because it's deprecated.
>> > The problem is, now, with speexDsp I can't find the "speex.h" header
>> and can't find either the speex_decode_init(), speex_decoder_ctl() APIs.
>> > It's only in the sampledec.c in the doc/ directory of speexdsp
>> > How can I use the speex decoder/encoder with the speex_jitter api
>> together ?
>> The Speex project has been split in 2, speex "the codec" (where you'll
>> find the decode_init and decoder_ctl API) and speexdsp "the DSP
>> library" where you'll find the jitter buffer API. The motivation was
>> that users want to be able to use purely the codec without the DSP
>> stuff and vice-versa.
>> N.B. The most active/used project in speexdsp is the resampler, you
>> may find jitterbuffer implementations elsewhere that are a better fit
>> for your project.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Speex-dev