[vorbis-dev] Reading OGG embedded in a pack file

Ken Rogoway Ken at Rogoway.com
Sat Apr 17 09:23:46 PDT 2004



I have a number of assets packed into a single file.  Some of these are OGG files.  I have code to seek to the start of an embedded file, but cannot find any OGG functions that let me start at an arbitary point in a stream.  The original code (which works) that opens a stream, then reads in the OGG data starts like this:

// Read from an already open stream.
// Assumes stream is positioned to start of OGG data
// Not a complete function, just enought to show what I am trying to do
void readFromPackfile( FILE * pStream )
{
    OggVorbis_File vf;
    ov_callbacks callbacks;
    vorbis_info *info;

    callbacks.read_func = sdl_read_func;
    callbacks.seek_func = sdl_seek_func;    // Will setting this to NULL let me read from the middle of a stream?
    callbacks.tell_func = sdl_tell_func;
    callbacks.close_func = sdl_close_func;

    if ( ov_open_callbacks( pStream, &vf, NULL, 0, callbacks)==0 )
    {
        // Valid OGG data, so do some code here to read it in...

        // Get our OGG info
        info = ov_info( &vf, -1 );
    }
}

After looking at the documentation I thought I could change the 4th parameter to be the offset into the stream for where my sub file (inside the pack file) is located.  This did not work.  It took about 10 seconds for the function to return so I am guessing it was seeking to the beginning of the stream and then scanning forward looking for the OGG headers.

There are comments about using streams that are not "seekable" and I thought this also might be a solution, but I could find nothing on how to tell Vorbis that a stream was not seekable.  Is it as simple as setting the callbacks.seek_func and callbacks.tell_func to NULL?

Does anyone have any experience reading OGG data from a already open stream which may have non-OGG data in it?

Thanks,

- Ken
 

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list