1 #ifndef __WEBCAM_SUPPORT_H
2 #define __WEBCAM_SUPPORT_H
5 #if defined (_WIN32) && !defined (__CYGWIN__) && defined (NETCOMM_WEBCAM)
11 extern AM_MEDIA_TYPE g_StillMediaType;
13 class SampleGrabberCallback :
public ISampleGrabberCB
17 STDMETHODIMP_( ULONG ) AddRef()
21 STDMETHODIMP_( ULONG ) Release()
26 STDMETHODIMP QueryInterface( REFIID riid,
void **ppvObject )
28 if (NULL == ppvObject)
return E_POINTER;
29 if ( riid == __uuidof( IUnknown ) ) {
30 *ppvObject =
static_cast< IUnknown*
> (
this);
33 if ( riid == __uuidof( ISampleGrabberCB ) ) {
34 *ppvObject =
static_cast< ISampleGrabberCB*
> (
this);
40 STDMETHODIMP SampleCB(
double Time, IMediaSample *pSample )
45 STDMETHODIMP BufferCB(
double Time,
BYTE *pBuffer,
long BufferLen );
49 #include <QuickTimeComponents.h>
50 pascal OSErr processFrame( SGChannel
c,
59 #define DEFAULT_CAPTURE_DRIVER 0
61 #define MAX_JPEG_SIZE 5000
86 #include <sys/types.h>
88 #include <sys/ioctl.h>
91 #include <linux/types.h>
93 #include <linux/videodev.h>
101 #define SETTING_BRIGHTNESS 0
102 #define SETTING_HUE 1
103 #define SETTING_COLOUR 2
104 #define SETTING_CONTRAST 3
108 #define CHANNEL_TUNER 0
109 #define CHANNEL_COMPOSITE 1
110 #define CHANNEL_SVIDEO 2
114 #define VIDEOMODE_PAL VIDEO_MODE_PAL
115 #define VIDEOMODE_NTSC VIDEO_MODE_NTSC
116 #define VIDEOMODE_SECAM VIDEO_MODE_SECAM
120 #define FORMAT_GREY VIDEO_PALETTE_GREY
121 #define FORMAT_RGB565 VIDEO_PALETTE_RGB565
122 #define FORMAT_RGB24 VIDEO_PALETTE_RGB24
123 #define FORMAT_RGB32 VIDEO_PALETTE_RGB32
124 #define FORMAT_YUV422P VIDEO_PALETTE_YUV422P
125 #define FORMAT_YUV420P VIDEO_PALETTE_YUV420P
129 #define REGION_NTSC_BROADCAST 0
130 #define REGION_NTSC_CABLE 1
131 #define REGION_NTSC_CABLE_HRC 2
132 #define REGION_NTSC_BROADCAST_JAPAN 3
133 #define REGION_NTSC_CABLE_JAPAN 4
134 #define REGION_PAL_EUROPE 5
135 #define REGION_PAL_EUROPE_EAST 6
136 #define REGION_PAL_ITALY 7
137 #define REGION_PAL_NEWZEALAND 8
138 #define REGION_PAL_AUSTRALIA 9
139 #define REGION_PAL_IRELAND 10
143 #define IMAGE_BUFFER_EMPTY 0
144 #define IMAGE_BUFFER_FULL 1
145 #define IMAGE_BUFFER_INUSE 2
147 static const int error_exit_status = -1;
151 #define NUM_CHANNEL_LISTS 11
160 struct CHANLIST *list;
163 #define CHAN_COUNT( x ) ( sizeof (x)/sizeof (struct CHANLIST) )
173 struct video_mmap vid_mmap[2];
174 int current_grab_number;
175 struct video_mbuf vid_mbuf;
180 pthread_mutex_t buffer_mutex;
181 pthread_t grab_thread;
182 pthread_cond_t buffer_cond;
187 int fps_update_interval;
190 unsigned short *y8_to_rgb565;
191 unsigned char *rgb565_to_y8;
201 int fg_open_device(
struct fgdevice *fg,
const char *devicename );
202 int fg_print_info(
struct fgdevice *fg );
203 int fg_close_device(
struct fgdevice *fg );
205 void fg_set_fps_interval(
struct fgdevice *fg,
int interval );
206 double fg_get_fps(
struct fgdevice *fg );
208 int fg_set_channel(
struct fgdevice *fg,
int channel,
int videomode );
209 int fg_set_frequency(
struct fgdevice *fg,
int region,
int index );
211 int fg_get_setting(
struct fgdevice *fg,
int which_setting );
212 int fg_set_setting(
struct fgdevice *fg,
int which_setting,
int value );
214 int fg_start_grab_image(
struct fgdevice *fg,
int width,
int height,
int format );
215 int fg_stop_grab_image(
struct fgdevice *fg );
216 void * fg_get_next_image(
struct fgdevice *fg );
218 double timeGet(
void );
220 int getFrequency(
int region,
int channel );
236 char channeltext[128];
238 #if defined (_WIN32) && !defined (__CYGWIN__) && defined (NETCOMM_WEBCAM)
239 SampleGrabberCallback g_SampleCB;
240 IGraphBuilder *pGraph;
241 ICaptureGraphBuilder2 *pCaptureGraph;
242 ICreateDevEnum *pDevEnum;
247 IMediaControl *pControl;
248 ISampleGrabber *pSampleGrabber;
250 friend class SampleGrabberCallback;
255 SeqGrabComponent sg_component;
256 SGChannel sg_channel;
258 short video_width, video_height;
260 Boolean gQuicktimeInitialized;
300 void DoError(
long code,
char *msg );
303 #if defined (_WIN32) && !defined (__CYGWIN__)
319 #endif //tells VCC not to generate min/max macros
326 #include "jmorecfg.h"
330 char * JpegFromCapture( HANDLE hDib,
BYTE *bmpBuffer,
long bmpLength,
int *jpegLength,
int nQuality, std::string csJpeg =
"" );
332 LPBITMAPINFOHEADER &lpbi,
337 std::string csJpeg );
338 BOOL JpegFromDib( HANDLE hDib,
341 std::string *pcsMsg );
344 LPBITMAPINFOHEADER &pbBmHdr,
347 struct jpeg_compress_struct cinfo,
348 JSAMPARRAY jsmpPixels );
349 BOOL DibToSamps( HANDLE hDib,
int nSampsPerRow,
struct jpeg_compress_struct cinfo, JSAMPARRAY jsmpPixels, std::string *pcsMsg );