|
1 // Copyright (c) 2008-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 // |
|
15 |
|
16 #ifndef __IMAGE_PROCESSOR_IMPL_H__ |
|
17 #define __IMAGE_PROCESSOR_IMPL_H__ |
|
18 |
|
19 #include <imageconversion.h> |
|
20 |
|
21 #include <imageprocessor/imageprocessor.h> |
|
22 #include <imageprocessor/imageprocessorpluginobserver.h> |
|
23 |
|
24 namespace ImageProcessor |
|
25 { |
|
26 class CImgProcessor; |
|
27 class MImgProcessorPlugin; |
|
28 class MImgProcessorObserver; |
|
29 class CImageProcessorCallback; |
|
30 class TEffect; |
|
31 class TPreview; |
|
32 class TOverlay; |
|
33 class TProgressInfo; |
|
34 class TInputInfo; |
|
35 class TOutputInfo; |
|
36 namespace Plugin |
|
37 { |
|
38 class MEffect; |
|
39 class MPreview; |
|
40 class MOverlay; |
|
41 class MProgressInfo; |
|
42 class MInputInfo; |
|
43 class MOutputInfo; |
|
44 } |
|
45 |
|
46 NONSHARABLE_CLASS(CImageProcessorDrmInput) : public CBase |
|
47 { |
|
48 public: |
|
49 static CImageProcessorDrmInput* NewL(TMMSource& aDrmFile); |
|
50 |
|
51 public: |
|
52 void ExecuteIntentL(); |
|
53 ~CImageProcessorDrmInput(); |
|
54 |
|
55 inline HBufC8* Buffer(); |
|
56 |
|
57 private: |
|
58 void ConstructL(TMMSource& aDrmFile); |
|
59 |
|
60 private: |
|
61 HBufC8* iDecryptedBuffer; |
|
62 ContentAccess::CContent* iContent; |
|
63 ContentAccess::CData* iData; |
|
64 ContentAccess::TIntent iIntent; |
|
65 }; |
|
66 |
|
67 inline HBufC8* CImageProcessorDrmInput::Buffer() |
|
68 { |
|
69 return iDecryptedBuffer; |
|
70 } |
|
71 |
|
72 NONSHARABLE_CLASS(CImageProcessorImpl) : public CBase, public MImgProcessorPluginObserver |
|
73 { |
|
74 private: |
|
75 static const TBool iValidStates[CImgProcessor::EStatesCount][CImgProcessor::EStatesCount]; |
|
76 |
|
77 public: |
|
78 static CImageProcessorImpl* NewL(RFs& aFileServerSession,CImgProcessor& aImageProcessor,MImgProcessorObserver& aObserver,TUid aPluginUid); |
|
79 void Cleanup(); |
|
80 |
|
81 void SupportedEffectsL(RArray<TUid>& aEffects) const; |
|
82 |
|
83 void SupportedInputFormatsL(RArray<TUid>& aFormats) const; |
|
84 void SupportedInputSubFormatsL(TUid aFormat, RArray<TUid>& aSubFormats) const; |
|
85 void SupportedInputImageFrameFormatsL(RArray<TUid>& aFormats) const; |
|
86 void SupportedInputDisplayModesL(RArray<TDisplayMode>& aDisplayModes) const; |
|
87 |
|
88 void SupportedOutputFormatsL(RArray<TUid>& aFormats) const; |
|
89 void SupportedOutputSubFormatsL(TUid aFormat, RArray<TUid>& aSubFormats) const; |
|
90 void SupportedOutputImageFrameFormatsL(RArray<TUid>& aFormats) const; |
|
91 void SupportedOutputDisplayModesL(RArray<TDisplayMode>& aDisplayModes) const; |
|
92 |
|
93 TUint64 SupportedOptions() const; |
|
94 TUint SupportedOperations() const; |
|
95 |
|
96 CImgProcessor::TState State() const; |
|
97 TSize CurrentSizeL() const; |
|
98 TRgb BackgroundColorL() const; |
|
99 |
|
100 TInt CalculatePixelBufferSizeL(TSize aSizeInPixels, TDisplayMode aDisplayMode, TUint32 aScanLineLength = 0) const; |
|
101 TInt CalculatePixelBufferSizeL(TSize aSizeInPixels, const TUid& aFormat, TUint32 aScanLineLength = 0) const; |
|
102 |
|
103 void CreateInputL(CFbsBitmap& aBitmap); |
|
104 void CreateInputL(CImageFrame& aPixelBuffer); |
|
105 void CreateInputL(const TSize& aSize, const TRgb& aColor); |
|
106 |
|
107 void SetBackgroundColorL(const TRgb& aColor); |
|
108 |
|
109 void SetInputRectL(const TRect& aRect); |
|
110 |
|
111 void SetInputL(const TDesC& aFilename, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
112 void SetInputL(RFile& aFile, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
113 void SetInputL(TMMSource& aDrmFile, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
114 void SetInputL(const TDesC8& aBuffer, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
115 void SetInputL(const CFbsBitmap& aBitmap, const CFbsBitmap* aMask = NULL); |
|
116 void SetInputL(const CImageFrame& aPixelBuffer); |
|
117 void SetInputL(CImagePanorama& aPanorama); |
|
118 |
|
119 |
|
120 void SetOptionsL(TUint64 aOptions); |
|
121 void ApplyOperationL(CImgProcessor::TOperation aOperation); |
|
122 |
|
123 void InputUpdatedL(); |
|
124 void ResetL(); |
|
125 |
|
126 void InitializeL(TUint64 aOptions); |
|
127 |
|
128 void ProcessL(const TSize& aSize, TBool aMaintainAspectRatio); |
|
129 void Cancel(); |
|
130 |
|
131 TEffect* EffectL(TUid aEffect); |
|
132 |
|
133 TBool CanUndoL() const; |
|
134 void UndoL(); |
|
135 void UndoAllL(); |
|
136 |
|
137 TBool CanRedoL() const; |
|
138 void RedoL(); |
|
139 void RedoAllL(); |
|
140 |
|
141 TPreview* PreviewL(TInt aPreviewId); |
|
142 |
|
143 TOverlay* OverlayL(); |
|
144 |
|
145 TProgressInfo* ProgressInfoL(); |
|
146 TInputInfo* InputInfoL(); |
|
147 TOutputInfo* OutputInfoL(); |
|
148 |
|
149 void SetOutputL(const TDesC& aFilename, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
150 void SetOutputL(RFile& aFile, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
151 void SetOutputL(RBuf8& aBuffer, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid); |
|
152 void SetOutputL(CImageFrame& aPixelBuffer); |
|
153 void SetOutputL(CFbsBitmap& aBitmap, CFbsBitmap* aMask = NULL); |
|
154 |
|
155 TAny* Extension(TUid aExtension); |
|
156 |
|
157 // framework utility functions |
|
158 void ConvertMimeTypeToUidL(const TDesC8& aMimeType, TUid& aFormat, TUid& aSubFormat); |
|
159 void ConvertFileExtensionToUidL(const TDesC& aFileExtension, TUid& aFormat, TUid& aSubFormat); |
|
160 void ConvertUidToMimeTypeL(TDes8& aMimeType, const TUid& aFormat, const TUid& aSubFormat); |
|
161 void ConvertUidToFileExtensionL(TDes& aFileExtension, const TUid& aFormat, const TUid& aSubFormat); |
|
162 |
|
163 ~CImageProcessorImpl(); |
|
164 |
|
165 void PostEvent(TInt aEventId, TUid aUid, TInt aId, TInt aError); |
|
166 void ProcessEventL(TInt aEventId, TUid aUid, TInt aId, TInt aError); |
|
167 void SetStateL(CImgProcessor::TState aState); |
|
168 void RestoreStateL(); |
|
169 |
|
170 TBool IsBusy(CImgProcessor::TState aState) const; |
|
171 void CheckStateL(CImgProcessor::TState aState) const; |
|
172 |
|
173 void AppendOverlayDrmInputL(); |
|
174 |
|
175 inline RArray<TUid>& PreviewOutputImageFrameFormatsL(); |
|
176 inline RArray<TDisplayMode>& PreviewOutputDisplayModesL(); |
|
177 inline RArray<TUid>& OverlayInputFormatsL(); |
|
178 inline RArray<TUid>& OverlayInputImageFrameFormatsL(); |
|
179 inline RArray<TDisplayMode>& OverlayInputDisplayModesL(); |
|
180 |
|
181 inline void SetOverlayDrmInput(CImageProcessorDrmInput* aOverlayDrmInput); |
|
182 inline void ResetOverlayDrmInput(); |
|
183 |
|
184 inline TBool IsInputSet() const; |
|
185 inline TBool IsOutputSet() const; |
|
186 inline TUint64 Options() const; |
|
187 |
|
188 private: |
|
189 CImageProcessorImpl(RFs& aFileServerSession, CImgProcessor& aImageProcessor, TUid aPluginUid); |
|
190 void ConstructL(MImgProcessorObserver& aObserver); |
|
191 |
|
192 void CheckInputFormatL(const TUid& aFormat, const TUid& aSubFormat); |
|
193 void CheckOutputFormatL(const TUid& aFormat, const TUid& aSubFormat); |
|
194 TBool IsFrameworkEffect(TUid aEffect) const; |
|
195 TBool IsPluginEffect(TUid aEffect) const; |
|
196 void InitializeFrameworkEffectsL(); |
|
197 |
|
198 TEffect* FindEffect(TUid aEffect) const; |
|
199 TEffect* CreateEffectL(TUid aEffect); |
|
200 TEffect* EffectFactoryL(TUid aEffect, Plugin::MEffect* aPluginEffect); |
|
201 |
|
202 TPreview* FindPreview(TInt aPreviewId) const; |
|
203 |
|
204 private: |
|
205 RFs& iFileServerSession; |
|
206 CImgProcessor& iImageProcessor; |
|
207 TUid iPluginUid; |
|
208 |
|
209 CImgProcessor::TState iState; |
|
210 CImgProcessor::TState iPreviousState; |
|
211 |
|
212 CImageProcessorCallback* iCallbackHandler; |
|
213 |
|
214 MImgProcessorPlugin* iPlugin; |
|
215 TUid iPluginDtorKey; |
|
216 |
|
217 TOverlay* iOverlay; |
|
218 TProgressInfo* iProgressInfo; |
|
219 TInputInfo* iInputInfo; |
|
220 TOutputInfo* iOutputInfo; |
|
221 |
|
222 CImageProcessorDrmInput* iDrmInput; |
|
223 CImageProcessorDrmInput* iOverlayDrmInput; |
|
224 |
|
225 RPointerArray<TEffect> iEffects; |
|
226 RPointerArray<TPreview> iPreviews; |
|
227 RPointerArray<CImageProcessorDrmInput> iOverlayDrmInputs;// to keep all decrypted buffer during session |
|
228 |
|
229 RArray<TUid> iFrameworkEffects; |
|
230 RArray<TUid> iPluginEffects; |
|
231 RArray<TUid> iInputFormats; |
|
232 RArray<TUid> iInputImageFrameFormats; |
|
233 RArray<TDisplayMode> iInputDisplayModes; |
|
234 RArray<TUid> iOutputFormats; |
|
235 RArray<TUid> iOutputImageFrameFormats; |
|
236 RArray<TDisplayMode> iOutputDisplayModes; |
|
237 |
|
238 RArray<TUid> iPreviewOutputImageFrameFormats; |
|
239 RArray<TDisplayMode> iPreviewOutputDisplayModes; |
|
240 RArray<TUid> iOverlayInputFormats; |
|
241 RArray<TUid> iOverlayInputImageFrameFormats; |
|
242 RArray<TDisplayMode> iOverlayInputDisplayModes; |
|
243 |
|
244 RFileExtensionMIMETypeArray iTypesUtilityArray; |
|
245 |
|
246 TUint64 iSupportedOptions; |
|
247 TUint64 iOptions; |
|
248 TUint iSupportedOperations; |
|
249 |
|
250 TBool iIsInputSet; |
|
251 TBool iIsOutputSet; |
|
252 }; |
|
253 |
|
254 inline RArray<TUid>& CImageProcessorImpl::PreviewOutputImageFrameFormatsL() |
|
255 { |
|
256 return iPreviewOutputImageFrameFormats; |
|
257 } |
|
258 |
|
259 inline RArray<TDisplayMode>& CImageProcessorImpl::PreviewOutputDisplayModesL() |
|
260 { |
|
261 return iPreviewOutputDisplayModes; |
|
262 } |
|
263 |
|
264 inline RArray<TUid>& CImageProcessorImpl::OverlayInputFormatsL() |
|
265 { |
|
266 return iOverlayInputFormats; |
|
267 } |
|
268 |
|
269 inline RArray<TUid>& CImageProcessorImpl::OverlayInputImageFrameFormatsL() |
|
270 { |
|
271 return iOverlayInputImageFrameFormats; |
|
272 } |
|
273 |
|
274 inline RArray<TDisplayMode>& CImageProcessorImpl::OverlayInputDisplayModesL() |
|
275 { |
|
276 return iOverlayInputDisplayModes; |
|
277 } |
|
278 |
|
279 inline TBool CImageProcessorImpl::IsInputSet() const |
|
280 { |
|
281 return iIsInputSet; |
|
282 } |
|
283 |
|
284 inline TBool CImageProcessorImpl::IsOutputSet() const |
|
285 { |
|
286 return iIsOutputSet; |
|
287 } |
|
288 |
|
289 inline TUint64 CImageProcessorImpl::Options() const |
|
290 { |
|
291 return iOptions; |
|
292 } |
|
293 |
|
294 inline void CImageProcessorImpl::SetOverlayDrmInput(CImageProcessorDrmInput* aOverlayDrmInput) |
|
295 { |
|
296 ResetOverlayDrmInput(); |
|
297 iOverlayDrmInput = aOverlayDrmInput; |
|
298 } |
|
299 |
|
300 inline void CImageProcessorImpl::ResetOverlayDrmInput() |
|
301 { |
|
302 delete iOverlayDrmInput; |
|
303 iOverlayDrmInput = NULL; |
|
304 } |
|
305 |
|
306 } // ImageProcessor |
|
307 |
|
308 #endif //__IMAGE_PROCESSOR_IMPL_H__ |