]> icculus.org git repositories - btb/d2x.git/blob - libmve/mvelib.h
comments/formatting/dist problems
[btb/d2x.git] / libmve / mvelib.h
1 #ifndef INCLUDED_MVELIB_H
2 #define INCLUDED_MVELIB_H
3
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 /*
8  * structure for maintaining info on a MVEFILE stream
9  */
10 typedef struct MVEFILE
11 {
12     int             stream;
13     unsigned char  *cur_chunk;
14     int             buf_size;
15     int             cur_fill;
16     int             next_segment;
17 } MVEFILE;
18
19 /*
20  * open a .MVE file
21  */
22 MVEFILE *mvefile_open(const char *filename);
23 MVEFILE *mvefile_open_filehandle(int filehandle);
24
25 /*
26  * close a .MVE file
27  */
28 void mvefile_close(MVEFILE *movie);
29 void mvefile_close_filehandle(MVEFILE *movie);
30
31 /*
32  * get size of next segment in chunk (-1 if no more segments in chunk)
33  */
34 int mvefile_get_next_segment_size(MVEFILE *movie);
35
36 /*
37  * get type of next segment in chunk (0xff if no more segments in chunk)
38  */
39 unsigned char mvefile_get_next_segment_major(MVEFILE *movie);
40
41 /*
42  * get subtype (version) of next segment in chunk (0xff if no more segments in
43  * chunk)
44  */
45 unsigned char mvefile_get_next_segment_minor(MVEFILE *movie);
46
47 /*
48  * see next segment (return NULL if no next segment)
49  */
50 unsigned char *mvefile_get_next_segment(MVEFILE *movie);
51
52 /*
53  * advance to next segment
54  */
55 void mvefile_advance_segment(MVEFILE *movie);
56
57 /*
58  * fetch the next chunk (return 0 if at end of stream)
59  */
60 int mvefile_fetch_next_chunk(MVEFILE *movie);
61
62 /*
63  * callback for segment type
64  */
65 typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context);
66
67 /*
68  * structure for maintaining an MVE stream
69  */
70 typedef struct MVESTREAM
71 {
72     MVEFILE                    *movie;
73     void                       *context;
74     MVESEGMENTHANDLER           handlers[32];
75 } MVESTREAM;
76
77 /*
78  * open an MVE stream
79  */
80 MVESTREAM *mve_open(const char *filename);
81 MVESTREAM *mve_open_filehandle(int filehandle);
82
83 /*
84  * close an MVE stream
85  */
86 void mve_close(MVESTREAM *movie);
87 void mve_close_filehandle(MVESTREAM *movie);
88
89 /*
90  * reset an MVE stream
91  */
92 void mve_reset(MVESTREAM *movie);
93
94 /*
95  * set segment type handler
96  */
97 void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler);
98
99 /*
100  * set segment handler context
101  */
102 void mve_set_handler_context(MVESTREAM *movie, void *context);
103
104 /*
105  * play next chunk
106  */
107 int mve_play_next_chunk(MVESTREAM *movie);
108
109 #endif /* INCLUDED_MVELIB_H */