📄 usbcam.h
字号:
#if !defined( _USBCAM_ )
#define _USBCAM_
//*****************************************************************************
// I N C L U D E S
//*****************************************************************************
#include <windows.h>
#include <devload.h>
#include <usbdi.h>
#include <pegdser.h>
#include <pegdpar.h>
#include <ntcompat.h>
#include "usbclient.h"
//*****************************************************************************
// D E F I N E S
//*****************************************************************************
#define DRIVER_NAME_SZ TEXT("USBCAM.DLL")
#define DEVICE_PREFIX TEXT("CAM")
#define CLASS_NAME_SZ TEXT("Camera_Class")
#define CLIENT_REGKEY_SZ TEXT("Drivers\\USB\\ClientDrivers\\Camera_Class")
#define USBCAM_SIG 'UCAM'
//
// USB Camera Interface Descriptor
//
#define USB_CAM_INTERFACE_CLASS 0x0E
#define USB_CAM_INTERFACE_SUBCLASS 0x01
#define USB_CAM_INTERFACE_SUBCLASS_VIDEOCONTROL 0x01
#define USB_CAM_INTERFACE_SUBCLASS_VIDEOSTREAMING 0x02
#define USB_CAM_INTERFACE_SUBCLASS_COLLECTION 0x03
//
// USB Camera Video Interface Protocol Codes
//
#define USB_CAM_PROTOCOL_UNDEFINED 0x00
//
// Video Class-Specification Descriptor Types
//
#define USB_CAM_CS_UNDEFFINED 0x20
#define USB_CAM_CS_DEVICE 0x21
#define USB_CAM_CS_CONFIGURATION 0x22
#define USB_CAM_CS_STRING 0x23
#define USB_CAM_CS_INTERFACE 0x24
#define USB_CAM_CS_ENDPOINT 0x25
//
// Default Timeout values
//
#define GET_PORT_STATUS_TIMEOUT 2000
#define GET_DEVICE_ID_TIMEOUT 2000
#define SOFT_RESET_TIMEOUT 2000
#define READ_TIMEOUT_INTERVAL 250
#define READ_TIMEOUT_MULTIPLIER 10
#define READ_TIMEOUT_CONSTANT 100
#define WRITE_TIMEOUT_MULTIPLIER 50
#define WRITE_TIMEOUT_CONSTANT 1000
//
// registry strings
//
#define GET_PORT_STATUS_TIMEOUT_SZ TEXT("PortStatusTimeout")
#define GET_DEVICE_ID_TIMEOUT_SZ TEXT("DeviceIdTimeout")
#define SOFT_RESET_TIMEOUT_SZ TEXT("SoftResetTimeout")
#define READ_TIMEOUT_MULTIPLIER_SZ TEXT("ReadTimeoutMultiplier")
#define READ_TIMEOUT_CONSTANT_SZ TEXT("ReadTimeoutConstant")
#define WRITE_TIMEOUT_MULTIPLIER_SZ TEXT("WriteTimeoutMultiplier")
#define WRITE_TIMEOUT_CONSTANT_SZ TEXT("WriteTimeoutConstant")
typedef struct _FLAGS {
UCHAR Open : 1; // bits 0
UCHAR UnloadPending : 1; // bits 1
UCHAR Reserved : 6; // bits 2-7
} FLAGS, *PFLAGS;
typedef struct _USBTIMEOUTS {
DWORD PortStatusTimeout;
DWORD DeviceIdTimeout;
DWORD SoftResetTimeout;
} USBTIMEOUTS, *PUSBTIMEOUTS;
//
// Our notion of a Pipe
//
typedef struct _PIPE {
//
// USB Pipe handle received from the stack
//
USB_PIPE hPipe;
//
// Endpoint's Address
//
UCHAR bIndex;
//
// Endpoint's wMaxPacketSize
//
USHORT wMaxPacketSize;
//
// Completion Event
//
HANDLE hEvent;
} PIPE, *PPIPE;
enum { QCIF = 1, QSIF, QPAL, CIF, SIF, PAL, VGA, CUSTOM, TOTMODE,};
/* available palette */#define P_RGB16 1#define P_RGB24 (1 << 1)#define P_RGB32 (1 << 2)#define P_YUV420 (1 << 3)#define P_YUV422 ( 1 << 4)#define P_RAW (1 << 5)#define P_JPEG (1 << 6)struct mwebcam { int width; int height; U16 t_palette;
U16 pipe;
int method; int mode;};
typedef struct _USBCAM_CONTEXT {
//
// We use a Signature (defined above) since we must read
// our context pointer out of the registry
//
ULONG Sig;
//
// sync object for this instance
//
CRITICAL_SECTION Lock;
//
// path to HKLM\Drivers\Active\xx
//
LPTSTR ActivePath;
//
// Handle for Stream interface.
//
HANDLE hStreamDevice;
//
// USB handle to the device
//
HANDLE hUsbDevice;
//
// USBD Function table
//
LPCUSB_FUNCS UsbFuncs;
//
// Fields from USB_INTERFACE that we need
//
UCHAR bInterfaceNumber;
UCHAR bAlternateSetting;
USHORT ConfigIndex;
//
// Bulk OUT Pipe
//
PIPE BulkOut;
//
// Bulk IN Pipe
//
PIPE BulkIn;
//
// completion signal used for endpoint 0
//
HANDLE hEP0Event;
//
// Signals the device has been closed.
//
HANDLE hCloseEvent;
//
// FLAGS
//
FLAGS Flags;
//
// Comm Timeouts
//
COMMTIMEOUTS Timeouts;
//
// USB Timeouts
//
USBTIMEOUTS UsbTimeouts;
int alt; /* current alternate setting */
int customid; /* product id get by probe */ int desc; /* enum camera name */ int ccd; /* If true, using the CCD otherwise the external input */ int chip_revision; /* set when probe the camera spca561 zc0301p for vm303 */ struct mwebcam mode_cam[TOTMODE]; /* all available mode registers by probe */ int bridge; /* Type of bridge (BRIDGE_SPCA505 or BRIDGE_SPCA506) */ int sensor; /* Type of image sensor chip */ int packet_size; /* Frame size per isoc desc *//* Determined by sensor type */ int maxwidth; int maxheight; int minwidth; int minheight;/* What we think the hardware is currently set to */ int brightness; int colour; int contrast; int hue; int whiteness; int exposure; // used by spca561 int autoexpo; int qindex; int width; /* use here for the init of each frame */ int height; int hdrwidth; int hdrheight; unsigned int format; int method; /* method ask for output pict */ int mode; /* requested frame size */ int pipe_size; // requested pipe size set according to mode U16 norme; /* norme in use Pal Ntsc Secam */
U16 channel; /* input composite video1 or svideo */
int cameratype; /* native in frame format */
} USBCAM_CONTEXT, *PUSBCAM_CONTEXT;
typedef void (*cam_ops) (USBCAM_CONTEXT *);
typedef int (*intcam_ops) (USBCAM_CONTEXT *);
typedef U16(*u16cam_ops) (USBCAM_CONTEXT *);
typedef int (*intcam_detect) (USBCAM_CONTEXT *,
unsigned char *, int *, int, int *);struct cam_operation { intcam_ops initialize; intcam_ops configure; cam_ops start; cam_ops stopN; cam_ops stop0; u16cam_ops get_bright; cam_ops set_bright; u16cam_ops get_contrast; cam_ops set_contrast; u16cam_ops get_colors; cam_ops set_colors; cam_ops set_autobright; cam_ops set_quality; cam_ops cam_shutdown; intcam_detect sof_detect; cam_ops set_50HZ; cam_ops set_60HZ; cam_ops set_50HZScale; cam_ops set_60HZScale; cam_ops set_NoFliker; cam_ops set_NoFlikerScale;};
//
// Is the pointer a valid PUSBPRN_CONTEXT
//
#define VALID_CONTEXT( p ) \
( p && USBCAM_SIG == p->Sig )
//
// Can the device accept any I/O requests
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -