sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\multimedia\t_camera_api.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <d32camerasc.h>
|
sl@0
|
20 |
#include <e32def.h>
|
sl@0
|
21 |
#include <e32def_private.h>
|
sl@0
|
22 |
#include "t_camera_display.h"
|
sl@0
|
23 |
#include "t_camera_bitmap.h"
|
sl@0
|
24 |
#include "d_mmcsc.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
_LIT(KTstLddFileName,"D_MMCSC.LDD");
|
sl@0
|
27 |
_LIT(KCamLddFileName,"ECAMERASC.LDD");
|
sl@0
|
28 |
|
sl@0
|
29 |
#ifdef __WINSCW__
|
sl@0
|
30 |
_LIT(KCamPddFileName,"_TEMPLATE_CAMERASC.PDD");
|
sl@0
|
31 |
#else
|
sl@0
|
32 |
_LIT(KCamPddFileName,"CAMERASC.PDD");
|
sl@0
|
33 |
#endif
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
_LIT(KCamFreePddExtension,".*");
|
sl@0
|
37 |
|
sl@0
|
38 |
_LIT(KFrameSize, "%dx%d");
|
sl@0
|
39 |
_LIT(KSensor, "d:\\Sensor_");
|
sl@0
|
40 |
_LIT(KUnderscore, "_");
|
sl@0
|
41 |
_LIT(KBmp, ".bmp");
|
sl@0
|
42 |
_LIT(KJpeg, ".jpg");
|
sl@0
|
43 |
_LIT(KSpeedTaggedJpeg, ".stj");
|
sl@0
|
44 |
|
sl@0
|
45 |
LOCAL_D TCameraCapsV02* CameraCaps;
|
sl@0
|
46 |
LOCAL_D TInt CapsSize;
|
sl@0
|
47 |
LOCAL_D TAny* CapsBufPtr;
|
sl@0
|
48 |
RTest Test(_L("T_CAMERA_API"));
|
sl@0
|
49 |
|
sl@0
|
50 |
const TInt KNumVideoFramesToAllocate=6;
|
sl@0
|
51 |
const TInt KNumVideoFramesToCapture=(KNumVideoFramesToAllocate-2);
|
sl@0
|
52 |
const TInt KHeapSize=0x4000;
|
sl@0
|
53 |
const TInt KUnit0=0;
|
sl@0
|
54 |
|
sl@0
|
55 |
enum TSecThreadTestId
|
sl@0
|
56 |
{
|
sl@0
|
57 |
ESecThreadTestOpen,
|
sl@0
|
58 |
ESecThreadTestDuplicateHandle,
|
sl@0
|
59 |
ESecThreadReuseHandle
|
sl@0
|
60 |
};
|
sl@0
|
61 |
|
sl@0
|
62 |
struct SSecondaryThreadInfo
|
sl@0
|
63 |
{
|
sl@0
|
64 |
TSecThreadTestId iTestId;
|
sl@0
|
65 |
TInt iExpectedRetVal;
|
sl@0
|
66 |
TThreadId iThreadId;
|
sl@0
|
67 |
TInt iDrvHandle;
|
sl@0
|
68 |
TInt iCameraModuleIndex;
|
sl@0
|
69 |
};
|
sl@0
|
70 |
|
sl@0
|
71 |
LOCAL_C TInt secondaryThread(TAny* aTestInfo)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
RTest stest(_L("Secondary test camera thread"));
|
sl@0
|
74 |
stest.Title();
|
sl@0
|
75 |
|
sl@0
|
76 |
stest.Start(_L("Check which test to perform"));
|
sl@0
|
77 |
SSecondaryThreadInfo sti =*((SSecondaryThreadInfo*)aTestInfo);
|
sl@0
|
78 |
|
sl@0
|
79 |
TInt r;
|
sl@0
|
80 |
switch(sti.iTestId)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
case ESecThreadTestOpen:
|
sl@0
|
83 |
{
|
sl@0
|
84 |
stest.Next(_L("Open channel test"));
|
sl@0
|
85 |
RDevCameraSc cam;
|
sl@0
|
86 |
r=cam.Open(sti.iCameraModuleIndex);
|
sl@0
|
87 |
stest(r==sti.iExpectedRetVal);
|
sl@0
|
88 |
cam.Close();
|
sl@0
|
89 |
break;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
case ESecThreadTestDuplicateHandle:
|
sl@0
|
92 |
{
|
sl@0
|
93 |
stest.Next(_L("Duplicate channel handle test"));
|
sl@0
|
94 |
|
sl@0
|
95 |
// Get a reference to the main thread - which created the handle
|
sl@0
|
96 |
RThread thread;
|
sl@0
|
97 |
r=thread.Open(sti.iThreadId);
|
sl@0
|
98 |
stest(r==KErrNone);
|
sl@0
|
99 |
|
sl@0
|
100 |
// Duplicate the driver handle passed from the other thread - for this thread
|
sl@0
|
101 |
RDevCameraSc cam;
|
sl@0
|
102 |
cam.SetHandle(sti.iDrvHandle);
|
sl@0
|
103 |
r=cam.Duplicate(thread);
|
sl@0
|
104 |
stest(r==sti.iExpectedRetVal);
|
sl@0
|
105 |
cam.Close();
|
sl@0
|
106 |
thread.Close();
|
sl@0
|
107 |
break;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
case ESecThreadReuseHandle:
|
sl@0
|
110 |
{
|
sl@0
|
111 |
stest.Next(_L("Re-use channel test"));
|
sl@0
|
112 |
RDevCameraSc* camPtr=(RDevCameraSc*)sti.iDrvHandle;
|
sl@0
|
113 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
114 |
camPtr->GetCamConfig(ECamCaptureModeImage, camConfBuf); // This should cause a panic.
|
sl@0
|
115 |
break;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
default:
|
sl@0
|
118 |
break;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
stest.End();
|
sl@0
|
122 |
return(KErrNone);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
/** Test for defect DEF135950. */
|
sl@0
|
126 |
LOCAL_C void DoCamDynamicSettingsTests(RDevCameraSc& aCam, RTest& aTest)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
aTest.Next(_L("DYNAMIC SETTINGS TESTS"));
|
sl@0
|
129 |
|
sl@0
|
130 |
aTest.Next(_L("Get the Caps size. Should be non-zero"));
|
sl@0
|
131 |
TInt capsSize = aCam.CapsSize();
|
sl@0
|
132 |
aTest(capsSize>0);
|
sl@0
|
133 |
|
sl@0
|
134 |
aTest.Next(_L("Get the Capabilities (driver owned copy)."));
|
sl@0
|
135 |
TPtrC8 driverCopy = aCam.Caps();
|
sl@0
|
136 |
aTest(driverCopy.Ptr() != NULL);
|
sl@0
|
137 |
aTest(driverCopy.Length()>0);
|
sl@0
|
138 |
|
sl@0
|
139 |
aTest.Next(_L("Test failure (buffer too small)."));
|
sl@0
|
140 |
TAny* capsBufPtr = User::Alloc(capsSize-1);
|
sl@0
|
141 |
aTest(capsBufPtr != NULL);
|
sl@0
|
142 |
TPtr8 smallBuf((TUint8*) capsBufPtr, capsSize-1, capsSize-1);
|
sl@0
|
143 |
aTest(KErrArgument==aCam.Caps(smallBuf));
|
sl@0
|
144 |
User::Free(capsBufPtr);
|
sl@0
|
145 |
|
sl@0
|
146 |
aTest.Next(_L("Get the Capabilities (client owned copy)."));
|
sl@0
|
147 |
capsBufPtr = User::Alloc(capsSize);
|
sl@0
|
148 |
aTest(capsBufPtr != NULL);
|
sl@0
|
149 |
TPtr8 clientCopy((TUint8*) capsBufPtr, capsSize, capsSize);
|
sl@0
|
150 |
aTest(KErrNone==aCam.Caps(clientCopy));
|
sl@0
|
151 |
aTest(clientCopy.Ptr() != NULL);
|
sl@0
|
152 |
aTest(clientCopy.Length()>0);
|
sl@0
|
153 |
|
sl@0
|
154 |
aTest.Next(_L("Obtain the range for Dynamic Settings from both copies (should be the same)."));
|
sl@0
|
155 |
|
sl@0
|
156 |
TDynamicRange &driverRangeBrightness = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeBrightness];
|
sl@0
|
157 |
TDynamicRange &clientRangeBrightness = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeBrightness];
|
sl@0
|
158 |
|
sl@0
|
159 |
aTest(driverRangeBrightness.iMin == 0);
|
sl@0
|
160 |
aTest(driverRangeBrightness.iMax == 6);
|
sl@0
|
161 |
aTest(driverRangeBrightness.iMin == clientRangeBrightness.iMin);
|
sl@0
|
162 |
aTest(driverRangeBrightness.iMax == clientRangeBrightness.iMax);
|
sl@0
|
163 |
|
sl@0
|
164 |
TDynamicRange &driverRangeContrast = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeContrast];
|
sl@0
|
165 |
TDynamicRange &clientRangeContrast = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeContrast];
|
sl@0
|
166 |
|
sl@0
|
167 |
aTest(driverRangeContrast.iMin == 0);
|
sl@0
|
168 |
aTest(driverRangeContrast.iMax == 6);
|
sl@0
|
169 |
aTest(driverRangeContrast.iMin == clientRangeContrast.iMin);
|
sl@0
|
170 |
aTest(driverRangeContrast.iMax == clientRangeContrast.iMax);
|
sl@0
|
171 |
|
sl@0
|
172 |
TDynamicRange &driverRangeColorEffect = ((TCameraCapsV02*)(driverCopy.Ptr()))->iDynamicRange[ECamAttributeColorEffect];
|
sl@0
|
173 |
TDynamicRange &clientRangeColorEffect = ((TCameraCapsV02*)(clientCopy.Ptr()))->iDynamicRange[ECamAttributeColorEffect];
|
sl@0
|
174 |
|
sl@0
|
175 |
aTest(driverRangeColorEffect.iMin == 0);
|
sl@0
|
176 |
aTest(driverRangeColorEffect.iMax == 7); // TBC::OV3640 set to 7, template driver set to 0x0040 (enum)
|
sl@0
|
177 |
aTest(driverRangeColorEffect.iMin == clientRangeColorEffect.iMin);
|
sl@0
|
178 |
aTest(driverRangeColorEffect.iMax == clientRangeColorEffect.iMax);
|
sl@0
|
179 |
|
sl@0
|
180 |
aTest.Next(_L("Test for invalid Min range."));
|
sl@0
|
181 |
aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, driverRangeBrightness.iMin-1)==KErrArgument);
|
sl@0
|
182 |
aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, driverRangeContrast.iMin-1)==KErrArgument);
|
sl@0
|
183 |
aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, driverRangeColorEffect.iMin-1)==KErrArgument);
|
sl@0
|
184 |
|
sl@0
|
185 |
aTest.Next(_L("Test for invalid Max range."));
|
sl@0
|
186 |
aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, driverRangeBrightness.iMax+1)==KErrArgument);
|
sl@0
|
187 |
aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, driverRangeContrast.iMax+1)==KErrArgument);
|
sl@0
|
188 |
aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, driverRangeColorEffect.iMax+1)==KErrArgument);
|
sl@0
|
189 |
|
sl@0
|
190 |
aTest.Next(_L("Test all valid settings as reported by range - Brightness"));
|
sl@0
|
191 |
for (TUint i=driverRangeBrightness.iMin; i <= driverRangeBrightness.iMax; ++i)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
aTest(aCam.SetDynamicAttribute(ECamAttributeBrightness, i)==KErrNone);
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
aTest.Next(_L("Test all valid settings as reported by range - Contrast"));
|
sl@0
|
197 |
for (TUint j=driverRangeContrast.iMin; j <= driverRangeContrast.iMax; ++j)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
aTest(aCam.SetDynamicAttribute(ECamAttributeContrast, j)==KErrNone);
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
aTest.Next(_L("Test all valid settings as reported by range - ColorEffect"));
|
sl@0
|
203 |
for (TUint k=driverRangeColorEffect.iMin; k <= driverRangeColorEffect.iMax; ++k)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
aTest(aCam.SetDynamicAttribute(ECamAttributeColorEffect, k)==KErrNone);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
User::Free(capsBufPtr);
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
/** Test for defect DEF135949. */
|
sl@0
|
212 |
LOCAL_C void DoCamBufferOffsetTests(RDevCameraSc& aCam, RTest& aTest, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
TInt r;
|
sl@0
|
215 |
|
sl@0
|
216 |
aTest.Next(_L("BUFFER ID OFFSET TESTS"));
|
sl@0
|
217 |
aTest.Printf(_L("PixelFormat = %d, FrameSize = %d x %d\n"),aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
|
sl@0
|
218 |
|
sl@0
|
219 |
// Configure Image Capture
|
sl@0
|
220 |
aTest.Next(_L("Get the camera config of Image mode"));
|
sl@0
|
221 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
222 |
aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
223 |
TCameraConfigV02 &camConf=camConfBuf();
|
sl@0
|
224 |
|
sl@0
|
225 |
camConf.iFrameSize=aFrameSize;
|
sl@0
|
226 |
camConf.iPixelFormat=aPixelFormat;
|
sl@0
|
227 |
camConf.iFrameRate=aFrameRate;
|
sl@0
|
228 |
|
sl@0
|
229 |
// Set the Image configuration.
|
sl@0
|
230 |
aTest.Next(_L("Set the Get the camera config of Image mode"));
|
sl@0
|
231 |
r=aCam.SetCamConfig(ECamCaptureModeImage,camConfBuf);
|
sl@0
|
232 |
aTest(r==KErrNone);
|
sl@0
|
233 |
aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
234 |
PrintCamConf(camConf,aTest);
|
sl@0
|
235 |
|
sl@0
|
236 |
// Create an Image chunk handle.
|
sl@0
|
237 |
aTest.Next(_L("Create the Image chunk"));
|
sl@0
|
238 |
RChunk imgChunkImage;
|
sl@0
|
239 |
TInt numBuffers=KNumVideoFramesToAllocate;
|
sl@0
|
240 |
r=aCam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,imgChunkImage);
|
sl@0
|
241 |
aTest(r==KErrNone);
|
sl@0
|
242 |
|
sl@0
|
243 |
aTest.Next(_L("Read and display the Image buffer config"));
|
sl@0
|
244 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
245 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
sl@0
|
246 |
aCam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBuf);
|
sl@0
|
247 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
248 |
|
sl@0
|
249 |
// Configure Video Capture
|
sl@0
|
250 |
aTest.Next(_L("Get the camera config of Video mode"));
|
sl@0
|
251 |
aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
252 |
camConf=camConfBuf();
|
sl@0
|
253 |
|
sl@0
|
254 |
camConf.iFrameSize=aFrameSize;
|
sl@0
|
255 |
camConf.iPixelFormat=aPixelFormat;
|
sl@0
|
256 |
camConf.iFrameRate=aFrameRate;
|
sl@0
|
257 |
|
sl@0
|
258 |
// Set the video configuration.
|
sl@0
|
259 |
aTest.Next(_L("Set the Get the camera config of Video mode"));
|
sl@0
|
260 |
r=aCam.SetCamConfig(ECamCaptureModeVideo,camConfBuf);
|
sl@0
|
261 |
aTest(r==KErrNone);
|
sl@0
|
262 |
aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
263 |
PrintCamConf(camConf,aTest);
|
sl@0
|
264 |
|
sl@0
|
265 |
// Create an Video chunk handle.
|
sl@0
|
266 |
aTest.Next(_L("Create the Video chunk"));
|
sl@0
|
267 |
RChunk chunkVideo;
|
sl@0
|
268 |
numBuffers=KNumVideoFramesToAllocate;
|
sl@0
|
269 |
r=aCam.SetBufConfigChunkCreate(ECamCaptureModeVideo,numBuffers,chunkVideo);
|
sl@0
|
270 |
aTest(r==KErrNone);
|
sl@0
|
271 |
|
sl@0
|
272 |
aTest.Next(_L("Read and display the Video buffer config"));
|
sl@0
|
273 |
aCam.GetBufferConfig(ECamCaptureModeVideo, bufferConfigBuf);
|
sl@0
|
274 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
275 |
|
sl@0
|
276 |
// Test that stop still returns an error.
|
sl@0
|
277 |
r=aCam.Stop();
|
sl@0
|
278 |
aTest(r==KErrGeneral);
|
sl@0
|
279 |
|
sl@0
|
280 |
// Set the current capture mode to image
|
sl@0
|
281 |
aTest.Next(_L("Set the camera in Image mode and capture a buffer, then requesting the buffer offset."));
|
sl@0
|
282 |
r=aCam.SetCaptureMode(ECamCaptureModeImage);
|
sl@0
|
283 |
aTest(r==KErrNone);
|
sl@0
|
284 |
|
sl@0
|
285 |
// Start the camera
|
sl@0
|
286 |
r=aCam.Start();
|
sl@0
|
287 |
aTest(r==KErrNone);
|
sl@0
|
288 |
|
sl@0
|
289 |
aTest.Next(_L("Issue a capture request"));
|
sl@0
|
290 |
TRequestStatus rs1;
|
sl@0
|
291 |
aCam.NotifyNewImage(rs1);
|
sl@0
|
292 |
User::WaitForRequest(rs1);
|
sl@0
|
293 |
TInt retId=rs1.Int();
|
sl@0
|
294 |
TInt retOffset=-1;
|
sl@0
|
295 |
aTest(retId>=0);
|
sl@0
|
296 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
297 |
aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
|
sl@0
|
298 |
aTest(retOffset>=0);
|
sl@0
|
299 |
|
sl@0
|
300 |
// Change capture mode
|
sl@0
|
301 |
aTest.Next(_L("Set the capture mode to Video."));
|
sl@0
|
302 |
r=aCam.SetCaptureMode(ECamCaptureModeVideo);
|
sl@0
|
303 |
aTest(r==KErrNone);
|
sl@0
|
304 |
|
sl@0
|
305 |
aTest.Next(_L("Request again the offset for the buffer in Image mode."));
|
sl@0
|
306 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
307 |
aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
|
sl@0
|
308 |
aTest(retOffset>=0);
|
sl@0
|
309 |
|
sl@0
|
310 |
// Stop the camera.
|
sl@0
|
311 |
r=aCam.Stop();
|
sl@0
|
312 |
aTest(r==KErrNone);
|
sl@0
|
313 |
|
sl@0
|
314 |
aTest.Next(_L("Close the chunk"));
|
sl@0
|
315 |
r=aCam.ChunkClose(ECamCaptureModeImage);
|
sl@0
|
316 |
aTest(r==KErrNone);
|
sl@0
|
317 |
r=aCam.ChunkClose(ECamCaptureModeVideo);
|
sl@0
|
318 |
aTest(r==KErrNone);
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
LOCAL_C void DoCamOpenCapTests(RTest& aTest,TInt aCameraSensorIndex)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
TInt r;
|
sl@0
|
325 |
|
sl@0
|
326 |
// Open the camera driver to obtain the basic capabilities for use throughout the tests and
|
sl@0
|
327 |
// then close it again so that it may be confirmed that opening multiple times is ok
|
sl@0
|
328 |
aTest.Next(_L("CHANNEL OPEN AND CAPABILITIES TESTS"));
|
sl@0
|
329 |
RDevCameraSc cam;
|
sl@0
|
330 |
aTest.Next(_L("Open a channel on the camera driver"));
|
sl@0
|
331 |
r=cam.Open(aCameraSensorIndex);
|
sl@0
|
332 |
aTest(r==KErrNone);
|
sl@0
|
333 |
|
sl@0
|
334 |
// Make sure that the driver can handle attempts to start it before it has been configured
|
sl@0
|
335 |
aTest.Next(_L("Try to start/stop camera before its configured"));
|
sl@0
|
336 |
r=cam.Start();
|
sl@0
|
337 |
aTest(r==KErrNotReady);
|
sl@0
|
338 |
r=cam.Stop();
|
sl@0
|
339 |
aTest(r==KErrGeneral);
|
sl@0
|
340 |
|
sl@0
|
341 |
aTest.Next(_L("Read the capabilities structure size of this device"));
|
sl@0
|
342 |
CapsSize=cam.CapsSize();
|
sl@0
|
343 |
aTest.Next(_L("Read and display the capabilities of this device"));
|
sl@0
|
344 |
CapsBufPtr = User::Alloc(CapsSize);
|
sl@0
|
345 |
TPtr8 capsPtr( (TUint8*)CapsBufPtr, CapsSize, CapsSize );
|
sl@0
|
346 |
r=cam.Caps(capsPtr);
|
sl@0
|
347 |
aTest(r==KErrNone);
|
sl@0
|
348 |
CameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
|
sl@0
|
349 |
PrintCamModes(CameraCaps,aTest);
|
sl@0
|
350 |
|
sl@0
|
351 |
TAny* frameSizeCapsBuf;
|
sl@0
|
352 |
SDevCamPixelFormat* pixelFormat;
|
sl@0
|
353 |
TBuf<80> buf;
|
sl@0
|
354 |
SDevCamFrameSize* frameSize;
|
sl@0
|
355 |
TPtr8 frameSizeCapsPtr(0,0,0);
|
sl@0
|
356 |
TUint fsCount, pfCount, theCount = 0;
|
sl@0
|
357 |
|
sl@0
|
358 |
/* IMAGE */
|
sl@0
|
359 |
/* Use pixel formats from 0 to CapsBuf->iNumImagePixelFormats */
|
sl@0
|
360 |
buf.Zero();
|
sl@0
|
361 |
buf.Append(KCaptureModeImage);
|
sl@0
|
362 |
buf.Append(_L("\r\n"));
|
sl@0
|
363 |
aTest.Printf(buf);
|
sl@0
|
364 |
pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
|
sl@0
|
365 |
for (pfCount = theCount; pfCount < CameraCaps->iNumImagePixelFormats; pfCount++)
|
sl@0
|
366 |
{
|
sl@0
|
367 |
buf.Zero();
|
sl@0
|
368 |
AppendPixelFormat(buf, pixelFormat->iPixelFormat);
|
sl@0
|
369 |
aTest.Printf(buf);
|
sl@0
|
370 |
frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
371 |
new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
372 |
r=cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizeCapsPtr);
|
sl@0
|
373 |
aTest(r==KErrNone);
|
sl@0
|
374 |
frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
|
sl@0
|
375 |
for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
|
sl@0
|
376 |
{
|
sl@0
|
377 |
aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
|
sl@0
|
378 |
frameSize++;
|
sl@0
|
379 |
}
|
sl@0
|
380 |
aTest.Printf(_L("\n"));
|
sl@0
|
381 |
User::Free(frameSizeCapsBuf);
|
sl@0
|
382 |
pixelFormat++;
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
/* VIDEO */
|
sl@0
|
386 |
buf.Zero();
|
sl@0
|
387 |
buf.Append(KCaptureModeVideo);
|
sl@0
|
388 |
buf.Append(_L("\r\n"));
|
sl@0
|
389 |
aTest.Printf(buf);
|
sl@0
|
390 |
pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
|
sl@0
|
391 |
pixelFormat += CameraCaps->iNumImagePixelFormats;
|
sl@0
|
392 |
theCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats;
|
sl@0
|
393 |
for (pfCount = CameraCaps->iNumImagePixelFormats; pfCount < theCount; pfCount++)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
buf.Zero();
|
sl@0
|
396 |
AppendPixelFormat(buf, pixelFormat->iPixelFormat);
|
sl@0
|
397 |
aTest.Printf(buf);
|
sl@0
|
398 |
frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
399 |
new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
400 |
r=cam.FrameSizeCaps(ECamCaptureModeVideo, pixelFormat->iPixelFormat, frameSizeCapsPtr);
|
sl@0
|
401 |
aTest(r==KErrNone);
|
sl@0
|
402 |
frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
|
sl@0
|
403 |
for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
|
sl@0
|
406 |
frameSize++;
|
sl@0
|
407 |
}
|
sl@0
|
408 |
aTest.Printf(_L("\n"));
|
sl@0
|
409 |
User::Free(frameSizeCapsBuf);
|
sl@0
|
410 |
pixelFormat++;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
/* VIEW FINDER */
|
sl@0
|
414 |
buf.Zero();
|
sl@0
|
415 |
buf.Append(KCaptureModeViewFinder);
|
sl@0
|
416 |
buf.Append(_L("\r\n"));
|
sl@0
|
417 |
aTest.Printf(buf);
|
sl@0
|
418 |
pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
|
sl@0
|
419 |
pixelFormat += (CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats);
|
sl@0
|
420 |
theCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats + CameraCaps->iNumViewFinderPixelFormats;
|
sl@0
|
421 |
for (pfCount = CameraCaps->iNumImagePixelFormats + CameraCaps->iNumVideoPixelFormats; pfCount < theCount; pfCount++)
|
sl@0
|
422 |
{
|
sl@0
|
423 |
buf.Zero();
|
sl@0
|
424 |
AppendPixelFormat(buf, pixelFormat->iPixelFormat);
|
sl@0
|
425 |
aTest.Printf(buf);
|
sl@0
|
426 |
frameSizeCapsBuf = User::Alloc(pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
427 |
new (&frameSizeCapsPtr) TPtr8((TUint8*)frameSizeCapsBuf, pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize), pixelFormat->iNumFrameSizes*sizeof(SDevCamFrameSize));
|
sl@0
|
428 |
r=cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizeCapsPtr);
|
sl@0
|
429 |
aTest(r==KErrNone);
|
sl@0
|
430 |
frameSize = (SDevCamFrameSize*) frameSizeCapsPtr.Ptr();
|
sl@0
|
431 |
for (fsCount = 0; fsCount < pixelFormat->iNumFrameSizes; fsCount++)
|
sl@0
|
432 |
{
|
sl@0
|
433 |
aTest.Printf(_L("%dx%d "),frameSize->iWidth,frameSize->iHeight);
|
sl@0
|
434 |
frameSize++;
|
sl@0
|
435 |
}
|
sl@0
|
436 |
aTest.Printf(_L("\n"));
|
sl@0
|
437 |
User::Free(frameSizeCapsBuf);
|
sl@0
|
438 |
pixelFormat++;
|
sl@0
|
439 |
}
|
sl@0
|
440 |
|
sl@0
|
441 |
aTest.Next(_L("Try opening the same unit a second time."));
|
sl@0
|
442 |
RDevCameraSc cam2;
|
sl@0
|
443 |
r=cam2.Open(aCameraSensorIndex);
|
sl@0
|
444 |
aTest(r==KErrInUse);
|
sl@0
|
445 |
|
sl@0
|
446 |
aTest.Next(_L("Open a channel from the 2nd thread without closing the 1st"));
|
sl@0
|
447 |
RThread thread;
|
sl@0
|
448 |
TRequestStatus stat;
|
sl@0
|
449 |
SSecondaryThreadInfo sti;
|
sl@0
|
450 |
|
sl@0
|
451 |
// Setup the 2nd thread to open a channel on the same unit
|
sl@0
|
452 |
sti.iTestId=ESecThreadTestOpen;
|
sl@0
|
453 |
sti.iExpectedRetVal=KErrInUse;
|
sl@0
|
454 |
sti.iCameraModuleIndex=aCameraSensorIndex;
|
sl@0
|
455 |
r=thread.Create(_L("Thread"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti);
|
sl@0
|
456 |
Test(r==KErrNone);
|
sl@0
|
457 |
thread.Logon(stat);
|
sl@0
|
458 |
thread.Resume();
|
sl@0
|
459 |
User::WaitForRequest(stat);
|
sl@0
|
460 |
Test(stat.Int()==KErrNone);
|
sl@0
|
461 |
Test(thread.ExitType()==EExitKill);
|
sl@0
|
462 |
thread.Close();
|
sl@0
|
463 |
User::After(10000); // Wait 10ms
|
sl@0
|
464 |
|
sl@0
|
465 |
aTest.Next(_L("Open a channel from the 2nd thread having closed the 1st"));
|
sl@0
|
466 |
cam.Close(); // Close the 1st channel
|
sl@0
|
467 |
sti.iTestId=ESecThreadTestOpen;
|
sl@0
|
468 |
sti.iExpectedRetVal=KErrNone;
|
sl@0
|
469 |
r=thread.Create(_L("Thread02"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti);
|
sl@0
|
470 |
Test(r==KErrNone);
|
sl@0
|
471 |
thread.Logon(stat);
|
sl@0
|
472 |
thread.Resume();
|
sl@0
|
473 |
User::WaitForRequest(stat);
|
sl@0
|
474 |
Test(stat.Int()==KErrNone);
|
sl@0
|
475 |
Test(thread.ExitType()==EExitKill);
|
sl@0
|
476 |
thread.Close();
|
sl@0
|
477 |
User::After(10000); // Wait 10ms
|
sl@0
|
478 |
|
sl@0
|
479 |
aTest.Next(_L("Re-open channel and duplicate it from 2nd thread"));
|
sl@0
|
480 |
r=cam.Open(aCameraSensorIndex); // Re-open the channel
|
sl@0
|
481 |
aTest(r==KErrNone);
|
sl@0
|
482 |
sti.iTestId=ESecThreadTestDuplicateHandle;
|
sl@0
|
483 |
sti.iExpectedRetVal=KErrAccessDenied;
|
sl@0
|
484 |
sti.iThreadId=RThread().Id(); // Get the ID of this thread
|
sl@0
|
485 |
sti.iDrvHandle=cam.Handle(); // Pass the channel handle
|
sl@0
|
486 |
|
sl@0
|
487 |
r=thread.Create(_L("Thread03"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti); // Create secondary thread
|
sl@0
|
488 |
Test(r==KErrNone);
|
sl@0
|
489 |
thread.Logon(stat);
|
sl@0
|
490 |
thread.Resume();
|
sl@0
|
491 |
User::WaitForRequest(stat);
|
sl@0
|
492 |
Test(stat.Int()==KErrNone);
|
sl@0
|
493 |
Test(thread.ExitType()==EExitKill);
|
sl@0
|
494 |
thread.Close();
|
sl@0
|
495 |
User::After(10000); // Wait 10ms
|
sl@0
|
496 |
|
sl@0
|
497 |
aTest.Next(_L("Re-use the same channel from 2nd thread"));
|
sl@0
|
498 |
sti.iTestId=ESecThreadReuseHandle;
|
sl@0
|
499 |
sti.iDrvHandle=(TInt)&cam; // Pass a pointer to the channel
|
sl@0
|
500 |
r=thread.Create(_L("Thread04"),secondaryThread,KDefaultStackSize,KHeapSize,KHeapSize,&sti); // Create secondary thread
|
sl@0
|
501 |
Test(r==KErrNone);
|
sl@0
|
502 |
thread.Logon(stat);
|
sl@0
|
503 |
thread.Resume();
|
sl@0
|
504 |
User::WaitForRequest(stat);
|
sl@0
|
505 |
TExitCategoryName exitCategoryName = thread.ExitCategory();
|
sl@0
|
506 |
Test.Printf(_L("Thread exit info: Cat:%S, Reason:%x, Type:%d\r\n"),&exitCategoryName,thread.ExitReason(),thread.ExitType());
|
sl@0
|
507 |
Test(thread.ExitType()==EExitPanic); // Secondary thread is expected to panic
|
sl@0
|
508 |
Test(stat.Int()==KErrNone);
|
sl@0
|
509 |
thread.Close();
|
sl@0
|
510 |
User::After(10000); // Wait 10ms
|
sl@0
|
511 |
|
sl@0
|
512 |
cam.Close();
|
sl@0
|
513 |
}
|
sl@0
|
514 |
|
sl@0
|
515 |
LOCAL_C void DoCamConfigTests(RDevCameraSc& aCam, RTest& aTest, TDevCamCaptureMode aCaptureMode, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize)
|
sl@0
|
516 |
{
|
sl@0
|
517 |
TInt r;
|
sl@0
|
518 |
|
sl@0
|
519 |
aTest.Next(_L("GETTING & SETTING CONFIG TESTS"));
|
sl@0
|
520 |
aTest.Printf(_L("CaptureMode = %d, PixelFormat = %x, FrameSize = %d x %d\n"),aCaptureMode,aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
|
sl@0
|
521 |
|
sl@0
|
522 |
aTest.Next(_L("Read and display the default camera config for requested capture mode"));
|
sl@0
|
523 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
524 |
aCam.GetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
525 |
TCameraConfigV02 &camConf=camConfBuf();
|
sl@0
|
526 |
PrintCamConf(camConf,aTest);
|
sl@0
|
527 |
|
sl@0
|
528 |
aTest.Next(_L("Read and display the default buffer config for requested capture mode"));
|
sl@0
|
529 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
530 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
sl@0
|
531 |
aCam.GetBufferConfig(aCaptureMode, bufferConfigBuf);
|
sl@0
|
532 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
533 |
|
sl@0
|
534 |
aTest.Next(_L("Setup the config - creating a chunk"));
|
sl@0
|
535 |
camConf.iFrameSize=aFrameSize;
|
sl@0
|
536 |
camConf.iPixelFormat=aPixelFormat;
|
sl@0
|
537 |
camConf.iFrameRate=aFrameSize.iMaxFrameRate;
|
sl@0
|
538 |
r=aCam.SetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
539 |
aTest(r==KErrNone);
|
sl@0
|
540 |
RChunk chunk;
|
sl@0
|
541 |
r=aCam.SetBufConfigChunkCreate(aCaptureMode, KNumVideoFramesToAllocate, chunk);
|
sl@0
|
542 |
aTest(r==KErrNone);
|
sl@0
|
543 |
aCam.GetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
544 |
PrintCamConf(camConf,aTest);
|
sl@0
|
545 |
|
sl@0
|
546 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
547 |
aCam.GetBufferConfig(aCaptureMode, bufferConfigBuf);
|
sl@0
|
548 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
549 |
|
sl@0
|
550 |
aTest.Next(_L("Close the chunk created"));
|
sl@0
|
551 |
chunk.Close();
|
sl@0
|
552 |
|
sl@0
|
553 |
aTest.Next(_L("Open a channel on the test driver"));
|
sl@0
|
554 |
RMmCreateSc tstDrv;
|
sl@0
|
555 |
r=tstDrv.Open(); // Opening the channel results in the creation of a shared chunk.
|
sl@0
|
556 |
aTest(r==KErrNone);
|
sl@0
|
557 |
|
sl@0
|
558 |
aTest.Next(_L("Get a handle on its shared chunk"));
|
sl@0
|
559 |
r=tstDrv.GetChunkHandle(chunk); // Get a handle on the shared chunk created by the test driver
|
sl@0
|
560 |
aTest(r==KErrNone);
|
sl@0
|
561 |
|
sl@0
|
562 |
aTest.Next(_L("Read and display the buffer config"));
|
sl@0
|
563 |
TMmSharedChunkBufConfig bufferConfigTest;
|
sl@0
|
564 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufTest(bufferConfigTest);
|
sl@0
|
565 |
|
sl@0
|
566 |
// Get info on the buffers within the shared chunk
|
sl@0
|
567 |
aTest.Next(_L("Get info. on the shared chunk"));
|
sl@0
|
568 |
r=tstDrv.GetBufInfo(bufferConfigBufTest);
|
sl@0
|
569 |
aTest(r==KErrNone);
|
sl@0
|
570 |
|
sl@0
|
571 |
PrintBufferConf(bufferConfigTest,aTest);
|
sl@0
|
572 |
aTest.Next(_L("Setup the config - supplying a chunk"));
|
sl@0
|
573 |
r=aCam.SetBufConfigChunkOpen(aCaptureMode, bufferConfigBufTest, chunk);
|
sl@0
|
574 |
aTest(r==KErrNone);
|
sl@0
|
575 |
aCam.GetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
576 |
PrintCamConf(camConf,aTest);
|
sl@0
|
577 |
aCam.GetBufferConfig(aCaptureMode, bufferConfigBufTest);
|
sl@0
|
578 |
PrintBufferConf(bufferConfigTest,aTest);
|
sl@0
|
579 |
|
sl@0
|
580 |
aTest.Next(_L("Close the chunk driver and the 2nd chunk"));
|
sl@0
|
581 |
tstDrv.Close();
|
sl@0
|
582 |
chunk.Close();
|
sl@0
|
583 |
}
|
sl@0
|
584 |
|
sl@0
|
585 |
LOCAL_C void DoCamVideoCaptureTests(RDevCameraSc& aCam, RTest& aTest, TDevCamCaptureMode aCaptureMode, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
TInt r;
|
sl@0
|
588 |
|
sl@0
|
589 |
aTest.Next(_L("VIDEO CAPTURE TESTS"));
|
sl@0
|
590 |
aTest.Printf(_L("CaptureMode = %d, PixelFormat = %x, FrameSize = %d x %d\n"),aCaptureMode,aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
|
sl@0
|
591 |
|
sl@0
|
592 |
// Configure Video or Viewfinder Capture
|
sl@0
|
593 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
594 |
aCam.GetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
595 |
TCameraConfigV02 &camConf=camConfBuf();
|
sl@0
|
596 |
|
sl@0
|
597 |
camConf.iFrameSize=aFrameSize;
|
sl@0
|
598 |
camConf.iPixelFormat=aPixelFormat;
|
sl@0
|
599 |
camConf.iFrameRate=aFrameRate;
|
sl@0
|
600 |
|
sl@0
|
601 |
// Set the camera configuration.
|
sl@0
|
602 |
r=aCam.SetCamConfig(aCaptureMode,camConfBuf);
|
sl@0
|
603 |
aTest(r==KErrNone);
|
sl@0
|
604 |
aCam.GetCamConfig(aCaptureMode, camConfBuf);
|
sl@0
|
605 |
PrintCamConf(camConf,aTest);
|
sl@0
|
606 |
|
sl@0
|
607 |
// Create a chunk handle and trigger the buffer creation.
|
sl@0
|
608 |
aTest.Next(_L("Setup the config - creating a chunk"));
|
sl@0
|
609 |
RChunk chunkVideo;
|
sl@0
|
610 |
TInt numBuffers=KNumVideoFramesToAllocate;
|
sl@0
|
611 |
r=aCam.SetBufConfigChunkCreate(aCaptureMode,numBuffers,chunkVideo);
|
sl@0
|
612 |
aTest(r==KErrNone);
|
sl@0
|
613 |
|
sl@0
|
614 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
615 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
616 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufVideo(bufferConfig);
|
sl@0
|
617 |
aCam.GetBufferConfig(aCaptureMode, bufferConfigBufVideo);
|
sl@0
|
618 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
619 |
|
sl@0
|
620 |
// Request and print the camera and buffer configurations for all three capture modes
|
sl@0
|
621 |
aTest.Next(_L("Read and display the camera configs"));
|
sl@0
|
622 |
aCam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
623 |
PrintCamConf(camConf,aTest);
|
sl@0
|
624 |
aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
625 |
PrintCamConf(camConf,aTest);
|
sl@0
|
626 |
aCam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
|
sl@0
|
627 |
PrintCamConf(camConf,aTest);
|
sl@0
|
628 |
|
sl@0
|
629 |
// Create and configure a display handler
|
sl@0
|
630 |
TCamDisplayHandler dispHand;
|
sl@0
|
631 |
r=dispHand.Init();
|
sl@0
|
632 |
aTest(r==KErrNone);
|
sl@0
|
633 |
|
sl@0
|
634 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
635 |
{
|
sl@0
|
636 |
r=dispHand.SetConfig(aFrameSize,aPixelFormat);
|
sl@0
|
637 |
aTest(r==KErrNone);
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
// Test that stop still returns an error.
|
sl@0
|
641 |
r=aCam.Stop();
|
sl@0
|
642 |
aTest(r==KErrGeneral);
|
sl@0
|
643 |
|
sl@0
|
644 |
// Set the current capture mode
|
sl@0
|
645 |
r=aCam.SetCaptureMode(aCaptureMode);
|
sl@0
|
646 |
aTest(r==KErrNone);
|
sl@0
|
647 |
|
sl@0
|
648 |
aTest.Next(_L("Start the camera in video mode"));
|
sl@0
|
649 |
r=aCam.Start();
|
sl@0
|
650 |
aTest(r==KErrNone);
|
sl@0
|
651 |
|
sl@0
|
652 |
aTest.Next(_L("Issue capture requests"));
|
sl@0
|
653 |
aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
|
sl@0
|
654 |
// Issue new image requests immediately. We'll have to wait while the
|
sl@0
|
655 |
// camera captures the images.
|
sl@0
|
656 |
TRequestStatus rs[KNumVideoFramesToCapture];
|
sl@0
|
657 |
TInt i;
|
sl@0
|
658 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
659 |
{
|
sl@0
|
660 |
aTest.Printf(_L("Requesting new image... %d\n"), i);
|
sl@0
|
661 |
aCam.NotifyNewImage(rs[i]);
|
sl@0
|
662 |
aTest.Printf(_L("Requested new image... %d\n"), i);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
TInt retId=-1;
|
sl@0
|
666 |
TInt retOffset=-1;
|
sl@0
|
667 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
668 |
{
|
sl@0
|
669 |
aTest.Printf(_L("Waiting for... %d\n"), i);
|
sl@0
|
670 |
User::WaitForRequest(rs[i]);
|
sl@0
|
671 |
retId=rs[i].Int();
|
sl@0
|
672 |
aTest(retId>=0);
|
sl@0
|
673 |
aTest.Printf(_L("Getting buffer offset for... %d\n"), i);
|
sl@0
|
674 |
aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
|
sl@0
|
675 |
aTest.Printf(_L("Buffer%d(id:%d) offset: %d(%xH)\r\n"),i,retId,retOffset,retOffset);
|
sl@0
|
676 |
aTest(retOffset>=0);
|
sl@0
|
677 |
}
|
sl@0
|
678 |
|
sl@0
|
679 |
TUint8* imgBase;
|
sl@0
|
680 |
|
sl@0
|
681 |
// Display each image received for 333ms
|
sl@0
|
682 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
683 |
{
|
sl@0
|
684 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
685 |
{
|
sl@0
|
686 |
retId=rs[i].Int();
|
sl@0
|
687 |
aTest(retId>=0);
|
sl@0
|
688 |
aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
|
sl@0
|
689 |
aTest(retOffset>=0);
|
sl@0
|
690 |
imgBase=chunkVideo.Base()+retOffset;
|
sl@0
|
691 |
r=dispHand.Process(imgBase);
|
sl@0
|
692 |
|
sl@0
|
693 |
#ifdef __WINSCW__
|
sl@0
|
694 |
aTest(r==KErrNotSupported);
|
sl@0
|
695 |
#else
|
sl@0
|
696 |
aTest(r==KErrNone);
|
sl@0
|
697 |
#endif
|
sl@0
|
698 |
|
sl@0
|
699 |
User::After(333000); // 0.33sec
|
sl@0
|
700 |
}
|
sl@0
|
701 |
}
|
sl@0
|
702 |
|
sl@0
|
703 |
aTest.Next(_L("Free the buffers"));
|
sl@0
|
704 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
705 |
{
|
sl@0
|
706 |
aTest.Printf(_L("Releasing %d(i:%d) "),rs[i].Int(), i);
|
sl@0
|
707 |
r=aCam.ReleaseBuffer(rs[i].Int());
|
sl@0
|
708 |
aTest.Printf(_L("buffer(%d), r=%d\n"),rs[i].Int(),r);
|
sl@0
|
709 |
aTest(r==KErrNone);
|
sl@0
|
710 |
}
|
sl@0
|
711 |
|
sl@0
|
712 |
aTest.Next(_L("Issue more capture requests"));
|
sl@0
|
713 |
// Wait a bit more so camera has images ready as soon as we issue the requests
|
sl@0
|
714 |
User::After(500000); // 0.5sec
|
sl@0
|
715 |
|
sl@0
|
716 |
aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
|
sl@0
|
717 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
718 |
aCam.NotifyNewImage(rs[i]);
|
sl@0
|
719 |
|
sl@0
|
720 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
721 |
{
|
sl@0
|
722 |
User::WaitForRequest(rs[i]);
|
sl@0
|
723 |
retId=rs[i].Int();
|
sl@0
|
724 |
aTest(retId>=0);
|
sl@0
|
725 |
aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
|
sl@0
|
726 |
aTest.Printf(_L("Buffer%d(id:%d) offset: %d(%xH)\r\n"),i,retId,retOffset,retOffset);
|
sl@0
|
727 |
aTest(retOffset>=0);
|
sl@0
|
728 |
}
|
sl@0
|
729 |
|
sl@0
|
730 |
aTest.Next(_L("Stop the camera."));
|
sl@0
|
731 |
r=aCam.Stop();
|
sl@0
|
732 |
aTest(r==KErrNone);
|
sl@0
|
733 |
|
sl@0
|
734 |
aTest.Next(_L("Start it again."));
|
sl@0
|
735 |
r=aCam.Start();
|
sl@0
|
736 |
aTest(r==KErrNone);
|
sl@0
|
737 |
|
sl@0
|
738 |
aTest.Next(_L("Continuously display for 10 secs"));
|
sl@0
|
739 |
RTimer tim;
|
sl@0
|
740 |
tim.CreateLocal();
|
sl@0
|
741 |
TRequestStatus timStatus;
|
sl@0
|
742 |
const TUint KTimeOut=10000000; // 10 seconds
|
sl@0
|
743 |
tim.After(timStatus,KTimeOut);
|
sl@0
|
744 |
aTest(timStatus==KRequestPending);
|
sl@0
|
745 |
aCam.NotifyNewImage(rs[0]);
|
sl@0
|
746 |
aCam.NotifyNewImage(rs[1]);
|
sl@0
|
747 |
FOREVER
|
sl@0
|
748 |
{
|
sl@0
|
749 |
User::WaitForAnyRequest();
|
sl@0
|
750 |
if (timStatus!=KRequestPending)
|
sl@0
|
751 |
{
|
sl@0
|
752 |
aCam.NotifyNewImageCancel();
|
sl@0
|
753 |
User::WaitForRequest(rs[0]);
|
sl@0
|
754 |
User::WaitForRequest(rs[1]);
|
sl@0
|
755 |
break;
|
sl@0
|
756 |
}
|
sl@0
|
757 |
else if (rs[0]!=KRequestPending)
|
sl@0
|
758 |
{
|
sl@0
|
759 |
retId=rs[0].Int();
|
sl@0
|
760 |
aTest(retId>=0);
|
sl@0
|
761 |
aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
|
sl@0
|
762 |
aTest(retOffset>=0);
|
sl@0
|
763 |
imgBase=chunkVideo.Base()+retOffset;
|
sl@0
|
764 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
765 |
{
|
sl@0
|
766 |
r=dispHand.Process(imgBase);
|
sl@0
|
767 |
|
sl@0
|
768 |
#ifdef __WINSCW__
|
sl@0
|
769 |
aTest(r==KErrNotSupported);
|
sl@0
|
770 |
#else
|
sl@0
|
771 |
aTest(r==KErrNone);
|
sl@0
|
772 |
#endif
|
sl@0
|
773 |
|
sl@0
|
774 |
}
|
sl@0
|
775 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
776 |
aTest(r==KErrNone);
|
sl@0
|
777 |
aCam.NotifyNewImage(rs[0]);
|
sl@0
|
778 |
}
|
sl@0
|
779 |
else if (rs[1]!=KRequestPending)
|
sl@0
|
780 |
{
|
sl@0
|
781 |
retId=rs[1].Int();
|
sl@0
|
782 |
aTest(retId>=0);
|
sl@0
|
783 |
aCam.BufferIdToOffset(aCaptureMode,retId,retOffset);
|
sl@0
|
784 |
aTest(retOffset>=0);
|
sl@0
|
785 |
imgBase=chunkVideo.Base()+retOffset;
|
sl@0
|
786 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
787 |
{
|
sl@0
|
788 |
r=dispHand.Process(imgBase);
|
sl@0
|
789 |
|
sl@0
|
790 |
#ifdef __WINSCW__
|
sl@0
|
791 |
aTest(r==KErrNotSupported);
|
sl@0
|
792 |
#else
|
sl@0
|
793 |
aTest(r==KErrNone);
|
sl@0
|
794 |
#endif
|
sl@0
|
795 |
|
sl@0
|
796 |
}
|
sl@0
|
797 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
798 |
aTest(r==KErrNone);
|
sl@0
|
799 |
aCam.NotifyNewImage(rs[1]);
|
sl@0
|
800 |
}
|
sl@0
|
801 |
else
|
sl@0
|
802 |
aTest(0);
|
sl@0
|
803 |
}
|
sl@0
|
804 |
|
sl@0
|
805 |
tim.Close();
|
sl@0
|
806 |
|
sl@0
|
807 |
aTest.Next(_L("Stop the camera."));
|
sl@0
|
808 |
r=aCam.Stop();
|
sl@0
|
809 |
aTest(r==KErrNone);
|
sl@0
|
810 |
|
sl@0
|
811 |
aTest.Next(_L("Close the chunk"));
|
sl@0
|
812 |
r=aCam.ChunkClose(aCaptureMode);
|
sl@0
|
813 |
}
|
sl@0
|
814 |
|
sl@0
|
815 |
LOCAL_C void DoCamImageCaptureTests(RDevCameraSc& aCam, RTest& aTest, TInt aCameraSensorIndex, const SDevCamPixelFormat& aPixelFormat, const SDevCamFrameSize& aFrameSize, TUint aFrameRate)
|
sl@0
|
816 |
{
|
sl@0
|
817 |
TInt r;
|
sl@0
|
818 |
|
sl@0
|
819 |
aTest.Next(_L("IMAGE CAPTURE TESTS"));
|
sl@0
|
820 |
aTest.Printf(_L("PixelFormat = %d, FrameSize = %d x %d\n"),aPixelFormat.iPixelFormat,aFrameSize.iWidth,aFrameSize.iHeight);
|
sl@0
|
821 |
|
sl@0
|
822 |
// Configure Image Capture
|
sl@0
|
823 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
824 |
aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
825 |
TCameraConfigV02 &camConf=camConfBuf();
|
sl@0
|
826 |
|
sl@0
|
827 |
camConf.iFrameSize=aFrameSize;
|
sl@0
|
828 |
camConf.iPixelFormat=aPixelFormat;
|
sl@0
|
829 |
camConf.iFrameRate=aFrameRate;
|
sl@0
|
830 |
|
sl@0
|
831 |
// Set the camera configuration.
|
sl@0
|
832 |
r=aCam.SetCamConfig(ECamCaptureModeImage,camConfBuf);
|
sl@0
|
833 |
aTest(r==KErrNone);
|
sl@0
|
834 |
aCam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
835 |
PrintCamConf(camConf,aTest);
|
sl@0
|
836 |
|
sl@0
|
837 |
// Create a chunk handle and trigger the buffer creation.
|
sl@0
|
838 |
aTest.Next(_L("Setup the config - creating a chunk"));
|
sl@0
|
839 |
RChunk chunkImage;
|
sl@0
|
840 |
TInt numBuffers=KNumVideoFramesToAllocate;
|
sl@0
|
841 |
r=aCam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,chunkImage);
|
sl@0
|
842 |
aTest(r==KErrNone);
|
sl@0
|
843 |
|
sl@0
|
844 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
845 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
846 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufImage(bufferConfig);
|
sl@0
|
847 |
aCam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBufImage);
|
sl@0
|
848 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
849 |
|
sl@0
|
850 |
// Create and configure a display handler
|
sl@0
|
851 |
TCamDisplayHandler dispHand;
|
sl@0
|
852 |
r=dispHand.Init();
|
sl@0
|
853 |
aTest(r==KErrNone);
|
sl@0
|
854 |
|
sl@0
|
855 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
856 |
{
|
sl@0
|
857 |
r=dispHand.SetConfig(aFrameSize,aPixelFormat);
|
sl@0
|
858 |
aTest(r==KErrNone);
|
sl@0
|
859 |
}
|
sl@0
|
860 |
|
sl@0
|
861 |
// Test that stop still returns an error.
|
sl@0
|
862 |
r=aCam.Stop();
|
sl@0
|
863 |
aTest(r==KErrGeneral);
|
sl@0
|
864 |
|
sl@0
|
865 |
// Set the current capture mode
|
sl@0
|
866 |
r=aCam.SetCaptureMode(ECamCaptureModeImage);
|
sl@0
|
867 |
aTest(r==KErrNone);
|
sl@0
|
868 |
|
sl@0
|
869 |
aTest.Next(_L("Start the camera in image capture mode"));
|
sl@0
|
870 |
r=aCam.Start();
|
sl@0
|
871 |
aTest(r==KErrNone);
|
sl@0
|
872 |
|
sl@0
|
873 |
aTest.Next(_L("Issue a capture request"));
|
sl@0
|
874 |
TRequestStatus rs1;
|
sl@0
|
875 |
aCam.NotifyNewImage(rs1);
|
sl@0
|
876 |
User::WaitForRequest(rs1);
|
sl@0
|
877 |
TInt retId=rs1.Int();
|
sl@0
|
878 |
TInt retOffset=-1;
|
sl@0
|
879 |
aTest(retId>=0);
|
sl@0
|
880 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
881 |
aTest.Printf(_L("Buffer offset: %d(%xH)\r\n"),retId,retOffset);
|
sl@0
|
882 |
aTest(retOffset>=0);
|
sl@0
|
883 |
|
sl@0
|
884 |
TUint8* imgBase;
|
sl@0
|
885 |
imgBase=chunkImage.Base()+retOffset;
|
sl@0
|
886 |
|
sl@0
|
887 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
888 |
{
|
sl@0
|
889 |
// Display the image received for 1s
|
sl@0
|
890 |
r=dispHand.Process(imgBase);
|
sl@0
|
891 |
|
sl@0
|
892 |
#ifdef __WINSCW__
|
sl@0
|
893 |
aTest(r==KErrNotSupported);
|
sl@0
|
894 |
#else
|
sl@0
|
895 |
aTest(r==KErrNone);
|
sl@0
|
896 |
#endif
|
sl@0
|
897 |
|
sl@0
|
898 |
User::After(1000000); // 1 sec
|
sl@0
|
899 |
}
|
sl@0
|
900 |
|
sl@0
|
901 |
// Save the to do MMC card with a filename to indicate its size. If no MMC card is present
|
sl@0
|
902 |
// then we will just display a warning rather than fail as this is an optional manual step
|
sl@0
|
903 |
TBuf<100> fileName(KSensor);
|
sl@0
|
904 |
fileName.AppendNum(aCameraSensorIndex);
|
sl@0
|
905 |
fileName.Append(KUnderscore);
|
sl@0
|
906 |
fileName.AppendFormat(KFrameSize, aFrameSize.iWidth, aFrameSize.iHeight);
|
sl@0
|
907 |
fileName.Append(KUnderscore);
|
sl@0
|
908 |
AppendPixelFormat(fileName, aPixelFormat.iPixelFormat);
|
sl@0
|
909 |
|
sl@0
|
910 |
TBool wrote = ETrue;
|
sl@0
|
911 |
RBitmap bitmap;
|
sl@0
|
912 |
|
sl@0
|
913 |
if ((aPixelFormat.iPixelFormat == EUidPixelFormatJPEG) || (aPixelFormat.iPixelFormat == EUidPixelFormatSpeedTaggedJPEG))
|
sl@0
|
914 |
{
|
sl@0
|
915 |
fileName.Append((aPixelFormat.iPixelFormat == EUidPixelFormatJPEG) ? KJpeg : KSpeedTaggedJpeg);
|
sl@0
|
916 |
r=bitmap.WriteBuffer(fileName, imgBase, (aFrameSize.iWidth * aFrameSize.iHeight * aPixelFormat.iPixelWidthInBytes));
|
sl@0
|
917 |
}
|
sl@0
|
918 |
else if ((aPixelFormat.iPixelFormat == EUidPixelFormatYUV_422Interleaved) || (aPixelFormat.iPixelFormat == EUidPixelFormatRGB_565))
|
sl@0
|
919 |
{
|
sl@0
|
920 |
fileName.Append(KBmp);
|
sl@0
|
921 |
r=bitmap.WriteBMP(fileName, imgBase, aPixelFormat, aFrameSize.iWidth, aFrameSize.iHeight);
|
sl@0
|
922 |
}
|
sl@0
|
923 |
else
|
sl@0
|
924 |
{
|
sl@0
|
925 |
wrote = EFalse;
|
sl@0
|
926 |
}
|
sl@0
|
927 |
|
sl@0
|
928 |
if (wrote)
|
sl@0
|
929 |
{
|
sl@0
|
930 |
if (r==KErrNone)
|
sl@0
|
931 |
{
|
sl@0
|
932 |
aTest.Printf(_L("Wrote image to %S\n"),&fileName);
|
sl@0
|
933 |
}
|
sl@0
|
934 |
else
|
sl@0
|
935 |
{
|
sl@0
|
936 |
aTest.Printf(_L("Warning: Unable to write %S (error = %d)\r\n"),&fileName,r);
|
sl@0
|
937 |
}
|
sl@0
|
938 |
}
|
sl@0
|
939 |
|
sl@0
|
940 |
aTest.Next(_L("Free the buffer"));
|
sl@0
|
941 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
942 |
aTest(r==KErrNone);
|
sl@0
|
943 |
|
sl@0
|
944 |
aTest.Next(_L("Issue two consecutive capture requests"));
|
sl@0
|
945 |
TRequestStatus rs2;
|
sl@0
|
946 |
aCam.NotifyNewImage(rs1);
|
sl@0
|
947 |
aCam.NotifyNewImage(rs2);
|
sl@0
|
948 |
|
sl@0
|
949 |
User::WaitForRequest(rs1);
|
sl@0
|
950 |
retId=rs1.Int();
|
sl@0
|
951 |
aTest(retId>=0);
|
sl@0
|
952 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
953 |
aTest.Printf(_L("Buffer0 offset: %d(%xH)\r\n"),retOffset,retOffset);
|
sl@0
|
954 |
aTest(retOffset>=0);
|
sl@0
|
955 |
|
sl@0
|
956 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
957 |
{
|
sl@0
|
958 |
// Display the image received for 1s
|
sl@0
|
959 |
imgBase=chunkImage.Base()+retOffset;
|
sl@0
|
960 |
r=dispHand.Process(imgBase);
|
sl@0
|
961 |
|
sl@0
|
962 |
#ifdef __WINSCW__
|
sl@0
|
963 |
aTest(r==KErrNotSupported);
|
sl@0
|
964 |
#else
|
sl@0
|
965 |
aTest(r==KErrNone);
|
sl@0
|
966 |
#endif
|
sl@0
|
967 |
|
sl@0
|
968 |
User::After(1000000); // 1 sec
|
sl@0
|
969 |
}
|
sl@0
|
970 |
|
sl@0
|
971 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
972 |
aTest(r==KErrNone);
|
sl@0
|
973 |
|
sl@0
|
974 |
User::WaitForRequest(rs2);
|
sl@0
|
975 |
retId=rs2.Int();
|
sl@0
|
976 |
aTest(retId>=0);
|
sl@0
|
977 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
978 |
aTest.Printf(_L("Buffer1 offset: %d(%xH)\r\n"),retOffset,retOffset);
|
sl@0
|
979 |
aTest(retOffset>=0);
|
sl@0
|
980 |
|
sl@0
|
981 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
982 |
{
|
sl@0
|
983 |
// Display the image received for 1s
|
sl@0
|
984 |
imgBase=chunkImage.Base()+retOffset;
|
sl@0
|
985 |
r=dispHand.Process(imgBase);
|
sl@0
|
986 |
|
sl@0
|
987 |
#ifdef __WINSCW__
|
sl@0
|
988 |
aTest(r==KErrNotSupported);
|
sl@0
|
989 |
#else
|
sl@0
|
990 |
aTest(r==KErrNone);
|
sl@0
|
991 |
#endif
|
sl@0
|
992 |
|
sl@0
|
993 |
User::After(1000000); // 1 sec
|
sl@0
|
994 |
}
|
sl@0
|
995 |
|
sl@0
|
996 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
997 |
aTest(r==KErrNone);
|
sl@0
|
998 |
|
sl@0
|
999 |
aTest.Next(_L("Issue four more separate capture requests"));
|
sl@0
|
1000 |
for (TInt i=0 ; i<4 ; i++)
|
sl@0
|
1001 |
{
|
sl@0
|
1002 |
aCam.NotifyNewImage(rs1);
|
sl@0
|
1003 |
User::WaitForRequest(rs1);
|
sl@0
|
1004 |
retId=rs1.Int();
|
sl@0
|
1005 |
aTest(retId>=0);
|
sl@0
|
1006 |
aCam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
1007 |
aTest.Printf(_L("Buffer%d offset: %d(%xH)\r\n"),i,retOffset,retOffset);
|
sl@0
|
1008 |
aTest(retOffset>=0);
|
sl@0
|
1009 |
|
sl@0
|
1010 |
if (aPixelFormat.iPixelFormat!=EUidPixelFormatJPEG && aPixelFormat.iPixelFormat!=EUidPixelFormatSpeedTaggedJPEG)
|
sl@0
|
1011 |
{
|
sl@0
|
1012 |
// Display the image received for 1s
|
sl@0
|
1013 |
imgBase=chunkImage.Base()+retOffset;
|
sl@0
|
1014 |
r=dispHand.Process(imgBase);
|
sl@0
|
1015 |
|
sl@0
|
1016 |
#ifdef __WINSCW__
|
sl@0
|
1017 |
aTest(r==KErrNotSupported);
|
sl@0
|
1018 |
#else
|
sl@0
|
1019 |
aTest(r==KErrNone);
|
sl@0
|
1020 |
#endif
|
sl@0
|
1021 |
|
sl@0
|
1022 |
User::After(1000000); // 1 sec
|
sl@0
|
1023 |
}
|
sl@0
|
1024 |
}
|
sl@0
|
1025 |
|
sl@0
|
1026 |
r=aCam.ReleaseBuffer(retId);
|
sl@0
|
1027 |
aTest(r==KErrNone);
|
sl@0
|
1028 |
|
sl@0
|
1029 |
aTest.Next(_L("Stop the camera."));
|
sl@0
|
1030 |
r=aCam.Stop();
|
sl@0
|
1031 |
aTest(r==KErrNone);
|
sl@0
|
1032 |
|
sl@0
|
1033 |
aTest.Next(_L("Close the chunk"));
|
sl@0
|
1034 |
r=aCam.ChunkClose(ECamCaptureModeImage);
|
sl@0
|
1035 |
aTest(r==KErrNone);
|
sl@0
|
1036 |
}
|
sl@0
|
1037 |
|
sl@0
|
1038 |
LOCAL_C void DoCamCancelTests(RTest& aTest, TInt aCameraSensorIndex)
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
TInt bufferSize, r;
|
sl@0
|
1041 |
SDevCamFrameSize* frameSizes;
|
sl@0
|
1042 |
TCameraConfigV02Buf camConfBuf;
|
sl@0
|
1043 |
|
sl@0
|
1044 |
aTest.Next(_L("CAPTURE CANCEL TESTS"));
|
sl@0
|
1045 |
|
sl@0
|
1046 |
RDevCameraSc cam;
|
sl@0
|
1047 |
aTest.Next(_L("Open a channel on the camera driver"));
|
sl@0
|
1048 |
r=cam.Open(aCameraSensorIndex);
|
sl@0
|
1049 |
aTest(r==KErrNone);
|
sl@0
|
1050 |
|
sl@0
|
1051 |
TInt numBuffers=KNumVideoFramesToAllocate;
|
sl@0
|
1052 |
SDevCamPixelFormat* pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
|
sl@0
|
1053 |
|
sl@0
|
1054 |
// Test Image Capture, if supported
|
sl@0
|
1055 |
if (CameraCaps->iNumImagePixelFormats)
|
sl@0
|
1056 |
{
|
sl@0
|
1057 |
// If iNumImagePixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1058 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1059 |
frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1060 |
Test(frameSizes != NULL);
|
sl@0
|
1061 |
bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1062 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1063 |
r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1064 |
Test(r == KErrNone);
|
sl@0
|
1065 |
|
sl@0
|
1066 |
cam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
1067 |
|
sl@0
|
1068 |
camConfBuf().iFrameSize=frameSizes[0];
|
sl@0
|
1069 |
camConfBuf().iPixelFormat=*pixelFormat;
|
sl@0
|
1070 |
camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
|
sl@0
|
1071 |
|
sl@0
|
1072 |
// Set the camera configuration.
|
sl@0
|
1073 |
r=cam.SetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
1074 |
aTest(r==KErrNone);
|
sl@0
|
1075 |
cam.GetCamConfig(ECamCaptureModeImage, camConfBuf);
|
sl@0
|
1076 |
PrintCamConf(camConfBuf(), aTest);
|
sl@0
|
1077 |
|
sl@0
|
1078 |
// Create a chunk handle and trigger the buffer creation.
|
sl@0
|
1079 |
RChunk chunkImage;
|
sl@0
|
1080 |
aTest.Next(_L("Setup the config - creating a chunk for image capture"));
|
sl@0
|
1081 |
r=cam.SetBufConfigChunkCreate(ECamCaptureModeImage,numBuffers,chunkImage);
|
sl@0
|
1082 |
aTest(r==KErrNone);
|
sl@0
|
1083 |
|
sl@0
|
1084 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
1085 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
1086 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufImage(bufferConfig);
|
sl@0
|
1087 |
cam.GetBufferConfig(ECamCaptureModeImage, bufferConfigBufImage);
|
sl@0
|
1088 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
1089 |
|
sl@0
|
1090 |
// Set the current capture mode
|
sl@0
|
1091 |
r=cam.SetCaptureMode(ECamCaptureModeImage);
|
sl@0
|
1092 |
aTest(r==KErrNone);
|
sl@0
|
1093 |
|
sl@0
|
1094 |
aTest.Next(_L("Start the camera in image capture mode."));
|
sl@0
|
1095 |
r=cam.Start();
|
sl@0
|
1096 |
aTest(r==KErrNone);
|
sl@0
|
1097 |
|
sl@0
|
1098 |
TRequestStatus rs[KNumVideoFramesToCapture];
|
sl@0
|
1099 |
TInt retId, retOffset;
|
sl@0
|
1100 |
|
sl@0
|
1101 |
aTest.Next(_L("Issue a request and then cancel it"));
|
sl@0
|
1102 |
cam.NotifyNewImage(rs[0]);
|
sl@0
|
1103 |
cam.NotifyNewImageCancel();
|
sl@0
|
1104 |
User::WaitForRequest(rs[0]);
|
sl@0
|
1105 |
retId=rs[0].Int();
|
sl@0
|
1106 |
aTest(retId==KErrCancel || retId>=0);
|
sl@0
|
1107 |
if (retId>=0)
|
sl@0
|
1108 |
{
|
sl@0
|
1109 |
cam.BufferIdToOffset(ECamCaptureModeImage,retId,retOffset);
|
sl@0
|
1110 |
aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
|
sl@0
|
1111 |
aTest(retOffset>=0);
|
sl@0
|
1112 |
cam.ReleaseBuffer(retId);
|
sl@0
|
1113 |
}
|
sl@0
|
1114 |
|
sl@0
|
1115 |
aTest.Next(_L("Stop the camera."));
|
sl@0
|
1116 |
r=cam.Stop();
|
sl@0
|
1117 |
aTest(r==KErrNone);
|
sl@0
|
1118 |
|
sl@0
|
1119 |
aTest.Next(_L("Close the Image chunk"));
|
sl@0
|
1120 |
chunkImage.Close();
|
sl@0
|
1121 |
|
sl@0
|
1122 |
delete [] frameSizes;
|
sl@0
|
1123 |
}
|
sl@0
|
1124 |
|
sl@0
|
1125 |
// Skip past the image pixel formats
|
sl@0
|
1126 |
pixelFormat += CameraCaps->iNumImagePixelFormats;
|
sl@0
|
1127 |
|
sl@0
|
1128 |
// Test Video Capture, if supported
|
sl@0
|
1129 |
if (CameraCaps->iNumVideoPixelFormats)
|
sl@0
|
1130 |
{
|
sl@0
|
1131 |
// If iNumVideoPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1132 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1133 |
frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1134 |
Test(frameSizes != NULL);
|
sl@0
|
1135 |
bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1136 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1137 |
r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1138 |
Test(r == KErrNone);
|
sl@0
|
1139 |
|
sl@0
|
1140 |
cam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
1141 |
|
sl@0
|
1142 |
camConfBuf().iFrameSize=frameSizes[0];
|
sl@0
|
1143 |
camConfBuf().iPixelFormat=*pixelFormat;
|
sl@0
|
1144 |
camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
|
sl@0
|
1145 |
|
sl@0
|
1146 |
// Set the camera configuration.
|
sl@0
|
1147 |
r=cam.SetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
1148 |
aTest(r==KErrNone);
|
sl@0
|
1149 |
cam.GetCamConfig(ECamCaptureModeVideo, camConfBuf);
|
sl@0
|
1150 |
PrintCamConf(camConfBuf(), aTest);
|
sl@0
|
1151 |
|
sl@0
|
1152 |
// Create a chunk handle and trigger the buffer creation.
|
sl@0
|
1153 |
RChunk chunkVideo;
|
sl@0
|
1154 |
aTest.Next(_L("Setup the config - creating a chunk for video capture"));
|
sl@0
|
1155 |
r=cam.SetBufConfigChunkCreate(ECamCaptureModeVideo,numBuffers,chunkVideo);
|
sl@0
|
1156 |
aTest(r==KErrNone);
|
sl@0
|
1157 |
|
sl@0
|
1158 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
1159 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
1160 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufVideo(bufferConfig);
|
sl@0
|
1161 |
cam.GetBufferConfig(ECamCaptureModeVideo, bufferConfigBufVideo);
|
sl@0
|
1162 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
1163 |
|
sl@0
|
1164 |
// Set the current capture mode
|
sl@0
|
1165 |
r=cam.SetCaptureMode(ECamCaptureModeVideo);
|
sl@0
|
1166 |
aTest(r==KErrNone);
|
sl@0
|
1167 |
|
sl@0
|
1168 |
aTest.Next(_L("Start the camera in video mode"));
|
sl@0
|
1169 |
r=cam.Start();
|
sl@0
|
1170 |
aTest(r==KErrNone);
|
sl@0
|
1171 |
|
sl@0
|
1172 |
aTest.Next(_L("Issue capture requests and globally cancel them all"));
|
sl@0
|
1173 |
aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
|
sl@0
|
1174 |
TRequestStatus rs[KNumVideoFramesToCapture];
|
sl@0
|
1175 |
TInt i;
|
sl@0
|
1176 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
1177 |
cam.NotifyNewImage(rs[i]);
|
sl@0
|
1178 |
|
sl@0
|
1179 |
cam.NotifyNewImageCancel();
|
sl@0
|
1180 |
|
sl@0
|
1181 |
TInt retOffset = -2;
|
sl@0
|
1182 |
TInt retId = -2;
|
sl@0
|
1183 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
1184 |
{
|
sl@0
|
1185 |
User::WaitForRequest(rs[i]);
|
sl@0
|
1186 |
retId=rs[i].Int();
|
sl@0
|
1187 |
aTest(retId==KErrCancel || retId>=0);
|
sl@0
|
1188 |
if (retId>=0)
|
sl@0
|
1189 |
{
|
sl@0
|
1190 |
cam.BufferIdToOffset(ECamCaptureModeVideo,retId,retOffset);
|
sl@0
|
1191 |
aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
|
sl@0
|
1192 |
aTest(retOffset>=0);
|
sl@0
|
1193 |
cam.ReleaseBuffer(retId);
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
}
|
sl@0
|
1196 |
|
sl@0
|
1197 |
aTest.Next(_L("Issue capture requests and individually cancel them all"));
|
sl@0
|
1198 |
aTest.Printf(_L("Request %d frames\r\n"),KNumVideoFramesToCapture);
|
sl@0
|
1199 |
|
sl@0
|
1200 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
1201 |
cam.NotifyNewImage(rs[i]);
|
sl@0
|
1202 |
|
sl@0
|
1203 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
1204 |
cam.NotifyNewImageCancel(rs[i]);
|
sl@0
|
1205 |
|
sl@0
|
1206 |
for (i=0 ; i<KNumVideoFramesToCapture; i++)
|
sl@0
|
1207 |
{
|
sl@0
|
1208 |
User::WaitForRequest(rs[i]);
|
sl@0
|
1209 |
retId=rs[i].Int();
|
sl@0
|
1210 |
aTest(retId==KErrCancel || retId>=0);
|
sl@0
|
1211 |
if (retId>=0)
|
sl@0
|
1212 |
{
|
sl@0
|
1213 |
cam.BufferIdToOffset(ECamCaptureModeVideo,retId,retOffset);
|
sl@0
|
1214 |
aTest.Printf(_L("Buffer%d : %d\r\n"),retId,retOffset);
|
sl@0
|
1215 |
aTest(retOffset>=0);
|
sl@0
|
1216 |
cam.ReleaseBuffer(retId);
|
sl@0
|
1217 |
}
|
sl@0
|
1218 |
}
|
sl@0
|
1219 |
|
sl@0
|
1220 |
aTest.Next(_L("Stop the camera."));
|
sl@0
|
1221 |
r=cam.Stop();
|
sl@0
|
1222 |
aTest(r==KErrNone);
|
sl@0
|
1223 |
|
sl@0
|
1224 |
aTest.Next(_L("Close the Video chunk"));
|
sl@0
|
1225 |
chunkVideo.Close();
|
sl@0
|
1226 |
|
sl@0
|
1227 |
delete [] frameSizes;
|
sl@0
|
1228 |
}
|
sl@0
|
1229 |
|
sl@0
|
1230 |
// Skip past the video pixel formats
|
sl@0
|
1231 |
pixelFormat += CameraCaps->iNumVideoPixelFormats;
|
sl@0
|
1232 |
|
sl@0
|
1233 |
// Test Viewfinder Capture, if supported
|
sl@0
|
1234 |
if (CameraCaps->iNumViewFinderPixelFormats)
|
sl@0
|
1235 |
{
|
sl@0
|
1236 |
// If iNumViewFinderPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1237 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1238 |
frameSizes = new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1239 |
Test(frameSizes != NULL);
|
sl@0
|
1240 |
bufferSize = (sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1241 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1242 |
r = cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1243 |
Test(r == KErrNone);
|
sl@0
|
1244 |
|
sl@0
|
1245 |
cam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
|
sl@0
|
1246 |
|
sl@0
|
1247 |
camConfBuf().iFrameSize=frameSizes[0];
|
sl@0
|
1248 |
camConfBuf().iPixelFormat=*pixelFormat;
|
sl@0
|
1249 |
camConfBuf().iFrameRate=frameSizes[0].iMaxFrameRate;
|
sl@0
|
1250 |
|
sl@0
|
1251 |
// Set the camera configuration.
|
sl@0
|
1252 |
r=cam.SetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
|
sl@0
|
1253 |
aTest(r==KErrNone);
|
sl@0
|
1254 |
cam.GetCamConfig(ECamCaptureModeViewFinder, camConfBuf);
|
sl@0
|
1255 |
PrintCamConf(camConfBuf(), aTest);
|
sl@0
|
1256 |
|
sl@0
|
1257 |
// Create a chunk handle and trigger the buffer creation.
|
sl@0
|
1258 |
RChunk chunkViewFinder;
|
sl@0
|
1259 |
aTest.Next(_L("Setup the config - creating a chunk for viewfinder capture"));
|
sl@0
|
1260 |
r=cam.SetBufConfigChunkCreate(ECamCaptureModeViewFinder,numBuffers,chunkViewFinder);
|
sl@0
|
1261 |
aTest(r==KErrNone);
|
sl@0
|
1262 |
|
sl@0
|
1263 |
aTest.Next(_L("Read and display the resulting buffer config"));
|
sl@0
|
1264 |
TMmSharedChunkBufConfig bufferConfig;
|
sl@0
|
1265 |
TPckg<TMmSharedChunkBufConfig> bufferConfigBufViewFinder(bufferConfig);
|
sl@0
|
1266 |
cam.GetBufferConfig(ECamCaptureModeViewFinder, bufferConfigBufViewFinder);
|
sl@0
|
1267 |
PrintBufferConf(bufferConfig,aTest);
|
sl@0
|
1268 |
|
sl@0
|
1269 |
aTest.Next(_L("Close the Viewfinder chunk"));
|
sl@0
|
1270 |
chunkViewFinder.Close();
|
sl@0
|
1271 |
|
sl@0
|
1272 |
delete [] frameSizes;
|
sl@0
|
1273 |
}
|
sl@0
|
1274 |
|
sl@0
|
1275 |
aTest.Next(_L("Close the drivers"));
|
sl@0
|
1276 |
cam.Close();
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
|
sl@0
|
1279 |
void CameraTests(TInt aCameraSensorIndex)
|
sl@0
|
1280 |
{
|
sl@0
|
1281 |
TUint index, size;
|
sl@0
|
1282 |
Test.Printf(_L("Testing unit number: %d\r\n"),aCameraSensorIndex);
|
sl@0
|
1283 |
|
sl@0
|
1284 |
// Perform some basic opening and multithreaded tests. We don't want just in time debugging during
|
sl@0
|
1285 |
// these tests
|
sl@0
|
1286 |
TBool justInTime=User::JustInTime();
|
sl@0
|
1287 |
User::SetJustInTime(EFalse);
|
sl@0
|
1288 |
DoCamOpenCapTests(Test,aCameraSensorIndex);
|
sl@0
|
1289 |
User::SetJustInTime(justInTime);
|
sl@0
|
1290 |
|
sl@0
|
1291 |
// Test request handling
|
sl@0
|
1292 |
DoCamCancelTests(Test, aCameraSensorIndex);
|
sl@0
|
1293 |
|
sl@0
|
1294 |
// Re-open the camera driver for use below and to ensure that it can deal with being re-opened (it
|
sl@0
|
1295 |
// has already been opened and closed by DoCamOpenCapTests())
|
sl@0
|
1296 |
RDevCameraSc cam;
|
sl@0
|
1297 |
Test.Next(_L("Open a channel on the camera driver"));
|
sl@0
|
1298 |
TInt r=cam.Open(aCameraSensorIndex);
|
sl@0
|
1299 |
Test(r==KErrNone);
|
sl@0
|
1300 |
|
sl@0
|
1301 |
// Test Dynamic Settings, e.g. Brightness, Contrast, etc.
|
sl@0
|
1302 |
DoCamDynamicSettingsTests(cam, Test);
|
sl@0
|
1303 |
|
sl@0
|
1304 |
// Go through all supported image, video and viewfinder pixel formats and perform configuration
|
sl@0
|
1305 |
// and capture tests on them all, for all supported frame sizes and frame rates
|
sl@0
|
1306 |
TInt bufferSize;
|
sl@0
|
1307 |
SDevCamFrameSize* frameSizes;
|
sl@0
|
1308 |
TBool imageConfigTestsDone=EFalse, videoConfigTestsDone=EFalse, viewFinderConfigTestsDone=EFalse;
|
sl@0
|
1309 |
SDevCamPixelFormat* pixelFormat = (SDevCamPixelFormat*) (CameraCaps + 1);
|
sl@0
|
1310 |
|
sl@0
|
1311 |
for (index = 0; index < CameraCaps->iNumImagePixelFormats; ++index)
|
sl@0
|
1312 |
{
|
sl@0
|
1313 |
// If iNumImagePixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1314 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1315 |
Test.Printf(_L("Image pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
|
sl@0
|
1316 |
frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1317 |
Test(frameSizes!=NULL);
|
sl@0
|
1318 |
bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1319 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1320 |
r = cam.FrameSizeCaps(ECamCaptureModeImage, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1321 |
Test(r == KErrNone);
|
sl@0
|
1322 |
|
sl@0
|
1323 |
// Test camera configuration for image capture. This is only done once for the sake of
|
sl@0
|
1324 |
// test expediency
|
sl@0
|
1325 |
if (!imageConfigTestsDone)
|
sl@0
|
1326 |
{
|
sl@0
|
1327 |
imageConfigTestsDone = ETrue;
|
sl@0
|
1328 |
DoCamConfigTests(cam, Test, ECamCaptureModeImage, *pixelFormat, frameSizes[0]);
|
sl@0
|
1329 |
}
|
sl@0
|
1330 |
|
sl@0
|
1331 |
// Test image capture mode
|
sl@0
|
1332 |
for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
|
sl@0
|
1333 |
{
|
sl@0
|
1334 |
DoCamImageCaptureTests(cam, Test, aCameraSensorIndex, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
|
sl@0
|
1335 |
}
|
sl@0
|
1336 |
|
sl@0
|
1337 |
// Test buffer offset
|
sl@0
|
1338 |
for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
DoCamBufferOffsetTests(cam, Test, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
|
sl@0
|
1341 |
}
|
sl@0
|
1342 |
|
sl@0
|
1343 |
delete [] frameSizes;
|
sl@0
|
1344 |
++pixelFormat;
|
sl@0
|
1345 |
}
|
sl@0
|
1346 |
|
sl@0
|
1347 |
for (index = 0; index < CameraCaps->iNumVideoPixelFormats; ++index)
|
sl@0
|
1348 |
{
|
sl@0
|
1349 |
// If iNumVideoPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1350 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1351 |
Test.Printf(_L("Video pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
|
sl@0
|
1352 |
frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1353 |
Test(frameSizes!=NULL);
|
sl@0
|
1354 |
bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1355 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1356 |
r = cam.FrameSizeCaps(ECamCaptureModeVideo, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1357 |
Test(r == KErrNone);
|
sl@0
|
1358 |
|
sl@0
|
1359 |
// Test camera configuration for video capture. This is only done once for the sake of
|
sl@0
|
1360 |
// test expediency
|
sl@0
|
1361 |
if (!videoConfigTestsDone)
|
sl@0
|
1362 |
{
|
sl@0
|
1363 |
videoConfigTestsDone=ETrue;
|
sl@0
|
1364 |
DoCamConfigTests(cam, Test, ECamCaptureModeVideo, *pixelFormat, frameSizes[0]);
|
sl@0
|
1365 |
}
|
sl@0
|
1366 |
|
sl@0
|
1367 |
// Test video capture mode
|
sl@0
|
1368 |
for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
|
sl@0
|
1369 |
{
|
sl@0
|
1370 |
DoCamVideoCaptureTests(cam, Test, ECamCaptureModeVideo, *pixelFormat,frameSizes[size], frameSizes[size].iMaxFrameRate);
|
sl@0
|
1371 |
}
|
sl@0
|
1372 |
delete [] frameSizes;
|
sl@0
|
1373 |
++pixelFormat;
|
sl@0
|
1374 |
}
|
sl@0
|
1375 |
|
sl@0
|
1376 |
for (index = 0; index < CameraCaps->iNumViewFinderPixelFormats; ++index)
|
sl@0
|
1377 |
{
|
sl@0
|
1378 |
// If iNumViewFinderPixelFormats is > 0 then the matching iNumFrameSizes should also be > 0
|
sl@0
|
1379 |
Test(pixelFormat->iNumFrameSizes > 0);
|
sl@0
|
1380 |
Test.Printf(_L("Viewfinder pixel format %x, number of frame sizes = %d\n"), pixelFormat->iPixelFormat, pixelFormat->iNumFrameSizes);
|
sl@0
|
1381 |
frameSizes=new SDevCamFrameSize[pixelFormat->iNumFrameSizes];
|
sl@0
|
1382 |
Test(frameSizes!=NULL);
|
sl@0
|
1383 |
bufferSize=(sizeof(SDevCamFrameSize) * pixelFormat->iNumFrameSizes);
|
sl@0
|
1384 |
TPtr8 frameSizesBuf((TUint8*) frameSizes, bufferSize, bufferSize);
|
sl@0
|
1385 |
r = cam.FrameSizeCaps(ECamCaptureModeViewFinder, pixelFormat->iPixelFormat, frameSizesBuf);
|
sl@0
|
1386 |
Test(r == KErrNone);
|
sl@0
|
1387 |
|
sl@0
|
1388 |
// Test camera configuration for view finder capture. This is only done once for the sake of
|
sl@0
|
1389 |
// test expediency
|
sl@0
|
1390 |
if (!viewFinderConfigTestsDone)
|
sl@0
|
1391 |
{
|
sl@0
|
1392 |
viewFinderConfigTestsDone=ETrue;
|
sl@0
|
1393 |
DoCamConfigTests(cam, Test, ECamCaptureModeViewFinder, *pixelFormat, frameSizes[0]);
|
sl@0
|
1394 |
}
|
sl@0
|
1395 |
|
sl@0
|
1396 |
// Test view finder capture mode
|
sl@0
|
1397 |
for (size = 0; size < pixelFormat->iNumFrameSizes; ++size)
|
sl@0
|
1398 |
{
|
sl@0
|
1399 |
DoCamVideoCaptureTests(cam, Test, ECamCaptureModeViewFinder, *pixelFormat, frameSizes[size], frameSizes[size].iMaxFrameRate);
|
sl@0
|
1400 |
}
|
sl@0
|
1401 |
delete [] frameSizes;
|
sl@0
|
1402 |
++pixelFormat;
|
sl@0
|
1403 |
}
|
sl@0
|
1404 |
cam.Close();
|
sl@0
|
1405 |
|
sl@0
|
1406 |
// And free the global capabilities buffer that was allocated in DoCamOpenCapTests()
|
sl@0
|
1407 |
User::Free(CapsBufPtr);
|
sl@0
|
1408 |
}
|
sl@0
|
1409 |
|
sl@0
|
1410 |
GLDEF_C TInt E32Main()
|
sl@0
|
1411 |
{
|
sl@0
|
1412 |
__UHEAP_MARK;
|
sl@0
|
1413 |
|
sl@0
|
1414 |
Test.Title();
|
sl@0
|
1415 |
Test.Start(_L("Camera module API test"));
|
sl@0
|
1416 |
|
sl@0
|
1417 |
Test.Next(_L("Loading CAMERA PDD"));
|
sl@0
|
1418 |
TInt r=User::LoadPhysicalDevice(KCamPddFileName);
|
sl@0
|
1419 |
Test.Printf(_L("Returned %d\r\n"),r);
|
sl@0
|
1420 |
|
sl@0
|
1421 |
if (r==KErrNotFound)
|
sl@0
|
1422 |
{
|
sl@0
|
1423 |
Test.Printf(_L("Shared chunk camera driver not supported - test skipped\r\n"));
|
sl@0
|
1424 |
Test.End();
|
sl@0
|
1425 |
Test.Close();
|
sl@0
|
1426 |
__UHEAP_MARKEND;
|
sl@0
|
1427 |
return(KErrNone);
|
sl@0
|
1428 |
}
|
sl@0
|
1429 |
|
sl@0
|
1430 |
Test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
1431 |
|
sl@0
|
1432 |
Test.Next(_L("Loading CAMERA LDD"));
|
sl@0
|
1433 |
r=User::LoadLogicalDevice(KCamLddFileName);
|
sl@0
|
1434 |
Test.Printf(_L("Returned %d\r\n"),r);
|
sl@0
|
1435 |
Test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
1436 |
|
sl@0
|
1437 |
Test.Next(_L("Loading D_MMCSC LDD"));
|
sl@0
|
1438 |
r=User::LoadLogicalDevice(KTstLddFileName);
|
sl@0
|
1439 |
Test.Printf(_L("Returned %d\r\n"),r);
|
sl@0
|
1440 |
Test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
1441 |
|
sl@0
|
1442 |
__KHEAP_MARK;
|
sl@0
|
1443 |
|
sl@0
|
1444 |
if (User::CommandLineLength()>0)
|
sl@0
|
1445 |
{
|
sl@0
|
1446 |
TBuf<0x100> cmd;
|
sl@0
|
1447 |
TInt moduleIndex = KUnit0;
|
sl@0
|
1448 |
User::CommandLine(cmd);
|
sl@0
|
1449 |
Test(cmd.Length()>0);
|
sl@0
|
1450 |
if (cmd[0]>='0' && cmd[0]<='9')
|
sl@0
|
1451 |
moduleIndex=(TInt)(cmd[0]-'0');
|
sl@0
|
1452 |
CameraTests(moduleIndex);
|
sl@0
|
1453 |
}
|
sl@0
|
1454 |
else // If no command line arguments are passed we perform tests on the module 0 and 1
|
sl@0
|
1455 |
{
|
sl@0
|
1456 |
CameraTests(0);
|
sl@0
|
1457 |
}
|
sl@0
|
1458 |
|
sl@0
|
1459 |
__KHEAP_MARKEND;
|
sl@0
|
1460 |
|
sl@0
|
1461 |
// Free the PDDs and LDDs
|
sl@0
|
1462 |
Test.Next(_L("Freeing ECAMERASC LDD"));
|
sl@0
|
1463 |
r=User::FreeLogicalDevice(KDevCameraScName);
|
sl@0
|
1464 |
Test(r==KErrNone);
|
sl@0
|
1465 |
|
sl@0
|
1466 |
Test.Next(_L("Freeing CAMERASC PDD"));
|
sl@0
|
1467 |
TFindPhysicalDevice fDr;
|
sl@0
|
1468 |
TFullName drivName;
|
sl@0
|
1469 |
TName searchName;
|
sl@0
|
1470 |
searchName.Append(KDevCameraScName);
|
sl@0
|
1471 |
searchName.Append(KCamFreePddExtension);
|
sl@0
|
1472 |
fDr.Find(searchName);
|
sl@0
|
1473 |
r=fDr.Next(drivName);
|
sl@0
|
1474 |
Test(r==KErrNone);
|
sl@0
|
1475 |
r=User::FreePhysicalDevice(drivName);
|
sl@0
|
1476 |
Test(r==KErrNone);
|
sl@0
|
1477 |
|
sl@0
|
1478 |
Test.Next(_L("Freeing D_MMCSC LDD"));
|
sl@0
|
1479 |
r=User::FreeLogicalDevice(KDevMmCScName);
|
sl@0
|
1480 |
Test(r==KErrNone);
|
sl@0
|
1481 |
|
sl@0
|
1482 |
Test.End();
|
sl@0
|
1483 |
Test.Close();
|
sl@0
|
1484 |
|
sl@0
|
1485 |
__UHEAP_MARKEND;
|
sl@0
|
1486 |
return(KErrNone);
|
sl@0
|
1487 |
}
|