|
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 // INCLUDE FILES |
|
20 #include <imageconversion.h> |
|
21 #include <cvtimageconverter.h> |
|
22 #include <rphcltserver.h> |
|
23 #include <cphcltimagehandler.h> |
|
24 #include <bautils.h> |
|
25 |
|
26 #include "cmultiframeprovider.h" |
|
27 #include "cmultiframeloopao.h" |
|
28 #include "cmultiframedataao.h" |
|
29 |
|
30 #include "CVSStillImageDataProvider.h" |
|
31 #include "cvtimagebitmap.h" |
|
32 |
|
33 static const TInt KQcifWidth = 176; |
|
34 static const TInt KQcifHeight = 144; |
|
35 |
|
36 // Default bitmap size is VGA |
|
37 static const TInt KDefaultBitmapSizeWidth = 640; |
|
38 static const TInt KDefaultBitmapSizeHeight = 480; |
|
39 |
|
40 // MACROS |
|
41 |
|
42 #ifdef _DEBUG |
|
43 # define __IF_DEBUG(t) {RDebug::t;} |
|
44 #else |
|
45 # define __IF_DEBUG(t) |
|
46 #endif |
|
47 |
|
48 // ============================ TScalingMediator =============================== |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // TScalingMediator::TScalingMediator( ) |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TScalingMediator::TScalingMediator() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // TScalingMediator::ScalingFinished( ) |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void TScalingMediator::ScalingFinished( TInt aError ) |
|
63 { |
|
64 __IF_DEBUG(Print(_L("TScalingMediator::ScalingFinished() >>"))); |
|
65 iWait->Signal( aError ); |
|
66 __IF_DEBUG(Print(_L("TScalingMediator::ScalingFinished() error %d <<"), aError)); |
|
67 } |
|
68 // ----------------------------------------------------------------------------- |
|
69 // TScalingMediator::ScalingFinished( ) |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void TScalingMediator::SetWaiter( CVSActiveWait< CMultiframeProvider >* aWait ) |
|
73 { |
|
74 iWait = aWait; |
|
75 } |
|
76 |
|
77 // ============================ CMultiframeProvider =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CMultiframeProvider::NewL( ) |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CMultiframeProvider* CMultiframeProvider::NewL( MMultiframeprovider* aObserver, TDisplayMode aDisplayMode ) |
|
84 { |
|
85 __IF_DEBUG(Print(_L("VideoSource: [%d] CMultiframeProvider::NewL() >>"), RThread().Id().operator TUint())); |
|
86 CMultiframeProvider* self = |
|
87 new (ELeave) CMultiframeProvider( aObserver, aDisplayMode ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 __IF_DEBUG(Print(_L("VideoSource: [%d] CMultiframeProvider::NewL() <<"), RThread().Id().operator TUint())); |
|
92 return self; |
|
93 } |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMultiframeProvider::CMultiframeProvider( |
|
96 // MVSDataProviderObserver* aObserver ) |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CMultiframeProvider::CMultiframeProvider( |
|
100 MMultiframeprovider* aObserver , TDisplayMode aDisplayMode ): iDisplayMode( aDisplayMode ), iObserver( aObserver ), iBlank( EFalse ), iGSImage( EFalse ) |
|
101 { |
|
102 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::CMultiframeProvider() >>"), RThread().Id().operator TUint())); |
|
103 //Set target VF size QCIF as default |
|
104 iTargetSize.SetSize( KQcifWidth , KQcifHeight ); |
|
105 iVFSize.SetSize( KQcifWidth , KQcifHeight ); |
|
106 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::CMultiframeProvider() <<"), RThread().Id().operator TUint())); |
|
107 } |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CMultiframeProvider::~CMultiframeProvider() |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CMultiframeProvider::~CMultiframeProvider() |
|
113 { |
|
114 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::~CMultiframeProvider() >>"), RThread().Id().operator TUint())); |
|
115 iFs.Close(); |
|
116 iFreezeCS.Close(); |
|
117 delete iImageDecoder; iImageDecoder = 0; |
|
118 delete iVtImageScalerInit; |
|
119 delete iVtImageScalerScale; |
|
120 delete iActiveWaitInit; |
|
121 delete iActiveWaitScale; |
|
122 delete iActiveWaitInitScale; |
|
123 delete iConverted; |
|
124 delete iMask; |
|
125 delete iTempBM; |
|
126 delete iDataTimer; |
|
127 delete iLoopAo; |
|
128 if ( iScaled != iBuffer1 && iScaled != iBuffer2 ) |
|
129 { |
|
130 delete iScaled; |
|
131 } |
|
132 delete iGSBitmap; |
|
133 if ( !iBlank || !iGSImage ) |
|
134 { |
|
135 delete iBuffer1; |
|
136 delete iBuffer2; |
|
137 } |
|
138 delete iFirstVfBuf; |
|
139 delete iSecondVfBuf; |
|
140 iFreeQueue.Close(); |
|
141 iDefaultImageFile.Close(); |
|
142 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::~CMultiframeProvider() <<"), RThread().Id().operator TUint())); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CMultiframeProvider::ConstructL() |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CMultiframeProvider::ConstructL() |
|
150 { |
|
151 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConstructL() >>"), RThread().Id().operator TUint())); |
|
152 User::LeaveIfError( iFs.Connect() ); |
|
153 User::LeaveIfError( iFreezeCS.CreateLocal() ); |
|
154 |
|
155 // Create waiters and mediators for scaling purposes |
|
156 iActiveWaitInit = new (ELeave) CVSActiveWait< CMultiframeProvider >( this ); |
|
157 iActiveWaitScale = new (ELeave) CVSActiveWait< CMultiframeProvider >( this ); |
|
158 iActiveWaitInitScale = new (ELeave) CVSActiveWait< CMultiframeProvider >( this ); |
|
159 iInitMediator.SetWaiter( iActiveWaitInitScale ); |
|
160 iScalingMediator.SetWaiter( iActiveWaitScale ); |
|
161 iVtImageScalerInit = CVtImageScaler::NewL( iInitMediator, CVtImageScaler::EBilinear ); |
|
162 iVtImageScalerScale = CVtImageScaler::NewL( iScalingMediator, CVtImageScaler::EBilinear ); |
|
163 iDataTimer = new (ELeave) CMultiframeDataAO( this ); |
|
164 iDataTimer->SetObserver( iObserver ); |
|
165 iLoopAo = new (ELeave) CMultiframeloopAO( this ); |
|
166 iFirstVfBuf = CVtImageBitmap::NewL( TSize( KQcifWidth >> 2, KQcifHeight >> 2 ), iDisplayMode ); |
|
167 iSecondVfBuf = CVtImageBitmap::NewL( TSize( KQcifWidth >> 2, KQcifHeight >> 2 ), iDisplayMode ); |
|
168 iSecondVFBuffer = EFalse; |
|
169 iFirstVFBuffer = ETrue; |
|
170 iIsVfStopped = EFalse; |
|
171 iWaitForConverting = EFalse; |
|
172 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConstructL() <<"), RThread().Id().operator TUint())); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMultiframeProvider::IniatializeGSL() |
|
177 // |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CMultiframeProvider::IniatializeGSL( const TGeneralSettingsImageType aType ) |
|
181 { |
|
182 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::IniatializeGSL() >>"), RThread().Id().operator TUint())); |
|
183 if ( aType == EGSStillImage ) |
|
184 { |
|
185 // Open connection to phone server |
|
186 RPhCltServer phoneClient; |
|
187 User::LeaveIfError( phoneClient.Connect() ); |
|
188 CleanupClosePushL( phoneClient ); |
|
189 |
|
190 CPhCltImageHandler* stillH = CPhCltImageHandler::NewL(); |
|
191 CleanupStack::PushL( stillH ); |
|
192 |
|
193 // Load images |
|
194 CPhCltImageParams* imageParams; |
|
195 imageParams = stillH->CPhCltBaseImageParamsL( EPhCltTypeVTStill ); |
|
196 CleanupStack::PushL( imageParams ); |
|
197 User::LeaveIfError( stillH->LoadImages( imageParams ) ); |
|
198 |
|
199 // Duplicate to image |
|
200 if( imageParams->Count() > 0 ) |
|
201 { |
|
202 __IF_DEBUG(Print(_L("iImageCount > 0"))); |
|
203 iGSBitmap = CVtImageBitmap::NewL( imageParams->GetImageL( 0 ) ); |
|
204 } |
|
205 else |
|
206 { |
|
207 __IF_DEBUG(Print(_L("iImageCount <= 0 -> User::Leave( KErrNotFound )"))); |
|
208 User::Leave( KErrNotFound ); |
|
209 } |
|
210 // Cleanup |
|
211 CleanupStack::PopAndDestroy( 3 ); // phoneClient, stillH, imageParams |
|
212 iScaled = CVtImageBitmap::NewL( TSize( KQcifWidth, KQcifHeight ), iDisplayMode ); |
|
213 |
|
214 // If bitmap has different display mode than screen, then new bitmap |
|
215 // is created and image is converted to screen's display mode |
|
216 if ( iGSBitmap->Bitmap().DisplayMode() != iDisplayMode || |
|
217 iGSBitmap->Bitmap().ExtendedBitmapType() != KNullUid ) |
|
218 { |
|
219 CVtImageBitmap* temp = CVtImageBitmap::NewL( |
|
220 iGSBitmap->Bitmap().SizeInPixels(), iDisplayMode ); |
|
221 CleanupStack::PushL( temp ); |
|
222 // Color conversion is done by blitting it to other bitmap |
|
223 CFbsBitmapDevice* fbd = CFbsBitmapDevice::NewL( &temp->Bitmap() ); |
|
224 CleanupStack::PushL( fbd ); |
|
225 CFbsBitGc* fgc = NULL; |
|
226 User::LeaveIfError( fbd->CreateContext( fgc ) ); |
|
227 CleanupStack::PushL( fgc ); |
|
228 fgc->BitBlt( TPoint(), &iGSBitmap->Bitmap() ); |
|
229 CleanupStack::PopAndDestroy( 2 ); // fbd, fgc |
|
230 CleanupStack::Pop(); // temp |
|
231 delete iGSBitmap; iGSBitmap = NULL; |
|
232 iGSBitmap = temp; |
|
233 } |
|
234 iGSImage = ETrue; |
|
235 iCount = 1; |
|
236 iActiveWaitInit->InitializeWaiter( &CMultiframeProvider::ConversionFinished ); |
|
237 iActiveWaitInit->Signal( KErrNone ); |
|
238 } |
|
239 else |
|
240 { // default still image prepared by using file handle |
|
241 InitializeL( NULL ); |
|
242 } |
|
243 iInitialization = ETrue; |
|
244 iDelay = 0; |
|
245 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::IniatializeGSL() <<"), RThread().Id().operator TUint())); |
|
246 } |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CMultiframeProvider::IniatializeBlank() |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CMultiframeProvider::IniatializeBlankL() |
|
253 { |
|
254 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::IniatializeBlank() >>"), RThread().Id().operator TUint())); |
|
255 iBlank = ETrue; |
|
256 iInitialization = ETrue; |
|
257 iDelay = 0; |
|
258 iCount = 1; |
|
259 |
|
260 CFbsBitmap* tempBitmap = 0; |
|
261 |
|
262 CreateBlankBitmapL( |
|
263 tempBitmap, |
|
264 TSize( KQcifWidth, KQcifHeight ), |
|
265 iDisplayMode, |
|
266 #ifdef _DEBUG |
|
267 KRgbYellow |
|
268 #else |
|
269 KRgbBlack |
|
270 #endif |
|
271 ); |
|
272 |
|
273 CleanupStack::PushL( tempBitmap ); |
|
274 iScaled = CVtImageBitmap::NewL( tempBitmap->Handle() ); |
|
275 CleanupStack::PopAndDestroy(); // tempBitmap |
|
276 tempBitmap = 0; |
|
277 |
|
278 iActiveWaitInit->InitializeWaiter( &CMultiframeProvider::BMSScalingFinished ); |
|
279 iActiveWaitInit->Signal( KErrNone ); |
|
280 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::IniatializeBlank() <<"), RThread().Id().operator TUint())); |
|
281 } |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CVSStillImageDataProvider::CreateBlankBitmapL( |
|
284 // CFbsBitmap*& aBitmap, const TSize& aSize, const TDisplayMode& aMode, |
|
285 // const TRgb& aColor ) |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CMultiframeProvider::CreateBlankBitmapL( |
|
289 CFbsBitmap*& aBitmap, |
|
290 const TSize& aSize, |
|
291 const TDisplayMode& aMode, |
|
292 const TRgb& aColor ) |
|
293 { |
|
294 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CreateBlankBitmapL() >>"), RThread().Id().operator TUint())); |
|
295 if( aBitmap ) |
|
296 { |
|
297 delete aBitmap; |
|
298 aBitmap = 0; |
|
299 } |
|
300 aBitmap = new (ELeave) CFbsBitmap(); |
|
301 User::LeaveIfError( aBitmap->Create( aSize, aMode ) ); |
|
302 CFbsBitmapDevice* fbd = CFbsBitmapDevice::NewL( aBitmap ); |
|
303 CleanupStack::PushL( fbd ); |
|
304 CFbsBitGc* fgc = 0; |
|
305 User::LeaveIfError( fbd->CreateContext( fgc ) ); |
|
306 CleanupStack::PushL( fgc ); |
|
307 |
|
308 fgc->SetPenColor( aColor ); |
|
309 fgc->SetBrushColor( aColor ); |
|
310 fgc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
311 fgc->DrawRect( TRect( aSize ) ); |
|
312 |
|
313 CleanupStack::PopAndDestroy( 2 ); // fbd, fgc |
|
314 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CreateBlankBitmapL() <<"), RThread().Id().operator TUint())); |
|
315 } |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CMultiframeProvider::Iniatialize() |
|
318 // |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CMultiframeProvider::InitializeL( const TFileName* aFileName ) |
|
322 { |
|
323 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::InitializeL() >>"), RThread().Id().operator TUint())); |
|
324 // Create bitmaps used for conversion and scaling |
|
325 iBuffer1 = CVtImageBitmap::NewL( TSize( KQcifWidth, KQcifHeight ), iDisplayMode ); |
|
326 iBuffer2 = CVtImageBitmap::NewL( TSize( KQcifWidth, KQcifHeight ), iDisplayMode ); |
|
327 User::LeaveIfError( iFreeQueue.Append( iBuffer1 ) ); |
|
328 User::LeaveIfError( iFreeQueue.Append( iBuffer2 ) ); |
|
329 iLoopAo->SetFreeBitmaps( 2 ); |
|
330 |
|
331 // Create ICL decoder in its own thread for current file |
|
332 TInt decodingoptions( |
|
333 CImageDecoder::TOptions( CImageDecoder::EOptionAlwaysThread | CImageDecoder::EAllowGeneratedMask ) ); |
|
334 |
|
335 if ( aFileName ) |
|
336 { |
|
337 __IF_DEBUG(Print(_L(" file name exist, creating CImageDecoder"))); |
|
338 iImageDecoder = CImageDecoder::FileNewL( iFs, *aFileName, (CImageDecoder::TOptions )decodingoptions /*CImageDecoder::EOptionNone*/ ); |
|
339 } |
|
340 else |
|
341 { |
|
342 __IF_DEBUG(Print(_L(" default vt image file => use phone server"))); |
|
343 // default VT image file handle obtained from phone server |
|
344 RPhCltServer phoneClient; |
|
345 User::LeaveIfError( phoneClient.Connect() ); |
|
346 __IF_DEBUG(Print(_L(" connected to phone server"))); |
|
347 CleanupClosePushL( phoneClient ); |
|
348 CPhCltImageHandler* handler = CPhCltImageHandler::NewL(); |
|
349 CleanupStack::PushL( handler ); |
|
350 __IF_DEBUG(Print(_L(" created image handler"))); |
|
351 User::LeaveIfError( handler->OpenDefaultVtImage( iDefaultImageFile ) ); |
|
352 decodingoptions &= ~CImageDecoder::EOptionAlwaysThread; |
|
353 __IF_DEBUG(Print(_L(" creating image decoder"))); |
|
354 iImageDecoder = CImageDecoder::FileNewL( iDefaultImageFile, ContentAccess::EPlay, (CImageDecoder::TOptions )decodingoptions ); |
|
355 __IF_DEBUG(Print(_L(" created image decoder"))); |
|
356 CleanupStack::PopAndDestroy( 2 ); // handler, phoneClient |
|
357 } |
|
358 // Use ICL to calculate frame count |
|
359 iCount = iImageDecoder->FrameCount(); |
|
360 __IF_DEBUG(Print(_L(" frame count=%d"),iCount)); |
|
361 //If advanced flags are on show only first frame! |
|
362 for ( TInt index = 0; index < iCount; ++index ) |
|
363 { |
|
364 TFrameInfo frameInfo( iImageDecoder->FrameInfo( index ) ); |
|
365 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::InitializeL() frameInfo.iFlags %b >>"), RThread().Id().operator TUint(), frameInfo.iFlags)); |
|
366 if ( frameInfo.iFlags & TFrameInfo::ELeaveInPlace ) |
|
367 { |
|
368 iDelay = 0; |
|
369 iCount = 1; |
|
370 } |
|
371 } |
|
372 //Set num of frames to viewer AO |
|
373 iLoopAo->SetFrameCount( iCount ); |
|
374 //For default loopping frame sequence is disabled |
|
375 iAnimation = EFalse; |
|
376 iInitialization = ETrue; |
|
377 //Start ICL image conversion (decoding) and local scaling |
|
378 ConvertAndScaleL( KFirstFrameIndx ); |
|
379 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::InitializeL() <<"), RThread().Id().operator TUint())); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CMultiframeProvider::SetVFScalingTargetSize() |
|
384 // |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void CMultiframeProvider::SetVFScalingTargetSize( TSize aSize ) |
|
388 { |
|
389 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::SetVFScalingTargetSize() >>"), RThread().Id().operator TUint())); |
|
390 iTargetSize = aSize; |
|
391 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::SetVFScalingTargetSize() W %d H %d <<"), RThread().Id().operator TUint(), aSize.iWidth , aSize.iHeight )); |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CMultiframeProvider::ConvertAndScaleL() |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CMultiframeProvider::ConvertAndScaleL( TInt aFrameIndex ) |
|
399 { |
|
400 // Variables related to Bitmap size |
|
401 // calculation |
|
402 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConvertAndScale() aFrameIndex %d>>"), RThread().Id().operator TUint(),aFrameIndex)); |
|
403 TSize convertedBitmapSize; |
|
404 TFrameInfo frameInfo( iImageDecoder->FrameInfo( aFrameIndex ) ); |
|
405 if ( !iInitialization ) |
|
406 { |
|
407 TInt delayindex; |
|
408 delayindex = aFrameIndex - 1; |
|
409 if ( delayindex < KFirstFrameIndx ) |
|
410 { |
|
411 delayindex = ( iCount - 1 ); |
|
412 } |
|
413 TFrameInfo delayframeInfo( iImageDecoder->FrameInfo( delayindex ) ); |
|
414 iDelay = delayframeInfo.iDelay; |
|
415 } |
|
416 else |
|
417 { |
|
418 iDelay = 1; |
|
419 } |
|
420 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConvertAndScale() iDelay %d>>"), RThread().Id().operator TUint(),iDelay.Int64() )); |
|
421 #ifdef _DEBUG |
|
422 TUint threadId( RThread().Id() ); |
|
423 switch ( frameInfo.iFrameDisplayMode ) |
|
424 { |
|
425 case EColor4K: |
|
426 RDebug::Print( _L( "VideoSource [%d]: FrameDPmode = EColor4K" ), |
|
427 threadId ); |
|
428 break; |
|
429 case EColor64K: |
|
430 RDebug::Print( _L( "VideoSource [%d]: FrameDPmode = EColor64K" ), |
|
431 threadId ); |
|
432 break; |
|
433 case EColor16M: |
|
434 RDebug::Print( _L( "VideoSource [%d]: FrameDPmode = EColor16M" ), |
|
435 threadId ); |
|
436 break; |
|
437 case EColor16MU: |
|
438 RDebug::Print( _L( "VideoSource [%d]: FrameDPmode = EColor16MU" ), |
|
439 threadId ); |
|
440 break; |
|
441 default: |
|
442 RDebug::Print( _L( "VideoSource [%d]: FrameDPmode = %d" ), |
|
443 threadId, frameInfo.iFrameDisplayMode ); |
|
444 break; |
|
445 } |
|
446 |
|
447 RDebug::Print( _L( "VideoSource [%d]: CMultiframeProvider:: frameInfo.iFlags %d" ), |
|
448 threadId,frameInfo.iFlags ); |
|
449 #endif // _DEBUG |
|
450 |
|
451 // Use imagedecoder to calculate how many times source picture needs to be divided by 2 |
|
452 // to fit in default (VGA) picture |
|
453 TInt reductionfactor = iImageDecoder->ReductionFactor( frameInfo.iOverallSizeInPixels, |
|
454 TSize( KDefaultBitmapSizeWidth, KDefaultBitmapSizeHeight ) ); |
|
455 if ( iImageDecoder->ReducedSize( frameInfo.iOverallSizeInPixels, reductionfactor, convertedBitmapSize ) ) |
|
456 { |
|
457 convertedBitmapSize = frameInfo.iOverallSizeInPixels; |
|
458 } |
|
459 |
|
460 #ifdef _DEBUG |
|
461 RDebug::Print( _L( "VideoSource [%d]: convertedBitmapSize Width = %d convertedBitmapSize Height = %d" ), |
|
462 threadId, convertedBitmapSize.iWidth, convertedBitmapSize.iHeight ); |
|
463 #endif // _DEBUG |
|
464 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConvertAndScale() iConverted"), RThread().Id().operator TUint())); |
|
465 iConverted = CVtImageBitmap::NewL( convertedBitmapSize, iDisplayMode ); |
|
466 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConvertAndScale() iConverted"), RThread().Id().operator TUint())); |
|
467 #ifdef _DEBUG |
|
468 RDebug::Print( _L( "VideoSource [%d]: convBitmap Width = %d convBitmap Height = %d" ), |
|
469 threadId, iConverted->Size().iWidth, iConverted->Size().iHeight ); |
|
470 #endif // _DEBUG |
|
471 |
|
472 iStartTime.HomeTime(); |
|
473 if ( iFreeQueue.Count() < 2 ) |
|
474 { |
|
475 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ConvertAndScale() iFreeQueue.Count() < 2 "), RThread().Id().operator TUint())); |
|
476 iOldBM = ETrue; |
|
477 iOldBitmap = iScaled; |
|
478 } |
|
479 iScaled = iFreeQueue[ 0 ]; |
|
480 iFreeQueue.Remove( 0 ); |
|
481 iLoopAo->RemoveFreeBitmaps( 1 ); |
|
482 iActiveWaitInit->InitializeWaiter( &CMultiframeProvider::ConversionFinished ); |
|
483 // Check if masking is supported |
|
484 if ( frameInfo.iFlags & TFrameInfo::ETransparencyPossible ) |
|
485 { |
|
486 // Create mask for bitmap |
|
487 iMask = new ( ELeave )CFbsBitmap(); |
|
488 User::LeaveIfError( iMask->Create( convertedBitmapSize, EGray256 )); |
|
489 iTempBM = CVtImageBitmap::NewL( convertedBitmapSize, iDisplayMode ); |
|
490 iImageDecoder->Convert( iActiveWaitInit->RequestStatus(), iTempBM->Bitmap(), *iMask, aFrameIndex ); |
|
491 } |
|
492 // No mask |
|
493 else |
|
494 { |
|
495 iImageDecoder->Convert( iActiveWaitInit->RequestStatus(), iConverted->Bitmap(), aFrameIndex ); |
|
496 } |
|
497 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConvertAndScale() <<"), RThread().Id().operator TUint())); |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CMultiframeProvider::ConversionFinished( TInt aError ) |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CMultiframeProvider::ConversionFinished( TInt aError ) |
|
505 { |
|
506 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ConversionFinished() >>"), RThread().Id().operator TUint())); |
|
507 if ( iCount == 1 || aError ) |
|
508 { |
|
509 // delete decoder if not needed any more |
|
510 // 1) single frame image, no further frames to convert |
|
511 // 2) error occured, decoder won't be used anyway |
|
512 __IF_DEBUG(Print(_L(" single frame image => destruct iImageDecoder, err %d"), aError ) ); |
|
513 delete iImageDecoder; |
|
514 iImageDecoder = NULL; |
|
515 } |
|
516 // no harm done if other than this used, handle would already be 0 |
|
517 iDefaultImageFile.Close(); |
|
518 if ( aError == KErrNone ) |
|
519 { |
|
520 iActiveWaitInitScale->InitializeWaiter( &CMultiframeProvider::BMSScalingFinished ); |
|
521 if ( iGSImage ) |
|
522 { |
|
523 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ConversionFinished() scale GS "), RThread().Id().operator TUint())); |
|
524 iVtImageScalerInit->Scale( *iGSBitmap, *iScaled ); |
|
525 } |
|
526 else |
|
527 { |
|
528 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ConversionFinished() scale "), RThread().Id().operator TUint())); |
|
529 // Blit mask into a converted bitmap |
|
530 if ( iMask ) |
|
531 { |
|
532 CGraphicsContext* bitmapcontext = NULL; |
|
533 CFbsBitmapDevice* bitmapdevice = NULL; |
|
534 // Create bm device |
|
535 TRAPD( error, bitmapdevice = CFbsBitmapDevice::NewL( &( iConverted->Bitmap() ) ) ); |
|
536 if ( error != KErrNone ) |
|
537 { |
|
538 iObserver->NotifyImageHandlingError( aError ); |
|
539 delete bitmapdevice; |
|
540 delete iTempBM; |
|
541 delete iMask; |
|
542 iMask = NULL; |
|
543 iTempBM = NULL; |
|
544 return; |
|
545 } |
|
546 // Create GC for bm |
|
547 error = bitmapdevice->CreateContext( bitmapcontext ); |
|
548 if ( error != KErrNone ) |
|
549 { |
|
550 iObserver->NotifyImageHandlingError( aError ); |
|
551 delete bitmapdevice; |
|
552 delete bitmapcontext; |
|
553 delete iTempBM; |
|
554 delete iMask; |
|
555 iMask = NULL; |
|
556 iTempBM = NULL; |
|
557 return; |
|
558 } |
|
559 // Fill destination bitmap with white color |
|
560 TRect rect( iConverted->Size() ); |
|
561 bitmapcontext->SetBrushStyle( CGraphicsContext:: ESolidBrush ); |
|
562 bitmapcontext->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
563 bitmapcontext->SetBrushColor( KRgbWhite ); |
|
564 bitmapcontext->SetPenColor( KRgbWhite); |
|
565 bitmapcontext->DrawRect( rect ); |
|
566 |
|
567 // Draw mask and data bitmap into a same destination bm |
|
568 bitmapcontext->DrawBitmapMasked( iConverted->Size(), &( iTempBM->Bitmap() ), iConverted->Size(), iMask, EFalse ); |
|
569 delete bitmapdevice; |
|
570 delete bitmapcontext; |
|
571 delete iTempBM; |
|
572 delete iMask; |
|
573 iMask = NULL; |
|
574 iTempBM = NULL; |
|
575 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ConversionFinished() iMask"), RThread().Id().operator TUint())); |
|
576 } |
|
577 iVtImageScalerInit->Scale( *iConverted, *iScaled ); |
|
578 } |
|
579 } |
|
580 // Allways inform Decoding problems |
|
581 else |
|
582 { |
|
583 iObserver->NotifyImageHandlingError( aError ); |
|
584 delete iTempBM; |
|
585 delete iMask; |
|
586 iMask = NULL; |
|
587 iTempBM = NULL; |
|
588 // GIF used when error happen |
|
589 if ( iCount > 1 ) |
|
590 { |
|
591 iCount = 1; |
|
592 } |
|
593 } |
|
594 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ConversionFinished() error %d <<"), RThread().Id().operator TUint(), aError)); |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CMultiframeProvider::BMSScalingFinished( TInt aError ) |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CMultiframeProvider::BMSScalingFinished( TInt aError ) |
|
602 { |
|
603 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::BMSScalingFinished() >>"), RThread().Id().operator TUint())); |
|
604 if ( aError == KErrNone ) |
|
605 { |
|
606 VFScalingReady(); |
|
607 } |
|
608 else |
|
609 { |
|
610 #if 0 |
|
611 if ( aError != KErrCancel ) // If KErrCancel, then ignore error! |
|
612 { |
|
613 iObserver->NotifyImageHandlingError( aError ); |
|
614 } |
|
615 //Needs to be deleted also in cancel case |
|
616 delete iConverted; iConverted = NULL; |
|
617 #endif |
|
618 delete iConverted; iConverted = NULL; |
|
619 iObserver->NotifyImageHandlingError( aError ); |
|
620 |
|
621 } |
|
622 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::BMSScalingFinished() err %d <<"), RThread().Id().operator TUint(), aError)); |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // CMultiframeProvider::AddBitmapToFreeQueue( CVtImageBitmap* aBitmap ) |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 void CMultiframeProvider::AddBitmapToFreeQueue() |
|
630 { |
|
631 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::AddBitmapToFreeQueue() >>"), RThread().Id().operator TUint())); |
|
632 if ( iOldBM ) |
|
633 { |
|
634 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::AddBitmapToFreeQueue() OLD BM"), RThread().Id().operator TUint())); |
|
635 iOldBM = EFalse; |
|
636 User::LeaveIfError( iFreeQueue.Append( iOldBitmap ) ); |
|
637 } |
|
638 else |
|
639 { |
|
640 User::LeaveIfError( iFreeQueue.Append( iScaled ) ); |
|
641 } |
|
642 iLoopAo->SetFreeBitmaps( 1 ); |
|
643 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::AddBitmapToFreeQueue() <<"), RThread().Id().operator TUint())); |
|
644 } |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // CMultiframeProvider::UseSecondVfBuffer() |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CMultiframeProvider::UseSecondVfBuffer() |
|
651 { |
|
652 iSecondVFBuffer = ETrue; |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // CMultiframeProvider::VFScalingReady() |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 void CMultiframeProvider::VFScalingReady() |
|
660 { |
|
661 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady() >>"), RThread().Id().operator TUint())); |
|
662 delete iConverted; iConverted = 0; |
|
663 |
|
664 // Calculate frame update delay here! |
|
665 TTime refpointtime; |
|
666 refpointtime.HomeTime(); |
|
667 TTimeIntervalMicroSeconds deltaTime = refpointtime.MicroSecondsFrom( iStartTime ); |
|
668 iFrameUpdateTime = iDelay.Int64() - deltaTime.Int64(); |
|
669 if ( iFrameUpdateTime < 0 ) |
|
670 { |
|
671 iFrameUpdateTime = 1; |
|
672 } |
|
673 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady() iFrameUpdateTime %d>>"), RThread().Id().operator TUint(), iFrameUpdateTime.Int64())); |
|
674 // Scale VF to fit in requested size |
|
675 // size is as default QCIF |
|
676 if ( iIsVfStopped ) |
|
677 { |
|
678 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady()VF Stop>>"), RThread().Id().operator TUint())); |
|
679 if ( iActiveWaitScale->IsActive() ) |
|
680 { |
|
681 //ScaleCopy running |
|
682 //Waiting is OK |
|
683 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady()ScaleCopy running>>"), RThread().Id().operator TUint())); |
|
684 } |
|
685 else |
|
686 { |
|
687 //ScaleCopy is not running, Jump ScaleCopy |
|
688 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady()jump ScaleCopy>>"), RThread().Id().operator TUint())); |
|
689 iActiveWaitScale->InitializeWaiter( &CMultiframeProvider::VFRescalingFinished ); |
|
690 iActiveWaitScale->Signal(KErrNone); |
|
691 } |
|
692 } |
|
693 else |
|
694 { |
|
695 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady()Normal run>>"), RThread().Id().operator TUint())); |
|
696 iVFUpdate = EFalse; |
|
697 ScaleCopy( iTargetSize ); |
|
698 } |
|
699 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFScalingReady() <<"), RThread().Id().operator TUint())); |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // CMultiframeProvider::ScaleCopy( TSize& aSize ) |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 void CMultiframeProvider::ScaleCopy( TSize& aSize, TBool aVFUpdate ) |
|
707 { |
|
708 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ScaleCopy() >>"), RThread().Id().operator TUint())); |
|
709 |
|
710 iVFUpdate = aVFUpdate; |
|
711 iVFSize = aSize; |
|
712 if ( iSecondVFBuffer && !iFirstVFBuffer ) |
|
713 { |
|
714 iVFbitmap = iSecondVfBuf; |
|
715 iSecondVFBuffer = EFalse; |
|
716 iFirstVFBuffer = ETrue; |
|
717 } |
|
718 else |
|
719 { |
|
720 iVFbitmap = iFirstVfBuf; |
|
721 iFirstVFBuffer = EFalse; |
|
722 } |
|
723 //If Scaling is ongoing |
|
724 if ( iActiveWaitScale->IsActive() ) |
|
725 { |
|
726 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ScaleCopy(): active, storing size"), RThread().Id().operator TUint())); |
|
727 iWantedVFSize = aSize; |
|
728 } |
|
729 else |
|
730 { |
|
731 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ScaleCopy(): scaling NOW"), RThread().Id().operator TUint())); |
|
732 iActiveWaitScale->InitializeWaiter( &CMultiframeProvider::VFRescalingFinished ); |
|
733 TInt result( iVFbitmap->Bitmap().Resize( aSize ) ); |
|
734 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeProvider::ScaleCopy() result %d <<"), RThread().Id().operator TUint(), result)); |
|
735 if ( result != KErrNone ) |
|
736 { |
|
737 iActiveWaitScale->Signal( result ); |
|
738 } |
|
739 else |
|
740 { |
|
741 iVtImageScalerScale->Scale( *iScaled, *iVFbitmap ); |
|
742 } |
|
743 } |
|
744 } |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CMultiframeProvider::NextFrame() |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CMultiframeProvider::NextFrame() |
|
750 { |
|
751 iFreezeCS.Wait(); |
|
752 iInitialization = EFalse; |
|
753 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::NextFrame() >>"), RThread().Id().operator TUint())); |
|
754 |
|
755 if ( iNumOfConsumers < 1 ) |
|
756 { |
|
757 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::NextFrame() Consumer < 1>>"), RThread().Id().operator TUint())); |
|
758 iFreezeCS.Signal(); |
|
759 return; |
|
760 } |
|
761 |
|
762 if (iCount > 1 && !iActiveWaitInit->IsActive() ) |
|
763 { |
|
764 if (iWaitForConverting) |
|
765 { |
|
766 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::NextFrame() Because CMultiframeloopAO::RunL is executing, so Signal is not needed"), RThread().Id().operator TUint())); |
|
767 } |
|
768 else |
|
769 { |
|
770 iLoopAo->Signal(); |
|
771 } |
|
772 } |
|
773 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::NextFrame() <<"), RThread().Id().operator TUint())); |
|
774 iFreezeCS.Signal(); |
|
775 } |
|
776 |
|
777 // ----------------------------------------------------------------------------- |
|
778 // CMultiframeProvider::IncreaseDataConsumer() |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 void CMultiframeProvider::IncreaseDataConsumer() |
|
782 { |
|
783 iFreezeCS.Wait(); |
|
784 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::IncreaseDataConsumer() >>"), RThread().Id().operator TUint())); |
|
785 ++iNumOfConsumers; |
|
786 iFreezeCS.Signal(); |
|
787 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::IncreaseDataConsumer() <<"), RThread().Id().operator TUint())); |
|
788 } |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // CMultiframeProvider::DecreaseDataConsumer() |
|
792 // ----------------------------------------------------------------------------- |
|
793 // |
|
794 void CMultiframeProvider::DecreaseDataConsumer() |
|
795 { |
|
796 iFreezeCS.Wait(); |
|
797 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::DecreaseDataConsumer() >>"), RThread().Id().operator TUint())); |
|
798 --iNumOfConsumers; |
|
799 if ( iNumOfConsumers < 1 ) |
|
800 { |
|
801 iLoopAo->CancelDataLoop(); |
|
802 iDataTimer->CancelTimeLoop(); |
|
803 } |
|
804 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::DecreaseDataConsumer() <<"), RThread().Id().operator TUint())); |
|
805 iFreezeCS.Signal(); |
|
806 } |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CMultiframeProvider::ScaleVF( const TSize& aSize ) |
|
809 // ----------------------------------------------------------------------------- |
|
810 // |
|
811 void CMultiframeProvider::ScaleVF( const TSize& aSize ) |
|
812 { |
|
813 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScaleVF() >>"), RThread().Id().operator TUint())); |
|
814 iActiveWaitScale->InitializeWaiter( &CMultiframeProvider::VFRescalingFinished ); |
|
815 TInt result( iVFbitmap->Bitmap().Resize( aSize ) ); |
|
816 ClearVFScalingTargetSize(); |
|
817 if ( result != KErrNone ) |
|
818 { |
|
819 iActiveWaitScale->Signal( result ); |
|
820 } |
|
821 else |
|
822 { |
|
823 iVtImageScalerScale->Scale( *iScaled, *iVFbitmap ); |
|
824 } |
|
825 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScaleVF() result %d <<"), RThread().Id().operator TUint(), result)); |
|
826 } |
|
827 |
|
828 // ----------------------------------------------------------------------------- |
|
829 // CMultiframeProvider::VFRescalingFinished( TInt aError ) |
|
830 // ----------------------------------------------------------------------------- |
|
831 // |
|
832 void CMultiframeProvider::VFRescalingFinished( TInt aError ) |
|
833 { |
|
834 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFRescalingFinished() >>"), RThread().Id().operator TUint())); |
|
835 if ( aError == KErrNone ) |
|
836 { |
|
837 if ( iWantedVFSize != TSize() ) |
|
838 { |
|
839 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFRescalingFinished() REScaling needed"), RThread().Id().operator TUint())); |
|
840 ScaleVF( iWantedVFSize ); |
|
841 ClearVFScalingTargetSize(); |
|
842 } |
|
843 else |
|
844 { |
|
845 iDataTimer->CancelTimeLoop(); |
|
846 |
|
847 if ( !iIsVfStopped && !iVFUpdate ) |
|
848 { |
|
849 //Normally, VF and VS work |
|
850 iVFCurrent = iVFbitmap; |
|
851 iYUVBitMap = iScaled; |
|
852 iDataTimer->LocalBuffer(iVFCurrent); |
|
853 iDataTimer->RemoteBuffer(iYUVBitMap); |
|
854 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScalecopyRemoteAndUpdate() normal, iFrameUpdateTime %d>>"), RThread().Id().operator TUint(), |
|
855 iFrameUpdateTime.Int64())); |
|
856 iDataTimer->Activate(iFrameUpdateTime, iInitialization, iVFUpdate); |
|
857 } |
|
858 else if ( iIsVfStopped && !iVFUpdate ) |
|
859 { |
|
860 //VF doesn't work. |
|
861 iYUVBitMap = iScaled; |
|
862 iDataTimer->RemoteBuffer(iYUVBitMap); |
|
863 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScalecopyRemoteAndUpdate() VF Stop, iFrameUpdateTime %d>>"), RThread().Id().operator TUint(), |
|
864 iFrameUpdateTime.Int64())); |
|
865 iDataTimer->Activate( iFrameUpdateTime, iInitialization, iVFUpdate); |
|
866 } |
|
867 else if ( iIsVfStopped && iVFUpdate ) |
|
868 { |
|
869 //VF restart |
|
870 iIsVfStopped = EFalse; |
|
871 iVFUpdate = EFalse; |
|
872 iVFCurrent = iVFbitmap; |
|
873 iYUVBitMap = iScaled; |
|
874 iDataTimer->LocalBuffer(iVFCurrent); |
|
875 iDataTimer->RemoteBuffer(iYUVBitMap); |
|
876 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScalecopyRemoteAndUpdate() VF Restart iFrameUpdateTime 1>>"), |
|
877 RThread().Id().operator TUint())); |
|
878 iDataTimer->Activate(1, iInitialization, iVFUpdate); |
|
879 } |
|
880 else |
|
881 { |
|
882 //maybe this condition never execute. |
|
883 iVFCurrent = iVFbitmap; |
|
884 iDataTimer->LocalBuffer(iVFCurrent); |
|
885 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ScalecopyRemoteAndUpdate() last one, iFrameUpdateTime %d>>"), RThread().Id().operator TUint(), |
|
886 iFrameUpdateTime.Int64())); |
|
887 iDataTimer->Activate( 1, iInitialization, iVFUpdate); |
|
888 } |
|
889 } |
|
890 } |
|
891 #if 0 |
|
892 else if ( ( aError == KErrCancel ) ) |
|
893 { |
|
894 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFRescalingFinished() CANCEL"), RThread().Id().operator TUint())); |
|
895 } |
|
896 else if( aError != KErrCancel ) // If KErrCancel, then ignore error! |
|
897 { |
|
898 iObserver->NotifyImageHandlingError( aError ); |
|
899 } |
|
900 #endif |
|
901 else |
|
902 { |
|
903 iObserver->NotifyImageHandlingError( aError ); |
|
904 } |
|
905 |
|
906 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::VFRescalingFinished() err %d <<"), RThread().Id().operator TUint(), aError)); |
|
907 } |
|
908 |
|
909 // ----------------------------------------------------------------------------- |
|
910 // CMultiframeProvider::IsVFStopped() |
|
911 // ----------------------------------------------------------------------------- |
|
912 // |
|
913 TBool CMultiframeProvider::IsVFStopped() |
|
914 { |
|
915 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::IsVFStopped() >>"), RThread().Id().operator TUint())); |
|
916 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::IsVFStopped() <<"), RThread().Id().operator TUint())); |
|
917 return iIsVfStopped; |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CMultiframeProvider::SetVFStop() |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 void CMultiframeProvider::SetVFStop() |
|
925 { |
|
926 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::SetVFStop() >>"), RThread().Id().operator TUint())); |
|
927 iIsVfStopped = ETrue; |
|
928 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::SetVFStop() <<"), RThread().Id().operator TUint())); |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CMultiframeProvider::WaitForConverting() |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 void CMultiframeProvider::WaitForConverting() |
|
936 { |
|
937 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::WaitForConverting() >>"), RThread().Id().operator TUint())); |
|
938 iWaitForConverting = ETrue; |
|
939 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::WaitForConverting() <<"), RThread().Id().operator TUint())); |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CMultiframeProvider::WaitForConverting() |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 void CMultiframeProvider::ReleaseForConverting() |
|
947 { |
|
948 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ReleaseForConverting() >>"), RThread().Id().operator TUint())); |
|
949 iWaitForConverting = EFalse; |
|
950 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ReleaseForConverting() <<"), RThread().Id().operator TUint())); |
|
951 } |
|
952 |
|
953 // ----------------------------------------------------------------------------- |
|
954 // CMultiframeProvider::ClearVFScalingTargetSize() |
|
955 // ----------------------------------------------------------------------------- |
|
956 // |
|
957 void CMultiframeProvider::ClearVFScalingTargetSize() |
|
958 { |
|
959 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ClearVFScalingTargetSize() >>"), RThread().Id().operator TUint())); |
|
960 iWantedVFSize = TSize(); |
|
961 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::ClearVFScalingTargetSize() <<"), RThread().Id().operator TUint())); |
|
962 } |
|
963 |
|
964 // ----------------------------------------------------------------------------- |
|
965 // CMultiframeProvider::CancelInitializing() |
|
966 // ----------------------------------------------------------------------------- |
|
967 // |
|
968 TBool CMultiframeProvider::CancelInitializing() |
|
969 { |
|
970 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CancelInitializing() >>"), RThread().Id().operator TUint())); |
|
971 TBool lResult = EFalse; |
|
972 |
|
973 if ( NULL == iImageDecoder ) |
|
974 { |
|
975 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CancelInitializing() iImageDecoder is NULL ==="), RThread().Id().operator TUint())); |
|
976 // In this condition, Convert is already finished |
|
977 if ( iVtImageScalerInit->IsActive() ) |
|
978 { |
|
979 __IF_DEBUG(Print(_L("VideoSource[%d] Line[%d]: CMultiframeProvider::CancelInitializing() iVtImageScalerInit->Cancel ==="), |
|
980 RThread().Id().operator TUint(), __LINE__)); |
|
981 iVtImageScalerInit->Cancel(); |
|
982 } |
|
983 else if ( iActiveWaitInitScale->IsActive() ) |
|
984 { |
|
985 __IF_DEBUG(Print(_L("VideoSource[%d] Line[%d]: CMultiframeProvider::CancelInitializing() iActiveWaitInitScale->Cancel ==="), |
|
986 RThread().Id().operator TUint(), __LINE__)); |
|
987 iActiveWaitInitScale->Cancel(); |
|
988 } |
|
989 else if ( iVtImageScalerScale->IsActive() ) |
|
990 { |
|
991 __IF_DEBUG(Print(_L("VideoSource[%d] Line[%d]: CMultiframeProvider::CancelInitializing() iVtImageScalerScale->Cancel ==="), |
|
992 RThread().Id().operator TUint(), __LINE__)); |
|
993 iVtImageScalerScale->Cancel(); |
|
994 } |
|
995 else if ( iActiveWaitScale->IsActive() ) |
|
996 { |
|
997 __IF_DEBUG(Print(_L("VideoSource[%d] Line[%d]: CMultiframeProvider::CancelInitializing() iActiveWaitScale->Cancel ==="), |
|
998 RThread().Id().operator TUint(), __LINE__)); |
|
999 iActiveWaitScale->Cancel(); |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 //In this condition, the convert,scale,copyScale were finished, |
|
1004 //so do nothing, Waiting for InitializeReady() |
|
1005 __IF_DEBUG(Print(_L("VideoSource[%d] Line[%d]: CMultiframeProvider::CancelInitializing() Nothong to do,wait finish ==="), |
|
1006 RThread().Id().operator TUint(), __LINE__)); |
|
1007 } |
|
1008 } |
|
1009 else |
|
1010 { |
|
1011 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CancelInitializing() cancel convert ==="), RThread().Id().operator TUint())); |
|
1012 //Convert is not finished, so we can cancel it, and return ETrue |
|
1013 iImageDecoder->Cancel(); |
|
1014 lResult = ETrue; |
|
1015 } |
|
1016 |
|
1017 __IF_DEBUG(Print(_L("VideoSource[%d]: CMultiframeProvider::CancelInitializing() <<"), RThread().Id().operator TUint())); |
|
1018 return lResult; |
|
1019 } |
|
1020 |
|
1021 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1022 |
|
1023 // End of File |
|
1024 |