8012b4f362
* NEW: renamed _Max properties, added *Default properties, included 'Features' in main class git-svn-id: svn://localhost/gambas/trunk@1834 867c0c6c-44f3-4631-809d-bfa615b0a4ec
191 lines
5.2 KiB
C
191 lines
5.2 KiB
C
/***************************************************************************
|
|
|
|
CWebcam.h
|
|
|
|
Webcam capture component
|
|
|
|
(C) 2005-2008 Daniel Campos Fernández <dcamposf@gmail.com>
|
|
|
|
Based on the GPL code from "video-capture":
|
|
|
|
(#) video-capture.c - modified from vidcat.c
|
|
Copyright (C) 1998 Rasca, Berlin
|
|
EMail: thron@gmx.de
|
|
Modifications (C) 2001, Nick Andrew <nick@nick-andrew.net>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 1, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
***************************************************************************/
|
|
#ifndef __CWEBCAM_H
|
|
#define __CWEBCAM_H
|
|
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/ioctl.h>
|
|
#include <linux/types.h>
|
|
#include <linux/videodev.h>
|
|
|
|
#include "videodev2.h"
|
|
#include "gambas.h"
|
|
|
|
#ifndef __CWEBCAM_C
|
|
|
|
extern GB_DESC CWebcamDesc[];
|
|
extern GB_DESC CTunerDesc[];
|
|
extern GB_DESC CFeaturesDesc[];
|
|
extern GB_STREAM_DESC VideoStream;
|
|
|
|
#else
|
|
|
|
#define THIS ((CWEBCAM *)_object)
|
|
#define DEVICE (THIS->dev)
|
|
// ++ V4L2
|
|
#define MCLEAR(x) memset (&(x), 0, sizeof (x))
|
|
#define gv4l2_V4L 1
|
|
#define gv4l2_V4L2 2
|
|
// --
|
|
#endif
|
|
|
|
typedef struct video_device {
|
|
int width;
|
|
int height;
|
|
int depth; // colour depth
|
|
int buffer_size; // always width * height * depth
|
|
int use_mmap; // mmap() available for capturing a frame
|
|
int capturing; // our device is capturing frames for us
|
|
|
|
struct video_capability vcap;
|
|
struct video_channel vchan;
|
|
struct video_mbuf vmbuf;
|
|
struct video_mmap vmmap;
|
|
struct video_window vwin;
|
|
struct video_picture videopict;
|
|
|
|
unsigned char *frame_buffer; // not the video memory, but one image
|
|
int dev; // fd of the physical device
|
|
int Freq2;
|
|
|
|
} video_device_t;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
GB_STREAM_DESC *desc;
|
|
int _reserved;
|
|
void *handle;
|
|
} VIDEO_STREAM;
|
|
|
|
// ++ V4L2
|
|
typedef struct gv4l2_buffer
|
|
{
|
|
void* start;
|
|
size_t length;
|
|
|
|
} gv4l2_buffer_t;
|
|
//--
|
|
|
|
typedef struct
|
|
{
|
|
GB_BASE ob;
|
|
GB_STREAM stream;
|
|
|
|
char *device;
|
|
video_device_t *dev;
|
|
unsigned char *membuf;
|
|
long gotframe;
|
|
long posframe;
|
|
|
|
// ++ YUYV->RGB conversion
|
|
void* frame; // "current" frame buffer
|
|
//--
|
|
// ++ V4L2
|
|
//
|
|
// There is some duplication here but we really don't want to use
|
|
// the v4l video_device_t structure ...
|
|
//
|
|
struct v4l2_capability cap;
|
|
struct v4l2_cropcap cropcap;
|
|
struct v4l2_crop crop;
|
|
struct v4l2_format fmt;
|
|
struct gv4l2_buffer* buffers;
|
|
//
|
|
int is_v4l2; // which version is this dev
|
|
int io; // raw device handle for V2
|
|
int use_mmap; // is MMAP available
|
|
int buffer_count; // number of buffers
|
|
int w,h; // "current" dimensions
|
|
//
|
|
int bright_max;
|
|
int hue_max;
|
|
int contrast_max;
|
|
int whiteness_max;
|
|
int color_max;
|
|
//
|
|
int bright_min;
|
|
int hue_min;
|
|
int contrast_min;
|
|
int whiteness_min;
|
|
int color_min;
|
|
//
|
|
int bright_def;
|
|
int hue_def;
|
|
int contrast_def;
|
|
int whiteness_def;
|
|
int color_def;
|
|
// --
|
|
|
|
} CWEBCAM;
|
|
|
|
|
|
int Video_stream_read(GB_STREAM *stream, char *buffer, int len);
|
|
int Video_stream_write(GB_STREAM *stream, char *buffer, int len);
|
|
int Video_stream_eof(GB_STREAM *stream);
|
|
int Video_stream_lof(GB_STREAM *stream, int64_t *len);
|
|
int Video_stream_open(GB_STREAM *stream, const char *path, int mode, void *data);
|
|
int Video_stream_seek(GB_STREAM *stream, int64_t pos, int whence);
|
|
int Video_stream_tell(GB_STREAM *stream, int64_t *pos);
|
|
int Video_stream_flush(GB_STREAM *stream);
|
|
int Video_stream_close(GB_STREAM *stream);
|
|
int Video_stream_handle(GB_STREAM *stream);
|
|
|
|
|
|
// ++ YUYV->RGB conversion
|
|
int convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height);
|
|
void yuv420p_to_rgb (unsigned char *image, unsigned char *image2, int x, int y, int z);
|
|
// --
|
|
|
|
// ++ V4L2
|
|
int gv4l2_available(CWEBCAM * _object);
|
|
void gv4l2_debug( char *s );
|
|
int gv4l2_xioctl( int fd,int request,void * arg);
|
|
int gv4l2_open_device( char* name );
|
|
void gv4l2_close_device( int id );
|
|
int gv4l2_init_device(CWEBCAM * _object , int width , int height );
|
|
int gv4l2_start_capture(CWEBCAM * _object);
|
|
int gv4l2_stop_capture(CWEBCAM * _object);
|
|
void gv4l2_uninit_device(CWEBCAM * _object);
|
|
void gv4l1_process_image (CWEBCAM * _object, void *start);
|
|
void gv4l2_process_image (CWEBCAM * _object, void *start);
|
|
int gv4l2_read_frame( CWEBCAM * _object );
|
|
int gv4l2_resize( CWEBCAM * _object , int width , int height );
|
|
int gv4l2_hue( CWEBCAM * _object , int hue );
|
|
int gv4l2_brightness( CWEBCAM * _object , int hue );
|
|
int gv4l2_contrast( CWEBCAM * _object , int value );
|
|
int gv4l2_color( CWEBCAM * _object , int value );
|
|
int gv4l2_whiteness( CWEBCAM * _object , int value );
|
|
// -- V4L2
|
|
|
|
#endif
|