Tremor documentation

Tremor version 1.0 - 20020403

ov_open_callbacks

declared in "ivorbisfile.h";

This is an alternative function used to open and initialize an OggVorbis_File structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structure.

Once this has been called, the same OggVorbis_File struct should be passed to all the libvorbisidec functions.

It is often useful to call ov_open_callbacks() simply to determine whether a given file is a vorbis bitstream. If the ov_open_callbacks() call fails, then the file is not recognizable as such. When you use ov_open_callbacks() for this, you should fclose() the file pointer if, and only if, the ov_open_callbacks() call fails. If it succeeds, you must call ov_clear() to clear the decoder's buffers and close the file for you.

See also Callbacks and Non-stdio I/O for information on designing and specifying the required callback functions.




int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);

Parameters

f
File pointer to an already opened file or pipe (it need not be seekable--though this obviously restricts what can be done with the bitstream).
vf
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec functions. Once this has been called, the same OggVorbis_File struct should be passed to all the libvorbisidec functions.
initial
Typically set to NULL. This parameter is useful if some data has already been read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial should be a pointer to a buffer containing the data read.
ibytes
Typically set to 0. This parameter is useful if some data has already been read from the file and the stream is not seekable. In this case, ibytes should contain the length (in bytes) of the buffer. Used together with initial.
callbacks
Pointer to a completed ov_callbacks struct which indicates desired custom file manipulation routines.

Return Values

  • 0 for success
  • less than zero for failure:
  • Notes

    If your decoder is threaded, it is recommended that you NOT call ov_open_callbacks() in the main control thread--instead, call ov_open_callbacks() IN your decode/playback thread. This is important because ov_open_callbacks() may be a fairly time-consuming call, given that the full structure of the file is determined at this point, which may require reading large parts of the file under certain circumstances (determining all the logical bitstreams in one physical bitstream, for example). See Thread Safety for other information on using libvorbisidec with threads.


    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403