00001 //========================================================================== 00019 //-------------------------------------------------------------------------- 00020 // 00021 // libfg - Frame Grabber interface for Linux 00022 // Copyright (c) 2002 Gavin Baker 00023 // 00024 // This library is free software; you can redistribute it and/or 00025 // modify it under the terms of the GNU Lesser General Public 00026 // License as published by the Free Software Foundation; either 00027 // version 2.1 of the License, or (at your option) any later version. 00028 // 00029 // This library is distributed in the hope that it will be useful, 00030 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00031 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00032 // Lesser General Public License for more details. 00033 // 00034 // You should have received a copy of the GNU Lesser General Public 00035 // License along with this library; if not, write to the Free Software 00036 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00037 // or obtain a copy from the GNU website at http://www.gnu.org/ 00038 // 00039 //========================================================================== 00040 00041 #ifndef __CAPTURE__H_ 00042 #define __CAPTURE__H_ 00043 00044 00045 #include <stdio.h> 00046 #include <fcntl.h> 00047 #include <stdlib.h> 00048 #include <unistd.h> 00049 00050 #include <sys/mman.h> 00051 #include <sys/ioctl.h> 00052 00053 #include <linux/fs.h> 00054 #include <linux/kernel.h> 00055 #include <linux/videodev.h> 00056 00057 #include "frame.h" 00058 00059 //========================================================================== 00060 // Definitions 00061 //========================================================================== 00062 00063 // Standard device for fg_open() 00064 #define FG_DEFAULT_DEVICE "/dev/video" 00066 // Normal capture size 00067 #define FG_DEFAULT_WIDTH 640 00068 #define FG_DEFAULT_HEIGHT 480 00069 00070 // Percentage of a ushort 00071 #define FG_PERCENT(n) ((n)*65535/100) 00072 #define FG_50PC FG_PERCENT(50) 00073 00074 // Default input sources 00075 #define FG_SOURCE_TV 0 00076 #define FG_SOURCE_COMPOSITE 1 00077 #define FG_SOURCE_SVIDEO 2 00078 00079 //-------------------------------------------------------------------------- 00086 //-------------------------------------------------------------------------- 00087 typedef struct 00088 { 00089 char* device; 00090 int fd; 00091 struct video_capability caps; 00092 struct video_channel* sources; 00093 int source; 00094 struct video_tuner tuner; 00095 struct video_window window; 00096 struct video_picture picture; 00097 struct video_mmap mmap; 00098 struct video_buffer fbuffer; 00099 struct video_mbuf mbuf; 00100 void* mb_map; 00101 int cur_frame; 00102 00103 } FRAMEGRABBER; 00104 00105 //-------------------------------------------------------------------------- 00116 //-------------------------------------------------------------------------- 00117 00118 FRAMEGRABBER* fg_open( const char* dev ); 00119 00120 //-------------------------------------------------------------------------- 00127 //-------------------------------------------------------------------------- 00128 00129 void fg_close( FRAMEGRABBER* fg ); 00130 00131 //-------------------------------------------------------------------------- 00146 //-------------------------------------------------------------------------- 00147 00148 FRAME* fg_grab( FRAMEGRABBER* fg ); 00149 00150 //-------------------------------------------------------------------------- 00164 //-------------------------------------------------------------------------- 00165 FRAME* fg_grab_frame( FRAMEGRABBER* fg, FRAME* fr ); 00166 00167 00168 //--------------------------------------------------------------------------- 00179 //--------------------------------------------------------------------------- 00180 00181 int fg_set_source( FRAMEGRABBER* fg, int src ); 00182 00183 00184 //-------------------------------------------------------------------------- 00195 //-------------------------------------------------------------------------- 00196 00197 int fg_set_source_norm( FRAMEGRABBER* fg, int norm ); 00198 00199 00200 //-------------------------------------------------------------------------- 00208 //-------------------------------------------------------------------------- 00209 00210 int fg_get_source_count( FRAMEGRABBER* fg ); 00211 00212 00213 //-------------------------------------------------------------------------- 00223 //-------------------------------------------------------------------------- 00224 00225 char* fg_get_source_name( FRAMEGRABBER* fg, int src ); 00226 00227 00228 //-------------------------------------------------------------------------- 00238 //-------------------------------------------------------------------------- 00239 00240 int fg_set_channel( FRAMEGRABBER* fg, float freq ); 00241 00242 00243 //-------------------------------------------------------------------------- 00251 //-------------------------------------------------------------------------- 00252 00253 float fg_get_channel( FRAMEGRABBER* fg ); 00254 00255 00256 //-------------------------------------------------------------------------- 00268 //-------------------------------------------------------------------------- 00269 00270 int fg_set_format( FRAMEGRABBER* fg, int fmt ); 00271 00272 //-------------------------------------------------------------------------- 00287 //-------------------------------------------------------------------------- 00288 00289 int fg_set_capture_window( FRAMEGRABBER* fg, 00290 int x, int y, int width, int height ); 00291 00292 00293 //-------------------------------------------------------------------------- 00303 //-------------------------------------------------------------------------- 00304 00305 int fg_set_brightness( FRAMEGRABBER* fg, int br ); 00306 00307 00308 //-------------------------------------------------------------------------- 00318 //-------------------------------------------------------------------------- 00319 00320 int fg_set_hue( FRAMEGRABBER* fg, int hu ); 00321 00322 00323 //-------------------------------------------------------------------------- 00334 //-------------------------------------------------------------------------- 00335 00336 int fg_set_colour( FRAMEGRABBER* fg, int co ); 00337 00338 00339 //-------------------------------------------------------------------------- 00349 //-------------------------------------------------------------------------- 00350 00351 int fg_set_color( FRAMEGRABBER* fg, int co ); 00352 00353 00354 //-------------------------------------------------------------------------- 00364 //-------------------------------------------------------------------------- 00365 00366 int fg_set_contrast( FRAMEGRABBER* fg, int ct ); 00367 00368 00369 //-------------------------------------------------------------------------- 00379 //-------------------------------------------------------------------------- 00380 00381 int fg_set_whiteness( FRAMEGRABBER* fg, int wh ); 00382 00383 00384 //-------------------------------------------------------------------------- 00393 //-------------------------------------------------------------------------- 00394 00395 FRAME* fg_new_compatible_frame( FRAMEGRABBER* fg ); 00396 00397 00398 //-------------------------------------------------------------------------- 00405 //-------------------------------------------------------------------------- 00406 00407 void fg_dump_info( FRAMEGRABBER* fg ); 00408 00409 00410 //========================================================================== 00411 00412 #endif /* __CAPTURE__H_ */