liboggz  1.1.1
Typedefs | Functions
oggz_io.h File Reference

Overriding the functions used for input and output of raw data. More...

Go to the source code of this file.

Typedefs

typedef size_t(* OggzIORead )(void *user_handle, void *buf, size_t n)
 This is the signature of a function which you provide for Oggz to call when it needs to acquire raw input data. More...
 
typedef size_t(* OggzIOWrite )(void *user_handle, void *buf, size_t n)
 This is the signature of a function which you provide for Oggz to call when it needs to output raw data. More...
 
typedef int(* OggzIOSeek )(void *user_handle, long offset, int whence)
 This is the signature of a function which you provide for Oggz to call when it needs to seek on the raw input or output data. More...
 
typedef long(* OggzIOTell )(void *user_handle)
 This is the signature of a function which you provide for Oggz to call when it needs to determine the current offset of the raw input or output data. More...
 
typedef int(* OggzIOFlush )(void *user_handle)
 This is the signature of a function which you provide for Oggz to call when it needs to flush the output data. More...
 

Functions

int oggz_io_set_read (OGGZ *oggz, OggzIORead read, void *user_handle)
 Set a function for Oggz to call when it needs to read input data. More...
 
void * oggz_io_get_read_user_handle (OGGZ *oggz)
 Retrieve the user_handle associated with the function you have provided for reading input data. More...
 
int oggz_io_set_write (OGGZ *oggz, OggzIOWrite write, void *user_handle)
 Set a function for Oggz to call when it needs to write output data. More...
 
void * oggz_io_get_write_user_handle (OGGZ *oggz)
 Retrieve the user_handle associated with the function you have provided for writing output data. More...
 
int oggz_io_set_seek (OGGZ *oggz, OggzIOSeek seek, void *user_handle)
 Set a function for Oggz to call when it needs to seek on its raw data. More...
 
void * oggz_io_get_seek_user_handle (OGGZ *oggz)
 Retrieve the user_handle associated with the function you have provided for seeking on input or output data. More...
 
int oggz_io_set_tell (OGGZ *oggz, OggzIOTell tell, void *user_handle)
 Set a function for Oggz to call when it needs to determine the offset within its input data (if OGGZ_READ) or output data (if OGGZ_WRITE). More...
 
void * oggz_io_get_tell_user_handle (OGGZ *oggz)
 Retrieve the user_handle associated with the function you have provided for determining the current offset in input or output data. More...
 
int oggz_io_set_flush (OGGZ *oggz, OggzIOFlush flush, void *user_handle)
 Set a function for Oggz to call when it needs to flush its output. More...
 
void * oggz_io_get_flush_user_handle (OGGZ *oggz)
 Retrieve the user_handle associated with the function you have provided for flushing output. More...
 

Detailed Description

Overriding the functions used for input and output of raw data.

OggzIO provides a way of overriding the functions Oggz uses to access its raw input or output data. This is required in many situations where the raw stream cannot be accessed via stdio, but can be accessed by other means. This is typically useful within media frameworks, where accessing and moving around in the data is possible only using methods provided by the framework.

The functions you provide for overriding IO will be used by Oggz whenever you call oggz_read() or oggz_write(). They will also be used repeatedly by Oggz when you call oggz_seek().

Note
Opening a file with oggz_open() or oggz_open_stdio() is equivalent to calling oggz_new() and setting stdio based functions for data IO.

Typedef Documentation

typedef int(* OggzIOFlush)(void *user_handle)

This is the signature of a function which you provide for Oggz to call when it needs to flush the output data.

The behaviour of this function is similar to that of fflush() in stdio.

Parameters
user_handleA generic pointer you have provided earlier
Return values
0Success
< 0An error condition
typedef size_t(* OggzIORead)(void *user_handle, void *buf, size_t n)

This is the signature of a function which you provide for Oggz to call when it needs to acquire raw input data.

Parameters
user_handleA generic pointer you have provided earlier
nThe length in bytes that Oggz wants to read
bufThe buffer that you read data into
Return values
> 0The number of bytes successfully read into the buffer
0to indicate that there is no more data to read (End of file)
< 0An error condition
typedef int(* OggzIOSeek)(void *user_handle, long offset, int whence)

This is the signature of a function which you provide for Oggz to call when it needs to seek on the raw input or output data.

Parameters
user_handleA generic pointer you have provided earlier
offsetThe offset in bytes to seek to
whenceSEEK_SET, SEEK_CUR or SEEK_END (as for stdio.h)
Return values
>= 0The offset seeked to
< 0An error condition
Note
If you provide an OggzIOSeek function, you MUST also provide an OggzIOTell function, or else all your seeks will fail.
typedef long(* OggzIOTell)(void *user_handle)

This is the signature of a function which you provide for Oggz to call when it needs to determine the current offset of the raw input or output data.

Parameters
user_handleA generic pointer you have provided earlier
Return values
>= 0The offset
< 0An error condition
typedef size_t(* OggzIOWrite)(void *user_handle, void *buf, size_t n)

This is the signature of a function which you provide for Oggz to call when it needs to output raw data.

Parameters
user_handleA generic pointer you have provided earlier
nThe length in bytes of the data
bufA buffer containing data to write
Return values
>= 0The number of bytes successfully written (may be less than n if a write error has occurred)
< 0An error condition

Function Documentation

void* oggz_io_get_flush_user_handle ( OGGZ oggz)

Retrieve the user_handle associated with the function you have provided for flushing output.

Parameters
oggzAn OGGZ handle
Returns
the associated user_handle
void* oggz_io_get_read_user_handle ( OGGZ oggz)

Retrieve the user_handle associated with the function you have provided for reading input data.

Parameters
oggzAn OGGZ handle
Returns
the associated user_handle
void* oggz_io_get_seek_user_handle ( OGGZ oggz)

Retrieve the user_handle associated with the function you have provided for seeking on input or output data.

Parameters
oggzAn OGGZ handle
Returns
the associated user_handle
void* oggz_io_get_tell_user_handle ( OGGZ oggz)

Retrieve the user_handle associated with the function you have provided for determining the current offset in input or output data.

Parameters
oggzAn OGGZ handle
Returns
the associated user_handle
void* oggz_io_get_write_user_handle ( OGGZ oggz)

Retrieve the user_handle associated with the function you have provided for writing output data.

Parameters
oggzAn OGGZ handle
Returns
the associated user_handle
int oggz_io_set_flush ( OGGZ oggz,
OggzIOFlush  flush,
void *  user_handle 
)

Set a function for Oggz to call when it needs to flush its output.

The meaning of this is similar to that of fflush() in stdio.

Parameters
oggzAn OGGZ handle
flushYour flushing function
user_handleAny arbitrary data you wish to pass to the function
Return values
0Success
OGGZ_ERR_BAD_OGGZoggz does not refer to an existing OGGZ
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ; oggz not open for writing.
OGGZ_ERR_OUT_OF_MEMORYOut of memory
int oggz_io_set_read ( OGGZ oggz,
OggzIORead  read,
void *  user_handle 
)

Set a function for Oggz to call when it needs to read input data.

Parameters
oggzAn OGGZ handle
readYour reading function
user_handleAny arbitrary data you wish to pass to the function
Return values
0Success
OGGZ_ERR_BAD_OGGZoggz does not refer to an existing OGGZ
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ; oggz not open for reading.
OGGZ_ERR_OUT_OF_MEMORYOut of memory
int oggz_io_set_seek ( OGGZ oggz,
OggzIOSeek  seek,
void *  user_handle 
)

Set a function for Oggz to call when it needs to seek on its raw data.

Parameters
oggzAn OGGZ handle
seekYour seeking function
user_handleAny arbitrary data you wish to pass to the function
Return values
0Success
OGGZ_ERR_BAD_OGGZoggz does not refer to an existing OGGZ
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_OUT_OF_MEMORYOut of memory
Note
If you provide an OggzIOSeek function, you MUST also provide an OggzIOTell function, or else all your seeks will fail.
int oggz_io_set_tell ( OGGZ oggz,
OggzIOTell  tell,
void *  user_handle 
)

Set a function for Oggz to call when it needs to determine the offset within its input data (if OGGZ_READ) or output data (if OGGZ_WRITE).

Parameters
oggzAn OGGZ handle
tellYour tell function
user_handleAny arbitrary data you wish to pass to the function
Return values
0Success
OGGZ_ERR_BAD_OGGZoggz does not refer to an existing OGGZ
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_OUT_OF_MEMORYOut of memory
int oggz_io_set_write ( OGGZ oggz,
OggzIOWrite  write,
void *  user_handle 
)

Set a function for Oggz to call when it needs to write output data.

Parameters
oggzAn OGGZ handle
writeYour writing function
user_handleAny arbitrary data you wish to pass to the function
Return values
0Success
OGGZ_ERR_BAD_OGGZoggz does not refer to an existing OGGZ
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ; oggz not open for writing.
OGGZ_ERR_OUT_OF_MEMORYOut of memory