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