| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
#ifdef HAVE_CONFIG_H |
|---|
| 26 |
# include "config.h" |
|---|
| 27 |
#endif |
|---|
| 28 |
|
|---|
| 29 |
#include <vlc_common.h> |
|---|
| 30 |
|
|---|
| 31 |
#include <Screen.h> |
|---|
| 32 |
#include <Bitmap.h> |
|---|
| 33 |
|
|---|
| 34 |
extern "C" |
|---|
| 35 |
{ |
|---|
| 36 |
|
|---|
| 37 |
#include "screen.h" |
|---|
| 38 |
|
|---|
| 39 |
struct screen_data_t |
|---|
| 40 |
{ |
|---|
| 41 |
BScreen * p_screen; |
|---|
| 42 |
BBitmap * p_bitmap; |
|---|
| 43 |
}; |
|---|
| 44 |
|
|---|
| 45 |
int screen_InitCapture( demux_t *p_demux ) |
|---|
| 46 |
{ |
|---|
| 47 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 48 |
screen_data_t *p_data; |
|---|
| 49 |
BRect rect; |
|---|
| 50 |
int i_chroma; |
|---|
| 51 |
int i_bits_per_pixel; |
|---|
| 52 |
|
|---|
| 53 |
p_sys->p_data = p_data = |
|---|
| 54 |
(screen_data_t *)malloc( sizeof( screen_data_t ) ); |
|---|
| 55 |
|
|---|
| 56 |
p_data->p_screen = new BScreen(); |
|---|
| 57 |
rect = p_data->p_screen->Frame(); |
|---|
| 58 |
|
|---|
| 59 |
p_data->p_bitmap = new BBitmap( rect, p_data->p_screen->ColorSpace() ); |
|---|
| 60 |
|
|---|
| 61 |
switch( p_data->p_screen->ColorSpace() ) |
|---|
| 62 |
{ |
|---|
| 63 |
case B_RGB32: |
|---|
| 64 |
i_chroma = VLC_FOURCC('R','V','3','2'); |
|---|
| 65 |
i_bits_per_pixel = 32; |
|---|
| 66 |
break; |
|---|
| 67 |
case B_RGB16: |
|---|
| 68 |
i_chroma = VLC_FOURCC('R','V','1','6'); |
|---|
| 69 |
i_bits_per_pixel = 16; |
|---|
| 70 |
break; |
|---|
| 71 |
default: |
|---|
| 72 |
msg_Err( p_demux, "screen depth %i unsupported", |
|---|
| 73 |
p_data->p_screen->ColorSpace() ); |
|---|
| 74 |
delete p_data->p_bitmap; |
|---|
| 75 |
delete p_data->p_screen; |
|---|
| 76 |
free( p_data ); |
|---|
| 77 |
return VLC_EGENERIC; |
|---|
| 78 |
} |
|---|
| 79 |
es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma ); |
|---|
| 80 |
p_sys->fmt.video.i_width = (int)rect.Width(); |
|---|
| 81 |
p_sys->fmt.video.i_height = (int)rect.Height(); |
|---|
| 82 |
p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel; |
|---|
| 83 |
|
|---|
| 84 |
return VLC_SUCCESS; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
int screen_CloseCapture( demux_t *p_demux ) |
|---|
| 88 |
{ |
|---|
| 89 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 90 |
screen_data_t *p_data = p_sys->p_data; |
|---|
| 91 |
|
|---|
| 92 |
delete p_data->p_bitmap; |
|---|
| 93 |
delete p_data->p_screen; |
|---|
| 94 |
free( p_data ); |
|---|
| 95 |
|
|---|
| 96 |
return VLC_SUCCESS; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
block_t *screen_Capture( demux_t *p_demux ) |
|---|
| 100 |
{ |
|---|
| 101 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 102 |
screen_data_t *p_data = p_sys->p_data; |
|---|
| 103 |
block_t *p_block; |
|---|
| 104 |
|
|---|
| 105 |
p_block = block_New( p_demux, p_sys->fmt.video.i_width * |
|---|
| 106 |
p_sys->fmt.video.i_height * |
|---|
| 107 |
p_sys->fmt.video.i_bits_per_pixel / 8 ); |
|---|
| 108 |
|
|---|
| 109 |
p_data->p_screen->ReadBitmap( p_data->p_bitmap ); |
|---|
| 110 |
|
|---|
| 111 |
for( unsigned i = 0; i < p_sys->fmt.video.i_height; i++ ) |
|---|
| 112 |
{ |
|---|
| 113 |
memcpy( p_block->p_buffer + i * p_sys->fmt.video.i_width * |
|---|
| 114 |
p_sys->fmt.video.i_bits_per_pixel / 8, |
|---|
| 115 |
(uint8_t *) p_data->p_bitmap->Bits() + |
|---|
| 116 |
i * p_data->p_bitmap->BytesPerRow(), |
|---|
| 117 |
p_sys->fmt.video.i_width * |
|---|
| 118 |
p_sys->fmt.video.i_bits_per_pixel / 8 ); |
|---|
| 119 |
} |
|---|
| 120 |
return p_block; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
} |
|---|