From 50c41acdff0c54caefe026db1bc0aab704e917db Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Fri, 18 Sep 2009 11:53:12 +0200 Subject: [PATCH] speexdec: allow for unknown varying number of frames per buffer In particular, this caters for RTP payloads with multiple frames per packet. --- ext/speex/gstspeexdec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/speex/gstspeexdec.c b/ext/speex/gstspeexdec.c index 7494227..38899b5 100644 --- a/ext/speex/gstspeexdec.c +++ b/ext/speex/gstspeexdec.c @@ -655,7 +655,7 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf, /* send data to the bitstream */ speex_bits_read_from (&dec->bits, (char *) data, size); - fpp = dec->header->frames_per_packet; + fpp = 0; bits = &dec->bits; GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d", size, fpp); @@ -677,8 +677,9 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf, } - /* now decode each frame */ - for (i = 0; i < fpp; i++) { + /* now decode each frame, catering for unknown number of them (e.g. rtp) */ + for (i = 0; (!fpp || i < fpp) && (!bits || speex_bits_remaining (bits) > 0); + i++) { GstBuffer *outbuf; gint16 *out_data; gint ret; -- 2.7.4