DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
cl_video.c File Reference
#include "quakedef.h"
#include "cl_video.h"
#include "dpvsimpledecode.h"
#include "cl_video_libavw.h"
+ Include dependency graph for cl_video.c:

Go to the source code of this file.

Data Structures

struct  cl_video_subtitle_info_t
 

Functions

void CL_CloseVideo (clvideo_t *video)
 
void CL_DrawVideo (void)
 
static int CL_DrawVideo_DisplaySubtitleLine (void *passthrough, const char *line, size_t length, float width, qbool isContinuation)
 
static float CL_DrawVideo_WordWidthFunc (void *passthrough, const char *w, size_t *length, float maxWidth)
 
clvideo_tCL_GetVideoByName (const char *name)
 
static clvideo_tCL_GetVideoBySlot (int slot)
 
clvideo_tCL_OpenVideo (const char *filename, const char *name, int owner, const char *subtitlesfile)
 
static void CL_PlayVideo_f (cmd_state_t *cmd)
 
void CL_PurgeOwner (int owner)
 
void CL_RestartVideo (clvideo_t *video)
 
void CL_SetVideoState (clvideo_t *video, clvideostate_t state)
 
static void CL_StopVideo_f (cmd_state_t *cmd)
 
void CL_Video_Frame (void)
 
void CL_Video_Init (void)
 
void CL_Video_KeyEvent (int key, int ascii, qbool down)
 
static void cl_video_newmap (void)
 
void CL_Video_Shutdown (void)
 
static void cl_video_shutdown (void)
 
static void cl_video_start (void)
 
void CL_VideoStart (char *filename, const char *subtitlesfile)
 
void CL_VideoStop (void)
 
static clvideo_tFindUnusedVid (void)
 
static void LinkVideoTexture (clvideo_t *video)
 
static void LoadSubtitles (clvideo_t *video, const char *subtitlesfile)
 
static qbool OpenStream (clvideo_t *video)
 
static clvideo_tOpenVideo (clvideo_t *video, const char *filename, const char *name, int owner, const char *subtitlesfile)
 
static void SuspendVideo (clvideo_t *video)
 
static void UnlinkVideoTexture (clvideo_t *video)
 
static void VideoUpdateCallback (rtexture_t *rt, void *data)
 
static qbool WakeVideo (clvideo_t *video)
 

Variables

static int cl_num_videos
 
cvar_t cl_video_brightness = {CF_CLIENT | CF_ARCHIVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."}
 
cvar_t cl_video_fadein = {CF_CLIENT | CF_ARCHIVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"}
 
cvar_t cl_video_fadeout = {CF_CLIENT | CF_ARCHIVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"}
 
cvar_t cl_video_keepaspectratio = {CF_CLIENT | CF_ARCHIVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"}
 
cvar_t cl_video_scale = {CF_CLIENT | CF_ARCHIVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."}
 
cvar_t cl_video_scale_vpos = {CF_CLIENT | CF_ARCHIVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"}
 
cvar_t cl_video_stipple = {CF_CLIENT | CF_ARCHIVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."}
 
cvar_t cl_video_subtitles = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"}
 
cvar_t cl_video_subtitles_lines = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"}
 
cvar_t cl_video_subtitles_textsize = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"}
 
static int cl_videobmask
 
static int cl_videobytesperpixel
 
static int cl_videogmask
 
int cl_videoplaying = false
 
static int cl_videormask
 
static clvideo_t cl_videos [MAXCLVIDEOS]
 
static rtexturepool_tcl_videotexturepool
 
cvar_t v_glslgamma_video = {CF_CLIENT | CF_ARCHIVE, "v_glslgamma_video", "1", "applies GLSL gamma to played video, could be a fraction, requires r_glslgamma_2d 1."}
 

Function Documentation

◆ CL_CloseVideo()

void CL_CloseVideo ( clvideo_t * video)

Definition at line 327 of file cl_video.c.

328{
329 int i;
330
331 if (!video || video->state == CLVIDEO_UNUSED)
332 return;
333
334 // close stream
335 if (!video->suspended || video->state != CLVIDEO_FIRSTFRAME)
336 {
337 if (video->stream)
338 video->close(video->stream);
339 video->stream = NULL;
340 }
341 // unlink texture
342 if (!video->suspended)
343 UnlinkVideoTexture(video);
344 // purge subtitles
345 if (video->subtitles)
346 {
347 for (i = 0; i < video->subtitles; i++)
348 Z_Free( video->subtitle_text[i] );
349 video->subtitles = 0;
350 }
351 video->state = CLVIDEO_UNUSED;
352}
static void UnlinkVideoTexture(clvideo_t *video)
Definition cl_video.c:84
@ CLVIDEO_UNUSED
Definition cl_video.h:15
@ CLVIDEO_FIRSTFRAME
Definition cl_video.h:19
int i
#define NULL
Definition qtypes.h:12
void * stream
Definition cl_video.h:41
qbool suspended
Definition cl_video.h:73
clvideostate_t state
Definition cl_video.h:38
void(* close)(void *stream)
Definition cl_video.h:62
int subtitles
Definition cl_video.h:56
char * subtitle_text[CLVIDEO_MAX_SUBTITLES]
Definition cl_video.h:57
#define Z_Free(data)
Definition zone.h:164

References clvideo_t::close, CLVIDEO_FIRSTFRAME, CLVIDEO_UNUSED, i, NULL, clvideo_t::state, clvideo_t::stream, clvideo_t::subtitle_text, clvideo_t::subtitles, clvideo_t::suspended, UnlinkVideoTexture(), and Z_Free.

Referenced by CL_PurgeOwner(), CL_Video_Shutdown(), CL_VideoStart(), CL_VideoStop(), and VM_cin_close().

◆ CL_DrawVideo()

void CL_DrawVideo ( void )

Definition at line 460 of file cl_video.c.

461{
462 clvideo_t *video;
463 float videotime, px, py, sx, sy, st[8], b;
465 int i;
466
467 if (!cl_videoplaying)
468 return;
469
470 video = CL_GetVideoBySlot( 0 );
471
472 // fix cvars
477
478 // calc video proportions
479 px = 0;
480 py = 0;
483 st[0] = 0.0; st[1] = 0.0;
484 st[2] = 1.0; st[3] = 0.0;
485 st[4] = 0.0; st[5] = 1.0;
486 st[6] = 1.0; st[7] = 1.0;
488 {
489 float a = video->getaspectratio(video->stream) / ((float)vid.mode.width / (float)vid.mode.height);
491 {
492 // clip instead of scale
493 if (a < 1.0) // clip horizontally
494 {
495 st[1] = st[3] = (1 - a)*0.5;
496 st[5] = st[7] = 1 - (1 - a)*0.5;
497 }
498 else if (a > 1.0) // clip vertically
499 {
500 st[0] = st[4] = (1 - 1/a)*0.5;
501 st[2] = st[6] = (1/a)*0.5;
502 }
503 }
504 else if (a < 1.0) // scale horizontally
505 {
506 px += sx * (1 - a) * 0.5;
507 sx *= a;
508 }
509 else if (a > 1.0) // scale vertically
510 {
511 a = 1 / a;
512 py += sy * (1 - a);
513 sy *= a;
514 }
515 }
516
517 if (cl_video_scale.value != 1)
518 {
519 px += sx * (1 - cl_video_scale.value) * 0.5;
520 py += sy * (1 - cl_video_scale.value) * ((bound(-1, cl_video_scale_vpos.value, 1) + 1) / 2);
521 sx *= cl_video_scale.value;
522 sy *= cl_video_scale.value;
523 }
524
525 // calc brightness for fadein and fadeout effects
529 else if (cl_video_fadeout.value && ((video->starttime + video->framenum * video->framerate) - host.realtime) < cl_video_fadeout.value)
530 b = pow(((video->starttime + video->framenum * video->framerate) - host.realtime)/cl_video_fadeout.value, 2);
531
532 // draw black bg in case stipple is active or video is scaled
533 if (cl_video_stipple.integer || px != 0 || py != 0 || sx != vid_conwidth.integer || sy != vid_conheight.integer)
534 DrawQ_Fill(0, 0, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, 1, 0);
535
536 // enable video-only polygon stipple (of global stipple is not active)
538 {
539 Con_Print("FIXME: cl_video_stipple not implemented\n");
541 }
542
543 // draw video
544 if (v_glslgamma_video.value >= 1)
545 DrawQ_SuperPic(px, py, video->cachepic, sx, sy, st[0], st[1], b, b, b, 1, st[2], st[3], b, b, b, 1, st[4], st[5], b, b, b, 1, st[6], st[7], b, b, b, 1, 0);
546 else
547 {
548 DrawQ_SuperPic(px, py, video->cachepic, sx, sy, st[0], st[1], b, b, b, 1, st[2], st[3], b, b, b, 1, st[4], st[5], b, b, b, 1, st[6], st[7], b, b, b, 1, DRAWFLAG_NOGAMMA);
549 if (v_glslgamma_video.value > 0.0)
550 DrawQ_SuperPic(px, py, video->cachepic, sx, sy, st[0], st[1], b, b, b, v_glslgamma_video.value, st[2], st[3], b, b, b, v_glslgamma_video.value, st[4], st[5], b, b, b, v_glslgamma_video.value, st[6], st[7], b, b, b, v_glslgamma_video.value, 0);
551 }
552
553 // VorteX: draw subtitle_text
554 if (!video->subtitles || !cl_video_subtitles.integer)
555 return;
556
557 // find current subtitle
558 videotime = host.realtime - video->starttime;
559 for (i = 0; i < video->subtitles; i++)
560 {
561 if (videotime >= video->subtitle_start[i] && videotime <= video->subtitle_end[i])
562 {
563 // found, draw it
564 si.font = FONT_NOTIFY;
565 si.x = vid_conwidth.integer * 0.1;
567 si.width = vid_conwidth.integer * 0.8;
569 si.alignment = 0.5;
571 si.textalpha = min(1, (videotime - video->subtitle_start[i])/0.5) * min(1, ((video->subtitle_end[i] - videotime)/0.3)); // fade in and fade out
573 break;
574 }
575 }
576}
cvar_t scr_stipple
Definition cl_screen.c:88
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
cvar_t cl_video_scale
Definition cl_video.c:9
cvar_t v_glslgamma_video
Definition cl_video.c:17
cvar_t cl_video_scale_vpos
Definition cl_video.c:10
cvar_t cl_video_subtitles_textsize
Definition cl_video.c:8
static float CL_DrawVideo_WordWidthFunc(void *passthrough, const char *w, size_t *length, float maxWidth)
Definition cl_video.c:433
cvar_t cl_video_brightness
Definition cl_video.c:12
static clvideo_t * CL_GetVideoBySlot(int slot)
Definition cl_video.c:267
cvar_t cl_video_subtitles_lines
Definition cl_video.c:7
cvar_t cl_video_subtitles
Definition cl_video.c:6
int cl_videoplaying
Definition cl_video.c:458
static int CL_DrawVideo_DisplaySubtitleLine(void *passthrough, const char *line, size_t length, float width, qbool isContinuation)
Definition cl_video.c:447
cvar_t cl_video_keepaspectratio
Definition cl_video.c:13
cvar_t cl_video_fadein
Definition cl_video.c:14
cvar_t cl_video_fadeout
Definition cl_video.c:15
cvar_t cl_video_stipple
Definition cl_video.c:11
int COM_Wordwrap(const char *string, size_t length, float continuationWidth, float maxWidth, COM_WordWidthFunc_t wordWidth, void *passthroughCW, COM_LineProcessorFunc processLine, void *passthroughPL)
Definition common.c:174
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
Definition gl_draw.c:847
void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height, float s1, float t1, float r1, float g1, float b1, float a1, float s2, float t2, float r2, float g2, float b2, float a2, float s3, float t3, float r3, float g3, float b3, float a3, float s4, float t4, float r4, float g4, float b4, float a4, int flags)
Definition gl_draw.c:1380
#define FONT_NOTIFY
Definition draw.h:131
@ DRAWFLAG_NOGAMMA
Definition draw.h:82
host_static_t host
Definition host.c:41
#define max(A, B)
Definition mathlib.h:38
#define min(A, B)
Definition mathlib.h:37
#define bound(min, num, max)
Definition mathlib.h:34
float pow(float a, float b)
float strlen(string s)
precision highp float
Definition shader_glsl.h:53
dp_FragColor b
ret a
vec2 px
float subtitle_start[CLVIDEO_MAX_SUBTITLES]
Definition cl_video.h:58
double starttime
Definition cl_video.h:43
struct cachepic_s * cachepic
Definition cl_video.h:50
float subtitle_end[CLVIDEO_MAX_SUBTITLES]
Definition cl_video.h:59
int framenum
Definition cl_video.h:44
double(* getaspectratio)(void *stream)
Definition cl_video.h:66
double framerate
Definition cl_video.h:45
float value
Definition cvar.h:74
int integer
Definition cvar.h:73
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46
int width
Definition vid.h:60
int height
Definition vid.h:61
viddef_mode_t mode
currently active video mode
Definition vid.h:73
viddef_t vid
global video state
Definition vid_shared.c:64

References a, cl_video_subtitle_info_t::alignment, b, bound, clvideo_t::cachepic, CL_DrawVideo_DisplaySubtitleLine(), CL_DrawVideo_WordWidthFunc(), CL_GetVideoBySlot(), cl_video_brightness, cl_video_fadein, cl_video_fadeout, cl_video_keepaspectratio, cl_video_scale, cl_video_scale_vpos, cl_video_stipple, cl_video_subtitles, cl_video_subtitles_lines, cl_video_subtitles_textsize, cl_videoplaying, COM_Wordwrap(), Con_Print(), Cvar_SetValueQuick(), DRAWFLAG_NOGAMMA, DrawQ_Fill(), DrawQ_SuperPic(), float, cl_video_subtitle_info_t::font, FONT_NOTIFY, cl_video_subtitle_info_t::fontsize, clvideo_t::framenum, clvideo_t::framerate, clvideo_t::getaspectratio, cl_video_subtitle_info_t::height, viddef_mode_t::height, host, i, cvar_t::integer, max, min, viddef_t::mode, pow(), px, host_static_t::realtime, scr_stipple, clvideo_t::starttime, clvideo_t::stream, strlen(), clvideo_t::subtitle_end, clvideo_t::subtitle_start, clvideo_t::subtitle_text, clvideo_t::subtitles, cl_video_subtitle_info_t::textalpha, v_glslgamma_video, cvar_t::value, vid, vid_conheight, vid_conwidth, cl_video_subtitle_info_t::width, viddef_mode_t::width, cl_video_subtitle_info_t::x, and cl_video_subtitle_info_t::y.

Referenced by SCR_DrawScreen().

◆ CL_DrawVideo_DisplaySubtitleLine()

static int CL_DrawVideo_DisplaySubtitleLine ( void * passthrough,
const char * line,
size_t length,
float width,
qbool isContinuation )
static

Definition at line 447 of file cl_video.c.

448{
450
451 int x = (int) (si->x + (si->width - width) * si->alignment);
452 if (length > 0)
453 DrawQ_String(x, si->y, line, length, si->fontsize, si->fontsize, 1.0, 1.0, 1.0, si->textalpha, 0, NULL, false, si->font);
454 si->y += si->fontsize;
455 return 1;
456}
float DrawQ_String(float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1320
static int(ZEXPORT *qz_inflate)(z_stream *strm
GLenum GLsizei width
Definition glquake.h:622
GLenum GLuint GLenum GLsizei length
Definition glquake.h:657
GLint GLenum GLint x
Definition glquake.h:651

References cl_video_subtitle_info_t::alignment, DrawQ_String(), cl_video_subtitle_info_t::font, cl_video_subtitle_info_t::fontsize, int(), length, NULL, cl_video_subtitle_info_t::textalpha, cl_video_subtitle_info_t::width, width, cl_video_subtitle_info_t::x, x, and cl_video_subtitle_info_t::y.

Referenced by CL_DrawVideo().

◆ CL_DrawVideo_WordWidthFunc()

static float CL_DrawVideo_WordWidthFunc ( void * passthrough,
const char * w,
size_t * length,
float maxWidth )
static

Definition at line 433 of file cl_video.c.

434{
436
437 if(w == NULL)
438 return si->fontsize * si->font->maxwidth;
439 if(maxWidth >= 0)
440 return DrawQ_TextWidth_UntilWidth(w, length, si->fontsize, si->fontsize, false, si->font, -maxWidth); // -maxWidth: we want at least one char
441 else if(maxWidth == -1)
442 return DrawQ_TextWidth(w, *length, si->fontsize, si->fontsize, false, si->font);
443 else
444 return 0;
445}
float DrawQ_TextWidth(const char *text, size_t maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1330
float DrawQ_TextWidth_UntilWidth(const char *text, size_t *maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt, float maxWidth)
Definition gl_draw.c:1335
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
float maxwidth
Definition draw.h:102

References DrawQ_TextWidth(), DrawQ_TextWidth_UntilWidth(), cl_video_subtitle_info_t::font, cl_video_subtitle_info_t::fontsize, length, dp_font_t::maxwidth, NULL, and w.

Referenced by CL_DrawVideo().

◆ CL_GetVideoByName()

clvideo_t * CL_GetVideoByName ( const char * name)

Definition at line 284 of file cl_video.c.

285{
286 int i;
287
288 for( i = 0 ; i < cl_num_videos ; i++ )
289 if( cl_videos[ i ].state != CLVIDEO_UNUSED
290 && !strcmp( cl_videos[ i ].name , name ) )
291 break;
292 if( i != cl_num_videos )
293 return CL_GetVideoBySlot( i );
294 else
295 return NULL;
296}
static int cl_num_videos
Definition cl_video.c:36
static clvideo_t cl_videos[MAXCLVIDEOS]
Definition cl_video.c:37
const GLchar * name
Definition glquake.h:601

References CL_GetVideoBySlot(), cl_num_videos, cl_videos, CLVIDEO_UNUSED, i, name, and NULL.

Referenced by VM_cin_close(), VM_cin_getstate(), VM_cin_restart(), and VM_cin_setstate().

◆ CL_GetVideoBySlot()

static clvideo_t * CL_GetVideoBySlot ( int slot)
static

Definition at line 267 of file cl_video.c.

268{
269 clvideo_t *video = &cl_videos[ slot ];
270
271 if( video->suspended )
272 {
273 if( !WakeVideo( video ) )
274 return NULL;
275 else if( video->state == CLVIDEO_RESETONWAKEUP )
276 video->framenum = -1;
277 }
278
279 video->lasttime = host.realtime;
280
281 return video;
282}
static qbool WakeVideo(clvideo_t *video)
Definition cl_video.c:107
@ CLVIDEO_RESETONWAKEUP
Definition cl_video.h:20
double lasttime
Definition cl_video.h:71

References cl_videos, CLVIDEO_RESETONWAKEUP, clvideo_t::framenum, host, clvideo_t::lasttime, NULL, host_static_t::realtime, clvideo_t::state, clvideo_t::suspended, and WakeVideo().

Referenced by CL_DrawVideo(), and CL_GetVideoByName().

◆ CL_OpenVideo()

clvideo_t * CL_OpenVideo ( const char * filename,
const char * name,
int owner,
const char * subtitlesfile )

Definition at line 245 of file cl_video.c.

246{
247 clvideo_t *video;
248 // sanity check
249 if( !name || !*name || strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) != 0 ) {
250 Con_DPrintf( "CL_OpenVideo: Bad video texture name '%s'!\n", name );
251 return NULL;
252 }
253
254 video = FindUnusedVid();
255 if( !video ) {
256 Con_Printf(CON_ERROR "CL_OpenVideo: unable to open video \"%s\" - video limit reached\n", filename );
257 return NULL;
258 }
259 video = OpenVideo( video, filename, name, owner, subtitlesfile );
260 // expand the active range to include the new entry
261 if (video) {
262 cl_num_videos = max(cl_num_videos, (int)(video - cl_videos) + 1);
263 }
264 return video;
265}
static clvideo_t * FindUnusedVid(void)
Definition cl_video.c:40
static clvideo_t * OpenVideo(clvideo_t *video, const char *filename, const char *name, int owner, const char *subtitlesfile)
Definition cl_video.c:215
#define CLVIDEOPREFIX
Definition cl_video.h:8
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_ERROR
Definition console.h:102
entity owner

References cl_num_videos, cl_videos, CLVIDEOPREFIX, Con_DPrintf(), CON_ERROR, Con_Printf(), FindUnusedVid(), max, name, NULL, OpenVideo(), and owner.

Referenced by VM_cin_open().

◆ CL_PlayVideo_f()

static void CL_PlayVideo_f ( cmd_state_t * cmd)
static

Definition at line 613 of file cl_video.c.

614{
615 char name[MAX_QPATH], subtitlesfile[MAX_QPATH];
616 const char *extension;
617
619
620 if (Sys_CheckParm("-benchmark"))
621 return;
622
623 if (Cmd_Argc(cmd) < 2)
624 {
625 Con_Print("usage: playvideo <videoname> [custom_subtitles_file]\nplays video named video/<videoname>.dpv\nif custom subtitles file is not presented\nit tries video/<videoname>.sub");
626 return;
627 }
628
629 extension = FS_FileExtension(Cmd_Argv(cmd, 1));
630 if (extension[0])
631 dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(cmd, 1));
632 else
633 dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(cmd, 1));
634 if ( Cmd_Argc(cmd) > 2)
636 else
637 {
638 dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(cmd, 1));
639 CL_VideoStart(name, subtitlesfile);
640 }
641}
void CL_StartVideo(void)
Definition cl_main.c:2786
void CL_VideoStart(char *filename, const char *subtitlesfile)
Definition cl_video.c:578
static int Cmd_Argc(cmd_state_t *cmd)
Definition cmd.h:249
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
Definition cmd.h:254
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
const char * FS_FileExtension(const char *in)
Definition fs.c:1403
void cmd(string command,...)
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327

References CL_StartVideo(), CL_VideoStart(), cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), dpsnprintf(), FS_FileExtension(), MAX_QPATH, name, and Sys_CheckParm().

Referenced by CL_Video_Init().

◆ CL_PurgeOwner()

void CL_PurgeOwner ( int owner)

Definition at line 411 of file cl_video.c.

412{
413 int i;
414
415 for (i = 0 ; i < cl_num_videos ; i++)
416 if (cl_videos[i].ownertag == owner)
418}
void CL_CloseVideo(clvideo_t *video)
Definition cl_video.c:327

References CL_CloseVideo(), cl_num_videos, cl_videos, i, and owner.

Referenced by VM_Cmd_Reset().

◆ CL_RestartVideo()

void CL_RestartVideo ( clvideo_t * video)

Definition at line 309 of file cl_video.c.

310{
311 if (!video)
312 return;
313
314 // reset time
315 video->starttime = video->lasttime = host.realtime;
316 video->framenum = -1;
317
318 // reopen stream
319 if (video->stream)
320 video->close(video->stream);
321 video->stream = NULL;
322 if (!OpenStream(video))
323 video->state = CLVIDEO_UNUSED;
324}
static qbool OpenStream(clvideo_t *video)
Definition cl_video.c:49

References clvideo_t::close, CLVIDEO_UNUSED, clvideo_t::framenum, host, clvideo_t::lasttime, NULL, OpenStream(), host_static_t::realtime, clvideo_t::starttime, clvideo_t::state, and clvideo_t::stream.

Referenced by CL_SetVideoState(), CL_Video_Frame(), CL_VideoStart(), and VM_cin_restart().

◆ CL_SetVideoState()

void CL_SetVideoState ( clvideo_t * video,
clvideostate_t state )

Definition at line 298 of file cl_video.c.

299{
300 if (!video)
301 return;
302
303 video->lasttime = host.realtime;
304 video->state = state;
305 if (state == CLVIDEO_FIRSTFRAME)
306 CL_RestartVideo(video);
307}
void CL_RestartVideo(clvideo_t *video)
Definition cl_video.c:309

References CL_RestartVideo(), CLVIDEO_FIRSTFRAME, host, clvideo_t::lasttime, host_static_t::realtime, and clvideo_t::state.

Referenced by CL_VideoStart(), and VM_cin_setstate().

◆ CL_StopVideo_f()

static void CL_StopVideo_f ( cmd_state_t * cmd)
static

Definition at line 643 of file cl_video.c.

644{
645 CL_VideoStop();
646}
void CL_VideoStop(void)
Definition cl_video.c:606

References CL_VideoStop().

Referenced by CL_Video_Init().

◆ CL_Video_Frame()

void CL_Video_Frame ( void )

Definition at line 355 of file cl_video.c.

356{
357 clvideo_t *video;
358 int destframe;
359 int i;
360
361 if (!cl_num_videos)
362 return;
363 for (video = cl_videos, i = 0 ; i < cl_num_videos ; video++, i++)
364 {
365 if (video->state != CLVIDEO_UNUSED && !video->suspended)
366 {
367 if (host.realtime - video->lasttime > CLTHRESHOLD)
368 {
369 SuspendVideo(video);
370 continue;
371 }
372 if (video->state == CLVIDEO_PAUSE)
373 {
374 video->starttime = host.realtime - video->framenum * video->framerate;
375 continue;
376 }
377 // read video frame from stream if time has come
378 if (video->state == CLVIDEO_FIRSTFRAME )
379 destframe = 0;
380 else
381 destframe = (int)((host.realtime - video->starttime) * video->framerate);
382 if (destframe < 0)
383 destframe = 0;
384 if (video->framenum < destframe)
385 {
386 do {
387 video->framenum++;
389 {
390 // finished?
391 CL_RestartVideo(video);
392 if (video->state == CLVIDEO_PLAY)
393 video->state = CLVIDEO_FIRSTFRAME;
394 return;
395 }
396 } while(video->framenum < destframe);
398 }
399 }
400 }
401
402 // stop main video
404 CL_VideoStop();
405
406 // reduce range to exclude unnecessary entries
407 while(cl_num_videos > 0 && cl_videos[cl_num_videos-1].state == CLVIDEO_UNUSED)
409}
static int cl_videormask
Definition cl_video.c:31
static int cl_videobytesperpixel
Definition cl_video.c:34
static int cl_videobmask
Definition cl_video.c:32
static void SuspendVideo(clvideo_t *video)
Definition cl_video.c:92
static int cl_videogmask
Definition cl_video.c:33
@ CLVIDEO_PAUSE
Definition cl_video.h:18
@ CLVIDEO_PLAY
Definition cl_video.h:16
#define CLTHRESHOLD
Definition cl_video.h:9
rtexture_t * Draw_GetPicTexture(cachepic_t *pic)
Definition gl_draw.c:224
void R_MarkDirtyTexture(rtexture_t *rt)
int(* decodeframe)(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow)
Definition cl_video.h:67
int width
Definition cl_video.h:52
void * imagedata
Definition cl_video.h:47

References clvideo_t::cachepic, cl_num_videos, CL_RestartVideo(), cl_videobmask, cl_videobytesperpixel, cl_videogmask, cl_videormask, cl_videos, CL_VideoStop(), CLTHRESHOLD, CLVIDEO_FIRSTFRAME, CLVIDEO_PAUSE, CLVIDEO_PLAY, CLVIDEO_UNUSED, clvideo_t::decodeframe, Draw_GetPicTexture(), clvideo_t::framenum, clvideo_t::framerate, host, i, clvideo_t::imagedata, int(), clvideo_t::lasttime, R_MarkDirtyTexture(), host_static_t::realtime, clvideo_t::starttime, clvideo_t::state, clvideo_t::stream, clvideo_t::suspended, SuspendVideo(), and clvideo_t::width.

Referenced by CL_Frame().

◆ CL_Video_Init()

void CL_Video_Init ( void )

Definition at line 675 of file cl_video.c.

676{
677 union
678 {
679 unsigned char b[4];
680 unsigned int i;
681 }
682 bgra;
683
684 cl_num_videos = 0;
686
687 // set masks in an endian-independent way (as they really represent bytes)
688 bgra.i = 0;bgra.b[0] = 0xFF;cl_videobmask = bgra.i;
689 bgra.i = 0;bgra.b[1] = 0xFF;cl_videogmask = bgra.i;
690 bgra.i = 0;bgra.b[2] = 0xFF;cl_videormask = bgra.i;
691
692 Cmd_AddCommand(CF_CLIENT, "playvideo", CL_PlayVideo_f, "play a .dpv video file" );
693 Cmd_AddCommand(CF_CLIENT, "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" );
694
705
707
709
711}
static void cl_video_start(void)
Definition cl_video.c:648
static void cl_video_shutdown(void)
Definition cl_video.c:660
static void cl_video_newmap(void)
Definition cl_video.c:671
static void CL_StopVideo_f(cmd_state_t *cmd)
Definition cl_video.c:643
static void CL_PlayVideo_f(cmd_state_t *cmd)
Definition cl_video.c:613
qbool LibAvW_OpenLibrary(void)
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25

References b, CF_CLIENT, cl_num_videos, CL_PlayVideo_f(), CL_StopVideo_f(), cl_video_brightness, cl_video_fadein, cl_video_fadeout, cl_video_keepaspectratio, cl_video_newmap(), cl_video_scale, cl_video_scale_vpos, cl_video_shutdown(), cl_video_start(), cl_video_stipple, cl_video_subtitles, cl_video_subtitles_lines, cl_video_subtitles_textsize, cl_videobmask, cl_videobytesperpixel, cl_videogmask, cl_videormask, Cmd_AddCommand(), Cvar_RegisterVariable(), i, LibAvW_OpenLibrary(), NULL, R_RegisterModule(), and v_glslgamma_video.

Referenced by CL_Init().

◆ CL_Video_KeyEvent()

void CL_Video_KeyEvent ( int key,
int ascii,
qbool down )

Definition at line 596 of file cl_video.c.

597{
598 // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting..
599 if( !down ) {
600 if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) {
601 CL_VideoStop();
602 }
603 }
604}
float K_SPACE
Definition keycodes.qc:10
float K_ENTER
Definition keycodes.qc:8
float K_ESCAPE
Definition keycodes.qc:9

References CL_VideoStop(), K_ENTER, K_ESCAPE, and K_SPACE.

Referenced by Key_Event().

◆ cl_video_newmap()

static void cl_video_newmap ( void )
static

Definition at line 671 of file cl_video.c.

672{
673}

Referenced by CL_Video_Init().

◆ CL_Video_Shutdown()

void CL_Video_Shutdown ( void )

Definition at line 713 of file cl_video.c.

714{
715 int i;
716
717 for (i = 0 ; i < cl_num_videos ; i++)
719
721}
void LibAvW_CloseLibrary(void)

References CL_CloseVideo(), cl_num_videos, cl_videos, i, and LibAvW_CloseLibrary().

Referenced by CL_Shutdown().

◆ cl_video_shutdown()

static void cl_video_shutdown ( void )
static

Definition at line 660 of file cl_video.c.

661{
662 int i;
663 clvideo_t *video;
664
665 for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
666 if( video->state != CLVIDEO_UNUSED && !video->suspended )
667 SuspendVideo( video );
669}
static rtexturepool_t * cl_videotexturepool
Definition cl_video.c:38
void R_FreeTexturePool(rtexturepool_t **rtexturepool)

References cl_num_videos, cl_videos, cl_videotexturepool, CLVIDEO_UNUSED, i, R_FreeTexturePool(), clvideo_t::state, clvideo_t::suspended, and SuspendVideo().

Referenced by CL_Video_Init().

◆ cl_video_start()

static void cl_video_start ( void )
static

Definition at line 648 of file cl_video.c.

649{
650 int i;
651 clvideo_t *video;
652
654
655 for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
656 if( video->state != CLVIDEO_UNUSED && !video->suspended )
657 LinkVideoTexture( video );
658}
static void LinkVideoTexture(clvideo_t *video)
Definition cl_video.c:77
rtexturepool_t * R_AllocTexturePool(void)

References cl_num_videos, cl_videos, cl_videotexturepool, CLVIDEO_UNUSED, i, LinkVideoTexture(), R_AllocTexturePool(), clvideo_t::state, and clvideo_t::suspended.

Referenced by CL_Video_Init().

◆ CL_VideoStart()

void CL_VideoStart ( char * filename,
const char * subtitlesfile )

Definition at line 578 of file cl_video.c.

579{
581
584 // already contains video/
585 if( !OpenVideo( cl_videos, filename, filename, 0, subtitlesfile ) )
586 return;
587 // expand the active range to include the new entry
589
590 cl_videoplaying = true;
591
594}
void CL_SetVideoState(clvideo_t *video, clvideostate_t state)
Definition cl_video.c:298

References CL_CloseVideo(), cl_num_videos, CL_RestartVideo(), CL_SetVideoState(), CL_StartVideo(), cl_videoplaying, cl_videos, CLVIDEO_PLAY, CLVIDEO_UNUSED, max, OpenVideo(), and clvideo_t::state.

Referenced by CL_PlayVideo_f().

◆ CL_VideoStop()

void CL_VideoStop ( void )

Definition at line 606 of file cl_video.c.

607{
608 cl_videoplaying = false;
609
611}

References CL_CloseVideo(), cl_videoplaying, and cl_videos.

Referenced by CL_ParseServerInfo(), CL_StopVideo_f(), CL_Video_Frame(), and CL_Video_KeyEvent().

◆ FindUnusedVid()

static clvideo_t * FindUnusedVid ( void )
static

Definition at line 40 of file cl_video.c.

41{
42 int i;
43 for( i = 1 ; i < MAXCLVIDEOS ; i++ )
44 if( cl_videos[ i ].state == CLVIDEO_UNUSED )
45 return &cl_videos[ i ];
46 return NULL;
47}
#define MAXCLVIDEOS
maximum number of video streams being played back at once (1 is reserved for the playvideo command)
Definition qdefs.h:138

References cl_videos, CLVIDEO_UNUSED, i, MAXCLVIDEOS, and NULL.

Referenced by CL_OpenVideo().

◆ LinkVideoTexture()

static void LinkVideoTexture ( clvideo_t * video)
static

Definition at line 77 of file cl_video.c.

78{
79 video->cachepic = Draw_NewPic(video->name, video->width, video->height, NULL, TEXTYPE_BGRA, TEXF_CLAMP);
80 // make R_GetTexture() call our VideoUpdateCallback
82}
static void VideoUpdateCallback(rtexture_t *rt, void *data)
Definition cl_video.c:71
cachepic_t * Draw_NewPic(const char *picname, int width, int height, unsigned char *pixels, textype_t textype, int texflags)
Definition gl_draw.c:256
void R_MakeTextureDynamic(rtexture_t *rt, updatecallback_t updatecallback, void *data)
@ TEXTYPE_BGRA
Definition r_textures.h:53
#define TEXF_CLAMP
Definition r_textures.h:15
char name[MAX_QPATH]
Definition cl_video.h:51
int height
Definition cl_video.h:53

References clvideo_t::cachepic, Draw_GetPicTexture(), Draw_NewPic(), clvideo_t::height, clvideo_t::name, NULL, R_MakeTextureDynamic(), TEXF_CLAMP, TEXTYPE_BGRA, VideoUpdateCallback(), and clvideo_t::width.

Referenced by cl_video_start(), OpenVideo(), and WakeVideo().

◆ LoadSubtitles()

static void LoadSubtitles ( clvideo_t * video,
const char * subtitlesfile )
static

Definition at line 128 of file cl_video.c.

129{
130 char *subtitle_text;
131 const char *data;
132 float subtime, sublen;
133 int numsubs = 0;
134
136 {
137 char overridename[MAX_QPATH];
138 cvar_t *langcvar;
139
140 langcvar = Cvar_FindVar(&cvars_all, "language", CF_CLIENT | CF_SERVER);
141 subtitle_text = NULL;
142 if (langcvar)
143 {
144 dpsnprintf(overridename, sizeof(overridename), "locale/%s/%s", langcvar->string, subtitlesfile);
145 subtitle_text = (char *)FS_LoadFile(overridename, cls.permanentmempool, false, NULL);
146 }
147 if (!subtitle_text)
148 subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
149 }
150 else
151 {
152 subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
153 }
154 if (!subtitle_text)
155 {
156 Con_DPrintf( "LoadSubtitles: can't open subtitle file '%s'!\n", subtitlesfile );
157 return;
158 }
159
160 // parse subtitle_text
161 // line is: x y "text" where
162 // x - start time
163 // y - seconds last (if 0 - last thru next sub, if negative - last to next sub - this amount of seconds)
164
165 data = subtitle_text;
166 for (;;)
167 {
168 if (!COM_ParseToken_QuakeC(&data, false))
169 break;
170 subtime = atof( com_token );
171 if (!COM_ParseToken_QuakeC(&data, false))
172 break;
173 sublen = atof( com_token );
174 if (!COM_ParseToken_QuakeC(&data, false))
175 break;
176 if (!com_token[0])
177 continue;
178 // check limits
179 if (video->subtitles == CLVIDEO_MAX_SUBTITLES)
180 {
181 Con_Printf(CON_WARN "WARNING: CLVIDEO_MAX_SUBTITLES = %i reached when reading subtitles from '%s'\n", CLVIDEO_MAX_SUBTITLES, subtitlesfile);
182 break;
183 }
184 // add a sub
185 video->subtitle_text[numsubs] = (char *) Mem_Alloc(cls.permanentmempool, strlen(com_token) + 1);
186 memcpy(video->subtitle_text[numsubs], com_token, strlen(com_token) + 1);
187 video->subtitle_start[numsubs] = subtime;
188 video->subtitle_end[numsubs] = sublen;
189 if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
190 {
191 if (video->subtitle_end[numsubs-1] <= 0)
192 video->subtitle_end[numsubs-1] = max(video->subtitle_start[numsubs-1], video->subtitle_start[numsubs] + video->subtitle_end[numsubs-1]);
193 else
194 video->subtitle_end[numsubs-1] = min(video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1], video->subtitle_start[numsubs]);
195 }
196 numsubs++;
197 // todo: check timing for consistency?
198 }
199 if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
200 {
201 if (video->subtitle_end[numsubs-1] <= 0)
202 video->subtitle_end[numsubs-1] = (float)99999999; // fixme: make it end when video ends?
203 else
204 video->subtitle_end[numsubs-1] = video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1];
205 }
206 Z_Free( subtitle_text );
207 video->subtitles = numsubs;
208/*
209 Con_Printf( "video->subtitles: %i\n", video->subtitles );
210 for (numsubs = 0; numsubs < video->subtitles; numsubs++)
211 Con_Printf( " %03.2f %03.2f : %s\n", video->subtitle_start[numsubs], video->subtitle_end[numsubs], video->subtitle_text[numsubs] );
212*/
213}
client_static_t cls
Definition cl_main.c:116
#define CLVIDEO_MAX_SUBTITLES
Definition cl_video.h:24
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49
gamemode_t gamemode
Definition com_game.c:26
@ GAME_BLOODOMNICIDE
Definition com_game.h:52
char com_token[MAX_INPUTLINE]
Definition common.c:39
qbool COM_ParseToken_QuakeC(const char **datapointer, qbool returnnewline)
Definition common.c:581
#define CON_WARN
Definition console.h:101
cvar_state_t cvars_all
Definition cvar.c:28
cvar_t * Cvar_FindVar(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
Definition cvar.c:36
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3540
GLsizeiptr const GLvoid * data
Definition glquake.h:639
mempool_t * permanentmempool
Definition client.h:572
Definition cvar.h:66
const char * string
Definition cvar.h:71
#define Mem_Alloc(pool, size)
Definition zone.h:92

References CF_CLIENT, CF_SERVER, cls, CLVIDEO_MAX_SUBTITLES, COM_ParseToken_QuakeC(), com_token, Con_DPrintf(), Con_Printf(), CON_WARN, Cvar_FindVar(), cvars_all, data, dpsnprintf(), float, FS_LoadFile(), GAME_BLOODOMNICIDE, gamemode, max, MAX_QPATH, Mem_Alloc, min, NULL, client_static_t::permanentmempool, cvar_t::string, strlen(), clvideo_t::subtitle_end, clvideo_t::subtitle_start, clvideo_t::subtitle_text, clvideo_t::subtitles, and Z_Free.

Referenced by OpenVideo().

◆ OpenStream()

static qbool OpenStream ( clvideo_t * video)
static

Definition at line 49 of file cl_video.c.

50{
51 const char *errorstring;
52
53 video->stream = dpvsimpledecode_open( video, video->filename, &errorstring);
54 if (video->stream)
55 return true;
56
57#ifdef JAMVIDEO
58 video->stream = jam_open( video, video->filename, &errorstring);
59 if (video->stream)
60 return true;
61#endif
62
63 video->stream = LibAvW_OpenVideo( video, video->filename, &errorstring);
64 if (video->stream)
65 return true;
66
67 Con_Printf(CON_ERROR "unable to open \"%s\", error: %s\n", video->filename, errorstring);
68 return false;
69}
void * jam_open(clvideo_t *video, char *filename, const char **errorstring)
void * LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **errorstring)
void * dpvsimpledecode_open(clvideo_t *video, char *filename, const char **errorstring)
char filename[MAX_QPATH]
Definition cl_video.h:75

References CON_ERROR, Con_Printf(), dpvsimpledecode_open(), clvideo_t::filename, jam_open(), LibAvW_OpenVideo(), and clvideo_t::stream.

Referenced by CL_RestartVideo(), OpenVideo(), and WakeVideo().

◆ OpenVideo()

static clvideo_t * OpenVideo ( clvideo_t * video,
const char * filename,
const char * name,
int owner,
const char * subtitlesfile )
static

Definition at line 215 of file cl_video.c.

216{
217 dp_strlcpy(video->filename, filename, sizeof(video->filename));
218 dpsnprintf(video->name, sizeof(video->name), CLVIDEOPREFIX "%s", name);
219 video->ownertag = owner;
220 if( strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) )
221 return NULL;
223
224 if( !OpenStream( video ) )
225 return NULL;
226
227 video->state = CLVIDEO_FIRSTFRAME;
228 video->framenum = -1;
229 video->framerate = video->getframerate( video->stream );
230 video->lasttime = host.realtime;
231 video->subtitles = 0;
232
233 video->width = video->getwidth( video->stream );
234 video->height = video->getheight( video->stream );
236 LinkVideoTexture( video );
237
238 // VorteX: load simple subtitle_text file
239 if (subtitlesfile[0])
240 LoadSubtitles( video, subtitlesfile );
241
242 return video;
243}
static void LoadSubtitles(clvideo_t *video, const char *subtitlesfile)
Definition cl_video.c:128
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
@ CACHEPICFLAG_QUIET
Definition draw.h:37
@ CACHEPICFLAG_NOTPERSISTENT
Definition draw.h:36
cachepic_t * Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
Definition gl_draw.c:86
int ownertag
Definition cl_video.h:37
double(* getframerate)(void *stream)
Definition cl_video.h:65
unsigned int(* getheight)(void *stream)
Definition cl_video.h:64
unsigned int(* getwidth)(void *stream)
Definition cl_video.h:63

References clvideo_t::cachepic, CACHEPICFLAG_NOTPERSISTENT, CACHEPICFLAG_QUIET, cl_videobytesperpixel, cls, CLVIDEO_FIRSTFRAME, CLVIDEOPREFIX, dp_strlcpy, dpsnprintf(), Draw_CachePic_Flags(), clvideo_t::filename, clvideo_t::framenum, clvideo_t::framerate, clvideo_t::getframerate, clvideo_t::getheight, clvideo_t::getwidth, clvideo_t::height, host, clvideo_t::imagedata, clvideo_t::lasttime, LinkVideoTexture(), LoadSubtitles(), Mem_Alloc, clvideo_t::name, name, NULL, OpenStream(), owner, clvideo_t::ownertag, client_static_t::permanentmempool, host_static_t::realtime, clvideo_t::state, clvideo_t::stream, clvideo_t::subtitles, and clvideo_t::width.

Referenced by CL_OpenVideo(), and CL_VideoStart().

◆ SuspendVideo()

static void SuspendVideo ( clvideo_t * video)
static

Definition at line 92 of file cl_video.c.

93{
94 if (video->suspended)
95 return;
96 video->suspended = true;
97 UnlinkVideoTexture(video);
98 // if we are in firstframe mode, also close the stream
99 if (video->state == CLVIDEO_FIRSTFRAME)
100 {
101 if (video->stream)
102 video->close(video->stream);
103 video->stream = NULL;
104 }
105}

References clvideo_t::close, CLVIDEO_FIRSTFRAME, NULL, clvideo_t::state, clvideo_t::stream, clvideo_t::suspended, and UnlinkVideoTexture().

Referenced by CL_Video_Frame(), and cl_video_shutdown().

◆ UnlinkVideoTexture()

static void UnlinkVideoTexture ( clvideo_t * video)
static

Definition at line 84 of file cl_video.c.

85{
86 // free the texture (this does not destroy the cachepic_t, which is eternal)
87 Draw_FreePic(video->name);
88 // free the image data
89 Mem_Free( video->imagedata );
90}
void Draw_FreePic(const char *picname)
Definition gl_draw.c:309
#define Mem_Free(mem)
Definition zone.h:96

References Draw_FreePic(), clvideo_t::imagedata, Mem_Free, and clvideo_t::name.

Referenced by CL_CloseVideo(), and SuspendVideo().

◆ VideoUpdateCallback()

static void VideoUpdateCallback ( rtexture_t * rt,
void * data )
static

Definition at line 71 of file cl_video.c.

72{
73 clvideo_t *video = (clvideo_t *) data;
74 Draw_NewPic(video->name, video->width, video->height, (unsigned char *)video->imagedata, TEXTYPE_BGRA, TEXF_CLAMP);
75}

References data, Draw_NewPic(), clvideo_t::height, clvideo_t::imagedata, clvideo_t::name, TEXF_CLAMP, TEXTYPE_BGRA, and clvideo_t::width.

Referenced by LinkVideoTexture().

◆ WakeVideo()

static qbool WakeVideo ( clvideo_t * video)
static

Definition at line 107 of file cl_video.c.

108{
109 if( !video->suspended )
110 return true;
111 video->suspended = false;
112
113 if( video->state == CLVIDEO_FIRSTFRAME )
114 if( !OpenStream( video ) ) {
115 video->state = CLVIDEO_UNUSED;
116 return false;
117 }
118
120 LinkVideoTexture( video );
121
122 // update starttime
123 video->starttime += host.realtime - video->lasttime;
124
125 return true;
126}

References cl_videobytesperpixel, cls, CLVIDEO_FIRSTFRAME, CLVIDEO_UNUSED, clvideo_t::height, host, clvideo_t::imagedata, clvideo_t::lasttime, LinkVideoTexture(), Mem_Alloc, OpenStream(), client_static_t::permanentmempool, host_static_t::realtime, clvideo_t::starttime, clvideo_t::state, clvideo_t::suspended, and clvideo_t::width.

Referenced by CL_GetVideoBySlot().

Variable Documentation

◆ cl_num_videos

◆ cl_video_brightness

cvar_t cl_video_brightness = {CF_CLIENT | CF_ARCHIVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."}

Definition at line 12 of file cl_video.c.

12{CF_CLIENT | CF_ARCHIVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_fadein

cvar_t cl_video_fadein = {CF_CLIENT | CF_ARCHIVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"}

Definition at line 14 of file cl_video.c.

14{CF_CLIENT | CF_ARCHIVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_fadeout

cvar_t cl_video_fadeout = {CF_CLIENT | CF_ARCHIVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"}

Definition at line 15 of file cl_video.c.

15{CF_CLIENT | CF_ARCHIVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_keepaspectratio

cvar_t cl_video_keepaspectratio = {CF_CLIENT | CF_ARCHIVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"}

Definition at line 13 of file cl_video.c.

13{CF_CLIENT | CF_ARCHIVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_scale

cvar_t cl_video_scale = {CF_CLIENT | CF_ARCHIVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."}

Definition at line 9 of file cl_video.c.

9{CF_CLIENT | CF_ARCHIVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_scale_vpos

cvar_t cl_video_scale_vpos = {CF_CLIENT | CF_ARCHIVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"}

Definition at line 10 of file cl_video.c.

10{CF_CLIENT | CF_ARCHIVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_stipple

cvar_t cl_video_stipple = {CF_CLIENT | CF_ARCHIVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."}

Definition at line 11 of file cl_video.c.

11{CF_CLIENT | CF_ARCHIVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_subtitles

cvar_t cl_video_subtitles = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"}

Definition at line 6 of file cl_video.c.

6{CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_subtitles_lines

cvar_t cl_video_subtitles_lines = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"}

Definition at line 7 of file cl_video.c.

7{CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_video_subtitles_textsize

cvar_t cl_video_subtitles_textsize = {CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"}

Definition at line 8 of file cl_video.c.

8{CF_CLIENT | CF_ARCHIVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"};

Referenced by CL_DrawVideo(), and CL_Video_Init().

◆ cl_videobmask

int cl_videobmask
static

Definition at line 32 of file cl_video.c.

Referenced by CL_Video_Frame(), and CL_Video_Init().

◆ cl_videobytesperpixel

int cl_videobytesperpixel
static

Definition at line 34 of file cl_video.c.

Referenced by CL_Video_Frame(), CL_Video_Init(), OpenVideo(), and WakeVideo().

◆ cl_videogmask

int cl_videogmask
static

Definition at line 33 of file cl_video.c.

Referenced by CL_Video_Frame(), and CL_Video_Init().

◆ cl_videoplaying

int cl_videoplaying = false

◆ cl_videormask

int cl_videormask
static

Definition at line 31 of file cl_video.c.

Referenced by CL_Video_Frame(), and CL_Video_Init().

◆ cl_videos

◆ cl_videotexturepool

rtexturepool_t* cl_videotexturepool
static

Definition at line 38 of file cl_video.c.

Referenced by cl_video_shutdown(), and cl_video_start().

◆ v_glslgamma_video

cvar_t v_glslgamma_video = {CF_CLIENT | CF_ARCHIVE, "v_glslgamma_video", "1", "applies GLSL gamma to played video, could be a fraction, requires r_glslgamma_2d 1."}

Definition at line 17 of file cl_video.c.

17{CF_CLIENT | CF_ARCHIVE, "v_glslgamma_video", "1", "applies GLSL gamma to played video, could be a fraction, requires r_glslgamma_2d 1."};

Referenced by CL_DrawVideo(), and CL_Video_Init().