Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
c624c5f7
Commit
c624c5f7
authored
Jul 26, 2004
by
Eric Petit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALL: splitted screen module (needed as BeOS requires C++)
parent
ca9c15af
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
650 additions
and
5 deletions
+650
-5
configure.ac
configure.ac
+9
-4
modules/access/Modules.am
modules/access/Modules.am
+0
-1
modules/access/screen/Modules.am
modules/access/screen/Modules.am
+14
-0
modules/access/screen/beos.cpp
modules/access/screen/beos.cpp
+99
-0
modules/access/screen/screen.c
modules/access/screen/screen.c
+172
-0
modules/access/screen/screen.h
modules/access/screen/screen.h
+41
-0
modules/access/screen/win32.c
modules/access/screen/win32.c
+177
-0
modules/access/screen/x11.c
modules/access/screen/x11.c
+138
-0
No files found.
configure.ac
View file @
c624c5f7
...
...
@@ -1622,7 +1622,14 @@ dnl
AC_ARG_ENABLE(screen,
[ --enable-screen Screen capture support (default enabled)])
if test "${enable_screen}" != "no" && test "${SYS}" != "darwin"; then
if test "${SYS}" != "mingw32"; then
if test "${SYS}" = "mingw32"; then
VLC_ADD_PLUGINS([screen])
VLC_ADD_LDFLAGS([screen],[-lgdi32])
elif test "${SYS}" = "beos"; then
VLC_ADD_PLUGINS([screen])
VLC_ADD_CXXFLAGS([screen],[])
VLC_ADD_LDFLAGS([screen],[-lbe])
else
CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
AC_CHECK_HEADERS(X11/Xlib.h, [
VLC_ADD_PLUGINS([screen])
...
...
@@ -1630,9 +1637,6 @@ if test "${enable_screen}" != "no" && test "${SYS}" != "darwin"; then
VLC_ADD_CPPFLAGS([screen],[-I${x_includes}])
])
CPPFLAGS="${CPPFLAGS_save}"
else
VLC_ADD_PLUGINS([screen])
VLC_ADD_LDFLAGS([screen],[-lgdi32])
fi
fi
...
...
@@ -3936,6 +3940,7 @@ AC_CONFIG_FILES([
modules/access/cdda/Makefile
modules/access/vcd/Makefile
modules/access/vcdx/Makefile
modules/access/screen/Makefile
modules/access_output/Makefile
modules/audio_filter/Makefile
modules/audio_filter/channel_mixer/Makefile
...
...
modules/access/Modules.am
View file @
c624c5f7
...
...
@@ -7,7 +7,6 @@ SOURCES_access_ftp = ftp.c
SOURCES_dvdnav = dvdnav.c
SOURCES_dvdread = dvdread.c
SOURCES_slp = slp.c
SOURCES_screen = screen.c
SOURCES_cdda = \
cdda.c \
vcd/cdrom.c \
...
...
modules/access/screen/Modules.am
0 → 100644
View file @
c624c5f7
if HAVE_WIN32
screen_extra = win32.c
else
if HAVE_BEOS
screen_extra = beos.cpp
else
screen_extra = x11.c
endif
endif
SOURCES_screen = \
screen.c \
screen.h \
$(screen_extra) \
$(NULL)
modules/access/screen/beos.cpp
0 → 100644
View file @
c624c5f7
/*****************************************************************************
* beos.cpp: Screen capture module.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: screen.c 8284 2004-07-26 10:27:55Z gbazin $
*
* Authors: Eric Petit <titer@m0k.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <Screen.h>
#include <Bitmap.h>
extern
"C"
{
#include "screen.h"
struct
screen_data_t
{
BScreen
*
p_screen
;
BBitmap
*
p_bitmap
;
};
int
screen_InitCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
screen_data_t
*
p_data
;
BRect
rect
;
p_sys
->
p_data
=
p_data
=
(
screen_data_t
*
)
malloc
(
sizeof
(
screen_data_t
)
);
p_data
->
p_screen
=
new
BScreen
();
rect
=
p_data
->
p_screen
->
Frame
();
p_data
->
p_bitmap
=
new
BBitmap
(
rect
,
p_data
->
p_screen
->
ColorSpace
()
);
/* FIXME */
es_format_Init
(
&
p_sys
->
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
)
);
p_sys
->
fmt
.
video
.
i_width
=
(
int
)
rect
.
Width
();
p_sys
->
fmt
.
video
.
i_height
=
(
int
)
rect
.
Height
();
p_sys
->
fmt
.
video
.
i_bits_per_pixel
=
32
;
return
VLC_SUCCESS
;
}
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
;
delete
p_data
->
p_bitmap
;
delete
p_data
->
p_screen
;
free
(
p_data
);
return
VLC_SUCCESS
;
}
block_t
*
screen_Capture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
screen_data_t
*
p_data
=
p_sys
->
p_data
;
block_t
*
p_block
;
p_block
=
block_New
(
p_demux
,
4
*
p_sys
->
fmt
.
video
.
i_width
*
p_sys
->
fmt
.
video
.
i_height
);
p_data
->
p_screen
->
ReadBitmap
(
p_data
->
p_bitmap
);
for
(
unsigned
i
=
0
;
i
<
p_sys
->
fmt
.
video
.
i_height
;
i
++
)
{
memcpy
(
p_block
->
p_buffer
+
i
*
4
*
p_sys
->
fmt
.
video
.
i_width
,
(
uint8_t
*
)
p_data
->
p_bitmap
->
Bits
()
+
i
*
p_data
->
p_bitmap
->
BytesPerRow
(),
p_sys
->
fmt
.
video
.
i_width
);
}
return
p_block
;
}
}
/* extern "C" */
modules/access/screen.c
→
modules/access/screen
/screen
.c
View file @
c624c5f7
...
...
@@ -29,10 +29,7 @@
#include <vlc/vlc.h>
#include <vlc/input.h>
#ifndef WIN32
# include <X11/Xlib.h>
# include <X11/Xutil.h>
#endif
#include "screen.h"
/*****************************************************************************
* Module descriptor
...
...
@@ -63,34 +60,9 @@ vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
struct
demux_sys_t
{
es_format_t
fmt
;
es_out_id_t
*
es
;
float
f_fps
;
mtime_t
i_next_date
;
int
i_incr
;
#ifndef WIN32
Display
*
p_display
;
#else
HDC
hdc_src
;
HDC
hdc_dst
;
HBITMAP
hbmp
;
HGDIOBJ
hgdi_backup
;
uint8_t
*
p_buffer
;
#endif
};
static
int
Control
(
demux_t
*
,
int
,
va_list
);
static
int
Demux
(
demux_t
*
);
static
int
InitCapture
(
demux_t
*
);
static
int
CloseCapture
(
demux_t
*
);
static
block_t
*
Capture
(
demux_t
*
);
/*****************************************************************************
* DemuxOpen:
*****************************************************************************/
...
...
@@ -106,7 +78,7 @@ 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
)
);
if
(
InitCapture
(
p_demux
)
!=
VLC_SUCCESS
)
if
(
screen_
InitCapture
(
p_demux
)
!=
VLC_SUCCESS
)
{
free
(
p_sys
);
return
VLC_EGENERIC
;
...
...
@@ -138,7 +110,7 @@ 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
;
CloseCapture
(
p_demux
);
screen_
CloseCapture
(
p_demux
);
free
(
p_sys
);
}
...
...
@@ -157,7 +129,7 @@ static int Demux( demux_t *p_demux )
p_sys
->
i_next_date
+=
p_sys
->
i_incr
;
mwait
(
p_sys
->
i_next_date
);
p_block
=
Capture
(
p_demux
);
p_block
=
screen_
Capture
(
p_demux
);
if
(
!
p_block
)
return
0
;
p_block
->
i_dts
=
p_block
->
i_pts
=
p_sys
->
i_next_date
;
...
...
@@ -170,244 +142,6 @@ static int Demux( demux_t *p_demux )
return
1
;
}
/*****************************************************************************
* Platform dependant capture functions
*****************************************************************************/
#ifdef WIN32
static
int
InitCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_chroma
,
i_bits_per_pixel
;
BITMAPINFO
bmi
;
/* Get the device context for the whole screen */
p_sys
->
hdc_src
=
CreateDC
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
);
if
(
!
p_sys
->
hdc_src
)
{
msg_Err
(
p_demux
,
"cannot get device context"
);
return
VLC_EGENERIC
;
}
p_sys
->
hdc_dst
=
CreateCompatibleDC
(
p_sys
->
hdc_src
);
if
(
!
p_sys
->
hdc_dst
)
{
msg_Err
(
p_demux
,
"cannot get compat device context"
);
ReleaseDC
(
0
,
p_sys
->
hdc_src
);
return
VLC_EGENERIC
;
}
i_bits_per_pixel
=
GetDeviceCaps
(
p_sys
->
hdc_src
,
BITSPIXEL
);
switch
(
i_bits_per_pixel
)
{
case
8
:
/* FIXME: set the palette */
i_chroma
=
VLC_FOURCC
(
'R'
,
'G'
,
'B'
,
'2'
);
break
;
case
15
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'5'
);
break
;
case
16
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'6'
);
break
;
case
24
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
break
;
case
32
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
);
break
;
default:
msg_Err
(
p_demux
,
"unknown screen depth %i"
,
p_sys
->
fmt
.
video
.
i_bits_per_pixel
);
ReleaseDC
(
0
,
p_sys
->
hdc_src
);
ReleaseDC
(
0
,
p_sys
->
hdc_dst
);
return
VLC_EGENERIC
;
}
#if 1
/* For now we force RV24 because of chroma inversion in the other cases*/
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
i_bits_per_pixel
=
24
;
#endif
es_format_Init
(
&
p_sys
->
fmt
,
VIDEO_ES
,
i_chroma
);
p_sys
->
fmt
.
video
.
i_width
=
GetDeviceCaps
(
p_sys
->
hdc_src
,
HORZRES
);
p_sys
->
fmt
.
video
.
i_height
=
GetDeviceCaps
(
p_sys
->
hdc_src
,
VERTRES
);
p_sys
->
fmt
.
video
.
i_bits_per_pixel
=
i_bits_per_pixel
;
/* Create the bitmap info header */
bmi
.
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bmi
.
bmiHeader
.
biWidth
=
p_sys
->
fmt
.
video
.
i_width
;
bmi
.
bmiHeader
.
biHeight
=
-
p_sys
->
fmt
.
video
.
i_height
;
bmi
.
bmiHeader
.
biPlanes
=
1
;
bmi
.
bmiHeader
.
biBitCount
=
p_sys
->
fmt
.
video
.
i_bits_per_pixel
;
bmi
.
bmiHeader
.
biCompression
=
BI_RGB
;
bmi
.
bmiHeader
.
biSizeImage
=
0
;
bmi
.
bmiHeader
.
biXPelsPerMeter
=
bmi
.
bmiHeader
.
biYPelsPerMeter
=
0
;
bmi
.
bmiHeader
.
biClrUsed
=
0
;
bmi
.
bmiHeader
.
biClrImportant
=
0
;
/* Create the bitmap storage space */
p_sys
->
hbmp
=
CreateDIBSection
(
p_sys
->
hdc_dst
,
(
BITMAPINFO
*
)
&
bmi
,
DIB_RGB_COLORS
,
(
void
**
)
&
p_sys
->
p_buffer
,
NULL
,
0
);
if
(
!
p_sys
->
hbmp
||
!
p_sys
->
p_buffer
)
{
msg_Err
(
p_demux
,
"cannot create bitmap"
);
if
(
p_sys
->
hbmp
)
DeleteObject
(
p_sys
->
hbmp
);
ReleaseDC
(
0
,
p_sys
->
hdc_src
);
DeleteDC
(
p_sys
->
hdc_dst
);
return
VLC_EGENERIC
;
}
/* Select the bitmap into the compatible DC */
p_sys
->
hgdi_backup
=
SelectObject
(
p_sys
->
hdc_dst
,
p_sys
->
hbmp
);
if
(
!
p_sys
->
hgdi_backup
)
{
msg_Err
(
p_demux
,
"cannot select bitmap"
);
}
return
VLC_SUCCESS
;
}
#else
static
int
InitCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
XWindowAttributes
win_info
;
int
i_chroma
;
/* Open the display */
p_sys
->
p_display
=
XOpenDisplay
(
NULL
);
if
(
!
p_sys
->
p_display
)
{
msg_Err
(
p_demux
,
"cannot open display"
);
return
VLC_EGENERIC
;
}
/* Get the parameters of the root window */
if
(
!
XGetWindowAttributes
(
p_sys
->
p_display
,
DefaultRootWindow
(
p_sys
->
p_display
),
&
win_info
)
)
{
msg_Err
(
p_demux
,
"can't get root window attributes"
);
XCloseDisplay
(
p_sys
->
p_display
);
return
VLC_EGENERIC
;
}
switch
(
win_info
.
depth
)
{
case
8
:
/* FIXME: set the palette */
i_chroma
=
VLC_FOURCC
(
'R'
,
'G'
,
'B'
,
'2'
);
break
;
case
15
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'5'
);
break
;
case
16
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'6'
);
break
;
case
24
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
break
;
case
32
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
);
break
;
default:
msg_Err
(
p_demux
,
"unknown screen depth %i"
,
win_info
.
depth
);
XCloseDisplay
(
p_sys
->
p_display
);
return
VLC_EGENERIC
;
}
es_format_Init
(
&
p_sys
->
fmt
,
VIDEO_ES
,
i_chroma
);
p_sys
->
fmt
.
video
.
i_width
=
win_info
.
width
;
p_sys
->
fmt
.
video
.
i_height
=
win_info
.
height
;
p_sys
->
fmt
.
video
.
i_bits_per_pixel
=
win_info
.
depth
;
#if 0
win_info.visual->red_mask;
win_info.visual->green_mask;
win_info.visual->blue_mask;
win_info.visual->bits_per_rgb;
#endif
return
VLC_SUCCESS
;
}
#endif
#ifdef WIN32
static
int
CloseCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
SelectObject
(
p_sys
->
hdc_dst
,
p_sys
->
hgdi_backup
);
DeleteObject
(
p_sys
->
hbmp
);
DeleteDC
(
p_sys
->
hdc_dst
);
ReleaseDC
(
0
,
p_sys
->
hdc_src
);
return
VLC_SUCCESS
;
}
#else
static
int
CloseCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
XCloseDisplay
(
p_sys
->
p_display
);
return
VLC_SUCCESS
;
}
#endif
#ifdef WIN32
static
block_t
*
Capture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block
;
int
i_size
;
if
(
!
BitBlt
(
p_sys
->
hdc_dst
,
0
,
0
,
p_sys
->
fmt
.
video
.
i_width
,
p_sys
->
fmt
.
video
.
i_height
,
p_sys
->
hdc_src
,
0
,
0
,
SRCCOPY
)
)
{
msg_Err
(
p_demux
,
"error during BitBlt()"
);
return
NULL
;
}
i_size
=
(
p_sys
->
fmt
.
video
.
i_bits_per_pixel
+
7
)
/
8
*
p_sys
->
fmt
.
video
.
i_width
*
p_sys
->
fmt
.
video
.
i_height
;
if
(
!
(
p_block
=
block_New
(
p_demux
,
i_size
)
)
)
{
msg_Warn
(
p_demux
,
"cannot get block"
);
return
0
;
}
memcpy
(
p_block
->
p_buffer
,
p_sys
->
p_buffer
,
i_size
);
return
p_block
;
}
#else
static
block_t
*
Capture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
block_t
*
p_block
;
XImage
*
image
;
int
i_size
;
image
=
XGetImage
(
p_sys
->
p_display
,
DefaultRootWindow
(
p_sys
->
p_display
),
0
,
0
,
p_sys
->
fmt
.
video
.
i_width
,
p_sys
->
fmt
.
video
.
i_height
,
AllPlanes
,
ZPixmap
);
if
(
!
image
)
{
msg_Warn
(
p_demux
,
"cannot get image"
);
return
0
;
}
i_size
=
image
->
bytes_per_line
*
image
->
height
;
if
(
!
(
p_block
=
block_New
(
p_demux
,
i_size
)
)
)
{
msg_Warn
(
p_demux
,
"cannot get block"
);
XDestroyImage
(
image
);
return
0
;
}
memcpy
(
p_block
->
p_buffer
,
image
->
data
,
i_size
);
XDestroyImage
(
image
);
return
p_block
;
}
#endif
/*****************************************************************************
* Control:
*****************************************************************************/
...
...
modules/access/screen/screen.h
0 → 100644
View file @
c624c5f7
/*****************************************************************************
* screen.h: Screen capture module.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
typedef
struct
screen_data_t
screen_data_t
;
struct
demux_sys_t
{
es_format_t
fmt
;
es_out_id_t
*
es
;
float
f_fps
;
mtime_t
i_next_date
;
int
i_incr
;
screen_data_t
*
p_data
;
};
int
screen_InitCapture
(
demux_t
*
);
int
screen_CloseCapture
(
demux_t
*
);
block_t
*
screen_Capture
(
demux_t
*
);
modules/access/screen/win32.c
0 → 100644
View file @
c624c5f7
/*****************************************************************************
* win32.c: Screen capture module.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include "screen.h"
struct
screen_data_t
{
HDC
hdc_src
;
HDC
hdc_dst
;
HBITMAP
hbmp
;
HGDIOBJ
hgdi_backup
;
uint8_t
*
p_buffer
;
};
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
;
BITMAPINFO
bmi
;
p_sys
->
p_data
=
p_data
=
malloc
(
sizeof
(
screen_data_t
)
);
/* Get the device context for the whole screen */
p_data
->
hdc_src
=
CreateDC
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
);
if
(
!
p_data
->
hdc_src
)
{
msg_Err
(
p_demux
,
"cannot get device context"
);
return
VLC_EGENERIC
;
}
p_data
->
hdc_dst
=
CreateCompatibleDC
(
p_data
->
hdc_src
);
if
(
!
p_data
->
hdc_dst
)
{
msg_Err
(
p_demux
,
"cannot get compat device context"
);
ReleaseDC
(
0
,
p_data
->
hdc_src
);
return
VLC_EGENERIC
;
}
i_bits_per_pixel
=
GetDeviceCaps
(
p_data
->
hdc_src
,
BITSPIXEL
);
switch
(
i_bits_per_pixel
)
{
case
8
:
/* FIXME: set the palette */
i_chroma
=
VLC_FOURCC
(
'R'
,
'G'
,
'B'
,
'2'
);
break
;
case
15
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'5'
);
break
;
case
16
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'6'
);
break
;
case
24
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
break
;
case
32
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
);
break
;
default:
msg_Err
(
p_demux
,
"unknown screen depth %i"
,
p_sys
->
fmt
.
video
.
i_bits_per_pixel
);
ReleaseDC
(
0
,
p_data
->
hdc_src
);
ReleaseDC
(
0
,
p_data
->
hdc_dst
);
return
VLC_EGENERIC
;
}
#if 1
/* For now we force RV24 because of chroma inversion in the other cases*/
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
i_bits_per_pixel
=
24
;
#endif
es_format_Init
(
&
p_sys
->
fmt
,
VIDEO_ES
,
i_chroma
);
p_sys
->
fmt
.
video
.
i_width
=
GetDeviceCaps
(
p_data
->
hdc_src
,
HORZRES
);
p_sys
->
fmt
.
video
.
i_height
=
GetDeviceCaps
(
p_data
->
hdc_src
,
VERTRES
);
p_sys
->
fmt
.
video
.
i_bits_per_pixel
=
i_bits_per_pixel
;
/* Create the bitmap info header */
bmi
.
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bmi
.
bmiHeader
.
biWidth
=
p_sys
->
fmt
.
video
.
i_width
;
bmi
.
bmiHeader
.
biHeight
=
-
p_sys
->
fmt
.
video
.
i_height
;
bmi
.
bmiHeader
.
biPlanes
=
1
;
bmi
.
bmiHeader
.
biBitCount
=
p_sys
->
fmt
.
video
.
i_bits_per_pixel
;
bmi
.
bmiHeader
.
biCompression
=
BI_RGB
;
bmi
.
bmiHeader
.
biSizeImage
=
0
;
bmi
.
bmiHeader
.
biXPelsPerMeter
=
bmi
.
bmiHeader
.
biYPelsPerMeter
=
0
;
bmi
.
bmiHeader
.
biClrUsed
=
0
;
bmi
.
bmiHeader
.
biClrImportant
=
0
;
/* Create the bitmap storage space */
p_data
->
hbmp
=
CreateDIBSection
(
p_data
->
hdc_dst
,
(
BITMAPINFO
*
)
&
bmi
,
DIB_RGB_COLORS
,
(
void
**
)
&
p_data
->
p_buffer
,
NULL
,
0
);
if
(
!
p_data
->
hbmp
||
!
p_data
->
p_buffer
)
{
msg_Err
(
p_demux
,
"cannot create bitmap"
);
if
(
p_data
->
hbmp
)
DeleteObject
(
p_data
->
hbmp
);
ReleaseDC
(
0
,
p_data
->
hdc_src
);
DeleteDC
(
p_data
->
hdc_dst
);
return
VLC_EGENERIC
;
}
/* Select the bitmap into the compatible DC */
p_data
->
hgdi_backup
=
SelectObject
(
p_data
->
hdc_dst
,
p_data
->
hbmp
);
if
(
!
p_data
->
hgdi_backup
)
{
msg_Err
(
p_demux
,
"cannot select bitmap"
);
}
return
VLC_SUCCESS
;
}
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
;
SelectObject
(
p_data
->
hdc_dst
,
p_data
->
hgdi_backup
);
DeleteObject
(
p_data
->
hbmp
);
DeleteDC
(
p_data
->
hdc_dst
);
ReleaseDC
(
0
,
p_data
->
hdc_src
);
free
(
p_data
);
return
VLC_SUCCESS
;
}
block_t
*
screen_Capture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
screen_data_t
*
p_data
=
p_sys
->
p_data
;
block_t
*
p_block
;
int
i_size
;
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
,
SRCCOPY
)
)
{
msg_Err
(
p_demux
,
"error during BitBlt()"
);
return
NULL
;
}
i_size
=
(
p_sys
->
fmt
.
video
.
i_bits_per_pixel
+
7
)
/
8
*
p_sys
->
fmt
.
video
.
i_width
*
p_sys
->
fmt
.
video
.
i_height
;
if
(
!
(
p_block
=
block_New
(
p_demux
,
i_size
)
)
)
{
msg_Warn
(
p_demux
,
"cannot get block"
);
return
0
;
}
memcpy
(
p_block
->
p_buffer
,
p_data
->
p_buffer
,
i_size
);
return
p_block
;
}
modules/access/screen/x11.c
0 → 100644
View file @
c624c5f7
/*****************************************************************************
* x11.c: Screen capture module.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "screen.h"
int
screen_InitCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
Display
*
p_display
;
XWindowAttributes
win_info
;
int
i_chroma
;
/* Open the display */
p_display
=
XOpenDisplay
(
NULL
);
if
(
!
p_display
)
{
msg_Err
(
p_demux
,
"cannot open display"
);
return
VLC_EGENERIC
;
}
p_sys
->
p_data
=
(
void
*
)
p_display
;
/* Get the parameters of the root window */
if
(
!
XGetWindowAttributes
(
p_display
,
DefaultRootWindow
(
p_display
),
&
win_info
)
)
{
msg_Err
(
p_demux
,
"can't get root window attributes"
);
XCloseDisplay
(
p_display
);
return
VLC_EGENERIC
;
}
switch
(
win_info
.
depth
)
{
case
8
:
/* FIXME: set the palette */
i_chroma
=
VLC_FOURCC
(
'R'
,
'G'
,
'B'
,
'2'
);
break
;
case
15
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'5'
);
break
;
case
16
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'1'
,
'6'
);
break
;
case
24
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'2'
,
'4'
);
break
;
case
32
:
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
);
break
;
default:
msg_Err
(
p_demux
,
"unknown screen depth %i"
,
win_info
.
depth
);
XCloseDisplay
(
p_display
);
return
VLC_EGENERIC
;
}
es_format_Init
(
&
p_sys
->
fmt
,
VIDEO_ES
,
i_chroma
);
p_sys
->
fmt
.
video
.
i_width
=
win_info
.
width
;
p_sys
->
fmt
.
video
.
i_height
=
win_info
.
height
;
p_sys
->
fmt
.
video
.
i_bits_per_pixel
=
win_info
.
depth
;
#if 0
win_info.visual->red_mask;
win_info.visual->green_mask;
win_info.visual->blue_mask;
win_info.visual->bits_per_rgb;
#endif
return
VLC_SUCCESS
;
}
int
screen_CloseCapture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
Display
*
p_display
=
(
Display
*
)
p_sys
->
p_data
;
XCloseDisplay
(
p_display
);
return
VLC_SUCCESS
;
}
block_t
*
screen_Capture
(
demux_t
*
p_demux
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
Display
*
p_display
=
(
Display
*
)
p_sys
->
p_data
;
block_t
*
p_block
;
XImage
*
image
;
int
i_size
;
image
=
XGetImage
(
p_display
,
DefaultRootWindow
(
p_display
),
0
,
0
,
p_sys
->
fmt
.
video
.
i_width
,
p_sys
->
fmt
.
video
.
i_height
,
AllPlanes
,
ZPixmap
);
if
(
!
image
)
{
msg_Warn
(
p_demux
,
"cannot get image"
);
return
0
;
}
i_size
=
image
->
bytes_per_line
*
image
->
height
;
if
(
!
(
p_block
=
block_New
(
p_demux
,
i_size
)
)
)
{
msg_Warn
(
p_demux
,
"cannot get block"
);
XDestroyImage
(
image
);
return
0
;
}
memcpy
(
p_block
->
p_buffer
,
image
->
data
,
i_size
);
XDestroyImage
(
image
);
return
p_block
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment