Hi, what is the good way to encode / decode multiple frames in packet ? I read that I must do multiple call to encode and thats it. But when I'm trying to decode,, it doesn't work. Maybe, the problem is my decode function.
<br><br>Here is my encode function<br><br><font size="1">void ms_speex_enc_process(MSSpeexEnc *obj)<br>{<br> ....<br><br> </font><font size="1"><span style="font-weight: bold;"><font size="2"><span style="font-weight: bold;">
Do I need to increase gran value to 640 or read / encode (2 times)</span></font></span></font><br><font size="1"> ms_fifo_get_read_ptr(inf,gran,(void**)&input); (gran = 320)<br> g_return_if_fail(input!=NULL);<br>
/* encode */<br> speex_bits_reset(&obj->bits); <br> <br> speex_encode_int(obj->speex_state,(short*)input,&obj->bits);<br><span style="font-weight: bold;"><font size="2"><span style="font-weight: bold;">
</span></font></span></font><font size="1"><span style="font-weight: bold;"><font size="2"><span style="font-weight: bold;"><span style="font-weight: bold;"></span></span></font></span></font><font size="1"><br> m=ms_message_new(speex_bits_nbytes(&obj->bits));
<br> //speex_bits_insert_terminator(&obj->bits);<br> m->size=speex_bits_write(&obj->bits,m->data,m->size);<br> ms_queue_put(outq,m);<br>}<br><br><font size="2">And my decode function <br><br>
<font size="1">void ms_speex_dec_process(MSSpeexDec *obj)<br>{<br> ....<br> <br> m=ms_queue_get(inq);<br> g_return_if_fail(m!=NULL);<br> speex_bits_reset(&obj->bits);<br> ms_fifo_get_write_ptr(outf,gran,(void**)&output);
<br> g_return_if_fail(output!=NULL);<br> if (m->data!=NULL){<br> <br> speex_bits_read_from(&obj->bits,m->data,m->size);<br> /* decode */<br> int ret = 1;<br> <font style="font-weight: bold;" size="2">
while( ret != -1 && speex_bits_remaining(&obj->bits) > 0 )<br> {<br> ret = speex_decode_int(obj->speex_state,&obj->bits,(short*)output);<br> }</font><br> <br>
}else{<br> /* we have a missing packet */<br> speex_decode_int(obj->speex_state,NULL,(short*)output);<br> }<br> ms_message_destroy(m);<br> <br>}<br><br><font size="2">Jonathan Blais</font><br>
</font></font></font>