|
1 /* |
|
2 * Copyright (c) 2006 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: MPX album art utility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXALBUMARTUTILITY_H |
|
20 #define CMPXALBUMARTUTILITY_H |
|
21 |
|
22 #include <e32def.h> |
|
23 #include <gdi.h> |
|
24 #include <metadatafield.hrh> |
|
25 |
|
26 class CMPXMedia; |
|
27 class CMPXImageUtil; |
|
28 class CMPXImageUtilSync; |
|
29 class CFbsBitmap; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Observer class for Async util operation |
|
35 * |
|
36 * @lib mpxalbumartutility.lib |
|
37 */ |
|
38 NONSHARABLE_CLASS( MMPXAlbumArtUtilityObserver ) |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * Notify that extraction of album art started. |
|
43 * |
|
44 * @since S60 3.2.3 |
|
45 */ |
|
46 virtual void ExtractAlbumArtStarted() = 0; |
|
47 |
|
48 /** |
|
49 * Notify that the extraction of album art has completed. |
|
50 * |
|
51 * @since S60 3.2.3 |
|
52 * @param aBitmap a converted image. |
|
53 * @param aErr error code |
|
54 */ |
|
55 virtual void ExtractAlbumArtCompleted( CFbsBitmap* aBitmap, TInt aErr ) = 0; |
|
56 |
|
57 }; |
|
58 |
|
59 /** |
|
60 * Music Player common utility class |
|
61 * |
|
62 * @lib mpxalbumartutility.lib |
|
63 */ |
|
64 class CMPXAlbumArtUtility: public CActive |
|
65 { |
|
66 public: |
|
67 /** |
|
68 * Two phased contructor |
|
69 * |
|
70 * @since S60 3.2.3 |
|
71 */ |
|
72 IMPORT_C static CMPXAlbumArtUtility* NewL(); |
|
73 |
|
74 /** |
|
75 * Destuctor |
|
76 * |
|
77 * @since S60 3.2.3 |
|
78 */ |
|
79 IMPORT_C ~CMPXAlbumArtUtility(); |
|
80 |
|
81 public: // async API |
|
82 /** |
|
83 * Extract album art data. |
|
84 * |
|
85 * @since S60 3.2.3 |
|
86 * @param aProp media property the media must contain the following |
|
87 * attributes: |
|
88 * TMPXAttribute( KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) |
|
89 * TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralUri ) |
|
90 * @param aObs callback after the operation completed. |
|
91 * @param aSize The size of the required destination BMP. |
|
92 * @param aDisplayMode the display mode of the destination BMP |
|
93 * @leave KErrNotReady, KErrNotFound, or KErrUnderflow |
|
94 * (Album Art, album art file name is not found |
|
95 * or object is not ready) |
|
96 */ |
|
97 IMPORT_C void ExtractAlbumArtL(const CMPXMedia& aProp, |
|
98 MMPXAlbumArtUtilityObserver& aObs, |
|
99 const TSize& aSize, |
|
100 TDisplayMode aDisplayMode = EColor64K); |
|
101 |
|
102 /** |
|
103 * Asynchronously decodes an image from a JPG file. Generates a BMP in memory. |
|
104 * |
|
105 * @since S60 3.2.3 |
|
106 * @param aStatus request status |
|
107 * @param aSourceJPGFile Full path and filename of the image to be decoded. |
|
108 * @param aDestBMP Destination bitmap, allocated inside. |
|
109 * @param aSize destination size to be used for calculating the optimal loading size |
|
110 * @param aDisplayMode the display mode of the destination BMP |
|
111 */ |
|
112 IMPORT_C void Decode(TRequestStatus& aStatus, const TDesC& aSourceJPGFile, |
|
113 CFbsBitmap& aDestBMP, TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
114 |
|
115 /** |
|
116 * Asynchronously decodes an image from JPG buffer. Generates a BMP in memory. |
|
117 * |
|
118 * @since S60 3.2.3 |
|
119 * @param aStatus request status |
|
120 * @param aSourceJPG JPG data |
|
121 * @param aDestBMP destination bitmap, created inside. |
|
122 * @param aSize destination size to be used for calculating the optimal loading size |
|
123 * @param aDisplayMode the display mode of the destination BMP |
|
124 */ |
|
125 IMPORT_C void Decode(TRequestStatus& aStatus, const TDesC8& aSourceJPG, CFbsBitmap& aDestBMP, |
|
126 TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
127 |
|
128 /** |
|
129 * Asynchronously encodes a BMP to a JPG. |
|
130 * |
|
131 * @since S60 3.2.3 |
|
132 * @param aStatus request status for ther asynchronous operation |
|
133 * @param aSourceBMP source BMP |
|
134 * @param aDestJPG destination JPG |
|
135 */ |
|
136 IMPORT_C void Encode(TRequestStatus& aStatus, const CFbsBitmap& aSourceBMP, |
|
137 HBufC8*& aDestJPG); |
|
138 |
|
139 /** |
|
140 * Asynchronously scales a BMP to a specified size. Generates another |
|
141 * BMP in memory. |
|
142 * |
|
143 * @since S60 3.2.3 |
|
144 * @param aStatus request status for ther asynchronous operation |
|
145 * @param aSourceBMP source BMP |
|
146 * @param aDestBMP destination BMP |
|
147 * @param aSize size to scale to |
|
148 * @param aDisplayMode display mode for the destination image |
|
149 */ |
|
150 IMPORT_C void Scale(TRequestStatus& aStatus, CFbsBitmap& aSourceBMP, CFbsBitmap& aDestBMP, |
|
151 TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
152 |
|
153 public: // sync API |
|
154 |
|
155 /** |
|
156 * Synchronously decodes an image from a JPG file. |
|
157 * |
|
158 * @since S60 3.2.3 |
|
159 * @param aSourceJPGFile Full path and filename of the image to be decoded. |
|
160 * @param aSize destination size to be used for calculating the optimal loading size |
|
161 * @param aDisplayMode the display mode of the destination BMP |
|
162 * @return converted bitmap. Ownership is transferred. |
|
163 */ |
|
164 IMPORT_C CFbsBitmap* DecodeL(const TDesC& aSourceJPGFile, TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
165 |
|
166 /** |
|
167 * Synchronously converts a JPG buffer to an CFbsBitmap. |
|
168 * |
|
169 * @since S60 3.2.3 |
|
170 * @param aSourceJPG JPG data |
|
171 * @param aSize destination size to be used for calculating the optimal loading size |
|
172 * @param aDisplayMode the display mode of the destination BMP |
|
173 * @return converted bitmap. Ownership is transferred. |
|
174 */ |
|
175 IMPORT_C CFbsBitmap* DecodeL(const TDesC8& aSourceJPG, TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
176 |
|
177 /** |
|
178 * Synchronously encodes a BMP to JPG. |
|
179 * |
|
180 * @since S60 3.2.3 |
|
181 * @param aSourceBMP source BMP |
|
182 * @return destination JPG, ownership is transferred |
|
183 */ |
|
184 IMPORT_C HBufC8* EncodeL(const CFbsBitmap& aSourceBMP); |
|
185 |
|
186 /** |
|
187 * Synchronously scales a BMP to a specified size |
|
188 * |
|
189 * @since S60 3.2.3 |
|
190 * @param aSourceBMP source BMP |
|
191 * @param aSize size to scale to |
|
192 * @param aDisplayMode display mode for the destination image |
|
193 * @return scaled BMP, ownership is transferred |
|
194 */ |
|
195 IMPORT_C CFbsBitmap* ScaleL(CFbsBitmap& aSourceBMP, TSize aSize, TDisplayMode aDisplayMode = EColor64K); |
|
196 |
|
197 /** |
|
198 * Extracts embedded album art field from the media file. |
|
199 * |
|
200 * @since S60 3.2.3 |
|
201 * @param aUri file URI |
|
202 * @return embebded JPG album art. Ownership is transferred. |
|
203 */ |
|
204 IMPORT_C HBufC8* ExtractL(const TDesC& aUri); |
|
205 |
|
206 /** |
|
207 * Returns a new bitmap object from bitmnap data. |
|
208 * |
|
209 * @since S60 3.2.3 |
|
210 * @param aBMPData source BMP data |
|
211 * @return new bitmap object. Ownership is transferred. |
|
212 */ |
|
213 IMPORT_C CFbsBitmap* BitmapL(const TDesC8& aBMPData); |
|
214 |
|
215 /** |
|
216 * Returns bitmap data from a bitmap object. |
|
217 * |
|
218 * @since S60 3.2.3 |
|
219 * @param aBMP source BMP |
|
220 * @return bitmap data. Ownership is transferred. |
|
221 */ |
|
222 IMPORT_C HBufC8* BitmapDataL(const CFbsBitmap& aBMP); |
|
223 |
|
224 /** |
|
225 * Cancel outstanding asynch requests. |
|
226 * |
|
227 * @since S60 3.2.3 |
|
228 */ |
|
229 IMPORT_C void CancelRequest(); |
|
230 |
|
231 private: |
|
232 |
|
233 /** |
|
234 * C++ constructor |
|
235 * |
|
236 * @since S60 3.2.3 |
|
237 */ |
|
238 CMPXAlbumArtUtility(); |
|
239 |
|
240 /** |
|
241 * Second phase constructor |
|
242 * |
|
243 * @since S60 3.2.3 |
|
244 * |
|
245 */ |
|
246 void ConstructL(); |
|
247 |
|
248 private: // From CActive |
|
249 /** |
|
250 * @since S60 3.2.3 |
|
251 * @see CActive |
|
252 */ |
|
253 void DoCancel(); |
|
254 |
|
255 /** |
|
256 * @since S60 3.2.3 |
|
257 * @see CActive |
|
258 */ |
|
259 void RunL(); |
|
260 |
|
261 /** |
|
262 * @since S60 3.2.3 |
|
263 * @see CActive |
|
264 */ |
|
265 TInt RunError(TInt aError); |
|
266 |
|
267 private: |
|
268 // Internal operation codes |
|
269 enum TOperation |
|
270 { |
|
271 EIdle = 0, |
|
272 EExtractAlbumArtL |
|
273 }; |
|
274 |
|
275 private: |
|
276 CMPXImageUtil* iImageUtil; |
|
277 CMPXImageUtilSync* iImageUtilSync; |
|
278 MMPXAlbumArtUtilityObserver* iObs; |
|
279 TOperation iCurrentOp; |
|
280 HBufC8* iAlbumArt; |
|
281 CFbsBitmap* iBitmap; |
|
282 }; |
|
283 |
|
284 #endif // CMPXALBUMARTUTILITY_H |
|
285 |
|
286 // End of File |