Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/libvorbis-1.2.0/include/vorbis/vorbisfile.h @ 16

Last change on this file since 16 was 16, checked in by landauf, 16 years ago

added libvorbis

File size: 6.8 KB
Line 
1/********************************************************************
2 *                                                                  *
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7 *                                                                  *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
9 * by the Xiph.Org Foundation http://www.xiph.org/                  *
10 *                                                                  *
11 ********************************************************************
12
13 function: stdio-based convenience library for opening/seeking/decoding
14 last mod: $Id: vorbisfile.h 13293 2007-07-24 00:09:47Z xiphmont $
15
16 ********************************************************************/
17
18#ifndef _OV_FILE_H_
19#define _OV_FILE_H_
20
21#ifdef __cplusplus
22extern "C"
23{
24#endif /* __cplusplus */
25
26#include <stdio.h>
27#include "codec.h"
28
29/* The function prototypes for the callbacks are basically the same as for
30 * the stdio functions fread, fseek, fclose, ftell.
31 * The one difference is that the FILE * arguments have been replaced with
32 * a void * - this is to be used as a pointer to whatever internal data these
33 * functions might need. In the stdio case, it's just a FILE * cast to a void *
34 *
35 * If you use other functions, check the docs for these functions and return
36 * the right values. For seek_func(), you *MUST* return -1 if the stream is
37 * unseekable
38 */
39typedef struct {
40  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
41  int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
42  int    (*close_func) (void *datasource);
43  long   (*tell_func)  (void *datasource);
44} ov_callbacks;
45
46/* a few sets of convenient callbacks, especially for use under
47 * Windows where ov_open_callbacks() should always be used instead of
48 * ov_open() to avoid problems with incompatable crt.o version linking
49 * issues. */
50
51static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
52  if(f==NULL)return(-1);
53  return fseek(f,off,whence);
54}
55
56static ov_callbacks OV_CALLBACKS_DEFAULT = {
57  (size_t (*)(void *, size_t, size_t, void *))  fread,
58  (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
59  (int (*)(void *))                             fclose,
60  (long (*)(void *))                            ftell
61};
62
63static ov_callbacks OV_CALLBACKS_NOCLOSE = {
64  (size_t (*)(void *, size_t, size_t, void *))  fread,
65  (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
66  (int (*)(void *))                             NULL,
67  (long (*)(void *))                            ftell
68};
69
70static ov_callbacks OV_CALLBACKS_STREAMONLY = {
71  (size_t (*)(void *, size_t, size_t, void *))  fread,
72  (int (*)(void *, ogg_int64_t, int))           NULL,
73  (int (*)(void *))                             fclose,
74  (long (*)(void *))                            NULL
75};
76
77static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {
78  (size_t (*)(void *, size_t, size_t, void *))  fread,
79  (int (*)(void *, ogg_int64_t, int))           NULL,
80  (int (*)(void *))                             NULL,
81  (long (*)(void *))                            NULL
82};
83
84#define  NOTOPEN   0
85#define  PARTOPEN  1
86#define  OPENED    2
87#define  STREAMSET 3
88#define  INITSET   4
89
90typedef struct OggVorbis_File {
91  void            *datasource; /* Pointer to a FILE *, etc. */
92  int              seekable;
93  ogg_int64_t      offset;
94  ogg_int64_t      end;
95  ogg_sync_state   oy;
96
97  /* If the FILE handle isn't seekable (eg, a pipe), only the current
98     stream appears */
99  int              links;
100  ogg_int64_t     *offsets;
101  ogg_int64_t     *dataoffsets;
102  long            *serialnos;
103  ogg_int64_t     *pcmlengths; /* overloaded to maintain binary
104                                  compatability; x2 size, stores both
105                                  beginning and end values */
106  vorbis_info     *vi;
107  vorbis_comment  *vc;
108
109  /* Decoding working state local storage */
110  ogg_int64_t      pcm_offset;
111  int              ready_state;
112  long             current_serialno;
113  int              current_link;
114
115  double           bittrack;
116  double           samptrack;
117
118  ogg_stream_state os; /* take physical pages, weld into a logical
119                          stream of packets */
120  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
121  vorbis_block     vb; /* local working space for packet->PCM decode */
122
123  ov_callbacks callbacks;
124
125} OggVorbis_File;
126
127
128extern int ov_clear(OggVorbis_File *vf);
129extern int ov_fopen(char *path,OggVorbis_File *vf);
130extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
131extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
132                char *initial, long ibytes, ov_callbacks callbacks);
133
134extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
135extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
136                char *initial, long ibytes, ov_callbacks callbacks);
137extern int ov_test_open(OggVorbis_File *vf);
138
139extern long ov_bitrate(OggVorbis_File *vf,int i);
140extern long ov_bitrate_instant(OggVorbis_File *vf);
141extern long ov_streams(OggVorbis_File *vf);
142extern long ov_seekable(OggVorbis_File *vf);
143extern long ov_serialnumber(OggVorbis_File *vf,int i);
144
145extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
146extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
147extern double ov_time_total(OggVorbis_File *vf,int i);
148
149extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
150extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
151extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
152extern int ov_time_seek(OggVorbis_File *vf,double pos);
153extern int ov_time_seek_page(OggVorbis_File *vf,double pos);
154
155extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
156extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
157extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);
158extern int ov_time_seek_lap(OggVorbis_File *vf,double pos);
159extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos);
160
161extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
162extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
163extern double ov_time_tell(OggVorbis_File *vf);
164
165extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
166extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
167
168extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,
169                          int *bitstream);
170extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
171                    int bigendianp,int word,int sgned,int *bitstream);
172extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);
173
174extern int ov_halfrate(OggVorbis_File *vf,int flag);
175extern int ov_halfrate_p(OggVorbis_File *vf);
176
177#ifdef __cplusplus
178}
179#endif /* __cplusplus */
180
181#endif
182
183
Note: See TracBrowser for help on using the repository browser.