|
1 // Copyright (c) 2004-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 #include "ImageDisplay.h" |
|
17 #include "ImageDisplayFramework.h" |
|
18 #include "ImageDisplayMain.h" |
|
19 |
|
20 /** |
|
21 Constructs a CImageDisplay object. |
|
22 |
|
23 @param aFs |
|
24 A reference to a file server session for the display API to use. |
|
25 @param aCallback |
|
26 A reference to a Image Display observer object which would recieve status notifications |
|
27 @return A pointer to a fully constructed CImageDisplay. |
|
28 |
|
29 */ |
|
30 EXPORT_C CImageDisplay* CImageDisplay::NewL(MIclImageDisplayObserver& aCallback, RFs& aFs) |
|
31 { |
|
32 CImageDisplay* self = new(ELeave) CImageDisplay(); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(aCallback, aFs); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 /** |
|
40 Constructor for this class. |
|
41 */ |
|
42 CImageDisplay::CImageDisplay() |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 /** |
|
48 Performs second phase of construction |
|
49 |
|
50 @param aCallback |
|
51 A reference to an observer interface implementation |
|
52 |
|
53 @param aFs |
|
54 A reference to a file server session for the display API to use. |
|
55 */ |
|
56 void CImageDisplay::ConstructL(MIclImageDisplayObserver& aCallback, RFs& aFs) |
|
57 { |
|
58 iBody = CImageDisplayFramework::NewL(*this, aCallback, aFs); |
|
59 } |
|
60 |
|
61 |
|
62 /** |
|
63 This is the destructor for this class |
|
64 and is responsible for deallocating all resources |
|
65 */ |
|
66 |
|
67 EXPORT_C CImageDisplay::~CImageDisplay() |
|
68 { |
|
69 delete iBody; |
|
70 } |
|
71 |
|
72 /** |
|
73 Specifies the UID of the image display plugin to load |
|
74 |
|
75 @param aPluginUid |
|
76 The plugin's implementation UID |
|
77 |
|
78 @panic ImageDisplay 1 EIllegalCallSequence Raised when a plugin is already loaded |
|
79 */ |
|
80 EXPORT_C void CImageDisplay::SetPluginUid(TUid aPluginUid) |
|
81 { |
|
82 ASSERT(iBody); |
|
83 iBody->SetPluginUid(aPluginUid); |
|
84 } |
|
85 |
|
86 /** |
|
87 Specifies the source of the image to display |
|
88 |
|
89 @param aSource |
|
90 The data source container. Note that the framework doesn't take a copy of actual data/filename etc. |
|
91 and they must persist during decoding |
|
92 @return KErrNone if the given source type is supported, otherwise KErrNotSupported |
|
93 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage |
|
94 */ |
|
95 EXPORT_C TInt CImageDisplay::SetImageSource(const TMMSource& aSource) |
|
96 { |
|
97 ASSERT(iBody); |
|
98 return iBody->SetImageSource(aSource); |
|
99 } |
|
100 |
|
101 /** |
|
102 Specifies the MIME type of the source image. |
|
103 |
|
104 @param aMIMEType |
|
105 The MIME type of the source image |
|
106 |
|
107 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage |
|
108 */ |
|
109 EXPORT_C void CImageDisplay::SetSourceMimeType(const TDesC8& aMIMEType) |
|
110 { |
|
111 ASSERT(iBody); |
|
112 iBody->SetSourceMimeType(aMIMEType); |
|
113 } |
|
114 |
|
115 /** |
|
116 Specifies the source image's type and (optionally) its subtype |
|
117 |
|
118 @param aImageType |
|
119 The UID of the source image's type |
|
120 @param aImageSubType |
|
121 The UID of the source image's subtype |
|
122 |
|
123 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
124 a plugin is not loaded yet |
|
125 */ |
|
126 EXPORT_C void CImageDisplay::SetSourceImageType(TUid aImageType, TUid aImageSubType) |
|
127 { |
|
128 ASSERT(iBody); |
|
129 iBody->SetSourceImageType(aImageType, aImageSubType); |
|
130 } |
|
131 |
|
132 /** |
|
133 Defines a clipping region. Only the specified region will be processed. |
|
134 |
|
135 @param aRect |
|
136 The coordinates of the clipping region |
|
137 |
|
138 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
139 a plugin is not loaded yet |
|
140 */ |
|
141 EXPORT_C void CImageDisplay::SetSourceRect(const TRect& aRect) |
|
142 { |
|
143 ASSERT(iBody); |
|
144 iBody->SetSourceRect(aRect); |
|
145 } |
|
146 |
|
147 /** |
|
148 Clears settings for the clipping region, but not the image region |
|
149 |
|
150 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
151 a plugin is not loaded yet |
|
152 */ |
|
153 EXPORT_C void CImageDisplay::ResetSourceRect() |
|
154 { |
|
155 ASSERT(iBody); |
|
156 iBody->ResetSourceRect(); |
|
157 } |
|
158 |
|
159 /** |
|
160 Specifies the requested image size. |
|
161 |
|
162 @param aDestinationSize |
|
163 The requested size of the image in pixels |
|
164 @param aMaintainAspectRatio |
|
165 Requests that the aspect ratio be maintained as far as possible |
|
166 Defaults to true |
|
167 |
|
168 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
169 a plugin is not loaded yet |
|
170 */ |
|
171 EXPORT_C void CImageDisplay::SetSizeInPixels(const TSize& aDestinationSize, TBool aMaintainAspectRatio) |
|
172 { |
|
173 ASSERT(iBody); |
|
174 iBody->SetSizeInPixels(aDestinationSize, aMaintainAspectRatio); |
|
175 } |
|
176 |
|
177 /** |
|
178 Specifies the requested image display mode. |
|
179 |
|
180 @param aDisplayMode |
|
181 The requested display mode |
|
182 |
|
183 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
184 a plugin is not loaded yet |
|
185 |
|
186 */ |
|
187 EXPORT_C void CImageDisplay::SetDisplayMode(TDisplayMode aDisplayMode) |
|
188 { |
|
189 ASSERT(iBody); |
|
190 iBody->SetDisplayMode(aDisplayMode); |
|
191 } |
|
192 |
|
193 /** |
|
194 Defines how the image is to be displayed. |
|
195 |
|
196 Note that all plugins support EOptionMainImage, whereas the availability of the other options depends on |
|
197 the image display plugin loaded. |
|
198 |
|
199 @param aOptions - image type selected using the TImageOptions flag set |
|
200 |
|
201 @return KErrArgument on wrong combination of options, especially if the rotate and |
|
202 mirror options aren't set together with EOptionThumbnail or EOptionMainImage. |
|
203 |
|
204 @panic ImageDisplay 1 EIllegalCallSequence Raised if the function was called during decoding stage or |
|
205 a plugin is not loaded yet |
|
206 */ |
|
207 EXPORT_C TInt CImageDisplay::SetOptions(TUint aOptions) |
|
208 { |
|
209 ASSERT(iBody); |
|
210 return iBody->SetOptions(aOptions); |
|
211 } |
|
212 |
|
213 /** |
|
214 Requests that a suitable plugin be selected and instantiated. |
|
215 Leaves with KErrNotFound if no suitable plugin found or if the framework |
|
216 or plugin finds any error in any of the preceeding SetXXX() calls |
|
217 |
|
218 @leave KErrNotFound |
|
219 No suitable plugin was found |
|
220 @leave KErrArgument |
|
221 One of the previously supplied parameters (image size, mime type etc.) is invalid |
|
222 |
|
223 @panic ImageDisplay 2 EUndefinedSourceType Raised when image source is not defined yet |
|
224 |
|
225 */ |
|
226 EXPORT_C void CImageDisplay::SetupL() |
|
227 { |
|
228 ASSERT(iBody); |
|
229 iBody->SetupL(); |
|
230 } |
|
231 |
|
232 /** |
|
233 Initiates an image display operation. |
|
234 The framework will panic if no plugin has been instantiated already. |
|
235 Note: That a plugin may perform some asynchronous operations within the |
|
236 current thread, so yielding to the Active Scheduler after calling this |
|
237 function is almost mandatory |
|
238 |
|
239 @panic ImageDisplay 1 EIllegalCallSequence |
|
240 No plugin loaded. |
|
241 |
|
242 @panic ImageDisplay 3 EUndefinedDestSize |
|
243 Raised when destination image size is not defined yet |
|
244 */ |
|
245 EXPORT_C void CImageDisplay::Play() |
|
246 { |
|
247 ASSERT(iBody); |
|
248 iBody->Play(); |
|
249 } |
|
250 |
|
251 /** |
|
252 Instructs a plug-in to pause its operation. An operation can be resumed |
|
253 by calling the Play() |
|
254 The framework will panic if no plugin has been instantiated already and |
|
255 Play() has not been called yet. |
|
256 |
|
257 @panic ImageDisplay 1 EIllegalCallSequence |
|
258 No plugin loaded. |
|
259 |
|
260 */ |
|
261 EXPORT_C void CImageDisplay::Pause() |
|
262 { |
|
263 ASSERT(iBody); |
|
264 iBody->Pause(); |
|
265 } |
|
266 |
|
267 /** |
|
268 Cancels any image display operation currently in progress. |
|
269 |
|
270 @panic ImageDisplay 1 EIllegalCallSequence Raised when no plugin loaded yet. |
|
271 */ |
|
272 EXPORT_C void CImageDisplay::StopPlay() |
|
273 { |
|
274 ASSERT(iBody); |
|
275 iBody->StopPlay(); |
|
276 } |
|
277 |
|
278 /** |
|
279 Resets all SetXXX() calls so that the state is the same as that immediately |
|
280 after a call to NewL(). Deletes the plugin if one is loaded. |
|
281 */ |
|
282 EXPORT_C void CImageDisplay::Reset() |
|
283 { |
|
284 ASSERT(iBody); |
|
285 iBody->Reset(); |
|
286 } |
|
287 |
|
288 /** |
|
289 Gets a pointer to a plugin extension |
|
290 @param aIFaceUid |
|
291 Requested extension interface Uid |
|
292 @param aIFacePtr |
|
293 Reference to pointer which would have interface pointer on sucessful completion, otherwise NULL |
|
294 @return KErrNotSupported if given extension interface is not supported |
|
295 or other system-wide error code |
|
296 @panic ImageDisplay 1 EIllegalCallSequence |
|
297 No plugin loaded. |
|
298 */ |
|
299 EXPORT_C TInt CImageDisplay::ExtensionInterface(TUid aIFaceUid, TAny*& aIFacePtr) |
|
300 { |
|
301 ASSERT(iBody); |
|
302 return iBody->ExtensionInterface(aIFaceUid, aIFacePtr); |
|
303 } |
|
304 |
|
305 /** |
|
306 Gets a reference to the current bitmap and mask |
|
307 |
|
308 @param aBitmap |
|
309 Reference to pointer which would have current frame bitmap address. |
|
310 @param aMask |
|
311 Reference to pointer which would have current frame mask address. This is NULL if no mask |
|
312 is available or if aBitmap has a display mode of EColor16MA (see SetDisplayMode()). |
|
313 |
|
314 @panic ImageDisplay 1 EIllegalCallSequence |
|
315 No plugin loaded or decoding was not started |
|
316 |
|
317 @see SetDisplayMode |
|
318 */ |
|
319 EXPORT_C void CImageDisplay::GetBitmap(const CFbsBitmap*& aBitmap, const CFbsBitmap*& aMask) const |
|
320 { |
|
321 ASSERT(iBody); |
|
322 iBody->GetBitmap(aBitmap, aMask); |
|
323 } |
|
324 |
|
325 /** |
|
326 Check to see if the current frame can be displayed now |
|
327 |
|
328 @return ETrue |
|
329 The current bitmap contains a valid image. It will return ETrue only when it is called in between the ImageReady() callback |
|
330 and a subsequent call to Play(). |
|
331 |
|
332 @panic ImageDisplay 1 EIllegalCallSequence |
|
333 No plugin loaded or decoding was not started |
|
334 */ |
|
335 EXPORT_C TBool CImageDisplay::ValidBitmap() const |
|
336 { |
|
337 ASSERT(iBody); |
|
338 return iBody->ValidBitmap(); |
|
339 } |
|
340 |
|
341 /** |
|
342 Returns an array of recommended image sizes i.e. sizes which would be processed faster |
|
343 @return a reference to the array of recommended image sizes |
|
344 |
|
345 @panic ImageDisplay 1 EIllegalCallSequence |
|
346 No plugin loaded. |
|
347 */ |
|
348 EXPORT_C const RArray<TSize>& CImageDisplay::RecommendedImageSizes() const |
|
349 { |
|
350 ASSERT(iBody); |
|
351 return iBody->RecommendedImageSizes(); |
|
352 } |
|
353 |
|
354 /** |
|
355 returns an integer, corresponding to the current image status (if known), the value will be comprised of elements of the TImageStatus bit field |
|
356 @return a combination TImageStatus flags |
|
357 |
|
358 @panic ImageDisplay 1 EIllegalCallSequence |
|
359 No plugin loaded. |
|
360 */ |
|
361 EXPORT_C TUint CImageDisplay::ImageStatus() const |
|
362 { |
|
363 ASSERT(iBody); |
|
364 return iBody->ImageStatus(); |
|
365 } |
|
366 |
|
367 /** |
|
368 returns the number of frames (if known) or an error code if unknown. |
|
369 @param aNumFrames |
|
370 a reference to frame number parameter which has meaning only if retrun value is KErrNone |
|
371 |
|
372 @return KErrNotSupported if a plug-in can't determine number of frames |
|
373 |
|
374 @panic ImageDisplay 1 EIllegalCallSequence |
|
375 No plugin loaded. |
|
376 */ |
|
377 EXPORT_C TInt CImageDisplay::NumFrames(TInt& aNumFrames) const |
|
378 { |
|
379 ASSERT(iBody); |
|
380 return iBody->NumFrames(aNumFrames); |
|
381 } |
|
382 |
|
383 const ContentAccess::TIntent KCCaccesUnknown=ContentAccess::EUnknown; |
|
384 |
|
385 /** |
|
386 Constructor for the descriptor-based image datasource. |
|
387 NOTE: Data is not copied, so the original buffer must be kept during image processing |
|
388 @param aData |
|
389 a reference to the pointer containing an image data |
|
390 |
|
391 */ |
|
392 EXPORT_C |
|
393 TDescriptorDataSource::TDescriptorDataSource(const TPtrC8& aData): |
|
394 TMMSource(KUidDescDataSource, ContentAccess::KDefaultContentObject, KCCaccesUnknown), |
|
395 iData(aData) |
|
396 { |
|
397 } |
|
398 |
|
399 /** |
|
400 Returns a reference to the pointer containing an image data. Data is not owned by this object. |
|
401 @return a reference to the data pointer |
|
402 */ |
|
403 EXPORT_C |
|
404 const TPtrC8& TDescriptorDataSource::DataBuf() const |
|
405 { |
|
406 return iData; |
|
407 } |