sl@0
|
1 |
// Copyright (c) 2008-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 "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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@internalComponent
|
sl@0
|
19 |
*/
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "mmdirectviewfinder.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <graphics/surfaceconfiguration.h>
|
sl@0
|
24 |
#include "w32std.h"
|
sl@0
|
25 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
26 |
#include <ecamdef.h>
|
sl@0
|
27 |
#endif
|
sl@0
|
28 |
|
sl@0
|
29 |
CMMDirectViewFinder* CMMDirectViewFinder::NewL(CMMCameraClientSession& aOwner)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
CMMDirectViewFinder* self = new (ELeave) CMMDirectViewFinder(aOwner);
|
sl@0
|
32 |
CleanupStack::PushL(self);
|
sl@0
|
33 |
self->ConstructL();
|
sl@0
|
34 |
CleanupStack::Pop(self);
|
sl@0
|
35 |
return self;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
void CMMDirectViewFinder::ConstructL()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
CMMDirectViewFinder::CMMDirectViewFinder(CMMCameraClientSession& aOwner)
|
sl@0
|
43 |
: iOwner(aOwner), iDirectViewFinderObserver(NULL), iPrepareCompleted(EFalse)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
iReferenceCount++;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
CMMDirectViewFinder::~CMMDirectViewFinder()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
void CMMDirectViewFinder::Release(CCamera::CCameraV2DirectViewFinder* aDirectViewFinderHandle)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
THashMapIter<TInt, CCamera::CCameraV2DirectViewFinder*> iter(iOwner.iHashMap);
|
sl@0
|
55 |
for (CCamera::CCameraV2DirectViewFinder* const* vF = iter.NextValue(); vF; vF = iter.NextValue())
|
sl@0
|
56 |
{
|
sl@0
|
57 |
if (*vF == aDirectViewFinderHandle)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
iOwner.iHashMap.Remove(*iter.CurrentKey());
|
sl@0
|
60 |
break;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
}
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
void CMMDirectViewFinder::CreateHistogramImplFactoryL(MImplementationFactory*& /*aImplFactoryPtr*/) const
|
sl@0
|
66 |
{
|
sl@0
|
67 |
User::Leave(KErrNotSupported);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
void CMMDirectViewFinder::GetImageProcessingImplFactoryL(MImplementationFactory*& /*aImplFactoryPtr*/) const
|
sl@0
|
71 |
{
|
sl@0
|
72 |
User::Leave(KErrNotSupported);
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
TAny* CMMDirectViewFinder::GetDirectSnapshotImpl(TUid /*aInterface*/) const
|
sl@0
|
76 |
{
|
sl@0
|
77 |
return NULL;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
void CMMDirectViewFinder::SetDirectViewFinderObserver(MDirectViewFinderObserver& aDirectViewFinderObserver)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
iDirectViewFinderObserver = &aDirectViewFinderObserver;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
void CMMDirectViewFinder::SetDirectViewFinderHandle(CCamera::CCameraV2DirectViewFinder* aDirectViewFinderHandle)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
TInt position = iOwner.iHashMap.Count();
|
sl@0
|
88 |
iDirectViewFinderHandle = aDirectViewFinderHandle;
|
sl@0
|
89 |
iOwner.iHashMap.Insert(position, iDirectViewFinderHandle);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
void CMMDirectViewFinder::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
TRect clip;
|
sl@0
|
95 |
clip.SetWidth(0);
|
sl@0
|
96 |
clip.SetHeight(0);
|
sl@0
|
97 |
|
sl@0
|
98 |
StartViewFinderDirectL(aWs, aScreenDevice, aWindow, aScreenRect, clip);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
void CMMDirectViewFinder::StartViewFinderDirectL(RWsSession& /*aWs*/, CWsScreenDevice& aScreenDevice,
|
sl@0
|
102 |
RWindowBase& aWindow, TRect& aScreenRect, TRect& aClipRect)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
// Make sure device is powered up (implies it has been reserved)
|
sl@0
|
105 |
if (!iOwner.iPoweredUp)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
User::Leave(KErrNotReady);
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
// Ensure start is not called twice
|
sl@0
|
111 |
CCamera::CCameraV2DirectViewFinder::TViewFinderState state;
|
sl@0
|
112 |
GetViewFinderStateL(state);
|
sl@0
|
113 |
if (state != CCamera::CCameraV2DirectViewFinder::EViewFinderInActive)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
User::Leave(KErrNotReady);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
TInt error = KErrNone;
|
sl@0
|
119 |
if (!iPrepareCompleted)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
TDirectViewFinderInfo directViewFinderInfo;
|
sl@0
|
122 |
// Retrieve screen number from the screen device
|
sl@0
|
123 |
directViewFinderInfo.iScreenNum = aScreenDevice.GetScreenNumber();
|
sl@0
|
124 |
directViewFinderInfo.iScreenRect = aScreenRect;
|
sl@0
|
125 |
directViewFinderInfo.iClipRect = aClipRect;
|
sl@0
|
126 |
TDirectViewFinderInfoPckg directViewFinderInfoPckg(directViewFinderInfo);
|
sl@0
|
127 |
|
sl@0
|
128 |
// Prepare viewfinder for playback and retrieve the surface id from the graphics sink
|
sl@0
|
129 |
error = iOwner.iCameraSession.SendMessage(ECamPrepareDirectViewFinder, directViewFinderInfoPckg);
|
sl@0
|
130 |
if (error == KErrNone)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
TSurfaceConfiguration surfaceConfig;
|
sl@0
|
133 |
directViewFinderInfo = directViewFinderInfoPckg();
|
sl@0
|
134 |
|
sl@0
|
135 |
error = surfaceConfig.SetSurfaceId(directViewFinderInfo.iSurfaceId);
|
sl@0
|
136 |
if (error == KErrNone)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
// User::LeaveIfError(surfaceConfig.SetOrientation(CFbsBitGc::EGraphicsOrientationRotated90));
|
sl@0
|
139 |
error = surfaceConfig.SetExtent(aScreenRect);
|
sl@0
|
140 |
if (error == KErrNone)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
// User::LeaveIfError(aWindow.SetRequiredDisplayMode(EColor64K));
|
sl@0
|
143 |
error = aWindow.SetBackgroundSurface(surfaceConfig, ETrue);
|
sl@0
|
144 |
if (error == KErrNone)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
iPrepareCompleted = ETrue;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
}
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
if (error != KErrNone)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
User::Leave(error);
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
// Start the viewfinder
|
sl@0
|
159 |
error = iOwner.iCameraSession.SendMessage(ECamStartDirectViewFinder);
|
sl@0
|
160 |
if (error != KErrNone)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
User::Leave(error);
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
// HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!!
|
sl@0
|
166 |
// TODO: Here to let tests run. Will be removed once foundation provide event registration/notification APIs
|
sl@0
|
167 |
iDirectViewFinderObserver->DirectViewFinderFirstFrameDisplayed(*iDirectViewFinderHandle, KErrNone);
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
void CMMDirectViewFinder::GetDirectViewFinderPropertiesL(TInt& aScreenNumber, TRect& aScreenRect, TRect& aClipRect) const
|
sl@0
|
171 |
{
|
sl@0
|
172 |
if (!iPrepareCompleted)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
User::Leave(KErrNotReady);
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
TDirectViewFinderInfo info;
|
sl@0
|
178 |
TDirectViewFinderInfoPckg pckg(info);
|
sl@0
|
179 |
|
sl@0
|
180 |
iOwner.iCameraSession.SendRxMessage(ECamDirectViewFinderProperties, pckg);
|
sl@0
|
181 |
info = pckg();
|
sl@0
|
182 |
aScreenNumber = info.iScreenNum;
|
sl@0
|
183 |
aScreenRect = info.iScreenRect;
|
sl@0
|
184 |
aClipRect = info.iClipRect;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
void CMMDirectViewFinder::PauseViewFinderDirect()
|
sl@0
|
188 |
{
|
sl@0
|
189 |
iOwner.iCameraSession.SendMessage(ECamPauseDirectViewFinder);
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
void CMMDirectViewFinder::ResumeViewFinderDirect()
|
sl@0
|
193 |
{
|
sl@0
|
194 |
iOwner.iCameraSession.SendMessage(ECamResumeDirectViewFinder);
|
sl@0
|
195 |
// HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!! HACK!!!
|
sl@0
|
196 |
// TODO: Here to let tests run. Will be removed once foundation provide event registration/notification APIs
|
sl@0
|
197 |
iDirectViewFinderObserver->DirectViewFinderFirstFrameDisplayed(*iDirectViewFinderHandle, KErrNone);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
void CMMDirectViewFinder::GetViewFinderStateL(CCamera::CCameraV2DirectViewFinder::TViewFinderState& aViewFinderState) const
|
sl@0
|
201 |
{
|
sl@0
|
202 |
TDirectViewFinderState state;
|
sl@0
|
203 |
TDirectViewFinderStatePckg pckg(state);
|
sl@0
|
204 |
|
sl@0
|
205 |
User::LeaveIfError(iOwner.iCameraSession.SendRxMessage(ECamDirectViewFinderState, pckg));
|
sl@0
|
206 |
|
sl@0
|
207 |
state = pckg();
|
sl@0
|
208 |
aViewFinderState = state.iState;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
void CMMDirectViewFinder::StopDirectViewFinder()
|
sl@0
|
212 |
{
|
sl@0
|
213 |
iOwner.iCameraSession.SendMessage(ECamStopDirectViewFinder);
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
void CMMDirectViewFinder::Release()
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iReferenceCount--;
|
sl@0
|
219 |
if (iReferenceCount == 0)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
delete this;
|
sl@0
|
222 |
}
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
void CMMDirectViewFinder::GetViewFinderFadingCapabilitiesL(CCameraViewFinder::TViewFinderFadingCapabilities& /*aVFFadingCapabilities*/) const
|
sl@0
|
226 |
{
|
sl@0
|
227 |
User::Leave(KErrNotSupported);
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
void CMMDirectViewFinder::GetViewFinderFadingEffectL(CCameraViewFinder::TViewFinderFadingEffect& /*aCurrentVFFadingEffect*/) const
|
sl@0
|
231 |
{
|
sl@0
|
232 |
User::Leave(KErrNotSupported);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
void CMMDirectViewFinder::SetViewFinderFadingEffect(const CCameraViewFinder::TViewFinderFadingEffect& /*aVFFadingEffect*/)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
TECAMEvent event(KUidECamEvent2ViewFinderFadingEffect, KErrNotSupported);
|
sl@0
|
238 |
iOwner.iCameraObserver2->HandleEvent(event);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
void CMMDirectViewFinder::GetViewFinderHandleL(TInt& aVFHandle) const
|
sl@0
|
242 |
{
|
sl@0
|
243 |
THashMapIter<TInt, CCamera::CCameraV2DirectViewFinder*> iter(iOwner.iHashMap);
|
sl@0
|
244 |
for (CCamera::CCameraV2DirectViewFinder* const* vF = iter.NextValue(); vF; vF = iter.NextValue())
|
sl@0
|
245 |
{
|
sl@0
|
246 |
if (*vF == iDirectViewFinderHandle)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
// Handle returned is position within the hash table + 100 (arbitrary value to show uniquenness of handle)
|
sl@0
|
249 |
aVFHandle = *iter.CurrentKey() + 100;
|
sl@0
|
250 |
return;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
}
|
sl@0
|
253 |
User::Leave(KErrNotFound);
|
sl@0
|
254 |
}
|