]> git.r.bdr.sh - rbdr/super-polarity/blob - vendor/frameworks/SDL2_mixer.framework/Versions/A/Frameworks/smpeg2.framework/Versions/A/Headers/smpeg.h
6bc2dbdc0d17eafa1fe6b1d6c6e7b113d11feca0
[rbdr/super-polarity] / vendor / frameworks / SDL2_mixer.framework / Versions / A / Frameworks / smpeg2.framework / Versions / A / Headers / smpeg.h
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 #include "MPEGframe.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #define SMPEG_MAJOR_VERSION 2
35 #define SMPEG_MINOR_VERSION 0
36 #define SMPEG_PATCHLEVEL 0
37
38 typedef struct {
39 Uint8 major;
40 Uint8 minor;
41 Uint8 patch;
42 } SMPEG_version;
43
44 /* This macro can be used to fill a version structure with the compile-time
45 * version of the SDL library.
46 */
47 #define SMPEG_VERSION(X) \
48 { \
49 (X)->major = SMPEG_MAJOR_VERSION; \
50 (X)->minor = SMPEG_MINOR_VERSION; \
51 (X)->patch = SMPEG_PATCHLEVEL; \
52 }
53
54 /* This is the actual SMPEG object */
55 typedef struct _SMPEG SMPEG;
56
57 /* Used to get information about the SMPEG object */
58 typedef struct _SMPEG_Info {
59 int has_audio;
60 int has_video;
61 int width;
62 int height;
63 int current_frame;
64 double current_fps;
65 char audio_string[80];
66 int audio_current_frame;
67 Uint32 current_offset;
68 Uint32 total_size;
69 double current_time;
70 double total_time;
71 } SMPEG_Info;
72
73 /* Possible MPEG status codes */
74 typedef enum {
75 SMPEG_ERROR = -1,
76 SMPEG_STOPPED,
77 SMPEG_PLAYING
78 } SMPEGstatus;
79
80
81 /* Matches the declaration of SDL_UpdateRect() */
82 typedef void(*SMPEG_DisplayCallback)(void *data, SMPEG_Frame *frame);
83
84 /* Create a new SMPEG object from an MPEG file.
85 On return, if 'info' is not NULL, it will be filled with information
86 about the MPEG object.
87 This function returns a new SMPEG object. Use SMPEG_error() to find out
88 whether or not there was a problem building the MPEG stream.
89 The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
90 subsystem. If not, you will have to use the SMPEG_playaudio() function below
91 to extract the decoded data.
92 */
93 extern DECLSPEC SMPEG* SMPEG_new(const char *file, SMPEG_Info* info, int sdl_audio);
94
95 /* The same as above for a file descriptor */
96 extern DECLSPEC SMPEG* SMPEG_new_descr(int file, SMPEG_Info* info, int sdl_audio);
97
98 /*
99 The same as above but for a raw chunk of data. SMPEG makes a copy of the
100 data, so the application is free to delete after a successful call to this
101 function.
102 */
103 extern DECLSPEC SMPEG* SMPEG_new_data(void *data, int size, SMPEG_Info* info, int sdl_audio);
104
105 /* The same for a generic SDL_RWops structure.
106 'freesrc' should be non-zero if SMPEG should close the source when it's done.
107 */
108 extern DECLSPEC SMPEG* SMPEG_new_rwops(SDL_RWops *src, SMPEG_Info* info, int freesrc, 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 frame display callback for MPEG video
129 'lock' is a mutex used to synchronize access to the frame data, and is held during the update callback.
130 */
131 extern DECLSPEC void SMPEG_setdisplay(SMPEG* mpeg, SMPEG_DisplayCallback callback, void* data, SDL_mutex* lock);
132
133 /* Set or clear looping play on an SMPEG object */
134 extern DECLSPEC void SMPEG_loop( SMPEG* mpeg, int repeat );
135
136 /* Play an SMPEG object */
137 extern DECLSPEC void SMPEG_play( SMPEG* mpeg );
138
139 /* Pause/Resume playback of an SMPEG object */
140 extern DECLSPEC void SMPEG_pause( SMPEG* mpeg );
141
142 /* Stop playback of an SMPEG object */
143 extern DECLSPEC void SMPEG_stop( SMPEG* mpeg );
144
145 /* Rewind the play position of an SMPEG object to the beginning of the MPEG */
146 extern DECLSPEC void SMPEG_rewind( SMPEG* mpeg );
147
148 /* Seek 'bytes' bytes in the MPEG stream */
149 extern DECLSPEC void SMPEG_seek( SMPEG* mpeg, int bytes);
150
151 /* Skip 'seconds' seconds in the MPEG stream */
152 extern DECLSPEC void SMPEG_skip( SMPEG* mpeg, float seconds );
153
154 /* Render a particular frame in the MPEG video */
155 extern DECLSPEC void SMPEG_renderFrame( SMPEG* mpeg, int framenum );
156
157 /* Render the last frame of an MPEG video */
158 extern DECLSPEC void SMPEG_renderFinal( SMPEG* mpeg );
159
160 /* Return NULL if there is no error in the MPEG stream, or an error message
161 if there was a fatal error in the MPEG stream for the SMPEG object.
162 */
163 extern DECLSPEC char *SMPEG_error( SMPEG* mpeg );
164
165 /* Exported callback function for audio playback.
166 The function takes a buffer and the amount of data to fill, and returns
167 the amount of data in bytes that was actually written. This will be the
168 amount requested unless the MPEG audio has finished.
169 */
170 extern DECLSPEC int SMPEG_playAudio( SMPEG *mpeg, Uint8 *stream, int len );
171
172 /* Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
173 */
174 extern DECLSPEC void SMPEG_playAudioSDL( void *mpeg, Uint8 *stream, int len );
175
176 /* Get the best SDL audio spec for the audio stream */
177 extern DECLSPEC int SMPEG_wantedSpec( SMPEG *mpeg, SDL_AudioSpec *wanted );
178
179 /* Inform SMPEG of the actual SDL audio spec used for sound playback */
180 extern DECLSPEC void SMPEG_actualSpec( SMPEG *mpeg, SDL_AudioSpec *spec );
181
182 #ifdef __cplusplus
183 }
184 #endif
185 #endif /* _SMPEG_H_ */