28 |
28 |
29 |
29 |
30 _LIT(KCameraDriverPddName, "webcamera.pdd"); |
30 _LIT(KCameraDriverPddName, "webcamera.pdd"); |
31 _LIT(KCameraDriverLddName, "ewebcamera.ldd"); |
31 _LIT(KCameraDriverLddName, "ewebcamera.ldd"); |
32 |
32 |
33 const TInt KCaptureWidth = 160; // Capture image width |
33 const TInt KCaptureWidth = 640; // Capture image width |
34 const TInt KCaptureHeight = 120; // Capture image height |
34 const TInt KCaptureHeight = 480; // Capture image height |
|
35 |
35 const TInt KCaptureLineBytes = KCaptureWidth * 3; // bytes of one line |
36 const TInt KCaptureLineBytes = KCaptureWidth * 3; // bytes of one line |
36 |
37 |
37 // |
38 // |
38 // CWebCamera class |
39 // CWebCamera class |
39 // |
40 // |
40 |
41 |
41 CWebCamera::CWebCamera(): |
42 CWebCamera::CWebCamera(): |
42 iCaptureBufPtr(NULL, 0) |
43 iCaptureBufPtr(NULL, 0) |
43 { |
44 { |
|
45 |
44 iInfo.iHardwareVersion.iMajor = 0; |
46 iInfo.iHardwareVersion.iMajor = 0; |
45 iInfo.iHardwareVersion.iMinor = 0; |
47 iInfo.iHardwareVersion.iMinor = 0; |
46 iInfo.iHardwareVersion.iBuild = 0; |
48 iInfo.iHardwareVersion.iBuild = 0; |
47 iInfo.iSoftwareVersion.iMajor = 0; |
49 iInfo.iSoftwareVersion.iMajor = 0; |
48 iInfo.iSoftwareVersion.iMinor = 0; |
50 iInfo.iSoftwareVersion.iMinor = 0; |
106 return self; |
110 return self; |
107 } |
111 } |
108 |
112 |
109 void CWebCamera::ConstructL() |
113 void CWebCamera::ConstructL() |
110 { |
114 { |
111 RDebug::Print(_L("CWebCamera::ConstructL_S")); |
|
112 // Open drivers. |
115 // Open drivers. |
113 TInt err; |
116 TInt err; |
114 |
117 |
115 err = User::LoadPhysicalDevice(KCameraDriverPddName); |
118 err = User::LoadPhysicalDevice(KCameraDriverPddName); |
116 RDebug::Print(_L("CWebCamera::ConstructL LoadPhysicalDevice[%d]"), err); |
|
117 |
119 |
118 if (err != KErrNone && err != KErrAlreadyExists) |
120 if (err != KErrNone && err != KErrAlreadyExists) |
119 { |
121 { |
120 User::Leave(err); |
122 User::Leave(err); |
121 } |
123 } |
122 |
124 |
123 err = User::LoadLogicalDevice(KCameraDriverLddName); |
125 err = User::LoadLogicalDevice(KCameraDriverLddName); |
124 RDebug::Print(_L("CWebCamera::ConstructL LoadLogicalDevice[%d]"), err); |
|
125 |
126 |
126 if (err != KErrNone && err != KErrAlreadyExists) |
127 if (err != KErrNone && err != KErrAlreadyExists) |
127 { |
128 { |
128 User::Leave(err); |
129 User::Leave(err); |
129 } |
130 } |
130 |
131 |
131 RDebug::Print(_L("CWebCamera::ConstructL iDriver.Open()")); |
|
132 iDriver.Open(); |
132 iDriver.Open(); |
133 |
133 |
134 iActive = CWebCameraActive::NewL(this, iDriver); |
134 iActive = CWebCameraActive::NewL(this, iDriver); |
135 iVfActive = CWebCameraVfActive::NewL(this, iDriver); |
135 iVfActive = CWebCameraVfActive::NewL(this, iDriver); |
136 |
136 |
137 User::LeaveIfError(iImageSizes.Append(TSize(640, 480))); // VGA |
137 User::LeaveIfError(iImageSizes.Append(TSize(640, 480))); // VGA |
138 User::LeaveIfError(iImageSizes.Append(TSize(160, 120))); // QQVGA |
138 User::LeaveIfError(iImageSizes.Append(TSize(160, 120))); // QQVGA |
139 iInfo.iNumImageSizesSupported = iImageSizes.Count(); |
139 iInfo.iNumImageSizesSupported = iImageSizes.Count(); |
140 |
140 |
141 RDebug::Print(_L("CWebCamera::ConstructL_E")); |
141 // Open chunk |
|
142 err = iDriver.OpenSharedChunks(iChunk, iChunkInfo); |
|
143 if (err != KErrNone) |
|
144 { |
|
145 User::Leave(err); |
|
146 } |
|
147 iChuckBase=iChunk.Base(); |
142 } |
148 } |
143 |
149 |
144 /** |
150 /** |
145 from CCameraPlugin |
151 from CCameraPlugin |
146 |
152 |
175 |
181 |
176 Duplicates the original camera object for use by, for example, multimedia systems. |
182 Duplicates the original camera object for use by, for example, multimedia systems. |
177 |
183 |
178 May leave with KErrNoMemory or KErrNotFound if aCameraHandle is not valid. |
184 May leave with KErrNoMemory or KErrNotFound if aCameraHandle is not valid. |
179 |
185 |
180 @param aObserver |
186 @param aObserver Reference to an observer. |
181 Reference to an observer. |
|
182 @param aCameraHandle Handle of an existing camera object. |
187 @param aCameraHandle Handle of an existing camera object. |
183 |
|
184 @return Duplicate of the original camera object. |
188 @return Duplicate of the original camera object. |
185 */ |
189 */ |
186 void CWebCamera::Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle) |
190 void CWebCamera::Construct2DupL(MCameraObserver& aObserver,TInt aCameraHandle) |
187 { |
191 { |
188 iObserver = &aObserver; |
192 iObserver = &aObserver; |
204 Index from 0 to CamerasAvailable()-1 inclusive specifying the |
208 Index from 0 to CamerasAvailable()-1 inclusive specifying the |
205 camera device to use. |
209 camera device to use. |
206 @param aPriority |
210 @param aPriority |
207 Value from -100 to 100 indicating relative priority of client to |
211 Value from -100 to 100 indicating relative priority of client to |
208 use camera. |
212 use camera. |
209 |
|
210 @return Pointer to a fully constructed CCamera object. Ownership is passed |
213 @return Pointer to a fully constructed CCamera object. Ownership is passed |
211 to the caller. |
214 to the caller. |
212 |
|
213 @leave May leave with KErrNoMemory or KErrNotSupported if aCameraIndex is |
215 @leave May leave with KErrNoMemory or KErrNotSupported if aCameraIndex is |
214 out of range. |
216 out of range. |
215 */ |
217 */ |
216 void CWebCamera::Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority) |
218 void CWebCamera::Construct2L(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority) |
217 { |
219 { |
362 Sets the digital zoom factor. |
357 Sets the digital zoom factor. |
363 |
358 |
364 This must be in the range of 0 to TCameraInfo::iMaxDigitalZoom inclusive. |
359 This must be in the range of 0 to TCameraInfo::iMaxDigitalZoom inclusive. |
365 |
360 |
366 May leave with KErrNotSupported if the zoom factor is out of range. |
361 May leave with KErrNotSupported if the zoom factor is out of range. |
367 |
|
368 @param aDigitalZoomFactor |
362 @param aDigitalZoomFactor |
369 The required digital zoom factor. |
363 The required digital zoom factor. |
370 */ |
364 */ |
371 void CWebCamera::SetDigitalZoomFactorL(TInt /*aDigitalZoomFactor = 0*/) |
365 void CWebCamera::SetDigitalZoomFactorL(TInt /*aDigitalZoomFactor = 0*/) |
372 { |
366 { |
442 |
436 |
443 /** |
437 /** |
444 from CCamera |
438 from CCamera |
445 |
439 |
446 Sets the flash mode. |
440 Sets the flash mode. |
447 |
|
448 No effect if this is not supported, see TCameraInfo::iFlashModesSupported. |
441 No effect if this is not supported, see TCameraInfo::iFlashModesSupported. |
449 |
|
450 May leave with KErrNotSupported if the specified flash mode is invalid. |
442 May leave with KErrNotSupported if the specified flash mode is invalid. |
451 |
|
452 @param aFlash |
443 @param aFlash |
453 The required flash mode. |
444 The required flash mode. |
454 */ |
445 */ |
455 void CWebCamera::SetFlashL(TFlash /*aFlash = EFlashNone*/) |
446 void CWebCamera::SetFlashL(TFlash /*aFlash = EFlashNone*/) |
456 { |
447 { |
458 |
449 |
459 /** |
450 /** |
460 from CCamera |
451 from CCamera |
461 |
452 |
462 Gets the currently set flash mode. |
453 Gets the currently set flash mode. |
463 |
|
464 @return The currently set flash mode. |
454 @return The currently set flash mode. |
465 @note if CCamera::New2L() or CCamera::NewDuplicate2L() is not used to create CCamera object, it is assumed that |
455 @note if CCamera::New2L() or CCamera::NewDuplicate2L() is not used to create CCamera object, it is assumed that |
466 application is not prepared to receive extra added enum values (unrecognised). So, any extra enum value(unrecognised) |
456 application is not prepared to receive extra added enum values (unrecognised). So, any extra enum value(unrecognised) |
467 (set in the ECAM implementation because of sharing clients) should not be returned from the ECAM implementation. |
457 (set in the ECAM implementation because of sharing clients) should not be returned from the ECAM implementation. |
468 To receive extra added enum values, application should rather use CCamera::New2L() or CCamera::NewDuplicate2L() |
458 To receive extra added enum values, application should rather use CCamera::New2L() or CCamera::NewDuplicate2L() |
571 |
561 |
572 @see CCamera::CCameraV2DirectViewFinder |
562 @see CCamera::CCameraV2DirectViewFinder |
573 */ |
563 */ |
574 void CWebCamera::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect) |
564 void CWebCamera::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect) |
575 { |
565 { |
576 RDebug::Print(_L("CWebCamera::StartViewFinderDirectL")); |
|
577 TRect emptyRect; |
566 TRect emptyRect; |
578 StartViewFinderDirectL(aWs, aScreenDevice, aWindow, aScreenRect, emptyRect); |
567 StartViewFinderDirectL(aWs, aScreenDevice, aWindow, aScreenRect, emptyRect); |
579 } |
568 } |
580 |
569 |
581 /** |
570 /** |
608 |
597 |
609 @see CCamera::CCameraClientViewFinder |
598 @see CCamera::CCameraClientViewFinder |
610 */ |
599 */ |
611 void CWebCamera::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect, TRect& aClipRect) |
600 void CWebCamera::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect, TRect& aClipRect) |
612 { |
601 { |
613 RDebug::Print(_L("CWebCamera::StartViewFinderDirectL'")); |
602 iVfActive->StartViewFinderDirectL(aWs, aScreenDevice, aWindow, aScreenRect, aClipRect, iChuckBase, iChunkRemSize); |
614 iVfActive->StartViewFinderDirectL(aWs, aScreenDevice, aWindow, aScreenRect, aClipRect); |
|
615 } |
603 } |
616 |
604 |
617 /** |
605 /** |
618 from CCamera |
606 from CCamera |
619 |
607 |
731 |
719 |
732 Queries whether the view finder is active. |
720 Queries whether the view finder is active. |
733 |
721 |
734 @return ETrue if the view finder is active. EFalse if the view finder is not |
722 @return ETrue if the view finder is active. EFalse if the view finder is not |
735 active. |
723 active. |
736 |
|
737 @note This method is assumed to be meant for default display only. KECamDefaultViewFinderHandle should be used to |
724 @note This method is assumed to be meant for default display only. KECamDefaultViewFinderHandle should be used to |
738 refer viewfinders started using CCamera methods. |
725 refer viewfinders started using CCamera methods. |
739 |
|
740 @see CCamera::CCameraV2DirectViewFinder |
726 @see CCamera::CCameraV2DirectViewFinder |
741 @see CCamera::CCameraClientViewFinder |
727 @see CCamera::CCameraClientViewFinder |
742 */ |
728 */ |
743 TBool CWebCamera::ViewFinderActive() const |
729 TBool CWebCamera::ViewFinderActive() const |
744 { |
730 { |
753 Used to switch between what the camera sees and what you would see if the |
739 Used to switch between what the camera sees and what you would see if the |
754 device were a mirror. |
740 device were a mirror. |
755 |
741 |
756 @param aMirror |
742 @param aMirror |
757 ETrue to set mirroring on, EFalse to set mirroring off. |
743 ETrue to set mirroring on, EFalse to set mirroring off. |
758 |
|
759 @leave KErrNotSupported. |
744 @leave KErrNotSupported. |
760 |
745 |
761 @note This method is assumed to be meant for default display only. KECamDefaultViewFinderHandle should be used to |
746 @note This method is assumed to be meant for default display only. KECamDefaultViewFinderHandle should be used to |
762 refer viewfinders started using CCamera methods. |
747 refer viewfinders started using CCamera methods. |
763 |
748 |
870 |
855 |
871 iCaptureBuf = HBufC8::NewL(KMaxBufSize); |
856 iCaptureBuf = HBufC8::NewL(KMaxBufSize); |
872 iCaptureBufPtr.Set(iCaptureBuf->Des()); |
857 iCaptureBufPtr.Set(iCaptureBuf->Des()); |
873 iCaptureBufPtr.SetLength(0); |
858 iCaptureBufPtr.SetLength(0); |
874 |
859 |
875 iActive->ImageCapture(iCaptureBufPtr); |
860 iActive->ImageCapture(iChunkRemSize); |
876 |
861 |
877 iImageCaptureActive = ETrue; |
862 iImageCaptureActive = ETrue; |
878 } |
863 } |
879 |
864 |
880 /** |
865 /** |
1136 from CCamera |
1121 from CCamera |
1137 |
1122 |
1138 Gets the currently set jpeg quality value. |
1123 Gets the currently set jpeg quality value. |
1139 |
1124 |
1140 Returns 0 if not supported. |
1125 Returns 0 if not supported. |
1141 |
|
1142 @return The currently set jpeg quality value. |
1126 @return The currently set jpeg quality value. |
1143 |
|
1144 @see CCamera::CCameraPreImageCaptureControl::GetImageMaxMemorySizeL(TUint& aMemorySize) |
1127 @see CCamera::CCameraPreImageCaptureControl::GetImageMaxMemorySizeL(TUint& aMemorySize) |
1145 */ |
1128 */ |
1146 TInt CWebCamera::JpegQuality() const |
1129 TInt CWebCamera::JpegQuality() const |
1147 { |
1130 { |
1148 return 0; |
1131 return 0; |
1154 Gets a custom interface. The client has to cast the returned pointer |
1137 Gets a custom interface. The client has to cast the returned pointer |
1155 to the appropriate type. |
1138 to the appropriate type. |
1156 |
1139 |
1157 @param aInterface |
1140 @param aInterface |
1158 The Uid of the particular interface function required. |
1141 The Uid of the particular interface function required. |
1159 |
|
1160 @return Custom interface pointer. NULL if the requested interface is not supported. |
1142 @return Custom interface pointer. NULL if the requested interface is not supported. |
1161 */ |
1143 */ |
1162 TAny* CWebCamera::CustomInterface(TUid aInterface) |
1144 TAny* CWebCamera::CustomInterface(TUid aInterface) |
1163 { |
1145 { |
1164 switch(aInterface.iUid) |
1146 switch(aInterface.iUid) |
1226 |
1204 |
1227 CallBack function of the ImageCapture |
1205 CallBack function of the ImageCapture |
1228 */ |
1206 */ |
1229 void CWebCamera::ImageCaptureCallBackL(TInt aError) |
1207 void CWebCamera::ImageCaptureCallBackL(TInt aError) |
1230 { |
1208 { |
1231 RDebug::Print(_L("CWebCamera::ImageCaptureCallBack_S")); |
|
1232 |
|
1233 iImageCaptureActive = EFalse; |
1209 iImageCaptureActive = EFalse; |
1234 |
1210 if (!iCaptureBitmap) |
1235 iCaptureBitmap = NULL; |
1211 { |
1236 CFbsBitmap* image = new (ELeave) CFbsBitmap(); |
1212 CFbsBitmap* image = new (ELeave) CFbsBitmap(); |
1237 CleanupStack::PushL(image); |
1213 CleanupStack::PushL(image); |
1238 User::LeaveIfError(image->Create(TSize(KCaptureWidth, KCaptureHeight), EColor16M)); |
1214 User::LeaveIfError(image->Create(TSize(KCaptureWidth, KCaptureHeight), EColor16M)); |
1239 CleanupStack::Pop(image); |
1215 CleanupStack::Pop(image); |
1240 iCaptureBitmap = image; |
1216 iCaptureBitmap = image; |
|
1217 } |
|
1218 |
|
1219 iCaptureBufPtr.Copy(iChuckBase,iChunkRemSize); |
1241 |
1220 |
1242 //////////////////////////////////////////////////////////////////////////////////////// |
1221 //////////////////////////////////////////////////////////////////////////////////////// |
1243 // output receive data log |
1222 // output receive data log |
1244 // RDebug::Print(_L("CWebCameraVfActive::ImageCaptureCallBack iCaptureBufPtr[%d]"), iCaptureBufPtr.Length()); |
1223 // RDebug::Print(_L("CWebCameraVfActive::ImageCaptureCallBack iCaptureBufPtr[%d]"), iCaptureBufPtr.Length()); |
1245 // TBuf<256> hexBuf; |
1224 // TBuf<256> hexBuf; |
1253 // } |
1232 // } |
1254 // } |
1233 // } |
1255 // RDebug::Print(hexBuf); |
1234 // RDebug::Print(hexBuf); |
1256 //////////////////////////////////////////////////////////////////////////////////////// |
1235 //////////////////////////////////////////////////////////////////////////////////////// |
1257 |
1236 |
1258 RDebug::Print(_L("CWebCamera::ImageCaptureCallBack start setscanline_S")); |
|
1259 for (TInt height=0; height<KCaptureHeight; height++) |
|
1260 { |
|
1261 TInt pos = height * KCaptureLineBytes; |
|
1262 TPtrC8 posptr = iCaptureBuf->Mid(pos, KCaptureLineBytes); |
|
1263 TBuf8<KCaptureLineBytes> buf; |
|
1264 buf.Copy(posptr); |
|
1265 iCaptureBitmap->SetScanLine(buf, ((KCaptureHeight-1)-height)); |
|
1266 } |
|
1267 RDebug::Print(_L("CWebCamera::ImageCaptureCallBack start setscanline_E")); |
|
1268 |
|
1269 if (iObserver) |
1237 if (iObserver) |
1270 { |
1238 { |
|
1239 TUint32 *wData = iCaptureBitmap->DataAddress(); |
|
1240 Mem::Copy(wData, iCaptureBufPtr.Ptr(), (KCaptureHeight * KCaptureLineBytes)); |
|
1241 |
1271 iObserver->ImageReady(iCaptureBitmap, iCaptureBuf, aError); |
1242 iObserver->ImageReady(iCaptureBitmap, iCaptureBuf, aError); |
|
1243 delete iCaptureBitmap; |
|
1244 iCaptureBitmap = NULL; |
1272 } |
1245 } |
1273 else if (iObserver2) |
1246 else if (iObserver2) |
1274 { |
1247 { |
1275 iObserver2->ImageBufferReady(*iCaptureCameraBuf, aError); |
1248 iObserver2->ImageBufferReady(*iCaptureCameraBuf, aError); |
1276 } |
1249 } |
1277 |
1250 |
1278 RDebug::Print(_L("CWebCamera::ImageCaptureCallBack_E")); |
|
1279 } |
1251 } |
1280 |
1252 |
1281 //from MWebCameraVfActiveCallBack |
1253 //from MWebCameraVfActiveCallBack |
1282 void CWebCamera::ViewFinderCallBack(TInt /*aError*/) |
1254 void CWebCamera::ViewFinderCallBack(TInt /*aError*/) |
1283 { |
1255 { |
1284 RDebug::Print(_L("CWebCamera::ViewFinderCallBack")); |
|
1285 } |
1256 } |
1286 |
1257 |
1287 |
1258 |
1288 // |
1259 // |
1289 // CWebCameraInfo class |
1260 // CWebCameraInfo class |