Main Page | Modules | File List | Globals

Using OggzMetric

Introduction

An OggzMetric is a helper function for Oggz's seeking mechanism.

If every position in an Ogg stream can be described by a metric such as time, then it is possible to define a function that, given a serialno and granulepos, returns a measurement in units such as milliseconds. Oggz will use this function repeatedly while seeking in order to navigate through the Ogg stream.

The meaning of the units is arbitrary, but must be consistent across all logical bitstreams. This allows Oggz to seek accurately through Ogg bitstreams containing multiple logical bitstreams such as tracks of media.

How to set metrics

You don't need to set metrics for Vorbis, Speex, Theora or Annodex. These can be handled automatically by Oggz.

For most others it is simply a matter of providing a linear multiplication factor (such as a sampling rate, if each packet's granulepos represents a sample number). For non-linear data streams, you will need to explicitly provide your own OggzMetric function.

Linear Metrics

Custom Metrics

For streams with non-linear granulepos, you need to set a custom metric:

Seeking with OggzMetrics

To seek, use oggz_seek_units(). Oggz will perform a ratio search through the Ogg bitstream, using the OggzMetric callback to determine its position relative to the desired unit.

Note:
Many data streams begin with headers describing such things as codec setup parameters. One of the assumptions Monty makes is:

Thus, the first action taken by applications dealing with such data is to read in and cache the decode headers; thereafter the application can safely seek to arbitrary points in the data.

This impacts seeking because the portion of the bitstream containing decode headers should not be considered part of the metric space. To inform Oggz not to seek earlier than the end of the decode headers, use oggz_set_data_start().


Generated on Fri May 21 16:55:01 2004 for liboggz by doxygen 1.3.5