00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include "config.h"
00065 #include "gxsm/plugin.h"
00066 #include "gxsm/xsmhard.h"
00067
00068
00069
00070 #define THIS_HWI_PLUGIN_NAME "video4linux"
00071
00072
00073 static void grab_v4l_init( void );
00074 static void grab_v4l_about( void );
00075 static void grab_v4l_configure( void );
00076 static void grab_v4l_cleanup( void );
00077
00078 extern "C" gint gxsm_v4l_open_video4l ();
00079 extern "C" gint gxsm_v4l_close_video4l ();
00080 extern "C" gint gxsm_v4l_maxwidth ();
00081 extern "C" gint gxsm_v4l_maxheight ();
00082 extern "C" gint gxsm_v4l_win_width ();
00083 extern "C" gint gxsm_v4l_win_height ();
00084 extern "C" gint gxsm_v4l_grab_video4l ();
00085 extern "C" gint gxsm_v4l_get_pixel (int *r, int *g, int *b);
00086
00087
00088 GxsmPlugin grab_v4l_pi = {
00089 NULL,
00090 NULL,
00091 0,
00092 NULL,
00093
00094
00095
00096
00097 "grab_v4l-"
00098 "HW-INT-1S-RGB",
00099
00100
00101
00102 THIS_HWI_PLUGIN_NAME,
00103
00104 "Video for Linux interface.",
00105
00106 "Percy Zahl",
00107
00108 N_("Hardware/"),
00109
00110 N_(THIS_HWI_PLUGIN_NAME"-HwI"),
00111
00112 N_("This is a "THIS_HWI_PLUGIN_NAME" - GXSM Hardware Interface"),
00113
00114 "N/A",
00115 NULL,
00116 NULL,
00117
00118
00119 grab_v4l_init,
00120
00121
00122 NULL,
00123
00124
00125 grab_v4l_about,
00126
00127
00128 grab_v4l_configure,
00129
00130
00131 NULL,
00132
00133
00134 grab_v4l_cleanup
00135 };
00136
00137
00138
00139 static const char *about_text = N_("GXSM grab_v4l Plugin\n\n"
00140 "Video for Linux frame grabber.");
00141
00142
00143
00144
00145
00146
00147
00148
00149 class gxsm_v4l : public XSM_Hardware{
00150 public:
00151 gxsm_v4l();
00152 virtual ~gxsm_v4l();
00153
00154 virtual void PutParameter(void *src, int grp=0);
00155 virtual void ExecCmd(int Cmd);
00156 virtual int WaitExec(int data);
00157
00158
00159 virtual long GetMaxPointsPerLine(){ return gxsm_v4l_maxwidth (); };
00160 virtual long GetMaxLines(){ return gxsm_v4l_maxheight (); };
00161 virtual long GetMaxChannels(){ return 1L; };
00162 virtual void SetDxDy(int dx, int dy);
00163 virtual void SetOffset(long x, long y);
00164 virtual void SetNx(long nx);
00165 virtual void SetAlpha(double alpha);
00166
00167 virtual void MovetoXY(long x, long y);
00168 virtual void StartScan2D();
00169 virtual void ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0=0 );
00170 virtual void EndScan2D();
00171 virtual gchar* get_info(){
00172 return g_strdup("*--GXSM HwI Plugin: v4l::XSM_Hardware --*\n"
00173 "video4linux on /dev/video0 is connected!\n"
00174 "*--Features--*\n"
00175 "SCAN: Yes\n"
00176 "*--ExecCMD options--*\n"
00177 "*--EOF--*\n"
00178 );
00179 };
00180
00181 private:
00182 DSP_Param dspPar;
00183
00184
00185 };
00186
00187
00188
00189
00190
00191 gxsm_v4l *v4l_hardware = NULL;
00192
00193
00194
00195
00196 gxsm_v4l::gxsm_v4l():XSM_Hardware(){
00197
00198 gxsm_v4l_open_video4l();
00199 }
00200
00201
00202
00203
00204
00205 gxsm_v4l::~gxsm_v4l(){
00206 gxsm_v4l_close_video4l ();
00207 }
00208
00209
00210
00211
00212
00213 void gxsm_v4l::PutParameter(void *src, int grp){
00214 }
00215
00216 void gxsm_v4l::ExecCmd(int Cmd){
00217 }
00218 int gxsm_v4l::WaitExec(int data){ return 0; }
00219 void gxsm_v4l::MovetoXY(long x, long y){ rx=x; ry=y; }
00220 void gxsm_v4l::SetDxDy(int dx, int dy){
00221 Dx = dx;
00222 Dy = dy;
00223 }
00224 void gxsm_v4l::SetOffset(long x, long y){
00225 rotoffx = x; rotoffy = y;
00226 }
00227 void gxsm_v4l::SetAlpha(double alpha){
00228 Alpha=M_PI*alpha/180.;
00229 rotmyy = rotmxx = cos(Alpha);
00230 rotmyx = -(rotmxy = sin(Alpha));
00231 }
00232 void gxsm_v4l::SetNx(long nx){
00233 Nx=nx;
00234 }
00235
00236
00237 void gxsm_v4l::StartScan2D(){
00238
00239 gxsm_v4l_grab_video4l ();
00240 }
00241
00242 void gxsm_v4l::EndScan2D(){
00243 ;
00244 }
00245
00246
00247
00248
00249 void gxsm_v4l::ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0 ){
00250 int r,g,b;
00251 if (yindex < 0){
00252 if (yindex != -1) return;
00253 if(Mob[0])
00254 for(int j=0; j < gxsm_v4l_win_height () && j<Mob[0]->GetNy (); j++){
00255 for(int i=0; i<gxsm_v4l_win_width () && i < Mob[0]->GetNx (); i++)
00256 Mob[0]->PutDataPkt ((double)i*j, i, j);
00257 if(!(j%32))
00258 gapp->check_events();
00259 }
00260 return;
00261 }
00262
00263 if(yindex >= gxsm_v4l_win_height ())
00264 return;
00265
00266 if(Mob[0])
00267 for(int i=0; i < gxsm_v4l_win_width () && i < Mob[0]->GetNx (); i++)
00268 Mob[0]->PutDataPkt((double) gxsm_v4l_get_pixel (&r, &g, &b), i, yindex);
00269
00270 if(!(yindex%32))
00271 gapp->check_events();
00272 }
00273
00274
00275
00276
00277
00278
00279
00280
00281 GxsmPlugin *get_gxsm_plugin_info ( void ){
00282 grab_v4l_pi.description = g_strdup_printf(N_("GXSM HwI grab_v4l plugin %s"), VERSION);
00283 return &grab_v4l_pi;
00284 }
00285
00286
00287
00288 XSM_Hardware *get_gxsm_hwi_hardware_class ( void *data ) {
00289 return v4l_hardware;
00290 }
00291
00292
00293 static void grab_v4l_init(void)
00294 {
00295 PI_DEBUG (DBG_L2, "grab_v4l Plugin Init");
00296 v4l_hardware = new gxsm_v4l ();
00297 }
00298
00299
00300 static void grab_v4l_about(void)
00301 {
00302 const gchar *authors[] = { grab_v4l_pi.authors, NULL};
00303 gtk_widget_show(gnome_about_new ( grab_v4l_pi.name,
00304 VERSION,
00305 N_("(C) 2000 the Free Software Foundation"),
00306 about_text,
00307 authors,
00308 NULL, NULL, NULL
00309 ));
00310 }
00311
00312
00313 static void grab_v4l_configure(void)
00314 {
00315 if(grab_v4l_pi.app)
00316 grab_v4l_pi.app->message("grab_v4l Plugin Configuration");
00317 }
00318
00319
00320 static void grab_v4l_cleanup(void)
00321 {
00322 PI_DEBUG (DBG_L2, "grab_v4l Plugin Cleanup");
00323 delete v4l_hardware;
00324 v4l_hardware = NULL;
00325 }
00326
00327
00328