Skip to content
Snippets Groups Projects
Commit 7915f5d3 authored by Steve Lhomme's avatar Steve Lhomme Committed by François Cartegnie
Browse files

access: screen: turn the sub-function calls into operations

Simplify the close callback which only needs to clean the screen_data_t.
parent d13e08b0
No related branches found
No related tags found
1 merge request!1523access: screen: add DXGI capture support on Windows
......@@ -42,6 +42,10 @@
extern int CGSMainConnectionID();
extern CGImageRef CGSCreateRegisteredCursorImage(int, char*, CGPoint*);
static void screen_CloseCapture(screen_data_t *);
static block_t *screen_Capture(demux_t *);
struct screen_data_t
{
block_t *p_block;
......@@ -128,14 +132,16 @@ int screen_InitCapture(demux_t *p_demux)
p_sys->fmt.video.i_frame_rate = 1000 * p_data->rate;
p_sys->fmt.video.i_frame_rate_base = 1000;
static const struct screen_capture_operations ops = {
screen_Capture, screen_CloseCapture,
};
p_sys->ops = &ops;
return VLC_SUCCESS;
}
int screen_CloseCapture(demux_t *p_demux)
static static void screen_CloseCapture(screen_data_t *p_data)
{
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data = p_sys->p_data;
if (p_data->offscreen_context)
CFRelease(p_data->offscreen_context);
......@@ -146,8 +152,6 @@ int screen_CloseCapture(demux_t *p_demux)
block_Release(p_data->p_block);
free(p_data);
return VLC_SUCCESS;
}
block_t *screen_Capture(demux_t *p_demux)
......
......@@ -256,7 +256,8 @@ static void Close( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
screen_CloseCapture( p_demux );
if (p_sys->ops)
p_sys->ops->close( p_sys->p_data );
#ifdef SCREEN_MOUSE
if( p_sys->p_mouse )
picture_Release( p_sys->p_mouse );
......@@ -286,7 +287,7 @@ static int Demux( demux_t *p_demux )
p_sys->i_next_date += extra_frames * p_sys->i_incr;
vlc_tick_wait( p_sys->i_next_date );
p_block = screen_Capture( p_demux );
p_block = p_sys->ops->capture( p_demux );
if( !p_block )
{
p_sys->i_next_date += p_sys->i_incr;
......
......@@ -38,6 +38,12 @@
typedef struct screen_data_t screen_data_t;
struct screen_capture_operations
{
block_t* (*capture)( demux_t * );
void (*close)( screen_data_t * );
};
typedef struct
{
es_format_t fmt;
......@@ -72,11 +78,10 @@ typedef struct
#endif
screen_data_t *p_data;
const struct screen_capture_operations *ops;
} demux_sys_t;
int screen_InitCapture ( demux_t * );
int screen_CloseCapture( demux_t * );
block_t *screen_Capture( demux_t * );
#ifdef SCREEN_SUBSCREEN
void FollowMouse( demux_sys_t *, int, int );
......
......@@ -32,6 +32,10 @@
#include "screen.h"
static void screen_CloseCapture(screen_data_t *);
static block_t *screen_Capture(demux_t *);
struct screen_data_t
{
HDC hdc_src;
......@@ -162,14 +166,16 @@ int screen_InitCapture( demux_t *p_demux )
p_data->ptl.x = - GetSystemMetrics( SM_XVIRTUALSCREEN );
p_data->ptl.y = - GetSystemMetrics( SM_YVIRTUALSCREEN );
static const struct screen_capture_operations ops = {
screen_Capture, screen_CloseCapture,
};
p_sys->ops = &ops;
return VLC_SUCCESS;
}
int screen_CloseCapture( demux_t *p_demux )
void screen_CloseCapture( screen_data_t *p_data )
{
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data = p_sys->p_data;
if( p_data->p_block ) block_Release( p_data->p_block );
if( p_data->hgdi_backup)
......@@ -178,8 +184,6 @@ int screen_CloseCapture( demux_t *p_demux )
DeleteDC( p_data->hdc_dst );
ReleaseDC( 0, p_data->hdc_src );
free( p_data );
return VLC_SUCCESS;
}
struct block_sys_t
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment