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