Hey all I have been working on a simple VOIP app and have gotten my self
totally confused.
is this the right process to follow? Any tips examples guidence would be
super awesome.
I have my voice data. capturing.
I encoding it so that there are multi speex frames per packet.
on  the reciving end i decode the package i recive.
Yeah it dosnt work at all. :D
this is the code  for the encode.
int PackVoiceData(SpeexBits *bits,int space_avalible_in_packect, int
size_of_data_avalible, int frame_size , void * data_to_pack, char *
destinantion_buffer )
{
    float frame[FRAME_SIZE];
    int offset= 0;
    float  * data_as_floats;
    short * data_as_shorts = (short *) data_to_pack;
    memset(destinantion_buffer , 0,size_of_data_avalible);
    /// memset(data_as_shorts , 0,size_of_data_avalible);
    int number_of_frames;
    /// clear the space each time.
    int length = space_avalible_in_packect;
    if ( size_of_data_avalible < space_avalible_in_packect )
    {
        length = size_of_data_avalible;
    }
    /// allocate space in memory for the float version of the data.
    data_as_floats = (float *)calloc ( length, sizeof( float));
    number_of_frames = length/FRAME_SIZE;
    for(int i=0; i< length; i++ )
    {
        data_as_floats[i] = data_as_shorts[i];
    }
    /// if size of data avaliable is less than the space avaliable in the
packet figure
    ///    the number of frames from the data avaliable
    speex_bits_reset( bits );
    /// Call speex incode n times before writing the data stream.
    for( int i =0 ; i < number_of_frames-1; i ++)
    {
        /// pack a frame
        for(int j=0; j< FRAME_SIZE; j++ )
        {
            frame[j] = data_as_floats [j+offset];
        }
        // this enoced the data
        speex_encode( encoder_state, frame , bits );
        // increase the offset
        offset+=FRAME_SIZE;
    }
    //speex_encode( encoder_state, frame , bits );
    /// write teh stream out.
    int bytes_to_write = speex_bits_nbytes( bits );
    /// transform from float to char* to write. The termination code is
acutomatically added to teh end of the stream.
    bytes_written = speex_bits_write( bits, destinantion_buffer,
bytes_to_write );
    /// return the amount of data writtne.
    printf( "bytes written %d\n" ,bytes_written );
    return bytes_written;
}
and the decode. ...
int Decode( SpeexBits *bits, char * input_bits, int data_in_length , char *
output )
{
    float  * out_put = (float *)calloc(  data_in_length,sizeof( float ) );
    int number_of_frames = data_in_length/FRAME_SIZE;
    int offset
    for( int i = 0; i< number_of_frames; i++ )
    {
        // read the bits into the byte stream struct.
        speex_bits_read_from( bits , input_bits, FRAME_SIZE );
        // decode the data.
        speex_decode( decoder_state, bits , out_put);
        for( int i = 0; i < data_in_length; i++ )
        {
            output[i+offset] = out_put[i];
        }
        offset+=FRAME_SIZE;
    }
    /// change the floats to shorts so it can be used by the sound out put.
    speex_bits_reset( bits );
}
my main  loop just caputures and sends and then recives with a wait
function/poll of the open socket.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20060802/f8d9703b/attachment.htm