libannodex  0.7.3
Typedefs | Functions
anx_read.h File Reference
#include <annodex/anx_types.h>

Go to the source code of this file.

Typedefs

typedef int(* AnxReadStream) (ANNODEX *annodex, double timebase, char *utc, void *user_data)
 Signature for a callback called when the 'Annodex' stream header is parsed. More...
 
typedef int(* AnxReadTrack) (ANNODEX *annodex, long serialno, char *id, char *content_type, anx_int64_t granule_rate_n, anx_int64_t granule_rate_d, int nr_header_packets, void *user_data)
 Signature for a callback called each time an 'AnxData' track header is parsed. More...
 
typedef int(* AnxReadHead) (ANNODEX *annodex, const AnxHead *head, void *user_data)
 Signature for a callback called when the head element is parsed. More...
 
typedef int(* AnxReadClip) (ANNODEX *annodex, const AnxClip *clip, void *user_data)
 Signature for a callback called each time a clip element is parsed. More...
 
typedef int(* AnxReadRaw) (ANNODEX *annodex, unsigned char *data, long n, long serialno, anx_int64_t granulepos, void *user_data)
 Signature for a callback called each time a raw data packet is found. More...
 

Functions

int anx_set_read_stream_callback (ANNODEX *annodex, AnxReadStream read_stream, void *user_data)
 Set the function to call each time an 'Annodex' stream header is parsed. More...
 
void * anx_get_read_stream_user_data (ANNODEX *annodex)
 Retrieve the user_data associated with an attached AnxReadStream callback. More...
 
int anx_set_read_track_callback (ANNODEX *annodex, AnxReadTrack read_track, void *user_data)
 Set the function to call each time an 'AnxData' track header is parsed. More...
 
void * anx_get_read_track_user_data (ANNODEX *annodex)
 Retrieve the user_data associated with an attached AnxReadTrack callback. More...
 
int anx_set_read_head_callback (ANNODEX *annodex, AnxReadHead read_head, void *user_data)
 Set the function to call when the head element is read. More...
 
void * anx_get_read_head_user_data (ANNODEX *annodex)
 Retrieve the user_data associated with an attached AnxReadHead callback. More...
 
int anx_set_read_clip_callback (ANNODEX *annodex, AnxReadClip read_clip, void *user_data)
 Set the function to call each time a clip is parsed. More...
 
void * anx_get_read_clip_user_data (ANNODEX *annodex)
 Retrieve the user_data associated with an attached AnxReadClip callback. More...
 
int anx_set_read_raw_callback (ANNODEX *annodex, AnxReadRaw read_raw, void *user_data)
 Set the function to call each time a raw data packet is read. More...
 
void * anx_get_read_raw_user_data (ANNODEX *annodex)
 Retrieve the user_data associated with an attached AnxReadRaw callback. More...
 
long anx_read (ANNODEX *annodex, long n)
 Read from an annodex opened with anx_open() or anx_open_stdio(). More...
 
long anx_read_input (ANNODEX *annodex, unsigned char *buf, long n)
 Input data from a memory buffer into an annodex. More...
 

Detailed Description

libannodex provides a convenient callback based framework for reading Annodex media. After opening an annodex for reading, you can attach various callbacks relevant to the parts of the file you are interested in, including the stream header, track headers, head element, clips and media data. Then, as bytes are read, libannodex will call your callbacks as appropriate.

For tutorial information and examples, refer to the following:

Typedef Documentation

◆ AnxReadClip

typedef int(* AnxReadClip) (ANNODEX *annodex, const AnxClip *clip, void *user_data)

Signature for a callback called each time a clip element is parsed.

Parameters
annodexthe ANNODEX* handle in use
clipthe clip element
user_dataA generic pointer you have provided earlier
Returns
  • ANX_CONTINUE on success, and to inform anx_read*() functions to continue on to the next packet
  • ANX_STOP_OK on success, to inform anx_read*() functions to return without further processing
  • ANX_STOP_ERR on error, to inform anx_read*() functions to return without further processing

◆ AnxReadHead

typedef int(* AnxReadHead) (ANNODEX *annodex, const AnxHead *head, void *user_data)

Signature for a callback called when the head element is parsed.

Parameters
annodexthe ANNODEX* handle in use
headthe head element
user_dataA generic pointer you have provided earlier
Returns
  • ANX_CONTINUE on success, and to inform anx_read*() functions to continue on to the next packet
  • ANX_STOP_OK on success, to inform anx_read*() functions to return without further processing
  • ANX_STOP_ERR on error, to inform anx_read*() functions to return without further processing

◆ AnxReadRaw

typedef int(* AnxReadRaw) (ANNODEX *annodex, unsigned char *data, long n, long serialno, anx_int64_t granulepos, void *user_data)

Signature for a callback called each time a raw data packet is found.

Parameters
annodexthe ANNODEX* handle in use
dataa pointer to the data read from the packet
nthe length in bytes of the data
serialnothe track serial number of the packet
granuleposthe granule position of the packet
user_dataA generic pointer you have provided earlier
Returns
  • ANX_CONTINUE on success, and to inform anx_read*() functions to continue on to the next packet
  • ANX_STOP_OK on success, to inform anx_read*() functions to return without further processing
  • ANX_STOP_ERR on error, to inform anx_read*() functions to return without further processing

◆ AnxReadStream

typedef int(* AnxReadStream) (ANNODEX *annodex, double timebase, char *utc, void *user_data)

Signature for a callback called when the 'Annodex' stream header is parsed.

Parameters
annodexthe ANNODEX* handle in use
timebasethe timebase of the annodex
utcthe UTC timebase of the annodex
user_dataA generic pointer you have provided earlier
Returns
  • ANX_CONTINUE on success, and to inform anx_read*() functions to continue on to the next packet
  • ANX_STOP_OK on success, to inform anx_read*() functions to return without further processing
  • ANX_STOP_ERR on error, to inform anx_read*() functions to return without further processing

◆ AnxReadTrack

typedef int(* AnxReadTrack) (ANNODEX *annodex, long serialno, char *id, char *content_type, anx_int64_t granule_rate_n, anx_int64_t granule_rate_d, int nr_header_packets, void *user_data)

Signature for a callback called each time an 'AnxData' track header is parsed.

Parameters
annodexthe ANNODEX* handle in use
serialnothe track serial number
idthe id attribute of the track
content_typethe content type of the track
granule_rate_nthe numerator of the granule rate
granule_rate_dthe denominator of the granule rate
nr_header_packetsthe number of header packets of the track
user_dataA generic pointer you have provided earlier
Returns
  • ANX_CONTINUE on success, and to inform anx_read*() functions to continue on to the next packet
  • ANX_STOP_OK on success, to inform anx_read*() functions to return without further processing
  • ANX_STOP_ERR on error, to inform anx_read*() functions to return without further processing

Function Documentation

◆ anx_get_read_clip_user_data()

void* anx_get_read_clip_user_data ( ANNODEX annodex)

Retrieve the user_data associated with an attached AnxReadClip callback.

Parameters
annodexan ANNODEX* handle
Returns
the associated user_data

◆ anx_get_read_head_user_data()

void* anx_get_read_head_user_data ( ANNODEX annodex)

Retrieve the user_data associated with an attached AnxReadHead callback.

Parameters
annodexan ANNODEX* handle
Returns
the associated user_data

◆ anx_get_read_raw_user_data()

void* anx_get_read_raw_user_data ( ANNODEX annodex)

Retrieve the user_data associated with an attached AnxReadRaw callback.

Parameters
annodexan ANNODEX* handle
Returns
the associated user_data

◆ anx_get_read_stream_user_data()

void* anx_get_read_stream_user_data ( ANNODEX annodex)

Retrieve the user_data associated with an attached AnxReadStream callback.

Parameters
annodexan ANNODEX* handle
Returns
the associated user_data

◆ anx_get_read_track_user_data()

void* anx_get_read_track_user_data ( ANNODEX annodex)

Retrieve the user_data associated with an attached AnxReadTrack callback.

Parameters
annodexan ANNODEX* handle
Returns
the associated user_data

◆ anx_read()

long anx_read ( ANNODEX annodex,
long  n 
)

Read from an annodex opened with anx_open() or anx_open_stdio().

The annodex is automatically parsed and relevant read callbacks are called, stopping when the required number of bytes have been read, or earlier if any of the read callbacks returned other than ANX_CONTINUE.

Parameters
annodexan ANNODEX* handle
ncount of bytes to read
Returns
the count of bytes actually read

◆ anx_read_input()

long anx_read_input ( ANNODEX annodex,
unsigned char *  buf,
long  n 
)

Input data from a memory buffer into an annodex.

Usually the annodex would have been created with anx_new(). The annodex is automatically parsed and relevant read callbacks are called, stopping when the required number of bytes have been read, or earlier if any of the read callbacks returned other than ANX_CONTINUE.

Parameters
annodexan ANNODEX* handle
bufa memory buffer containing data to input
ncount of bytes to input
Returns
the count of bytes actually input

◆ anx_set_read_clip_callback()

int anx_set_read_clip_callback ( ANNODEX annodex,
AnxReadClip  read_clip,
void *  user_data 
)

Set the function to call each time a clip is parsed.

Parameters
annodexan ANNODEX* handle
read_clipthe callback to call
user_dataArbitrary data you wish to pass to your callback
Returns
0 on success

◆ anx_set_read_head_callback()

int anx_set_read_head_callback ( ANNODEX annodex,
AnxReadHead  read_head,
void *  user_data 
)

Set the function to call when the head element is read.

Parameters
annodexan ANNODEX* handle
read_headthe callback to call
user_dataArbitrary data you wish to pass to your callback
Returns
0 on success, -1 on failure

◆ anx_set_read_raw_callback()

int anx_set_read_raw_callback ( ANNODEX annodex,
AnxReadRaw  read_raw,
void *  user_data 
)

Set the function to call each time a raw data packet is read.

Parameters
annodexan ANNODEX* handle
read_rawthe callback to call
user_dataArbitrary data you wish to pass to your callback
Returns
0 on success, -1 on failure

◆ anx_set_read_stream_callback()

int anx_set_read_stream_callback ( ANNODEX annodex,
AnxReadStream  read_stream,
void *  user_data 
)

Set the function to call each time an 'Annodex' stream header is parsed.

Parameters
annodexan ANNODEX* handle
read_streamthe callback to call
user_dataArbitrary data you wish to pass to your callback
Returns
0 on success, -1 on failure

◆ anx_set_read_track_callback()

int anx_set_read_track_callback ( ANNODEX annodex,
AnxReadTrack  read_track,
void *  user_data 
)

Set the function to call each time an 'AnxData' track header is parsed.

Parameters
annodexan ANNODEX* handle
read_trackthe callback to call
user_dataArbitrary data you wish to pass to your callback
Returns
0 on success, -1 on failure