Commit cbc5984d authored by jm's avatar jm

Manual update -- including Speex-specific jitter buffer


git-svn-id: http://svn.xiph.org/trunk/speex@13981 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent eca2fc11
Copyright 2002-2007 Xiph.org Foundation
Copyright 2002-2007 Jean-Marc Valin
Copyright 2005-2007 Analog Devices Inc.
Copyright 2005-2007 Commonwealth Scientific and Industrial Research Organisation (CSIRO)
Copyright 2005-2007 Commonwealth Scientific and Industrial Research
Organisation (CSIRO)
Copyright 1993, 2002, 2006 David Rowe
Copyright 2003 EpicGames
Copyright 1992-1994 Jutta Degener, Carsten Bormann
......
......@@ -10,7 +10,7 @@ SPEEX_MICRO_VERSION=15
SPEEX_EXTRA_VERSION=-git
#SPEEX_VERSION=
#SPEEX_VERSION=$SPEEX_MAJOR_VERSION.$SPEEX_MINOR_VERSION.$SPEEX_MICRO_VERSION$SPEEX_EXTRA_VERSION
SPEEX_VERSION="1.2beta2"
SPEEX_VERSION="1.2beta3"
SPEEX_LT_CURRENT=5
SPEEX_LT_REVISION=0
......
......@@ -9651,6 +9651,25 @@ preview false
\end_inset
\end_layout
\begin_layout Standard
\newpage
\end_layout
\begin_layout Chapter
Jitter Buffer for Speex
\end_layout
\begin_layout Standard
\begin_inset Include \lstinputlisting{speex_jitter_buffer.c}[caption={Example of using the jitter buffer for Speex packets},label={example-speex-jitter},numbers=left,numberstyle={\footnotesize}]
preview false
\end_inset
\end_layout
\begin_layout Standard
......@@ -9695,40 +9714,16 @@ name "sec:Speex-License"
\end_layout
\begin_layout Standard
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
\end_layout
\begin_inset Include \verbatiminput{/home/jm/dsp/speex/COPYING}
preview false
\end_inset
\begin_layout Itemize
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
\end_layout
\begin_layout Itemize
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
\end_layout
\begin_layout Itemize
Neither the name of the Xiph.org Foundation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
\end_layout
\begin_layout Standard
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\begin_layout Standard
\end_layout
\begin_layout Standard
......
#include <speex/speex_jitter.h>
void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate)
{
jitter->dec = decoder;
speex_decoder_ctl(decoder, SPEEX_GET_FRAME_SIZE, &jitter->frame_size);
jitter->packets = jitter_buffer_init(jitter->frame_size);
speex_bits_init(&jitter->current_packet);
jitter->valid_bits = 0;
}
void speex_jitter_destroy(SpeexJitter *jitter)
{
jitter_buffer_destroy(jitter->packets);
speex_bits_destroy(&jitter->current_packet);
}
void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp)
{
JitterBufferPacket p;
p.data = packet;
p.len = len;
p.timestamp = timestamp;
p.span = jitter->frame_size;
jitter_buffer_put(jitter->packets, &p);
}
void speex_jitter_get(SpeexJitter *jitter, spx_int16_t *out, int *current_timestamp)
{
int i;
int ret;
spx_int32_t activity;
char data[2048];
JitterBufferPacket packet;
packet.data = data;
if (jitter->valid_bits)
{
/* Try decoding last received packet */
ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
if (ret == 0)
{
jitter_buffer_tick(jitter->packets);
return;
} else {
jitter->valid_bits = 0;
}
}
ret = jitter_buffer_get(jitter->packets, &packet, NULL);
if (ret != JITTER_BUFFER_OK)
{
/* No packet found */
/*fprintf (stderr, "lost/late frame\n");*/
/*Packet is late or lost*/
speex_decode_int(jitter->dec, NULL, out);
} else {
speex_bits_read_from(&jitter->current_packet, packet.data, packet.len);
/* Decode packet */
ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
if (ret == 0)
{
jitter->valid_bits = 1;
} else {
/* Error while decoding */
for (i=0;i<jitter->frame_size;i++)
out[i]=0;
}
}
speex_decoder_ctl(jitter->dec, SPEEX_GET_ACTIVITY, &activity);
if (activity < 30)
jitter_buffer_update_delay(jitter->packets, &packet, NULL);
jitter_buffer_tick(jitter->packets);
}
int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter)
{
return jitter_buffer_get_pointer_timestamp(jitter->packets);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment