Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 pmbaty 1
/*
2
    SMPEG - SDL MPEG Player Library
3
    Copyright (C) 1999  Loki Entertainment Software
4
 
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Library General Public
7
    License as published by the Free Software Foundation; either
8
    version 2 of the License, or (at your option) any later version.
9
 
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Library General Public License for more details.
14
 
15
    You should have received a copy of the GNU Library General Public
16
    License along with this library; if not, write to the Free
17
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*/
19
 
20
/* This is the C interface to the SMPEG library */
21
 
22
#ifndef _SMPEG_H_
23
#define _SMPEG_H_
24
 
25
#include "SDL.h"
26
#include "SDL_mutex.h"
27
#include "SDL_audio.h"
28
 
29
#include "MPEGfilter.h"
30
 
31
#ifdef __cplusplus
32
extern "C" {
33
#endif
34
 
35
#define SMPEG_MAJOR_VERSION      0
36
#define SMPEG_MINOR_VERSION      4
37
#define SMPEG_PATCHLEVEL         5
38
 
39
typedef struct {
40
        Uint8 major;
41
        Uint8 minor;
42
        Uint8 patch;
43
} SMPEG_version;
44
 
45
/* This macro can be used to fill a version structure with the compile-time
46
 * version of the SDL library.
47
 */
48
#define SMPEG_VERSION(X)                                                \
49
{                                                                       \
50
        (X)->major = SMPEG_MAJOR_VERSION;                               \
51
        (X)->minor = SMPEG_MINOR_VERSION;                               \
52
        (X)->patch = SMPEG_PATCHLEVEL;                                  \
53
}
54
 
55
/* This is the actual SMPEG object */
56
typedef struct _SMPEG SMPEG;
57
 
58
/* Used to get information about the SMPEG object */
59
typedef struct _SMPEG_Info {
60
    int has_audio;
61
    int has_video;
62
    int width;
63
    int height;
64
    int current_frame;
65
    double current_fps;
66
    char audio_string[80];
67
    int  audio_current_frame;
68
    Uint32 current_offset;
69
    Uint32 total_size;
70
    double current_time;
71
    double total_time;
72
} SMPEG_Info;
73
 
74
/* Possible MPEG status codes */
75
typedef enum {
76
    SMPEG_ERROR = -1,
77
    SMPEG_STOPPED,
78
    SMPEG_PLAYING
79
} SMPEGstatus;
80
 
81
 
82
/* Matches the declaration of SDL_UpdateRect() */
83
typedef void(*SMPEG_DisplayCallback)(SDL_Surface* dst, int x, int y,
84
                                     unsigned int w, unsigned int h);
85
 
86
/* Create a new SMPEG object from an MPEG file.
87
   On return, if 'info' is not NULL, it will be filled with information
88
   about the MPEG object.
89
   This function returns a new SMPEG object.  Use SMPEG_error() to find out
90
   whether or not there was a problem building the MPEG stream.
91
   The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
92
   subsystem. If not, you will have to use the SMPEG_playaudio() function below
93
   to extract the decoded data.
94
 */
95
extern DECLSPEC SMPEG* SMPEG_new(const char *file, SMPEG_Info* info, int sdl_audio);
96
 
97
/* The same as above for a file descriptor */
98
extern DECLSPEC SMPEG* SMPEG_new_descr(int file, SMPEG_Info* info, int sdl_audio);
99
 
100
/*
101
   The same as above but for a raw chunk of data.  SMPEG makes a copy of the
102
   data, so the application is free to delete after a successful call to this
103
   function.
104
 */
105
extern DECLSPEC SMPEG* SMPEG_new_data(void *data, int size, SMPEG_Info* info, int sdl_audio);
106
 
107
/* The same for a generic SDL_RWops structure. */
108
extern DECLSPEC SMPEG* SMPEG_new_rwops(SDL_RWops *src, SMPEG_Info* info, int sdl_audio);
109
 
110
/* Get current information about an SMPEG object */
111
extern DECLSPEC void SMPEG_getinfo( SMPEG* mpeg, SMPEG_Info* info );
112
 
113
/* Enable or disable audio playback in MPEG stream */
114
extern DECLSPEC void SMPEG_enableaudio( SMPEG* mpeg, int enable );
115
 
116
/* Enable or disable video playback in MPEG stream */
117
extern DECLSPEC void SMPEG_enablevideo( SMPEG* mpeg, int enable );
118
 
119
/* Delete an SMPEG object */
120
extern DECLSPEC void SMPEG_delete( SMPEG* mpeg );
121
 
122
/* Get the current status of an SMPEG object */
123
extern DECLSPEC SMPEGstatus SMPEG_status( SMPEG* mpeg );
124
 
125
/* Set the audio volume of an MPEG stream, in the range 0-100 */
126
extern DECLSPEC void SMPEG_setvolume( SMPEG* mpeg, int volume );
127
 
128
/* Set the destination surface for MPEG video playback
129
   'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
130
   'callback' is a function called when an area of 'dst' needs to be updated.
131
   If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
132
*/
133
extern DECLSPEC void SMPEG_setdisplay(SMPEG* mpeg, SDL_Surface* dst, SDL_mutex* surfLock,
134
                                            SMPEG_DisplayCallback callback);
135
 
136
/* Set or clear looping play on an SMPEG object */
137
extern DECLSPEC void SMPEG_loop( SMPEG* mpeg, int repeat );
138
 
139
/* Scale pixel display on an SMPEG object */
140
extern DECLSPEC void SMPEG_scaleXY( SMPEG* mpeg, int width, int height );
141
extern DECLSPEC void SMPEG_scale( SMPEG* mpeg, int scale );
142
/* */
143
#define SMPEG_double(mpeg, on) \
144
        SMPEG_scale(mpeg, (on) ? 2 : 1)
145
 
146
/* Move the video display area within the destination surface */
147
extern DECLSPEC void SMPEG_move( SMPEG* mpeg, int x, int y );
148
 
149
/* Set the region of the video to be shown */
150
extern DECLSPEC void SMPEG_setdisplayregion(SMPEG* mpeg, int x, int y, int w, int h);
151
 
152
/* Play an SMPEG object */
153
extern DECLSPEC void SMPEG_play( SMPEG* mpeg );
154
 
155
/* Pause/Resume playback of an SMPEG object */
156
extern DECLSPEC void SMPEG_pause( SMPEG* mpeg );
157
 
158
/* Stop playback of an SMPEG object */
159
extern DECLSPEC void SMPEG_stop( SMPEG* mpeg );
160
 
161
/* Rewind the play position of an SMPEG object to the beginning of the MPEG */
162
extern DECLSPEC void SMPEG_rewind( SMPEG* mpeg );
163
 
164
/* Seek 'bytes' bytes in the MPEG stream */
165
extern DECLSPEC void SMPEG_seek( SMPEG* mpeg, int bytes);
166
 
167
/* Skip 'seconds' seconds in the MPEG stream */
168
extern DECLSPEC void SMPEG_skip( SMPEG* mpeg, float seconds );
169
 
170
/* Render a particular frame in the MPEG video
171
   API CHANGE: This function no longer takes a target surface and position.
172
               Use SMPEG_setdisplay() and SMPEG_move() to set this information.
173
*/
174
extern DECLSPEC void SMPEG_renderFrame( SMPEG* mpeg, int framenum );
175
 
176
/* Render the last frame of an MPEG video */
177
extern DECLSPEC void SMPEG_renderFinal( SMPEG* mpeg, SDL_Surface* dst, int x, int y );
178
 
179
/* Set video filter */
180
extern DECLSPEC SMPEG_Filter * SMPEG_filter( SMPEG* mpeg, SMPEG_Filter * filter );
181
 
182
/* Return NULL if there is no error in the MPEG stream, or an error message
183
   if there was a fatal error in the MPEG stream for the SMPEG object.
184
*/
185
extern DECLSPEC char *SMPEG_error( SMPEG* mpeg );
186
 
187
/* Exported callback function for audio playback.
188
   The function takes a buffer and the amount of data to fill, and returns
189
   the amount of data in bytes that was actually written.  This will be the
190
   amount requested unless the MPEG audio has finished.
191
*/
192
extern DECLSPEC int SMPEG_playAudio( SMPEG *mpeg, Uint8 *stream, int len );
193
 
194
/* Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
195
*/
196
extern DECLSPEC void SMPEG_playAudioSDL( void *mpeg, Uint8 *stream, int len );
197
 
198
/* Get the best SDL audio spec for the audio stream */
199
extern DECLSPEC int SMPEG_wantedSpec( SMPEG *mpeg, SDL_AudioSpec *wanted );
200
 
201
/* Inform SMPEG of the actual SDL audio spec used for sound playback */
202
extern DECLSPEC void SMPEG_actualSpec( SMPEG *mpeg, SDL_AudioSpec *spec );
203
 
204
#ifdef __cplusplus
205
}
206
#endif
207
#endif /* _SMPEG_H_ */