blob: 7ebc042769a1b5e9b89302a40bc9bd46bd0d34ad [file] [log] [blame]
Gloria Wang0f6f2522010-02-04 13:58:20 -08001/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
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. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: stdio-based convenience library for opening/seeking/decoding
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 "ivorbiscodec.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
46typedef struct OggVorbis_File {
47 void *datasource; /* Pointer to a FILE *, etc. */
48 int seekable;
49 ogg_int64_t offset;
50 ogg_int64_t end;
51 ogg_sync_state *oy;
52
53 /* If the FILE handle isn't seekable (eg, a pipe), only the current
54 stream appears */
55 int links;
56 ogg_int64_t *offsets;
57 ogg_int64_t *dataoffsets;
58 ogg_uint32_t *serialnos;
59 ogg_int64_t *pcmlengths;
60 vorbis_info vi;
61 vorbis_comment vc;
62
63 /* Decoding working state local storage */
64 ogg_int64_t pcm_offset;
65 int ready_state;
66 ogg_uint32_t current_serialno;
67 int current_link;
68
69 ogg_int64_t bittrack;
70 ogg_int64_t samptrack;
71
72 ogg_stream_state *os; /* take physical pages, weld into a logical
73 stream of packets */
74 vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */
75
76 ov_callbacks callbacks;
77
78} OggVorbis_File;
79
80extern int ov_clear(OggVorbis_File *vf);
81extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
82extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
83 char *initial, long ibytes, ov_callbacks callbacks);
84
85extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
86extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
87 char *initial, long ibytes, ov_callbacks callbacks);
88extern int ov_test_open(OggVorbis_File *vf);
89
90extern long ov_bitrate(OggVorbis_File *vf,int i);
91extern long ov_bitrate_instant(OggVorbis_File *vf);
92extern long ov_streams(OggVorbis_File *vf);
93extern long ov_seekable(OggVorbis_File *vf);
94extern long ov_serialnumber(OggVorbis_File *vf,int i);
95
96extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
97extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
98extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
99
100extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
101extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
102extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
103extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
104extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
105
106extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
107extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
108extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
109
110extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
111extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
112
113extern long ov_read(OggVorbis_File *vf,void *buffer,int length,
114 int *bitstream);
115
116#ifdef __cplusplus
117}
118#endif /* __cplusplus */
119
120#endif
121
122