|
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 "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * ISB - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ecamwebcameraactive.h" |
|
19 |
|
20 |
|
21 // |
|
22 // CWebCameraActive |
|
23 // |
|
24 CWebCameraActive* CWebCameraActive::NewL(MWebCameraActiveCallBack* aOwner, RWebcameraDevice& aDriver) |
|
25 { |
|
26 CWebCameraActive* self = new(ELeave) CWebCameraActive(aOwner, aDriver); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 CleanupStack::Pop(self); |
|
30 |
|
31 return self; |
|
32 } |
|
33 |
|
34 CWebCameraActive::CWebCameraActive(MWebCameraActiveCallBack* aOwner, RWebcameraDevice& aDriver) |
|
35 :CActive(CActive::EPriorityStandard), |
|
36 iOwner(aOwner), |
|
37 iDriver(aDriver) |
|
38 { |
|
39 CActiveScheduler::Add(this); |
|
40 } |
|
41 |
|
42 CWebCameraActive::~CWebCameraActive() |
|
43 { |
|
44 } |
|
45 |
|
46 /** |
|
47 * RunL. |
|
48 */ |
|
49 void CWebCameraActive::RunL() |
|
50 { |
|
51 TInt wError = iStatus.Int(); |
|
52 |
|
53 switch(iOperation) |
|
54 { |
|
55 case ECamActiveReserve: |
|
56 iOwner->ReserveCallBack(wError); |
|
57 break; |
|
58 |
|
59 case ECamActivePowerOn: |
|
60 iOwner->PowerOnCallBack(wError); |
|
61 break; |
|
62 |
|
63 case ECamActiveImageCapture: |
|
64 iOwner->ImageCaptureCallBackL(wError); |
|
65 break; |
|
66 } |
|
67 iOperation = ECamActiveIdle; |
|
68 } |
|
69 |
|
70 void CWebCameraActive::DoCancel() |
|
71 { |
|
72 } |
|
73 |
|
74 void CWebCameraActive::ConstructL() |
|
75 { |
|
76 } |
|
77 |
|
78 /** |
|
79 Asynchronous function that performs any required initialisation and reserves |
|
80 the camera for exclusive use. |
|
81 |
|
82 Calls CWebCamera::ReserveCallBack when complete. |
|
83 */ |
|
84 void CWebCameraActive::Reserve() |
|
85 { |
|
86 iOperation = ECamActiveReserve; |
|
87 |
|
88 //Because there is not a camera device, I do not handle it |
|
89 TRequestStatus* status = &iStatus; |
|
90 User::RequestComplete(status, KErrNone); |
|
91 SetActive(); |
|
92 } |
|
93 |
|
94 /** |
|
95 Asynchronous method to switch on camera power. |
|
96 |
|
97 User must have successfully called Reserve() prior to calling this function. |
|
98 |
|
99 Calls CWebCamera::PowerOnCallBack when power on is complete. |
|
100 */ |
|
101 void CWebCameraActive::PowerOn() |
|
102 { |
|
103 iOperation = ECamActivePowerOn; |
|
104 |
|
105 //Because there is not a camera device, I do not handle it |
|
106 TRequestStatus* status = &iStatus; |
|
107 User::RequestComplete(status, KErrNone); |
|
108 SetActive(); |
|
109 } |
|
110 |
|
111 /** |
|
112 Cancels the asynchronous still image capture. |
|
113 |
|
114 Calls CWebCamera::ImageCaptureCallBackL when capture is complete. |
|
115 |
|
116 * @param aDes descriptor to store a capture image |
|
117 */ |
|
118 void CWebCameraActive::ImageCapture(TDes8& aDes) |
|
119 { |
|
120 iOperation = ECamActiveImageCapture; |
|
121 |
|
122 // start capture image |
|
123 // The division transfer is going to support in the next version. |
|
124 iDriver.Capture(iStatus, aDes); |
|
125 SetActive(); |
|
126 } |
|
127 |
|
128 /** |
|
129 Cancels the asynchronous still image capture. |
|
130 |
|
131 @see CWebCamera::CancelCaptureImage |
|
132 */ |
|
133 void CWebCameraActive::CancelCaptureImage() |
|
134 { |
|
135 iOperation = ECamActiveIdle; |
|
136 |
|
137 iDriver.CaptureCancel(); |
|
138 SetActive(); |
|
139 } |
|
140 |