several extremely minor fixes
[platform/upstream/libvorbis.git] / include / vorbis / vorbisfile.h
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-2001             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10  *                                                                  *
11  ********************************************************************
12
13  function: stdio-based convenience library for opening/seeking/decoding
14  last mod: $Id: vorbisfile.h,v 1.16 2001/12/20 01:00:25 segher Exp $
15
16  ********************************************************************/
17
18 #ifndef _OV_FILE_H_
19 #define _OV_FILE_H_
20
21 #ifdef __cplusplus
22 extern "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  */
39 typedef 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 #define  NOTOPEN   0
47 #define  PARTOPEN  1
48 #define  OPENED    2
49 #define  STREAMSET 3
50 #define  INITSET   4
51
52 typedef struct OggVorbis_File {
53   void            *datasource; /* Pointer to a FILE *, etc. */
54   int              seekable;
55   ogg_int64_t      offset;
56   ogg_int64_t      end;
57   ogg_sync_state   oy; 
58
59   /* If the FILE handle isn't seekable (eg, a pipe), only the current
60      stream appears */
61   int              links;
62   ogg_int64_t     *offsets;
63   ogg_int64_t     *dataoffsets;
64   long            *serialnos;
65   ogg_int64_t     *pcmlengths;
66   vorbis_info     *vi;
67   vorbis_comment  *vc;
68
69   /* Decoding working state local storage */
70   ogg_int64_t      pcm_offset;
71   int              ready_state;
72   long             current_serialno;
73   int              current_link;
74
75   double           bittrack;
76   double           samptrack;
77
78   ogg_stream_state os; /* take physical pages, weld into a logical
79                           stream of packets */
80   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
81   vorbis_block     vb; /* local working space for packet->PCM decode */
82
83   ov_callbacks callbacks;
84
85 } OggVorbis_File;
86
87 extern int ov_clear(OggVorbis_File *vf);
88 extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
89 extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
90                 char *initial, long ibytes, ov_callbacks callbacks);
91
92 extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
93 extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
94                 char *initial, long ibytes, ov_callbacks callbacks);
95 extern int ov_test_open(OggVorbis_File *vf);
96
97 extern long ov_bitrate(OggVorbis_File *vf,int i);
98 extern long ov_bitrate_instant(OggVorbis_File *vf);
99 extern long ov_streams(OggVorbis_File *vf);
100 extern long ov_seekable(OggVorbis_File *vf);
101 extern long ov_serialnumber(OggVorbis_File *vf,int i);
102
103 extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
104 extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
105 extern double ov_time_total(OggVorbis_File *vf,int i);
106
107 extern int ov_raw_seek(OggVorbis_File *vf,long pos);
108 extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
109 extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
110 extern int ov_time_seek(OggVorbis_File *vf,double pos);
111 extern int ov_time_seek_page(OggVorbis_File *vf,double pos);
112
113 extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
114 extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
115 extern double ov_time_tell(OggVorbis_File *vf);
116
117 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
118 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
119
120 extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,
121                           int *bitstream);
122 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
123                     int bigendianp,int word,int sgned,int *bitstream);
124
125 #ifdef __cplusplus
126 }
127 #endif /* __cplusplus */
128
129 #endif
130
131