[Speex-dev] Speex + Ogg package

Jere Gmail zon7mail at gmail.com
Sun Aug 6 17:53:32 PDT 2006


I'm currently working on a speex + theora webchat.
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.
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).
Any help will be greatly appreciated.


Into the encoder I have this code:

speex_bits_reset(&enc_bits);
for(int i=0;i<FRAMES_PACKET;i++)
{
    int nb_samples;
    //Here I get the microphone data.
    while((nb_samples=Check_Mic(Mic_data))==0);
    speex_encode_int(enc_state, Mic_data, &enc_bits);

    total_samples += nb_samples;
    speex_bits_insert_terminator(&enc_bits);

    //The time stamp
    if(i==0)
        ((int*)packet)[0]=total_samples;
}
int nbBytes = speex_bits_write(&enc_bits, packet+4, 2000);
tam=nbBytes+4;

//Now the ogg package
op.packet = (unsigned char *)packet;
op.bytes = nbBytes+4;
op.b_o_s = 0;
op.packetno = packet_id;
packet_id++;

ogg_stream_packetin(&os, &op);
ogg_stream_flush(&os, &audio_page);

return audio_page;
}

As for the decoder I have this.

//Incoming data from udp is on buffer
char *buffer=ogg_sync_buffer(&oy,4096);
memcpy(buffer,buff,len);
ogg_sync_wrote(&oy,len);
while(ogg_sync_pageout(&oy,&audio_page)>0)
{
    if (stream_init == 0)
    {
        ogg_stream_init(&os, ogg_page_serialno(&audio_page));
        stream_init = 1;
    }
    queue_page(&audio_page);

    while(ogg_stream_packetout(&os,&op)>0)
    {
        int b;
        ogg_stream_pagein(&os, &audio_page);
        int len=(audio_page.body_len-4)/FRAMES_PACKET;

        char *datos=(char*)op.packet;
        char m[100];
        sprintf(m,"paq %d",op.packetno);
        System::Console::WriteLine(gcnew String(m));

        int t=((int *)datos)[0];
        for(int i=0;i<FRAMES_PACKET;i++)
            speex_jitter_put(&jitter,(datos+4)+len*i,len,t+FRAME_SIZE*i);
    }
}


-- 
http://www.apple.com
A veces me da por ahi. Otras como que no.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20060807/88642a6c/attachment.html


More information about the Speex-dev mailing list