|
1 /* |
|
2 * Copyright (c) 2010 ISB. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * ISB - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: UVC FOrmat Header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <comm.h> |
|
20 |
|
21 |
|
22 #ifndef WEBCAMERA_UVC_H_ |
|
23 #define WEBCAMERA_UVC_H_ |
|
24 |
|
25 |
|
26 #define KWebcameraEoh (TUint8)(0x80) |
|
27 #define KWebcameraErr (TUint8)(0x40) |
|
28 #define KWebcameraSti (TUint8)(0x20) |
|
29 #define KWebcameraRes (TUint8)(0x10) |
|
30 #define KWebcameraScr (TUint8)(0x08) |
|
31 #define KWebcameraPts (TUint8)(0x04) |
|
32 #define KWebcameraEof (TUint8)(0x02) |
|
33 #define KWebcameraFid (TUint8)(0x01) |
|
34 #define KWebcameraTokenCounter (TUint16)(0x1fff) |
|
35 |
|
36 |
|
37 /* UVC DescriptorType */ |
|
38 #define KWebcameraSCUndefined (TUint8)(0x00) |
|
39 #define KWebcameraSCVideoControl (TUint8)(0x01) |
|
40 #define KWebcameraSCVideoStreaming (TUint8)(0x02) |
|
41 #define KWebcameraSCVideoInterfaceCollection (TUint8)(0x03) |
|
42 |
|
43 /* VideoStreaming DescriptorSubType */ |
|
44 #define KWebcameraVSUndefined (TUint8)(0x00) |
|
45 #define KWebcameraVSInputHeader (TUint8)(0x01) |
|
46 #define KWebcameraVSOutputHeader (TUint8)(0x02) |
|
47 #define KWebcameraVSStillImageFrame (TUint8)(0x03) |
|
48 #define KWebcameraVSFormatUnconmpressed (TUint8)(0x04) |
|
49 #define KWebcameraVSFrameUncompressed (TUint8)(0x05) |
|
50 #define KWebcameraVSFormatJPEG (TUint8)(0x06) |
|
51 #define KWebcameraVSFrameJPEG (TUint8)(0x07) |
|
52 #define KWebcameraVSFormatMPEG2TS (TUint8)(0x0a) |
|
53 #define KWebcameraVSFormatDV (TUint8)(0x0c) |
|
54 #define KWebcameraVSColorFormat (TUint8)(0x0d) |
|
55 #define KWebcameraVSFormatFrameBased (TUint8)(0x10) |
|
56 #define KWebcameraVSFrameFrameBased (TUint8)(0x11) |
|
57 #define KWebcameraVSFormatStreamBased (TUint8)(0x12) |
|
58 |
|
59 /* VideoFormat(GUID) */ |
|
60 #define KWebcameraYuy2 (TUint32)(0x32595559) |
|
61 #define KWebcameraVideoStream (TUint32)(0x73646976) |
|
62 |
|
63 class TWebcameraGuid |
|
64 { |
|
65 public: |
|
66 TUint32 iData1; |
|
67 TUint16 iData2; |
|
68 TUint16 iData3; |
|
69 TUint8 iData4[8]; |
|
70 }; |
|
71 |
|
72 class TWebcameraDataFortmat |
|
73 { |
|
74 public: |
|
75 TUint32 iFormatSize; |
|
76 TUint32 iFlags; |
|
77 TUint32 iSampleSize; |
|
78 TUint32 iReserved; |
|
79 TWebcameraGuid iMajorFormat; |
|
80 TWebcameraGuid iSubFormat; |
|
81 TWebcameraGuid iSpecifier; |
|
82 }; |
|
83 |
|
84 class TWebcameraRect |
|
85 { |
|
86 public: |
|
87 TInt32 iLeft; |
|
88 TInt32 iTop; |
|
89 TInt32 iRight; |
|
90 TInt32 iBottom; |
|
91 }; |
|
92 |
|
93 class TWebcameraBitmapInfoHeader |
|
94 { |
|
95 public: |
|
96 TUint32 iSize; |
|
97 TInt32 iWidth; |
|
98 TInt32 iHeight; |
|
99 TUint16 iPlanes; |
|
100 TUint16 iBitCount; |
|
101 TUint32 iCompression; |
|
102 TUint32 iSizeImage; |
|
103 TInt32 iXPelsPerMeter; |
|
104 TInt32 iYPelsPerMeter; |
|
105 TUint32 iClrUsed; |
|
106 TUint32 iClrImportant; |
|
107 }; |
|
108 |
|
109 class TWebcameraVideoInfoHeader |
|
110 { |
|
111 public: |
|
112 TWebcameraRect iRcSource; |
|
113 TWebcameraRect iRcTarget; |
|
114 TUint32 iDwBitRate; |
|
115 TUint32 iDwBitErrorRate; |
|
116 Int64 iAvgTimePerFrame; |
|
117 TWebcameraBitmapInfoHeader iBmiHeader; |
|
118 }; |
|
119 |
|
120 class TWebcameraDataInfo |
|
121 { |
|
122 public: |
|
123 TWebcameraDataFortmat iDataFortmat; |
|
124 TWebcameraVideoInfoHeader iVideoInfoHeader; |
|
125 }; |
|
126 |
|
127 class TWebcameraUVCSourceClockReference |
|
128 { |
|
129 public: |
|
130 TUint16 iTokenCounter; |
|
131 TUint32 iSourceTimeClock; |
|
132 }; |
|
133 |
|
134 class TWebcameraUVCHeaderFormat |
|
135 { |
|
136 /** |
|
137 Variables that configure UVC Header. |
|
138 */ |
|
139 public: |
|
140 TUint8 iHeaderLength; |
|
141 TUint8 iHeaderInfo; |
|
142 TUint32 iPresentationTime; |
|
143 TWebcameraUVCSourceClockReference iSourceClockReference; |
|
144 }; |
|
145 |
|
146 class TWebcameraUVCFormatDescriptor |
|
147 { |
|
148 public: |
|
149 TUint8 iLength; |
|
150 TUint8 iDescriptorType; |
|
151 TUint8 iDescriptorSubType; |
|
152 TUint8 iFormatIndex; |
|
153 TUint8 iNumFrameDescriptor; |
|
154 TWebcameraGuid iGuid; |
|
155 TUint8 iBitsPerPixel; |
|
156 TUint8 iDefaultFrameIndex; |
|
157 TUint8 iAspectRatioX; |
|
158 TUint8 iAspectRatioY; |
|
159 TUint8 iInterlaceFlags; |
|
160 TUint8 iCopyProtect; |
|
161 TUint8 iDataoffset; |
|
162 TUint8 iPacketLength1; |
|
163 TUint32 iPacketLength2; |
|
164 TUint8 iStrideLength; |
|
165 TWebcameraGuid iGuidStrideFormat; |
|
166 TUint8 iFlags; |
|
167 TUint8 iVariableSize; |
|
168 TUint32 iMaxVideoFrameBufferSize; |
|
169 TUint8 iFormatType; |
|
170 }; |
|
171 |
|
172 class TWebcameraUVCFrameInterval |
|
173 { |
|
174 public: |
|
175 TUint32 iFrameInterval1; |
|
176 TUint32 iFrameInterval2; |
|
177 TUint32 iFrameInterval3; |
|
178 }; |
|
179 |
|
180 class TWebcameraUVCFrameDescriptor |
|
181 { |
|
182 public: |
|
183 TUint8 iLength; |
|
184 TUint8 iDescriptorType; |
|
185 TUint8 iDescriptorSubType; |
|
186 TUint8 iFrameIndex; |
|
187 TUint8 iCapabilities; |
|
188 TUint16 iWidth; |
|
189 TUint16 iHeight; |
|
190 TUint32 iMinBitRate; |
|
191 TUint32 iMaxBitRate; |
|
192 TUint32 iMaxVideoFrameBufferSize; |
|
193 TUint32 iDefaultFrameInterval; |
|
194 TUint8 iFrameIntervalType; |
|
195 TWebcameraUVCFrameInterval iFrameInterval; |
|
196 TUint32 iBytesPerLine; |
|
197 }; |
|
198 |
|
199 class TWebcameraUVCDescriptor |
|
200 { |
|
201 public: |
|
202 TWebcameraUVCFormatDescriptor iFormatDescriptor; |
|
203 TWebcameraUVCFrameDescriptor iFrameDescriptor; |
|
204 }; |
|
205 |
|
206 class TWebcameraUVC |
|
207 { |
|
208 public: |
|
209 TWebcameraUVCHeaderFormat iUVCHeader; |
|
210 TWebcameraUVCDescriptor iUVCDescriptor; |
|
211 }; |
|
212 |
|
213 /** |
|
214 Describe UVC base class. |
|
215 */ |
|
216 class DWebCameraUVCDescriptor : public DBase// : public DWebCameraUVCBase |
|
217 { |
|
218 public://function |
|
219 /** |
|
220 Constructor. |
|
221 */ |
|
222 DWebCameraUVCDescriptor(); |
|
223 |
|
224 /** |
|
225 Destructor. |
|
226 */ |
|
227 ~DWebCameraUVCDescriptor(); |
|
228 /** |
|
229 |
|
230 Describe UVC Format Descriptor and Frame Descriptor. |
|
231 |
|
232 @param aDataInfo [in] Information of data from lower layer. |
|
233 bDescriptor. |
|
234 */ |
|
235 virtual TWebcameraUVCDescriptor DescribeDescriptor(const TWebcameraDataInfo aDataInfo); |
|
236 }; |
|
237 |
|
238 /** |
|
239 Describe descriptor of YUY2 format included in UVC. |
|
240 */ |
|
241 class DWebCameraUVCDescribeDescriptorYUY2 : public DWebCameraUVCDescriptor |
|
242 { |
|
243 public://function |
|
244 /** |
|
245 Constructor. |
|
246 */ |
|
247 DWebCameraUVCDescribeDescriptorYUY2(); |
|
248 |
|
249 /** |
|
250 Destructor. |
|
251 */ |
|
252 ~DWebCameraUVCDescribeDescriptorYUY2(); |
|
253 |
|
254 /** |
|
255 Describe UVC Descriptor of YUY2 Format. |
|
256 |
|
257 @param aDataInfo [in] Information of data from lower layer. |
|
258 @return bDescriptor. |
|
259 */ |
|
260 TWebcameraUVCDescriptor DescribeDescriptor(const TWebcameraDataInfo aDataInfo); |
|
261 }; |
|
262 |
|
263 /** |
|
264 Describe UVC header class. |
|
265 */ |
|
266 class DWebCameraUVCHeader |
|
267 { |
|
268 public://function |
|
269 /** |
|
270 Constructor. |
|
271 */ |
|
272 DWebCameraUVCHeader(); |
|
273 |
|
274 /** |
|
275 Destructor. |
|
276 */ |
|
277 ~DWebCameraUVCHeader(); |
|
278 |
|
279 public://function |
|
280 /** |
|
281 Describe UVC Header. |
|
282 @param aDataInfo [in] Information of data from lower layer. |
|
283 @return bHeader. |
|
284 */ |
|
285 TWebcameraUVCHeaderFormat DescribeHeader(const TWebcameraDataInfo aDataInfo); |
|
286 |
|
287 private://function |
|
288 /** |
|
289 Describe HeaderInfo to be included UVC Header. |
|
290 @param aDataInfo [in] Information of data form lower layer. |
|
291 @return bHeaderInfo. |
|
292 */ |
|
293 TUint8 DescribeHeaderInfo(TWebcameraDataInfo aDataInfo); |
|
294 |
|
295 /** |
|
296 Describe HeaderLength to be included UVC Header. |
|
297 @param aDataInfo [in] Information of data from lower layer. |
|
298 @return bHeaderLength. |
|
299 */ |
|
300 TUint8 DescribeHeaderLength(TWebcameraDataInfo aDataInfo, TUint8 aHeaderInfo); |
|
301 |
|
302 /** |
|
303 Describe PresentationTime to be included UVC Header. |
|
304 @param aDataInfo [in] Information of data from lower layer. |
|
305 @return bPresentationTime. |
|
306 */ |
|
307 TUint32 DescribePresentationTime(TWebcameraDataInfo aDataInfo); |
|
308 |
|
309 /** |
|
310 Describe SourceClockReference to be included UVC Header. |
|
311 @param aDataInfo [in] Information of data from lower layer. |
|
312 @return bSourceClockReference. |
|
313 */ |
|
314 TWebcameraUVCSourceClockReference DescribeSourceClockReference(TWebcameraDataInfo aDataInfo); |
|
315 |
|
316 private://variable. |
|
317 TUint8 iFID; |
|
318 }; |
|
319 |
|
320 /** |
|
321 Describe class. |
|
322 */ |
|
323 class DWebCameraDescribe : public DBase |
|
324 { |
|
325 public://function. |
|
326 /** |
|
327 Constructor. |
|
328 */ |
|
329 DWebCameraDescribe(); |
|
330 |
|
331 /** |
|
332 Destructor. |
|
333 */ |
|
334 ~DWebCameraDescribe(); |
|
335 |
|
336 public://function |
|
337 /** |
|
338 Parse iDataInfo from lower layer and describe UVC Header and Descriptor. |
|
339 @param aDataInfo [in] Information of data from lower layer. |
|
340 aDescriptror [out] Header and Descriptor format of YUY2 format. |
|
341 @return KErrNone. |
|
342 */ |
|
343 TWebcameraUVC ParseDataInfo(const TWebcameraDataInfo aDataInfo); |
|
344 |
|
345 private://val. |
|
346 DWebCameraUVCDescriptor* iDescribe; |
|
347 }; |
|
348 |
|
349 #endif /* WEBCAMERA_UVC_H_ */ |