xref: /haiku/src/add-ons/media/media-add-ons/usb_webcam/addons/uvc/UVCCamDevice.h (revision 344ded80d400028c8f561b4b876257b94c12db4a)
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 #include <usb/USB_video.h>
14 
15 
16 class UVCCamDevice : public CamDevice {
17 public:
18 								UVCCamDevice(CamDeviceAddon &_addon,
19 									BUSBDevice* _device);
20 	virtual						~UVCCamDevice();
21 
22 	virtual bool				SupportsIsochronous();
23 	virtual status_t			StartTransfer();
24 	virtual status_t			StopTransfer();
25 	virtual status_t			SuggestVideoFrame(uint32 &width,
26 									uint32 &height);
27 	virtual status_t			AcceptVideoFrame(uint32 &width,
28 									uint32 &height);
29 	virtual void				AddParameters(BParameterGroup *group,
30 									int32 &index);
31 	virtual status_t			GetParameterValue(int32 id,
32 									bigtime_t *last_change, void *value,
33 									size_t *size);
34 	virtual status_t			SetParameterValue(int32 id, bigtime_t when,
35 									const void *value, size_t size);
36 	virtual status_t			FillFrameBuffer(BBuffer *buffer,
37 									bigtime_t *stamp = NULL);
38 
39 private:
40 			void				_ParseVideoControl(
41 									const usbvc_class_descriptor* descriptor,
42 									size_t len);
43 			void				_ParseVideoStreaming(
44 									const usbvc_class_descriptor* descriptor,
45 									size_t len);
46 			status_t			_ProbeCommitFormat();
47 			status_t			_SelectBestAlternate();
48 			status_t			_SelectIdleAlternate();
49 			void 				_DecodeColor(unsigned char *dst,
50 									unsigned char *src, int32 width,
51 									int32 height);
52 
53 			void				_AddProcessingParameter(BParameterGroup* group,
54 									int32 index,
55 									const usb_video_processing_unit_descriptor*
56 										descriptor);
57 			float				_AddParameter(BParameterGroup* group,
58 									BParameterGroup** subgroup, int32 index,
59 									uint16 wValue, const char* name);
60 			uint8 				_AddAutoParameter(BParameterGroup* subgroup,
61 									int32 index, uint16 wValue);
62 			status_t			_SetParameterValue(uint16 wValue,
63 									int16 setValue);
64 			status_t			_SetParameterValue(uint16 wValue,
65 									int8 setValue);
66 
67 
68 			usbvc_interface_header_descriptor *fHeaderDescriptor;
69 
70 			const BUSBEndpoint*	fInterruptIn;
71 			uint32				fControlIndex;
72 			uint16				fControlRequestIndex;
73 			uint32				fStreamingIndex;
74 			uint32				fUncompressedFormatIndex;
75 			uint32				fUncompressedFrameIndex;
76 			uint32				fMJPEGFormatIndex;
77 			uint32				fMJPEGFrameIndex;
78 			uint32				fMaxVideoFrameSize;
79 			uint32				fMaxPayloadTransferSize;
80 
81 			BList				fUncompressedFrames;
82 			BList				fMJPEGFrames;
83 
84 			float				fBrightness;
85 			float				fContrast;
86 			float				fHue;
87 			float				fSaturation;
88 			float				fSharpness;
89 			float				fGamma;
90 			float				fWBTemp;
91 			float				fWBComponent;
92 			float				fBacklightCompensation;
93 			float				fGain;
94 
95 			bool				fBinaryBacklightCompensation;
96 
97 			int					fWBTempAuto;
98 			int					fWBCompAuto;
99 			int					fHueAuto;
100 			int					fBacklightCompensationBinary;
101 			int					fPowerlineFrequency;
102 
103 
104 };
105 
106 
107 class UVCCamDeviceAddon : public CamDeviceAddon {
108 public:
109 								UVCCamDeviceAddon(WebCamMediaAddOn* webcam);
110 	virtual 					~UVCCamDeviceAddon();
111 
112 	virtual const char*			BrandName();
113 	virtual UVCCamDevice*		Instantiate(CamRoster &roster,
114 									BUSBDevice *from);
115 };
116 
117 #endif /* _UVC_CAM_DEVICE_H */
118 
119