1 /*****************************************************************************
2 * beos.cpp: Screen capture module.
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Eric Petit <titer@m0k.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
42 int screen_InitCapture( demux_t *p_demux )
44 demux_sys_t *p_sys = p_demux->p_sys;
45 screen_data_t *p_data;
50 p_sys->p_data = p_data =
51 (screen_data_t *)malloc( sizeof( screen_data_t ) );
53 p_data->p_screen = new BScreen();
54 rect = p_data->p_screen->Frame();
56 p_data->p_bitmap = new BBitmap( rect, p_data->p_screen->ColorSpace() );
58 switch( p_data->p_screen->ColorSpace() )
61 i_chroma = VLC_FOURCC('R','V','3','2');
62 i_bits_per_pixel = 32;
65 i_chroma = VLC_FOURCC('R','V','1','6');
66 i_bits_per_pixel = 16;
69 msg_Err( p_demux, "screen depth %i unsupported",
70 p_data->p_screen->ColorSpace() );
71 delete p_data->p_bitmap;
72 delete p_data->p_screen;
76 es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma );
77 p_sys->fmt.video.i_width = (int)rect.Width();
78 p_sys->fmt.video.i_height = (int)rect.Height();
79 p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel;
84 int screen_CloseCapture( demux_t *p_demux )
86 demux_sys_t *p_sys = p_demux->p_sys;
87 screen_data_t *p_data = p_sys->p_data;
89 delete p_data->p_bitmap;
90 delete p_data->p_screen;
96 block_t *screen_Capture( demux_t *p_demux )
98 demux_sys_t *p_sys = p_demux->p_sys;
99 screen_data_t *p_data = p_sys->p_data;
102 p_block = block_New( p_demux, p_sys->fmt.video.i_width *
103 p_sys->fmt.video.i_height *
104 p_sys->fmt.video.i_bits_per_pixel / 8 );
106 p_data->p_screen->ReadBitmap( p_data->p_bitmap );
108 for( unsigned i = 0; i < p_sys->fmt.video.i_height; i++ )
110 memcpy( p_block->p_buffer + i * p_sys->fmt.video.i_width *
111 p_sys->fmt.video.i_bits_per_pixel / 8,
112 (uint8_t *) p_data->p_bitmap->Bits() +
113 i * p_data->p_bitmap->BytesPerRow(),
114 p_sys->fmt.video.i_width *
115 p_sys->fmt.video.i_bits_per_pixel / 8 );