1 /* 2 * Copyright 2011, Gabriel Hartmann, gabriel.hartmann@gmail.com. 3 * Copyright 2011, Jérôme Duval, korli@users.berlios.de. 4 * Copyright 2009, Ithamar Adema, <ithamar.adema@team-embedded.nl>. 5 * Distributed under the terms of the MIT License. 6 */ 7 #ifndef _UVC_CAM_DEVICE_H 8 #define _UVC_CAM_DEVICE_H 9 10 11 #include "CamDevice.h" 12 #include "USB_video.h" 13 14 15 class UVCCamDevice : public CamDevice { 16 public: 17 UVCCamDevice(CamDeviceAddon &_addon, 18 BUSBDevice* _device); 19 virtual ~UVCCamDevice(); 20 21 virtual bool SupportsIsochronous(); 22 virtual status_t StartTransfer(); 23 virtual status_t StopTransfer(); 24 virtual status_t SuggestVideoFrame(uint32 &width, 25 uint32 &height); 26 virtual status_t AcceptVideoFrame(uint32 &width, 27 uint32 &height); 28 virtual void AddParameters(BParameterGroup *group, 29 int32 &index); 30 virtual status_t GetParameterValue(int32 id, 31 bigtime_t *last_change, void *value, 32 size_t *size); 33 virtual status_t SetParameterValue(int32 id, bigtime_t when, 34 const void *value, size_t size); 35 virtual status_t FillFrameBuffer(BBuffer *buffer, 36 bigtime_t *stamp = NULL); 37 38 private: 39 void _ParseVideoControl( 40 const usbvc_class_descriptor* descriptor, 41 size_t len); 42 void _ParseVideoStreaming( 43 const usbvc_class_descriptor* descriptor, 44 size_t len); 45 status_t _ProbeCommitFormat(); 46 status_t _SelectBestAlternate(); 47 status_t _SelectIdleAlternate(); 48 void _DecodeColor(unsigned char *dst, 49 unsigned char *src, int32 width, 50 int32 height); 51 52 void _AddProcessingParameter(BParameterGroup* group, 53 int32 index, 54 const usbvc_processing_unit_descriptor* 55 descriptor); 56 float _AddParameter(BParameterGroup* group, 57 BParameterGroup** subgroup, int32 index, 58 uint16 wValue, const char* name); 59 uint8 _AddAutoParameter(BParameterGroup* subgroup, 60 int32 index, uint16 wValue); 61 status_t _SetParameterValue(uint16 wValue, 62 int16 setValue); 63 status_t _SetParameterValue(uint16 wValue, 64 int8 setValue); 65 66 67 usbvc_interface_header_descriptor *fHeaderDescriptor; 68 69 const BUSBEndpoint* fInterruptIn; 70 uint32 fControlIndex; 71 uint16 fControlRequestIndex; 72 uint32 fStreamingIndex; 73 uint32 fUncompressedFormatIndex; 74 uint32 fUncompressedFrameIndex; 75 uint32 fMJPEGFormatIndex; 76 uint32 fMJPEGFrameIndex; 77 uint32 fMaxVideoFrameSize; 78 uint32 fMaxPayloadTransferSize; 79 80 BList fUncompressedFrames; 81 BList fMJPEGFrames; 82 83 float fBrightness; 84 float fContrast; 85 float fHue; 86 float fSaturation; 87 float fSharpness; 88 float fGamma; 89 float fWBTemp; 90 float fWBComponent; 91 float fBacklightCompensation; 92 float fGain; 93 94 bool fBinaryBacklightCompensation; 95 96 int fWBTempAuto; 97 int fWBCompAuto; 98 int fHueAuto; 99 int fBacklightCompensationBinary; 100 int fPowerlineFrequency; 101 102 103 }; 104 105 106 class UVCCamDeviceAddon : public CamDeviceAddon { 107 public: 108 UVCCamDeviceAddon(WebCamMediaAddOn* webcam); 109 virtual ~UVCCamDeviceAddon(); 110 111 virtual const char* BrandName(); 112 virtual UVCCamDevice* Instantiate(CamRoster &roster, 113 BUSBDevice *from); 114 }; 115 116 #endif /* _UVC_CAM_DEVICE_H */ 117 118