1
/********************************************************************
3
* THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
5
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
9
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
12
********************************************************************
14
function: stdio-based convenience library for opening/seeking/decoding
16
********************************************************************/
24
#endif /* __cplusplus */
27
#include "ivorbiscodec.h"
29
#define CHUNKSIZE 1024
30
/* The function prototypes for the callbacks are basically the same as for
31
* the stdio functions fread, fseek, fclose, ftell.
32
* The one difference is that the FILE * arguments have been replaced with
33
* a void * - this is to be used as a pointer to whatever internal data these
34
* functions might need. In the stdio case, it's just a FILE * cast to a void *
36
* If you use other functions, check the docs for these functions and return
37
* the right values. For seek_func(), you *MUST* return -1 if the stream is
41
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
42
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
43
int (*close_func) (void *datasource);
44
long (*tell_func) (void *datasource);
53
typedef struct OggVorbis_File {
54
void *datasource; /* Pointer to a FILE *, etc. */
60
/* If the FILE handle isn't seekable (eg, a pipe), only the current
64
ogg_int64_t *dataoffsets;
65
ogg_uint32_t *serialnos;
66
ogg_int64_t *pcmlengths;
70
/* Decoding working state local storage */
71
ogg_int64_t pcm_offset;
73
ogg_uint32_t current_serialno;
77
ogg_int64_t samptrack;
79
ogg_stream_state *os; /* take physical pages, weld into a logical
81
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
82
vorbis_block vb; /* local working space for packet->PCM decode */
84
ov_callbacks callbacks;
88
extern int ov_clear(OggVorbis_File *vf);
89
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
90
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
91
char *initial, long ibytes, ov_callbacks callbacks);
93
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
94
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
95
char *initial, long ibytes, ov_callbacks callbacks);
96
extern int ov_test_open(OggVorbis_File *vf);
98
extern long ov_bitrate(OggVorbis_File *vf,int i);
99
extern long ov_bitrate_instant(OggVorbis_File *vf);
100
extern long ov_streams(OggVorbis_File *vf);
101
extern long ov_seekable(OggVorbis_File *vf);
102
extern long ov_serialnumber(OggVorbis_File *vf,int i);
104
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
105
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
106
extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
108
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
109
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
110
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
111
extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
112
extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
114
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
115
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
116
extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
118
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
119
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
121
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
126
#endif /* __cplusplus */