Chris@3: /******************************************************************** Chris@3: * * Chris@3: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * Chris@3: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * Chris@3: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * Chris@3: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * Chris@3: * * Chris@3: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * Chris@3: * by the Xiph.Org Foundation http://www.xiph.org/ * Chris@3: * * Chris@3: ******************************************************************** Chris@3: Chris@3: function: stdio-based convenience library for opening/seeking/decoding Chris@3: last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $ Chris@3: Chris@3: ********************************************************************/ Chris@3: Chris@3: #ifndef _OV_FILE_H_ Chris@3: #define _OV_FILE_H_ Chris@3: Chris@3: #ifdef __cplusplus Chris@3: extern "C" Chris@3: { Chris@3: #endif /* __cplusplus */ Chris@3: Chris@3: #include Chris@3: #include "codec.h" Chris@3: Chris@3: /* The function prototypes for the callbacks are basically the same as for Chris@3: * the stdio functions fread, fseek, fclose, ftell. Chris@3: * The one difference is that the FILE * arguments have been replaced with Chris@3: * a void * - this is to be used as a pointer to whatever internal data these Chris@3: * functions might need. In the stdio case, it's just a FILE * cast to a void * Chris@3: * Chris@3: * If you use other functions, check the docs for these functions and return Chris@3: * the right values. For seek_func(), you *MUST* return -1 if the stream is Chris@3: * unseekable Chris@3: */ Chris@3: typedef struct { Chris@3: size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); Chris@3: int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); Chris@3: int (*close_func) (void *datasource); Chris@3: long (*tell_func) (void *datasource); Chris@3: } ov_callbacks; Chris@3: Chris@3: #ifndef OV_EXCLUDE_STATIC_CALLBACKS Chris@3: Chris@3: /* a few sets of convenient callbacks, especially for use under Chris@3: * Windows where ov_open_callbacks() should always be used instead of Chris@3: * ov_open() to avoid problems with incompatible crt.o version linking Chris@3: * issues. */ Chris@3: Chris@3: static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ Chris@3: if(f==NULL)return(-1); Chris@3: Chris@3: #ifdef __MINGW32__ Chris@3: return fseeko64(f,off,whence); Chris@3: #elif defined (_WIN32) Chris@3: return _fseeki64(f,off,whence); Chris@3: #else Chris@3: return fseek(f,off,whence); Chris@3: #endif Chris@3: } Chris@3: Chris@3: /* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as Chris@3: * static data. That means that every file which includes this header Chris@3: * will get its own copy of these structs whether it uses them or Chris@3: * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS. Chris@3: * These static symbols are essential on platforms such as Windows on Chris@3: * which several different versions of stdio support may be linked to Chris@3: * by different DLLs, and we need to be certain we know which one Chris@3: * we're using (the same one as the main application). Chris@3: */ Chris@3: Chris@3: static ov_callbacks OV_CALLBACKS_DEFAULT = { Chris@3: (size_t (*)(void *, size_t, size_t, void *)) fread, Chris@3: (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, Chris@3: (int (*)(void *)) fclose, Chris@3: (long (*)(void *)) ftell Chris@3: }; Chris@3: Chris@3: static ov_callbacks OV_CALLBACKS_NOCLOSE = { Chris@3: (size_t (*)(void *, size_t, size_t, void *)) fread, Chris@3: (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, Chris@3: (int (*)(void *)) NULL, Chris@3: (long (*)(void *)) ftell Chris@3: }; Chris@3: Chris@3: static ov_callbacks OV_CALLBACKS_STREAMONLY = { Chris@3: (size_t (*)(void *, size_t, size_t, void *)) fread, Chris@3: (int (*)(void *, ogg_int64_t, int)) NULL, Chris@3: (int (*)(void *)) fclose, Chris@3: (long (*)(void *)) NULL Chris@3: }; Chris@3: Chris@3: static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { Chris@3: (size_t (*)(void *, size_t, size_t, void *)) fread, Chris@3: (int (*)(void *, ogg_int64_t, int)) NULL, Chris@3: (int (*)(void *)) NULL, Chris@3: (long (*)(void *)) NULL Chris@3: }; Chris@3: Chris@3: #endif Chris@3: Chris@3: #define NOTOPEN 0 Chris@3: #define PARTOPEN 1 Chris@3: #define OPENED 2 Chris@3: #define STREAMSET 3 Chris@3: #define INITSET 4 Chris@3: Chris@3: typedef struct OggVorbis_File { Chris@3: void *datasource; /* Pointer to a FILE *, etc. */ Chris@3: int seekable; Chris@3: ogg_int64_t offset; Chris@3: ogg_int64_t end; Chris@3: ogg_sync_state oy; Chris@3: Chris@3: /* If the FILE handle isn't seekable (eg, a pipe), only the current Chris@3: stream appears */ Chris@3: int links; Chris@3: ogg_int64_t *offsets; Chris@3: ogg_int64_t *dataoffsets; Chris@3: long *serialnos; Chris@3: ogg_int64_t *pcmlengths; /* overloaded to maintain binary Chris@3: compatibility; x2 size, stores both Chris@3: beginning and end values */ Chris@3: vorbis_info *vi; Chris@3: vorbis_comment *vc; Chris@3: Chris@3: /* Decoding working state local storage */ Chris@3: ogg_int64_t pcm_offset; Chris@3: int ready_state; Chris@3: long current_serialno; Chris@3: int current_link; Chris@3: Chris@3: double bittrack; Chris@3: double samptrack; Chris@3: Chris@3: ogg_stream_state os; /* take physical pages, weld into a logical Chris@3: stream of packets */ Chris@3: vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ Chris@3: vorbis_block vb; /* local working space for packet->PCM decode */ Chris@3: Chris@3: ov_callbacks callbacks; Chris@3: Chris@3: } OggVorbis_File; Chris@3: Chris@3: Chris@3: extern int ov_clear(OggVorbis_File *vf); Chris@3: extern int ov_fopen(const char *path,OggVorbis_File *vf); Chris@3: extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); Chris@3: extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, Chris@3: const char *initial, long ibytes, ov_callbacks callbacks); Chris@3: Chris@3: extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); Chris@3: extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, Chris@3: const char *initial, long ibytes, ov_callbacks callbacks); Chris@3: extern int ov_test_open(OggVorbis_File *vf); Chris@3: Chris@3: extern long ov_bitrate(OggVorbis_File *vf,int i); Chris@3: extern long ov_bitrate_instant(OggVorbis_File *vf); Chris@3: extern long ov_streams(OggVorbis_File *vf); Chris@3: extern long ov_seekable(OggVorbis_File *vf); Chris@3: extern long ov_serialnumber(OggVorbis_File *vf,int i); Chris@3: Chris@3: extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); Chris@3: extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); Chris@3: extern double ov_time_total(OggVorbis_File *vf,int i); Chris@3: Chris@3: extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_time_seek(OggVorbis_File *vf,double pos); Chris@3: extern int ov_time_seek_page(OggVorbis_File *vf,double pos); Chris@3: Chris@3: extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); Chris@3: extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); Chris@3: extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); Chris@3: Chris@3: extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); Chris@3: extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); Chris@3: extern double ov_time_tell(OggVorbis_File *vf); Chris@3: Chris@3: extern vorbis_info *ov_info(OggVorbis_File *vf,int link); Chris@3: extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); Chris@3: Chris@3: extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, Chris@3: int *bitstream); Chris@3: extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, Chris@3: int bigendianp,int word,int sgned,int *bitstream, Chris@3: void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); Chris@3: extern long ov_read(OggVorbis_File *vf,char *buffer,int length, Chris@3: int bigendianp,int word,int sgned,int *bitstream); Chris@3: extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); Chris@3: Chris@3: extern int ov_halfrate(OggVorbis_File *vf,int flag); Chris@3: extern int ov_halfrate_p(OggVorbis_File *vf); Chris@3: Chris@3: #ifdef __cplusplus Chris@3: } Chris@3: #endif /* __cplusplus */ Chris@3: Chris@3: #endif Chris@3: