|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Video Source subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_MULTIFRAMEPROVIDER_H |
|
20 #define C_MULTIFRAMEPROVIDER_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <f32file.h> |
|
24 #include <gdi.h> |
|
25 #include "cactivewait.h" |
|
26 #include "cvtimagescaler.h" |
|
27 #include "mmultiframeprovider.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class CVtImageBitmap; |
|
32 class CImageDecoder; |
|
33 class CMultiframeloopAO; |
|
34 class TScalingMediator; |
|
35 class CMultiframeProvider; |
|
36 class CMultiframeDataAO; |
|
37 |
|
38 const TInt KFirstFrameIndx = 0; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 // ============================ TScalingMediator =============================== |
|
42 /** |
|
43 * Internal implementation of still scaling mediator |
|
44 * @lib videosource.lib |
|
45 */ |
|
46 |
|
47 NONSHARABLE_CLASS( TScalingMediator) : public MVtImageScalerObserver |
|
48 { |
|
49 public : |
|
50 TScalingMediator(); |
|
51 public : |
|
52 /** |
|
53 * @see MVtImageScalerObserver::ScalingFinished( TInt aError ) |
|
54 */ |
|
55 void ScalingFinished( TInt aError ); |
|
56 |
|
57 /** |
|
58 * Sets waiter observer |
|
59 */ |
|
60 void SetWaiter( CVSActiveWait< CMultiframeProvider >* aWait ); |
|
61 private : |
|
62 CVSActiveWait< CMultiframeProvider >* iWait; |
|
63 }; |
|
64 |
|
65 |
|
66 // ============================ CMultiframeProvider =============================== |
|
67 /** |
|
68 * Internal implementation of multiframe provider |
|
69 * @lib videosource.lib |
|
70 */ |
|
71 NONSHARABLE_CLASS( CMultiframeProvider ) : public CBase |
|
72 { |
|
73 |
|
74 public : // Constructors and destructor |
|
75 |
|
76 /** |
|
77 * Static factory function create instance of this class. |
|
78 * @param "aObserver" Pointer to data provider observer. |
|
79 * @param aDisplayMode current display mode |
|
80 * @exception Can leave with one of the system wide error codes. |
|
81 * @return Pointer to new instance. |
|
82 */ |
|
83 static CMultiframeProvider* NewL( MMultiframeprovider* aObserver, TDisplayMode aDisplayMode ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 ~CMultiframeProvider(); |
|
89 |
|
90 |
|
91 public : // Functions from base classes |
|
92 |
|
93 /** |
|
94 * Initializes this instance from image or multiframe file. |
|
95 * @param aFileName Name of the file from which this intance will be |
|
96 * initialized. |
|
97 * @exception Can leave with one of the system wide error codes. |
|
98 */ |
|
99 void InitializeL( const TFileName* aFileName ); |
|
100 |
|
101 /** |
|
102 * Cancel initialization of multiframe provider. |
|
103 * @return ETrue if don't need to wait a error message. |
|
104 */ |
|
105 TBool CancelInitializing(); |
|
106 |
|
107 /** |
|
108 * Initializes this instance for blank image bitmap. |
|
109 */ |
|
110 void IniatializeBlankL(); |
|
111 |
|
112 /** |
|
113 * Initializes this instance for Generalsettings image bitmap. |
|
114 */ |
|
115 void IniatializeGSL( const TGeneralSettingsImageType aType ); |
|
116 /** |
|
117 * Sets ViewFinder size |
|
118 * @param aSize size of target bitmap (view finder) |
|
119 */ |
|
120 void SetVFScalingTargetSize( TSize aSize ); |
|
121 |
|
122 /** |
|
123 * Decodes and scales initialized image or multiframe file |
|
124 * @param aFrameindex index of frame to be decoded and scaled |
|
125 */ |
|
126 void ConvertAndScaleL( TInt aFrameIndex ); |
|
127 |
|
128 /** |
|
129 * Scales and copies decoded frame for view finder display |
|
130 * @param aSize size of target bitmap ( view fiender ) |
|
131 */ |
|
132 void ScaleCopy( TSize& aSize, TBool aVFUpdate = EFalse ); |
|
133 |
|
134 /** |
|
135 * Signals looping AO to proceed to next frame |
|
136 */ |
|
137 void NextFrame(); |
|
138 |
|
139 /** |
|
140 * Clears ViewFinder size |
|
141 */ |
|
142 void ClearVFScalingTargetSize(); |
|
143 |
|
144 /** |
|
145 * Increases number of data consumers by one |
|
146 */ |
|
147 void IncreaseDataConsumer(); |
|
148 |
|
149 /** |
|
150 * Decreases number of data consumers by one |
|
151 * and if number is less than one it cancels data looping |
|
152 * mechanism |
|
153 */ |
|
154 void DecreaseDataConsumer(); |
|
155 |
|
156 /** |
|
157 * Adds used bitmap to free queue |
|
158 */ |
|
159 void AddBitmapToFreeQueue(); |
|
160 |
|
161 /** |
|
162 * Indicates that second VF buffer needs to be used |
|
163 */ |
|
164 void UseSecondVfBuffer(); |
|
165 |
|
166 /** |
|
167 * Indicates that VF has been stopped |
|
168 */ |
|
169 TBool IsVFStopped(); |
|
170 |
|
171 /** |
|
172 * Set ViewFinder of Multiframe provider to stop |
|
173 */ |
|
174 void SetVFStop(); |
|
175 |
|
176 /** |
|
177 * Wait for converting function exit |
|
178 */ |
|
179 void WaitForConverting(); |
|
180 |
|
181 /** |
|
182 * Release converting flag |
|
183 */ |
|
184 void ReleaseForConverting(); |
|
185 |
|
186 private : // Constructors and destructor |
|
187 |
|
188 /** |
|
189 * Constructor. |
|
190 * @param "aObserver" Pointer to data provider observer. |
|
191 * @param aDisplayMode current display mode |
|
192 */ |
|
193 CMultiframeProvider( MMultiframeprovider* aObserver, TDisplayMode aDisplayMode ); |
|
194 |
|
195 /** |
|
196 * 2nd phase constructor. |
|
197 * @exception Can leave with one of the system wide error codes. |
|
198 */ |
|
199 void ConstructL(); |
|
200 |
|
201 /** |
|
202 * Image conversion finished callback. This method is called when image |
|
203 * conversion is done. |
|
204 * @param "aError" Error code. KErrNone if no error happened, one of the |
|
205 * system wide error codes. |
|
206 * otherwise. |
|
207 */ |
|
208 void ConversionFinished( TInt aError ); |
|
209 |
|
210 /** |
|
211 * Image scaling finished callback. This method is called when image |
|
212 * scaling is done. |
|
213 * @param "aError" Error code. KErrNone if no error happened, one of |
|
214 * the system wide error codes. |
|
215 */ |
|
216 void BMSScalingFinished( TInt aError ); |
|
217 |
|
218 /** |
|
219 * Scales VF to new size. |
|
220 * @param "aSize" New VF size. |
|
221 * the system wide error codes. |
|
222 */ |
|
223 void ScaleVF( const TSize& aSize ); |
|
224 |
|
225 /** |
|
226 * When view finder frame must be rescaled (wanted view finder size is |
|
227 * neither QCIF nor QQQCIF) this callback will be called when the |
|
228 * rescaling has finished. |
|
229 * @param "aError" Error code. KErrNone if no error happened, one of |
|
230 * the system wide error codes. |
|
231 */ |
|
232 void VFRescalingFinished( TInt aError ); |
|
233 |
|
234 /** |
|
235 * When view finder frames are rescaled this callback method will be |
|
236 * called. |
|
237 * @param "aError" Error code. KErrNone if no error happened, one of |
|
238 * the system wide error codes. |
|
239 */ |
|
240 void VFScalingReady(); |
|
241 |
|
242 /** |
|
243 * Creates blank bitmap with given size, color mode and color. |
|
244 * @param "aBitmap" Bitmap pointer reference into which pointer to new |
|
245 * isntance will be copied. |
|
246 * @param "aSize" Size of the blank bitmap to be created. |
|
247 * @param "aMode" Color mode for created bitmap. |
|
248 * @param "aColor" Color of created bitmap. |
|
249 * @exception Can leave with one of the system wide error codes. |
|
250 */ |
|
251 void CreateBlankBitmapL( CFbsBitmap*& aBitmap, const TSize& aSize, const TDisplayMode& aMode, const TRgb& aColor ); |
|
252 |
|
253 public : // Data |
|
254 |
|
255 TBool iAnimation; |
|
256 |
|
257 TBool iConvertAndScale; |
|
258 |
|
259 protected: // Data |
|
260 |
|
261 RCriticalSection iFreezeCS; |
|
262 |
|
263 private : //Data |
|
264 |
|
265 |
|
266 // Source image for CVtImageScaler |
|
267 CVtImageBitmap* iConverted; |
|
268 |
|
269 // Target image for CVtImageScaler |
|
270 CVtImageBitmap* iScaled; |
|
271 CVtImageBitmap* iBuffer1; |
|
272 CVtImageBitmap* iBuffer2; |
|
273 |
|
274 // Pointer to remote image |
|
275 CVtImageBitmap* iYUVBitMap; |
|
276 |
|
277 // Pointer to QCIF sized view finder image |
|
278 CVtImageBitmap* iVFbitmap; |
|
279 CVtImageBitmap* iFirstVfBuf; |
|
280 CVtImageBitmap* iSecondVfBuf; |
|
281 |
|
282 // Boolean values of VF buffer validation |
|
283 TBool iSecondVFBuffer; |
|
284 TBool iFirstVFBuffer; |
|
285 |
|
286 // Pointer to bitmap loaded from GS |
|
287 CVtImageBitmap* iGSBitmap; |
|
288 |
|
289 // Pointer to selected view finder image |
|
290 CVtImageBitmap* iVFCurrent; |
|
291 |
|
292 // Viewer AO instance |
|
293 CMultiframeloopAO* iLoopAo;// owned |
|
294 |
|
295 // Initalisation scaling mediator |
|
296 TScalingMediator iInitMediator; |
|
297 |
|
298 // ViewFinder scaling scaling mediator |
|
299 TScalingMediator iScalingMediator; |
|
300 |
|
301 // Waiter instance for initialisation |
|
302 CVSActiveWait< CMultiframeProvider >* iActiveWaitInit;// owned |
|
303 |
|
304 // Waiter instance for scaling |
|
305 CVSActiveWait< CMultiframeProvider >* iActiveWaitScale;// owned |
|
306 |
|
307 // Waiter instance for scaling |
|
308 CVSActiveWait< CMultiframeProvider >* iActiveWaitInitScale; // owned |
|
309 |
|
310 // VT image scaler instance for initialisation |
|
311 CVtImageScaler* iVtImageScalerInit; // owned |
|
312 |
|
313 // VT image scaler instance for scaling |
|
314 CVtImageScaler* iVtImageScalerScale; // owned |
|
315 |
|
316 // Image decoder instance |
|
317 CImageDecoder* iImageDecoder; // owned |
|
318 |
|
319 // Wanted view finder size |
|
320 TSize iWantedVFSize; |
|
321 |
|
322 // FireServer session instance |
|
323 RFs iFs; |
|
324 |
|
325 // Current display mode |
|
326 TDisplayMode iDisplayMode; |
|
327 |
|
328 // Rescaling recuirement flag |
|
329 TBool iVFRescalingRequired; |
|
330 |
|
331 // Multiframe observer instance |
|
332 MMultiframeprovider* iObserver; |
|
333 |
|
334 // VF bitmap size |
|
335 TSize iTargetSize; |
|
336 |
|
337 // Is blank image share |
|
338 TBool iBlank; |
|
339 |
|
340 // Is GS image share |
|
341 TBool iGSImage; |
|
342 |
|
343 // Is second bitmap in use |
|
344 TBool iOldBM; |
|
345 |
|
346 // Pointer to old bitmap |
|
347 CVtImageBitmap* iOldBitmap; |
|
348 |
|
349 // Frame count |
|
350 TInt iCount; |
|
351 |
|
352 // Is initialization ongoing flag |
|
353 TBool iInitialization; |
|
354 |
|
355 // Frame delay |
|
356 TTimeIntervalMicroSeconds iDelay; |
|
357 |
|
358 // Start time for image conversion |
|
359 TTime iStartTime; |
|
360 |
|
361 // Data timer expiration / Frame update time |
|
362 TTimeIntervalMicroSeconds iFrameUpdateTime; |
|
363 |
|
364 // Pointer to data timer AO |
|
365 CMultiframeDataAO* iDataTimer; |
|
366 |
|
367 // Number of data consumers |
|
368 TInt iNumOfConsumers; |
|
369 |
|
370 // Queue for bitmaps that are free for use |
|
371 RPointerArray<CVtImageBitmap> iFreeQueue; |
|
372 |
|
373 // Pointer to bitmap mask |
|
374 CFbsBitmap* iMask; |
|
375 |
|
376 // Pointer to temporary bitmap |
|
377 CVtImageBitmap* iTempBM; |
|
378 |
|
379 TSize iVFSize; |
|
380 |
|
381 // Boolean value of VF buffer update |
|
382 TBool iVFUpdate; |
|
383 |
|
384 // file handle to default VT image |
|
385 RFile iDefaultImageFile; |
|
386 // Boolean value of VF buffer stopping |
|
387 TBool iIsVfStopped; |
|
388 |
|
389 // Boolean value of VF buffer stopping |
|
390 TBool iWaitForConverting; |
|
391 }; |
|
392 |
|
393 #endif // C_MULTIFRAMEPROVIDER_H |
|
394 |
|
395 // End of File |