]> git.xonotic.org Git - xonotic/darkplaces.git/blob - cl_video.h
Add qdefs.h and qstats.h to split up quakedef.h. Make a lot of headers standalone...
[xonotic/darkplaces.git] / cl_video.h
1
2 #ifndef CL_VIDEO_H
3 #define CL_VIDEO_H
4
5 #include "draw.h"
6
7 #define CLVIDEOPREFIX   "video/"
8 #define CLTHRESHOLD             2.0
9
10 #define MENUOWNER               1
11
12 typedef enum clvideostate_e
13 {
14         CLVIDEO_UNUSED,
15         CLVIDEO_PLAY,
16         CLVIDEO_LOOP,
17         CLVIDEO_PAUSE,
18         CLVIDEO_FIRSTFRAME,
19         CLVIDEO_RESETONWAKEUP,
20         CLVIDEO_STATECOUNT
21 } clvideostate_t;
22
23 #define CLVIDEO_MAX_SUBTITLES 512
24
25 extern cvar_t cl_video_subtitles;
26 extern cvar_t cl_video_subtitles_lines;
27 extern cvar_t cl_video_subtitles_textsize;
28 extern cvar_t cl_video_scale;
29 extern cvar_t cl_video_scale_vpos;
30 extern cvar_t cl_video_stipple;
31 extern cvar_t cl_video_brightness;
32 extern cvar_t cl_video_keepaspectratio;
33
34 typedef struct clvideo_s
35 {
36         int             ownertag;
37         clvideostate_t state;
38
39         // private stuff
40         void    *stream;
41
42         double  starttime;
43         int             framenum;
44         double  framerate;
45
46         void    *imagedata;
47
48         // cachepic holds the relevant texture_t and we simply update the texture as needed
49         cachepic_t *cachepic;
50         char    name[MAX_QPATH]; // name of this video UI element (not the filename)
51         int             width;
52         int             height;
53
54         // VorteX: subtitles array
55         int             subtitles;
56         char    *subtitle_text[CLVIDEO_MAX_SUBTITLES];
57         float   subtitle_start[CLVIDEO_MAX_SUBTITLES];
58         float   subtitle_end[CLVIDEO_MAX_SUBTITLES];
59
60         // this functions gets filled by video format module
61         void (*close) (void *stream);
62         unsigned int (*getwidth) (void *stream);
63         unsigned int (*getheight) (void *stream);
64         double (*getframerate) (void *stream);
65         double (*getaspectratio) (void *stream);
66         int (*decodeframe) (void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow);
67
68         // if a video is suspended, it is automatically paused (else we'd still have to process the frames)
69         // used to determine whether the video's resources should be freed or not
70     double  lasttime;
71         // when lasttime - realtime > THRESHOLD, all but the stream is freed
72         qbool suspended;
73
74         char    filename[MAX_QPATH];
75 } clvideo_t;
76
77 clvideo_t*      CL_OpenVideo( const char *filename, const char *name, int owner, const char *subtitlesfile );
78 clvideo_t*      CL_GetVideoByName( const char *name );
79 void            CL_SetVideoState( clvideo_t *video, clvideostate_t state );
80 void            CL_RestartVideo( clvideo_t *video );
81
82 void            CL_CloseVideo( clvideo_t * video );
83 void            CL_PurgeOwner( int owner );
84
85 void            CL_Video_Frame( void ); // update all videos
86 void            CL_Video_Init( void );
87 void            CL_Video_Shutdown( void );
88
89 // old interface
90 extern int cl_videoplaying;
91
92 void CL_DrawVideo( void );
93 void CL_VideoStart( char *filename, const char *subtitlesfile );
94 void CL_VideoStop( void );
95
96 // new function used for fullscreen videos
97 // TODO: Andreas Kirsch: move this subsystem somewhere else (preferably host) since the cl_video system shouldnt do such work like managing key events..
98 void CL_Video_KeyEvent( int key, int ascii, qbool down );
99
100 #endif