I'm currently working on a speex + theora webchat.<br>I have both working alone, but to make them work together and to know where the package goes, I'm trying to use ogg packages.<br>With theora there has been no problem, but with speex I can't make it work. The problem is that for a second it works great, but then it begings to gain lag, and in a little time it has 5-10 lag seconds (into the same machine, working on loopback). Currently I'm packaging 4 frames per package (FRAMES_PACKET=4).
<br>Any help will be greatly appreciated.<br><br><br>Into the encoder I have this code:<br><br>speex_bits_reset(&enc_bits);<br>for(int i=0;i<FRAMES_PACKET;i++)<br>{<br> int nb_samples;<br> //Here I get the microphone data.
<br> while((nb_samples=Check_Mic(Mic_data))==0);<br> speex_encode_int(enc_state, Mic_data, &enc_bits);<br><br> total_samples += nb_samples;<br> speex_bits_insert_terminator(&enc_bits);<br><br> //The time stamp
<br> if(i==0)<br> ((int*)packet)[0]=total_samples;<br>}<br>int nbBytes = speex_bits_write(&enc_bits, packet+4, 2000);<br>tam=nbBytes+4;<br><br>//Now the ogg package<br>op.packet = (unsigned char *)packet;<br>
op.bytes = nbBytes+4;<br>op.b_o_s = 0;<br>op.packetno = packet_id;<br>packet_id++;<br><br>ogg_stream_packetin(&os, &op);<br>ogg_stream_flush(&os, &audio_page);<br><br>return audio_page;<br>}<br><br>As for the decoder I have this.
<br><br>//Incoming data from udp is on buffer<br>char *buffer=ogg_sync_buffer(&oy,4096);<br>memcpy(buffer,buff,len);<br>ogg_sync_wrote(&oy,len);<br>while(ogg_sync_pageout(&oy,&audio_page)>0)<br>{<br> if (stream_init == 0)
<br> {<br> ogg_stream_init(&os, ogg_page_serialno(&audio_page));<br> stream_init = 1;<br> }<br> queue_page(&audio_page);<br><br> while(ogg_stream_packetout(&os,&op)>0)<br> {
<br> int b;<br> ogg_stream_pagein(&os, &audio_page);<br> int len=(audio_page.body_len-4)/FRAMES_PACKET;<br><br> char *datos=(char*)op.packet;<br> char m[100];<br> sprintf(m,"paq %d",
op.packetno);<br> System::Console::WriteLine(gcnew String(m));<br><br> int t=((int *)datos)[0];<br> for(int i=0;i<FRAMES_PACKET;i++)<br> speex_jitter_put(&jitter,(datos+4)+len*i,len,t+FRAME_SIZE*i);
<br> }<br>}<br><br clear="all"><br>-- <br><a href="http://www.apple.com">http://www.apple.com</a><br>A veces me da por ahi. Otras como que no.