Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

beos.cpp

00001 /*****************************************************************************
00002  * beos.cpp: Screen capture module.
00003  *****************************************************************************
00004  * Copyright (C) 2004 the VideoLAN team
00005  * $Id: beos.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Eric Petit <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #include <stdlib.h>
00025 
00026 #include <vlc/vlc.h>
00027 #include <vlc/input.h>
00028 
00029 #include <Screen.h>
00030 #include <Bitmap.h>
00031 
00032 extern "C"
00033 {
00034 
00035 #include "screen.h"
00036 
00037 struct screen_data_t
00038 {
00039     BScreen * p_screen;
00040     BBitmap * p_bitmap;
00041 };
00042 
00043 int screen_InitCapture( demux_t *p_demux )
00044 {
00045     demux_sys_t   *p_sys = p_demux->p_sys;
00046     screen_data_t *p_data;
00047     BRect          rect;
00048     int            i_chroma;
00049     int            i_bits_per_pixel;
00050 
00051     p_sys->p_data = p_data =
00052         (screen_data_t *)malloc( sizeof( screen_data_t ) );
00053 
00054     p_data->p_screen = new BScreen();
00055     rect = p_data->p_screen->Frame();
00056 
00057     p_data->p_bitmap = new BBitmap( rect, p_data->p_screen->ColorSpace() );
00058 
00059     switch( p_data->p_screen->ColorSpace() )
00060     {
00061         case B_RGB32:
00062             i_chroma = VLC_FOURCC('R','V','3','2');
00063             i_bits_per_pixel = 32;
00064             break;
00065         case B_RGB16:
00066             i_chroma = VLC_FOURCC('R','V','1','6');
00067             i_bits_per_pixel = 16;
00068             break;
00069         default:
00070             msg_Err( p_demux, "screen depth %i unsupported",
00071                      p_data->p_screen->ColorSpace() );
00072             delete p_data->p_bitmap;
00073             delete p_data->p_screen;
00074             free( p_data );
00075             return VLC_EGENERIC;
00076     }
00077     es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma );
00078     p_sys->fmt.video.i_width  = (int)rect.Width();
00079     p_sys->fmt.video.i_height = (int)rect.Height();
00080     p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel;
00081 
00082     return VLC_SUCCESS;
00083 }
00084 
00085 int screen_CloseCapture( demux_t *p_demux )
00086 {
00087     demux_sys_t   *p_sys  = p_demux->p_sys;
00088     screen_data_t *p_data = p_sys->p_data;
00089 
00090     delete p_data->p_bitmap;
00091     delete p_data->p_screen;
00092     free( p_data );
00093 
00094     return VLC_SUCCESS;
00095 }
00096 
00097 block_t *screen_Capture( demux_t *p_demux )
00098 {
00099     demux_sys_t   *p_sys  = p_demux->p_sys;
00100     screen_data_t *p_data = p_sys->p_data;
00101     block_t       *p_block;
00102 
00103     p_block = block_New( p_demux, p_sys->fmt.video.i_width *
00104                          p_sys->fmt.video.i_height *
00105                          p_sys->fmt.video.i_bits_per_pixel / 8 );
00106 
00107     p_data->p_screen->ReadBitmap( p_data->p_bitmap );
00108 
00109     for( unsigned i = 0; i < p_sys->fmt.video.i_height; i++ )
00110     {
00111         memcpy( p_block->p_buffer + i * p_sys->fmt.video.i_width *
00112                     p_sys->fmt.video.i_bits_per_pixel / 8,
00113                 (uint8_t *) p_data->p_bitmap->Bits() +
00114                     i * p_data->p_bitmap->BytesPerRow(),
00115                 p_sys->fmt.video.i_width *
00116                     p_sys->fmt.video.i_bits_per_pixel / 8 );
00117     }
00118     return p_block;
00119 }
00120 
00121 } /* extern "C" */

Generated on Tue Dec 20 10:14:26 2005 for vlc-0.8.4a by  doxygen 1.4.2