Vorbisfile documentation

vorbisfile version 1.2.0 - 20070723

ov_open

declared in "vorbis/vorbisfile.h";

ov_open is one of three initialization functions used to initialize an OggVorbis_File structure and prepare a bitstream for playback.

WARNING for Windows developers: Do not use ov_open() in Windows applications; Windows linking places restrictions on passing FILE * handles successfully, and ov_open() runs afoul of these restrictions [a]. See the ov_open_callbacks() page for details on using ov_open_callbacks() instead.

The first argument must be a 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 should be a pointer to the OggVorbis_File structure -- this is used for ALL the externally visible libvorbisfile functions. Once this has been called, the same OggVorbis_File struct should be passed to all the libvorbisfile functions.

The vf structure initialized using ov_fopen() must eventually be cleaned using ov_clear(). Once a FILE * handle is passed to ov_open() successfully, the application MUS>lor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">

Vorbisfile documentation

vorbisfile version 1.2.0 - 20070723

ov_time_seek_page

declared in "vorbis/vorbisfile.h";

For seekable streams, this seeks to closest full page preceding the given time. This function is faster than ov_time_seek because it doesn't seek through the last few samples to reach an exact time, but it is also less accurate. This should be used when speed is important.

This function also updates everything needed within the decoder, so you can immediately call ov_read() and get data from the newly seeked to position.

This function does not work for unseekable streams.


int ov_time_seek_page(OggVorbis_File *vf, double s);

Parameters

vf
Pointer to our already opened and initialized OggVorbis_File structure.
ms
Location to seek to within the file, specified in seconds.

Return Values




copyright © 2007 Xiph.org

Ogg Vorbis

Vorbisfile documentation

vorbisfile version 1.2.0 - 20070723

./usr/share/doc/libvorbis-dev/html/vorbisfile/example.html0000644000000000000000000001242211044155477022602 0ustar rootroot Vorbisfile - Example Code

Vorbisfile documentation

vorbisfile version 1.2.0 - 20070723

Decoding Example Code

The following is a run-through of the decoding example program supplied with libvorbisfile, vorbisfile_example.c. This program takes a vorbis bitstream from stdin and writes raw pcm to stdout.

First, relevant headers, including vorbis-specific "vorbis/codec.h" and "vorbisfile.h" have to be included.


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "vorbis/codec.h"
#include "vorbisfile.h"

We also have to make a concession to Windows users here. If we are using windows for decoding, we must declare these libraries so that we can set stdin/stdout to binary.


#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#endif

Next, a buffer for the pcm audio output is declared.


char pcmout[4096];

Inside main(), we declare our primary OggVorbis_File structure. We also declare a few other helpful variables to track out progress within the file. Also, we make our final concession to Windows users by setting the stdin and stdout to binary mode.


int main(int argc, char **argv){
  OggVorbis_File vf;
  int eof=0;
  int current_section;

#ifdef _WIN32
  _setmode( _fileno( stdin ), _O_BINARY );
  _setmode( _fileno( stdout ), _O_BINARY );
#endif

We call ov_open_callbacks() to initialize the OggVorbis_File structure with default values. ov_open_callbacks() also checks to ensure that we're reading Vorbis format and not something else. The OV_CALLBACKS_NOCLOSE callbacks instruct libvorbisfile not to close stdin later during cleanup.


  if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
      exit(1);
  }

</