Commit 1909f528 authored by gbazin's avatar gbazin

* modules/access/screen/*: added a win32 only --screen-fragment-size option to...

* modules/access/screen/*: added a win32 only --screen-fragment-size option to do a kind of progressive capture by splitting the screen in several fragments. This does help user interactivity while capturing but also produces artefacts when moving windows around.
parent 0a9f281f
......@@ -42,6 +42,13 @@
#define FPS_LONGTEXT N_( \
"Allows you to set the desired frame rate for the capture." )
#ifdef WIN32
#define FRAGS_TEXT N_("Capture fragement size")
#define FRAGS_LONGTEXT N_( \
"Allows you optimize the capture by fragmenting the screen in chunks " \
"of predefined height (16 might be a good value, and 0 means disabled)." )
#endif
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
......@@ -58,6 +65,11 @@ vlc_module_begin();
CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
add_float( "screen-fps", SCREEN_FPS, 0, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE );
#ifdef WIN32
add_integer( "screen-fragment-size", 0, NULL, FRAGS_TEXT,
FRAGS_LONGTEXT, VLC_TRUE );
#endif
set_capability( "access_demux", 0 );
add_shortcut( "screen" );
set_callbacks( Open, Close );
......@@ -84,6 +96,15 @@ static int Open( vlc_object_t *p_this )
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
/* Update default_pts to a suitable value for screen access */
var_Create( p_demux, "screen-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_demux, "screen-fps", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
var_Get( p_demux, "screen-fps", &val );
p_sys->f_fps = val.f_float;
p_sys->i_incr = 1000000 / val.f_float;
p_sys->i_next_date = 0;
if( screen_InitCapture( p_demux ) != VLC_SUCCESS )
{
free( p_sys );
......@@ -96,15 +117,6 @@ static int Open( vlc_object_t *p_this )
p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt );
/* Update default_pts to a suitable value for screen access */
var_Create( p_demux, "screen-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_demux, "screen-fps", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
var_Get( p_demux, "screen-fps", &val );
p_sys->f_fps = val.f_float;
p_sys->i_incr = 1000000 / val.f_float;
p_sys->i_next_date = 0;
return VLC_SUCCESS;
}
......@@ -136,7 +148,11 @@ static int Demux( demux_t *p_demux )
mwait( p_sys->i_next_date );
p_block = screen_Capture( p_demux );
if( !p_block ) return 0;
if( !p_block )
{
p_sys->i_next_date += p_sys->i_incr;
return 1;
}
p_block->i_dts = p_block->i_pts = p_sys->i_next_date;
......
......@@ -41,6 +41,10 @@ struct screen_data_t
HDC hdc_dst;
BITMAPINFO bmi;
HGDIOBJ hgdi_backup;
int i_fragment_size;
int i_fragment;
block_t *p_block;
};
int screen_InitCapture( demux_t *p_demux )
......@@ -48,6 +52,7 @@ int screen_InitCapture( demux_t *p_demux )
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data;
int i_chroma, i_bits_per_pixel;
vlc_value_t val;
p_sys->p_data = p_data = malloc( sizeof( screen_data_t ) );
......@@ -111,6 +116,19 @@ int screen_InitCapture( demux_t *p_demux )
p_data->bmi.bmiHeader.biClrUsed = 0;
p_data->bmi.bmiHeader.biClrImportant = 0;
var_Create( p_demux, "screen-fragment-size",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_demux, "screen-fragment-size", &val );
p_data->i_fragment_size =
val.i_int > 0 ? val.i_int : p_sys->fmt.video.i_height;
p_data->i_fragment_size =
val.i_int > p_sys->fmt.video.i_height ? p_sys->fmt.video.i_height :
p_data->i_fragment_size;
p_sys->f_fps *= (p_sys->fmt.video.i_height/p_data->i_fragment_size);
p_sys->i_incr = 1000000 / p_sys->f_fps;
p_data->i_fragment = 0;
p_data->p_block = 0;
return VLC_SUCCESS;
}
......@@ -119,6 +137,8 @@ int screen_CloseCapture( demux_t *p_demux )
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)
SelectObject( p_data->hdc_dst, p_data->hgdi_backup );
......@@ -172,16 +192,6 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
return NULL;
}
if( !BitBlt( p_data->hdc_dst, 0, 0,
p_sys->fmt.video.i_width, p_sys->fmt.video.i_height,
p_data->hdc_src, 0, 0,
IS_WINNT ? SRCCOPY | CAPTUREBLT : SRCCOPY ) )
{
msg_Err( p_demux, "error during BitBlt()" );
DeleteObject( hbmp );
return NULL;
}
/* Build block */
if( !(p_block = malloc( sizeof( block_t ) + sizeof( block_sys_t ) )) )
{
......@@ -206,13 +216,39 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
block_t *screen_Capture( demux_t *p_demux )
{
block_t *p_block;
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data = p_sys->p_data;
if( !( p_block = CaptureBlockNew( p_demux ) ) )
if( !p_data->i_fragment )
{
msg_Warn( p_demux, "cannot get block" );
return 0;
if( !( p_data->p_block = CaptureBlockNew( p_demux ) ) )
{
msg_Warn( p_demux, "cannot get block" );
return 0;
}
}
return p_block;
if( !BitBlt( p_data->hdc_dst, 0, p_data->i_fragment *
p_data->i_fragment_size,
p_sys->fmt.video.i_width, p_data->i_fragment_size,
p_data->hdc_src, 0, p_data->i_fragment *
p_data->i_fragment_size,
IS_WINNT ? SRCCOPY | CAPTUREBLT : SRCCOPY ) )
{
msg_Err( p_demux, "error during BitBlt()" );
return NULL;
}
p_data->i_fragment++;
if( !( p_data->i_fragment %
(p_sys->fmt.video.i_height/p_data->i_fragment_size) ) )
{
block_t *p_block = p_data->p_block;
p_data->i_fragment = 0;
p_data->p_block = 0;
return p_block;
}
return NULL;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment