|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Not for public use |
|
15 // Abstract threaded relay between Image{Decoder,Encoder} and Priv object |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __THREAD_RELAY_H__ |
|
20 #define __THREAD_RELAY_H__ |
|
21 |
|
22 #include "GenThreadRelay.h" |
|
23 #include "ImageRelay.h" |
|
24 #include "iclextproxystubutil.h" |
|
25 |
|
26 class TCustomSyncParams |
|
27 { |
|
28 public: |
|
29 TRequestStatus* iRequestStatus; |
|
30 TInt iParam; |
|
31 }; |
|
32 |
|
33 class TDecodeSetFileParams |
|
34 { |
|
35 public: |
|
36 const TDesC* iSourceFilename; |
|
37 CImageDecoder::TOptions iOptions; |
|
38 }; |
|
39 class TDecodeSetFileHandleParams |
|
40 { |
|
41 public: |
|
42 RFile* iFile; |
|
43 CImageDecoder::TOptions iOptions; |
|
44 }; |
|
45 |
|
46 class TDecodeSetDataParams |
|
47 { |
|
48 public: |
|
49 const TDesC8* iSourceData; |
|
50 CImageDecoder::TOptions iOptions; |
|
51 }; |
|
52 |
|
53 class TDecodeConvertParams |
|
54 { |
|
55 public: |
|
56 TRequestStatus* iRequestStatus; |
|
57 TInt iDestinationHandle; |
|
58 TInt iDestinationMaskHandle; |
|
59 TInt iFrameNumber; |
|
60 }; |
|
61 |
|
62 class TEncodeSetFileParams |
|
63 { |
|
64 public: |
|
65 const TDesC* iDestinationFilename; |
|
66 CImageEncoder::TOptions iOptions; |
|
67 }; |
|
68 |
|
69 class TEncodeSetFileHandleParams |
|
70 { |
|
71 public: |
|
72 RFile* iFile; |
|
73 CImageEncoder::TOptions iOptions; |
|
74 }; |
|
75 |
|
76 class TEncodeSetDataParams |
|
77 { |
|
78 public: |
|
79 HBufC8** iDestinationData; |
|
80 CImageEncoder::TOptions iOptions; |
|
81 }; |
|
82 |
|
83 class TEncodeConvertParams |
|
84 { |
|
85 public: |
|
86 TRequestStatus* iRequestStatus; |
|
87 TInt iSourceHandle; |
|
88 const CFrameImageData* iFrameImageData; |
|
89 }; |
|
90 |
|
91 class CBufferCopyListener; // declared here |
|
92 /** |
|
93 * |
|
94 * This class is not for public use |
|
95 * To avoid simultaneous update problems on buffer copy on descriptors, |
|
96 * this will be done in the main thread. This AO wait for buffer copy requests |
|
97 * and do the copy in the main thread. |
|
98 * |
|
99 */ |
|
100 NONSHARABLE_CLASS( CBufferCopyListener ): public CActive |
|
101 { |
|
102 public: |
|
103 static CBufferCopyListener* NewL(const RThread* aSubThread); |
|
104 virtual ~CBufferCopyListener(); |
|
105 |
|
106 void CopyBufferToDescriptor(TRequestStatus& aCallerStatus, TDes8& aBuffer, const TDesC8& aSource, TInt aPosition, TInt aSize); |
|
107 |
|
108 protected: |
|
109 //From CActive |
|
110 void RunL(); |
|
111 void DoCancel(); |
|
112 |
|
113 private: |
|
114 CBufferCopyListener(const RThread* aSubThread); |
|
115 void Prime(); |
|
116 void DoBufferCopy(); |
|
117 |
|
118 private: |
|
119 TRequestStatus* iCallerStatus; //not owned |
|
120 TDes8* iBuffer; //not owned |
|
121 const TDesC8* iSource; //not owned |
|
122 TInt iPosition; |
|
123 TInt iSize; |
|
124 const RThread* iSubThread; //not owned |
|
125 }; |
|
126 |
|
127 /** |
|
128 * |
|
129 * This class is not for public use |
|
130 * Implement client side thread interface for threaded De/Encoding |
|
131 * |
|
132 */ |
|
133 class CImageConvOperationStub; |
|
134 class CImageConvScalerStub; |
|
135 class CImageConvStreamedDecodeStub; |
|
136 class CThreadDecoderRelay; |
|
137 class CSubThreadDecoderRelay; // declared here |
|
138 NONSHARABLE_CLASS( CSubThreadDecoderRelay ): public CSubThreadRelay, |
|
139 public MImageDecoderPrivSupport |
|
140 { |
|
141 public: |
|
142 enum TFunctionCode |
|
143 { |
|
144 EFunctionTerminate = KTerminationFunction, |
|
145 EFunctionCancel, |
|
146 EFunctionSetFile, |
|
147 EFunctionSetData, |
|
148 EFunctionContinueHeader, |
|
149 EFunctionConvert, |
|
150 EFunctionConvertMask, |
|
151 EFunctionContinueConvert, |
|
152 EFunctionHandleNewImage, |
|
153 EFunctionCustomSync, |
|
154 EFunctionCustomAsync, |
|
155 EFunctionSetFileHandle, |
|
156 EFunctionGetExtension, |
|
157 EFunctionExecuteCommandL, |
|
158 EFunctionExecuteAsyncCommand |
|
159 }; |
|
160 |
|
161 public: |
|
162 static CSubThreadRelay* NewL(TThreadId aMainThreadId, TAny* aDecoderParam); |
|
163 virtual ~CSubThreadDecoderRelay(); |
|
164 |
|
165 void SetFunctionInProgress(); |
|
166 void ResetFunctionInProgress(); |
|
167 |
|
168 void AbortDecode(); |
|
169 void CancelBody(); |
|
170 |
|
171 TInt FrameCount() const; |
|
172 |
|
173 void SetFileL(const TDesC& aSourceFilename, const CImageDecoder::TOptions aOptions); |
|
174 void SetFileL(RFile& aFile, const CImageDecoder::TOptions aOptions); |
|
175 void SetDataL(const TDesC8& aSourceData, const CImageDecoder::TOptions aOptions); |
|
176 |
|
177 void ContinueProcessingHeaderL(); |
|
178 |
|
179 void Convert(TRequestStatus* aRequestStatus, TInt aDestinationHandle, TInt aFrameNumber); |
|
180 void Convert(TRequestStatus* aRequestStatus, TInt aDestinationHandle, TInt aDestinationMaskHandle, TInt aFrameNumber); |
|
181 void ContinueConvert(TRequestStatus* aRequestStatus); |
|
182 |
|
183 void HandleNewlyOpenedImageL(); |
|
184 |
|
185 void CustomSyncL(TInt aParam); |
|
186 void CustomAsync(TRequestStatus* aRequestStatus, TInt aParam); |
|
187 |
|
188 void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr); |
|
189 void HandleExecuteCommandL(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
190 void HandleExecuteAsyncCommand(TExecuteCommandParamsAsyncBase& aExecuteCommandBase); |
|
191 |
|
192 //From MImageDecoderPrivSupport |
|
193 TBool MustUseBufferWithDescriptor() const; |
|
194 void CopyBufferToDescriptor(TDes8& aBuffer, const TDesC8& aSource, TInt aPosition, TInt aSize); |
|
195 TBool AmInThread() const; |
|
196 TBool ShouldAbort() const; |
|
197 void Lock(); |
|
198 void Unlock(); |
|
199 void SaveFrameCount(TInt aFrameCount); |
|
200 |
|
201 //From MImageDecoderPriv |
|
202 void SetIntent(TIntent aIntent); |
|
203 void SetUniqueIdL(const TDesC& aUniqueId); |
|
204 TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue); |
|
205 |
|
206 protected: |
|
207 //From CThreadRelay |
|
208 void RunFunctionL(TInt aFunctionCode, TAny* aParameters); |
|
209 |
|
210 private: |
|
211 CSubThreadDecoderRelay(CBufferCopyListener* aBufferCopyListener); |
|
212 void ConstructL(TThreadId aMainThreadId, CImageDecodeConstruct* aConstruct); |
|
213 |
|
214 private: |
|
215 CImageDecoderPriv* iBody; |
|
216 |
|
217 CFbsBitmap* iDestination; //Duplicate the client bitmap in this thread |
|
218 CFbsBitmap* iDestinationMask; //Duplicate the client mask bitmap in this thread |
|
219 RFs iFileSession; //This thread uses its own file session |
|
220 TInt iFrameCount; |
|
221 TBool iAbortDecode; |
|
222 RMutex iFrameTableMutex; |
|
223 |
|
224 RMutex iBufferCopyMutex; |
|
225 TBool iFunctionCallInProgress; //ETrue if a function call to this thread is in progress |
|
226 |
|
227 CBufferCopyListener* iBufferCopyListener; //not owned |
|
228 |
|
229 TRequestStatus* iCallerStatus; //not owned |
|
230 TDes8* iBuffer; //not owned |
|
231 const TDesC8* iSource; //not owned |
|
232 TInt iPosition; |
|
233 TInt iSize; |
|
234 |
|
235 // Framework Extension stubs |
|
236 RPointerArray<CImageConvStubBase> iStubs; |
|
237 |
|
238 friend class CThreadDecoderRelay; |
|
239 }; |
|
240 |
|
241 /** |
|
242 * |
|
243 * This class is not for public use |
|
244 * Implement client side thread interface for threaded De/Encoding |
|
245 * |
|
246 */ |
|
247 class CThreadEncoderRelay; |
|
248 class CSubThreadEncoderRelay; |
|
249 NONSHARABLE_CLASS( CSubThreadEncoderRelay ): public CSubThreadRelay, |
|
250 public MImageEncoderPrivSupport |
|
251 { |
|
252 public: |
|
253 enum TFunctionCode |
|
254 { |
|
255 EFunctionTerminate = KTerminationFunction, |
|
256 EFunctionCancel, |
|
257 EFunctionSetFile, |
|
258 EFunctionSetData, |
|
259 EFunctionConvert, |
|
260 EFunctionCustomSync, |
|
261 EFunctionCustomAsync, |
|
262 EFunctionSetFileHandle, |
|
263 EFunctionGetExtension, |
|
264 EFunctionExecuteCommandL, |
|
265 EFunctionExecuteAsyncCommand |
|
266 }; |
|
267 |
|
268 public: |
|
269 static CSubThreadRelay* NewL(TThreadId aMainThreadId, TAny* aEncoderParam); |
|
270 virtual ~CSubThreadEncoderRelay(); |
|
271 |
|
272 void AbortEncode(); |
|
273 void CancelBody(); |
|
274 |
|
275 void SetFileL(const TDesC& aDestinationFilename, const CImageEncoder::TOptions aOptions); |
|
276 void SetFileL(RFile& aFile, const CImageEncoder::TOptions aOptions); |
|
277 void SetDataL(HBufC8*& aDestinationData, const CImageEncoder::TOptions aOptions); |
|
278 void Convert(TRequestStatus* aRequestStatus, TInt aSourceHandle, const CFrameImageData* aFrameImageData); |
|
279 |
|
280 void CustomSyncL(TInt aParam); |
|
281 void CustomAsync(TRequestStatus* aRequestStatus, TInt aParam); |
|
282 |
|
283 void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr); |
|
284 void HandleExecuteCommandL(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
285 void HandleExecuteAsyncCommand(TExecuteCommandParamsAsyncBase& aExecuteCommandBase); |
|
286 |
|
287 //From MImageEncoderPrivSupport |
|
288 TBool AmInThread() const; |
|
289 TBool ShouldAbort() const; |
|
290 |
|
291 protected: |
|
292 virtual void RunFunctionL(TInt aFunctionCode, TAny* aParameters); |
|
293 |
|
294 private: |
|
295 CSubThreadEncoderRelay(); |
|
296 void ConstructL(TThreadId aMainThreadId, CImageEncodeConstruct* aConstruct); |
|
297 |
|
298 private: |
|
299 CImageEncoderPriv* iBody; |
|
300 |
|
301 CFbsBitmap* iSource; |
|
302 RFs iFileSession; //This thread use its own file session |
|
303 TBool iAbortEncode; |
|
304 |
|
305 // Framework Extension stubs |
|
306 RPointerArray<CImageConvStubBase> iStubs; |
|
307 |
|
308 friend class CThreadEncoderRelay; |
|
309 }; |
|
310 |
|
311 class CThreadDecoderRelay; |
|
312 /** |
|
313 * |
|
314 * This class is not for public use |
|
315 * Implement client side thread interface for threaded Decoding |
|
316 * |
|
317 */ |
|
318 NONSHARABLE_CLASS( CThreadDecoderRelay ): public CThreadRelay, |
|
319 public MImageDecoderRelay, |
|
320 public MImageConvExtensionThreadedSupport |
|
321 { |
|
322 public: |
|
323 static CThreadDecoderRelay* NewL(CImageDecodeConstruct* aConstruct); |
|
324 virtual ~CThreadDecoderRelay(); |
|
325 |
|
326 //From MImageDecoderRelay |
|
327 void Cancel(); |
|
328 |
|
329 void SetFileL(RFs& aFs, const TDesC& aSourceFilename, const CImageDecoder::TOptions aOptions = CImageDecoder::EOptionNone); |
|
330 void SetFileL(RFile& name, const CImageDecoder::TOptions aOptions = CImageDecoder::EOptionNone); |
|
331 void SetDataL(RFs& aFs, const TDesC8& aSourceData, const CImageDecoder::TOptions aOptions = CImageDecoder::EOptionNone); |
|
332 |
|
333 CImageDecoderPlugin* Plugin() const; |
|
334 |
|
335 void HandleNewlyOpenedImageL(); |
|
336 |
|
337 void Convert(TRequestStatus* aRequestStatus, CFbsBitmap& aDestination, TInt aFrameNumber); |
|
338 void Convert(TRequestStatus* aRequestStatus, CFbsBitmap& aDestination, CFbsBitmap& aDestinationMask, TInt aFrameNumber = 0); |
|
339 void ContinueConvert(TRequestStatus* aRequestStatus); |
|
340 |
|
341 void ContinueProcessingHeaderL(); |
|
342 |
|
343 const TFrameInfo& FrameInfo(TInt aFrameNumber) const; |
|
344 CFrameInfoStrings* FrameInfoStringsLC(TInt aFrameNumber); |
|
345 |
|
346 TUid ImplementationUid() const; |
|
347 |
|
348 TInt FrameCount() const; |
|
349 TBool IsImageHeaderProcessingComplete() const; |
|
350 const CFrameImageData& FrameData(TInt aFrameNumber) const; |
|
351 |
|
352 TInt NumberOfImageComments() const; |
|
353 HBufC* ImageCommentL(TInt aCommentNumber) const; |
|
354 TInt NumberOfFrameComments(TInt aFrameNumber) const; |
|
355 HBufC* FrameCommentL(TInt aFrameNumber, TInt aCommentNumber) const; |
|
356 |
|
357 // custom command support |
|
358 void CustomSyncL(TInt aParam); |
|
359 void CustomAsync(TRequestStatus* aRequestStatus, TInt aParam); |
|
360 |
|
361 void TransferConstructOwnership(); |
|
362 |
|
363 void SetIntent(TIntent aIntent); |
|
364 void SetUniqueIdL(const TDesC& aUniqueId); |
|
365 TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue); |
|
366 |
|
367 void SetImageTypeL(TInt aImageType); |
|
368 |
|
369 TInt ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const; |
|
370 TInt ReducedSize(const TSize& aOriginalSize, TInt aReductionFactor, TSize& aReducedSize) const; |
|
371 |
|
372 TInt SetDecoderThreadPriority(TThreadPriority aPriority); |
|
373 |
|
374 // from MImageDecoderRelay |
|
375 void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr); |
|
376 void SetClippingRectL(const TRect* aClipRect); |
|
377 TInt GetDestinationSize(TSize& aSize, TInt aFrameNumber = 0); |
|
378 CImageConvExtensionCache& ExtensionCache(); |
|
379 |
|
380 // from MImageConvExtensionThreadedSupport |
|
381 void ExecuteCommand(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
382 void ExecuteCommandL(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
383 void ExecuteAsyncCommand(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
384 |
|
385 |
|
386 private: |
|
387 CThreadDecoderRelay(CImageDecodeConstruct* aConstruct); |
|
388 void ConstructL(); |
|
389 |
|
390 void RunFunction(TInt aFunctionCode, TAny* aParameters); |
|
391 void RunFunctionL(TInt aFunctionCode, TAny* aParameters); |
|
392 |
|
393 private: |
|
394 CSubThreadDecoderRelay* iSubThreadDecoderRelay; //not owned |
|
395 CImageDecoderPriv* iBody; //not owned (for straight calls) |
|
396 TInt iOwnConstruct; |
|
397 CImageDecodeConstruct* iConstruct; |
|
398 CBufferCopyListener* iBufferCopyListener; //AO in main thread that listen for requests from sub thread |
|
399 CImageConvExtensionCache* iExtensionCache; |
|
400 }; |
|
401 |
|
402 class CThreadEncoderRelay; |
|
403 /** |
|
404 * |
|
405 * This class is not for public use |
|
406 * Implement client side thread interface for threaded Encoding |
|
407 * |
|
408 */ |
|
409 NONSHARABLE_CLASS( CThreadEncoderRelay ): public CThreadRelay, |
|
410 public MImageEncoderRelay, |
|
411 public MImageConvExtensionThreadedSupport |
|
412 { |
|
413 public: |
|
414 static CThreadEncoderRelay* NewL(CImageEncodeConstruct* aConstruct); |
|
415 virtual ~CThreadEncoderRelay(); |
|
416 |
|
417 //From MImageEncoderRelay |
|
418 void Cancel(); |
|
419 |
|
420 void SetFileL(RFs& aFs, const TDesC& aDestinationFilename, const CImageEncoder::TOptions aOptions); |
|
421 void SetFileL(RFile& name, const CImageEncoder::TOptions aOptions); |
|
422 void SetDataL(HBufC8*& aDestinationData, const CImageEncoder::TOptions aOptions); |
|
423 |
|
424 CImageEncoderPlugin* Plugin() const; |
|
425 |
|
426 void Convert(TRequestStatus* aRequestStatus, const CFbsBitmap& aSource, const CFrameImageData* aFrameImageData); |
|
427 |
|
428 TUid ImplementationUid() const; |
|
429 |
|
430 // Framework extension |
|
431 void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr); |
|
432 CImageConvExtensionCache& ExtensionCache(); |
|
433 |
|
434 // custom command support |
|
435 void CustomSyncL(TInt aParam); |
|
436 void CustomAsync(TRequestStatus* aRequestStatus, TInt aParam); |
|
437 |
|
438 void TransferConstructOwnership(); |
|
439 |
|
440 void SetThumbnail(TBool aDoGenerateThumbnail); |
|
441 |
|
442 TInt SetEncoderThreadPriority(TThreadPriority aPriority); |
|
443 |
|
444 // from MImageConvExtensionThreadedSupport |
|
445 void ExecuteCommand(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
446 void ExecuteCommandL(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
447 void ExecuteAsyncCommand(TExecuteCommandParamsBase& aExecuteCommandBase); |
|
448 |
|
449 private: |
|
450 CThreadEncoderRelay(CImageEncodeConstruct* aConstruct); |
|
451 void ConstructL(); |
|
452 |
|
453 void RunFunction(TInt aFunctionCode, TAny* aParameters); |
|
454 void RunFunctionL(TInt aFunctionCode, TAny* aParameters); |
|
455 |
|
456 private: |
|
457 TInt iOwnConstruct; |
|
458 CImageEncodeConstruct* iConstruct; |
|
459 CSubThreadEncoderRelay* iSubThreadEncoderRelay; //Not owned |
|
460 CImageEncoderPriv* iBody; //not owned (for straight calls) |
|
461 CImageConvExtensionCache* iExtensionCache; |
|
462 }; |
|
463 |
|
464 /** |
|
465 * |
|
466 * This class is not for public use |
|
467 * |
|
468 */ |
|
469 class TThreadDecoderRelayParam |
|
470 { |
|
471 public: |
|
472 CImageDecodeConstruct* iConstruct; |
|
473 CBufferCopyListener* iBufferCopyListener; |
|
474 }; |
|
475 |
|
476 /** |
|
477 * |
|
478 * This class is not for public use |
|
479 * |
|
480 */ |
|
481 class TThreadEncoderRelayParam |
|
482 { |
|
483 public: |
|
484 CImageEncodeConstruct* iConstruct; |
|
485 }; |
|
486 |
|
487 #endif // __THREAD_RELAY_H__ |
|
488 |