22 class CMPXMedia; |
22 class CMPXMedia; |
23 class CMPXCollectionPath; |
23 class CMPXCollectionPath; |
24 class CMetaDataUtility; |
24 class CMetaDataUtility; |
25 class CMPXFileInfoUtility; |
25 class CMPXFileInfoUtility; |
26 class CMPXDrmMediaUtility; |
26 class CMPXDrmMediaUtility; |
|
27 class MMPXMetadataExtractorObserver; |
27 #include <thumbnailmanager.h> |
28 #include <thumbnailmanager.h> |
28 #include <thumbnailmanagerobserver.h> |
29 #include <thumbnailmanagerobserver.h> |
29 |
30 |
30 /** |
31 /** |
31 * Extracts metadata from a file. |
32 * Extracts metadata from a file. |
32 * |
33 * |
33 * @lib mpxfilehandler.lib |
34 * @lib mpxfilehandler.lib |
34 */ |
35 */ |
35 class CMPXMetadataExtractor : public CBase, |
36 class CMPXMetadataExtractor : public CBase, |
36 public MThumbnailManagerObserver |
37 public MThumbnailManagerObserver |
37 { |
38 { |
38 |
39 |
39 public: |
40 public: |
40 /* |
41 /* |
41 * Two-Phased Constructor. |
42 * Two-Phased Constructor. |
70 * @param aMedia MPX Media object to add album art attribute. |
71 * @param aMedia MPX Media object to add album art attribute. |
71 * @return error id |
72 * @return error id |
72 */ |
73 */ |
73 IMPORT_C TInt ExtractAlbumArtL( CMPXMedia* aMedia ); |
74 IMPORT_C TInt ExtractAlbumArtL( CMPXMedia* aMedia ); |
74 |
75 |
|
76 /* |
|
77 * Create a media object for a file. This is a asynchronous function. |
|
78 * This function will leave with KErrAbort if still processing last request. |
|
79 * Callback function is HandleCreateMediaComplete() |
|
80 * @since 9.2 |
|
81 * @param aFile a fullpath to the file. |
|
82 * @param aObs Metadata Extractor Observer |
|
83 * @param aMetadataOnly extract metadata only or not. Default EFalse |
|
84 */ |
|
85 IMPORT_C void CreateMediaAsyncL( const TDesC& aFile, |
|
86 MMPXMetadataExtractorObserver* aObs, |
|
87 TBool aMetadataOnly = EFalse ); |
|
88 |
|
89 /** |
|
90 * Cancel request. This will empty the task array and stop the wait loop. This |
|
91 * will cause the CreateMediaL() to finish more quickly. Also, |
|
92 * all outstanding thumbnail requests are cancelled. |
|
93 * @since 9.2 |
|
94 */ |
|
95 IMPORT_C void CancelRequest(); |
|
96 |
75 private: // New Functions: |
97 private: // New Functions: |
76 |
98 |
77 /** |
99 /** |
78 * Set default media properties. |
100 * Set default media properties. |
79 * @since 3.2.3 |
101 * @since 3.2.3 |
82 void SetDefaultL( CMPXMedia& aMediaProp ); |
104 void SetDefaultL( CMPXMedia& aMediaProp ); |
83 |
105 |
84 /** |
106 /** |
85 * Function to go through the metadata entries. |
107 * Function to go through the metadata entries. |
86 * @since 3.2.3 |
108 * @since 3.2.3 |
87 * @param aProp Media Properties to update. |
109 */ |
88 * @param aFile File name |
110 void SetMediaPropertiesL(); |
89 */ |
|
90 void SetMediaPropertiesL( CMPXMedia& aProp, |
|
91 const TDesC& aFile ); |
|
92 |
111 |
93 /** |
112 /** |
94 * Sets other media properties not found from metadata util. |
113 * Sets other media properties not found from metadata util. |
95 * @since 3.2.3 |
114 * @since 3.2.3 |
96 * @param aProp Media Properties to update. |
115 */ |
97 * @param aFile file name. |
116 void SetExtMediaPropertiesL(); |
98 * @param aMetadataOnly extract metadata only or not Default EFalse. |
|
99 * @param aFileHandle file handle to the file. |
|
100 * @param aFileErr file handle error if file could not be opened |
|
101 */ |
|
102 void SetExtMediaPropertiesL( CMPXMedia& aProp, |
|
103 const TDesC& aFile, |
|
104 TBool aMetadataOnly, |
|
105 RFile& aFileHandle, |
|
106 TInt aFileErr ); |
|
107 |
117 |
108 /** |
118 /** |
109 * Checks to see if a container type is supported. |
119 * Checks to see if a container type is supported. |
110 * @since 3.2.3 |
120 * @since 3.2.3 |
111 * @param aFile file path. |
121 * @param aFile file path. |
149 * Callback when the timer times out. |
159 * Callback when the timer times out. |
150 */ |
160 */ |
151 static TInt TimeoutTimerCallback(TAny* aPtr); |
161 static TInt TimeoutTimerCallback(TAny* aPtr); |
152 |
162 |
153 /** |
163 /** |
154 * Get album art metadata. |
|
155 * @since 5.0 |
|
156 * @param aMedia |
|
157 * @return error ID |
|
158 */ |
|
159 TInt GetMediaAlbumArtL( CMPXMedia& aMedia, |
|
160 const TDesC& aFile ); |
|
161 |
|
162 /** |
|
163 * Add album art to media object. |
164 * Add album art to media object. |
164 * @since 5.0 |
165 * @since 5.0 |
165 * @param aMedia |
166 * @param aMedia |
166 */ |
167 */ |
167 void AddMediaAlbumArtL( CMPXMedia& aMedia, |
168 void AddMediaAlbumArtL( CMPXMedia& aMedia, |
168 const TDesC& aFile, |
169 const TDesC& aFile ); |
169 TDesC8& aValue); |
|
170 |
170 |
171 /** |
171 /** |
172 * Check if can send request to TNM or not. |
172 * Check if can send request to TNM or not. |
173 * @since 5.0 |
173 * @since 5.0 |
174 * |
174 * |
175 */ |
175 */ |
176 void CheckBeforeSendRequest(); |
176 void CheckBeforeSendRequest(); |
|
177 |
|
178 /** |
|
179 * Cancel all outstanding thumbnail requests |
|
180 * @since 9.2 |
|
181 * |
|
182 */ |
|
183 void CancelAllThumbnailRequests(); |
|
184 |
|
185 /** |
|
186 * Create media and set default data. |
|
187 * @since 9.2 |
|
188 * |
|
189 */ |
|
190 void DoCreateMediaL(); |
|
191 |
|
192 /** |
|
193 * Execute task at index 0. |
|
194 * @since 9.2 |
|
195 * |
|
196 */ |
|
197 void ExecuteTaskL(); |
|
198 |
|
199 /** |
|
200 * Cancel task timer. |
|
201 */ |
|
202 void CancelTaskTimer(); |
|
203 |
|
204 /** |
|
205 * Callback when the task timer expires. |
|
206 */ |
|
207 static TInt TaskTimerCallback(TAny* aPtr); |
|
208 |
|
209 /** |
|
210 * Populate task array |
|
211 * @since 9.2 |
|
212 */ |
|
213 void AddTasksL(); |
|
214 |
|
215 /** |
|
216 * Opens the file |
|
217 * @since 9.2 |
|
218 * @return system error |
|
219 */ |
|
220 TInt OpenFile(); |
|
221 |
|
222 /** |
|
223 * Handle task timer expired |
|
224 * @since 9.2 |
|
225 */ |
|
226 void HandleTaskTimerExpired(); |
|
227 |
|
228 /** |
|
229 * Clean up |
|
230 * @since 9.2 |
|
231 */ |
|
232 void CleanUp(); |
177 |
233 |
178 private: |
234 private: |
179 |
235 |
180 /** |
236 /** |
181 * Private Two-Phased constuctor. |
237 * Private Two-Phased constuctor. |
188 RPointerArray<CMPXCollectionType>& aTypes ); |
244 RPointerArray<CMPXCollectionType>& aTypes ); |
189 |
245 |
190 void ConstructL(); |
246 void ConstructL(); |
191 |
247 |
192 private: // data |
248 private: // data |
|
249 enum EMetadataExtractorTasks |
|
250 { |
|
251 ETaskCreateMedia, |
|
252 ETaskAddMetadata, |
|
253 ETaskAddExtMetadata, |
|
254 ETaskAddAlbumArt, |
|
255 ETaskCheckBeforeSend |
|
256 }; |
|
257 |
193 CMetaDataUtility* iMetadataUtility; // extract metadata from file |
258 CMetaDataUtility* iMetadataUtility; // extract metadata from file |
194 CMPXDrmMediaUtility* iDrmMediaUtility; // extra drm data from file |
259 CMPXDrmMediaUtility* iDrmMediaUtility; // extra drm data from file |
195 CMPXFileInfoUtility* iFileInfoUtil; // extract duration/bitrate etc from file |
260 CMPXFileInfoUtility* iFileInfoUtil; // extract duration/bitrate etc from file |
196 RFs& iFs; |
261 RFs& iFs; |
197 RApaLsSession& iAppArc; |
262 RApaLsSession& iAppArc; |
198 RPointerArray<CMPXCollectionType>& iSupportedTypes; // not owned |
263 RPointerArray<CMPXCollectionType>& iSupportedTypes; // not owned |
199 |
264 |
200 CThumbnailManager* iTNManager; |
265 CThumbnailManager* iTNManager; |
201 CActiveSchedulerWait* iTNSyncWait; // wait loop use to sync thumbnail |
266 CActiveSchedulerWait* iTNSyncWait; // wait loop use to sync thumbnail |
202 CPeriodic* iTimer; // backup timer to stop wait loop |
267 CPeriodic* iTimer; // backup timer to stop wait loop |
203 TInt iOutstandingThumbnailRequest; |
268 RArray<TThumbnailRequestId> iArrayTNRequestId; |
204 TInt iTNMBlockCount; |
269 RArray<EMetadataExtractorTasks> iArrayTasks; |
|
270 TBool iCancelled; |
|
271 CPeriodic* iTaskTimer; // timer for task execution |
|
272 MMPXMetadataExtractorObserver* iObs; // metadata extractor obserer |
|
273 TFileName iFileName; |
|
274 RFile iFile; |
|
275 CMPXMedia* iMedia; // ownership transferred |
|
276 TBool iMetadataOnly; |
|
277 TInt iFileOpenError; |
205 }; |
278 }; |
206 |
279 |
207 #endif // CMPXMETADATAEXTRACTOR_H |
280 #endif // CMPXMETADATAEXTRACTOR_H |