Made API consistent wrt in64_t internal types and return values
[platform/upstream/libvorbis.git] / include / vorbis / vorbisfile.h
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: stdio-based convenience library for opening/seeking/decoding
15  last mod: $Id: vorbisfile.h,v 1.5 2000/06/14 10:13:35 xiphmont Exp $
16
17  ********************************************************************/
18
19 #ifndef _OV_FILE_H_
20 #define _OV_FILE_H_
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif /* __cplusplus */
26
27 #include <stdio.h>
28 #include "codec.h"
29
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 *
35  * 
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
38  * unseekable
39  */
40 typedef struct {
41   size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
42   int    (*seek_func)  (void *datasource, int64_t offset, int whence);
43   int    (*close_func) (void *datasource);
44   long   (*tell_func)  (void *datasource);
45 } ov_callbacks;
46
47
48 typedef struct {
49   void             *datasource; /* Pointer to a FILE *, etc. */
50   int              seekable;
51   int64_t          offset;
52   int64_t          end;
53   ogg_sync_state   oy; 
54
55   /* If the FILE handle isn't seekable (eg, a pipe), only the current
56      stream appears */
57   int              links;
58   int64_t          *offsets;
59   int64_t          *dataoffsets;
60   long             *serialnos;
61   int64_t          *pcmlengths;
62   vorbis_info      *vi;
63   vorbis_comment   *vc;
64
65   /* Decoding working state local storage */
66   int64_t          pcm_offset;
67   int              decode_ready;
68   long             current_serialno;
69   int              current_link;
70
71   ogg_stream_state os; /* take physical pages, weld into a logical
72                           stream of packets */
73   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
74   vorbis_block     vb; /* local working space for packet->PCM decode */
75
76   ov_callbacks callbacks;
77
78 } OggVorbis_File;
79
80 extern int ov_clear(OggVorbis_File *vf);
81 extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
82 extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
83                 char *initial, long ibytes, ov_callbacks callbacks);
84
85 extern long ov_bitrate(OggVorbis_File *vf,int i);
86 extern long ov_streams(OggVorbis_File *vf);
87 extern long ov_seekable(OggVorbis_File *vf);
88 extern long ov_serialnumber(OggVorbis_File *vf,int i);
89
90 extern int64_t ov_raw_total(OggVorbis_File *vf,int i);
91 extern int64_t ov_pcm_total(OggVorbis_File *vf,int i);
92 extern double ov_time_total(OggVorbis_File *vf,int i);
93
94 extern int ov_raw_seek(OggVorbis_File *vf,long pos);
95 extern int ov_pcm_seek(OggVorbis_File *vf,int64_t pos);
96 extern int ov_time_seek(OggVorbis_File *vf,double pos);
97
98 extern int64_t ov_raw_tell(OggVorbis_File *vf);
99 extern int64_t ov_pcm_tell(OggVorbis_File *vf);
100 extern double ov_time_tell(OggVorbis_File *vf);
101
102 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
103 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
104
105 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
106                     int bigendianp,int word,int sgned,int *bitstream);
107
108 #ifdef __cplusplus
109 }
110 #endif /* __cplusplus */
111
112 #endif
113
114