|
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: Extracts metadata from a file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXMETADATAEXTRACTOR_H |
|
20 #define CMPXMETADATAEXTRACTOR_H |
|
21 |
|
22 class CMPXMedia; |
|
23 class CMPXCollectionPath; |
|
24 class CMetaDataUtility; |
|
25 class CMPXFileInfoUtility; |
|
26 class CMPXDrmMediaUtility; |
|
27 #include <thumbnailmanager.h> |
|
28 #include <thumbnailmanagerobserver.h> |
|
29 |
|
30 /** |
|
31 * Extracts metadata from a file. |
|
32 * |
|
33 * @lib mpxfilehandler.lib |
|
34 */ |
|
35 class CMPXMetadataExtractor : public CBase, |
|
36 public MThumbnailManagerObserver |
|
37 { |
|
38 |
|
39 public: |
|
40 /* |
|
41 * Two-Phased Constructor. |
|
42 *@since 3.2.3 |
|
43 */ |
|
44 IMPORT_C static CMPXMetadataExtractor* NewL( RFs& aFs, |
|
45 RApaLsSession& aAppArc, |
|
46 RPointerArray<CMPXCollectionType>& aTypes ); |
|
47 |
|
48 /* |
|
49 * Virtual Destructor. |
|
50 *@since 3.2.3 |
|
51 */ |
|
52 virtual ~CMPXMetadataExtractor(); |
|
53 |
|
54 public: // New Functions |
|
55 |
|
56 /* |
|
57 * Create a media object for a file. |
|
58 * @since 3.2.3 |
|
59 * @param aFile a fullpath to the file. |
|
60 * @param aNewProperty on return a new media property will be created. |
|
61 * @param aMetadataOnly extract metadata only or not. Default EFalse |
|
62 */ |
|
63 IMPORT_C void CreateMediaL( const TDesC& aFile, |
|
64 CMPXMedia*& aNewProperty, |
|
65 TBool aMetadataOnly = EFalse ); |
|
66 |
|
67 /** |
|
68 * Extract album art from a file and add to thumbnail manager. |
|
69 * @since 5.0 |
|
70 * @param aMedia MPX Media object to add album art attribute. |
|
71 * @return error id |
|
72 */ |
|
73 IMPORT_C TInt ExtractAlbumArtL( CMPXMedia* aMedia ); |
|
74 |
|
75 private: // New Functions: |
|
76 |
|
77 /** |
|
78 * Set default media properties. |
|
79 * @since 3.2.3 |
|
80 * @param aMediaProp media properties to update |
|
81 */ |
|
82 void SetDefaultL( CMPXMedia& aMediaProp ); |
|
83 |
|
84 /** |
|
85 * Function to go through the metadata entries. |
|
86 * @since 3.2.3 |
|
87 * @param aProp Media Properties to update. |
|
88 * @param aFile File name |
|
89 */ |
|
90 void SetMediaPropertiesL( CMPXMedia& aProp, |
|
91 const TDesC& aFile ); |
|
92 |
|
93 /** |
|
94 * Sets other media properties not found from metadata util. |
|
95 * @since 3.2.3 |
|
96 * @param aProp Media Properties to update. |
|
97 * @param aFile file name. |
|
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 |
|
108 /** |
|
109 * Checks to see if a container type is supported. |
|
110 * @since 3.2.3 |
|
111 * @param aFile file path. |
|
112 * @param aIndex index to the supported types array. |
|
113 * @return index to the mimetype |
|
114 */ |
|
115 TInt SupportedContainerTypeL( const TDesC& aFile, TInt aIndex ); |
|
116 |
|
117 // From MThumbnailManagerObserver |
|
118 /** |
|
119 * Preview thumbnail generation or loading is complete. |
|
120 * @since S60 v5.0 |
|
121 * @param aThumbnail An object representing the resulting thumbnail. |
|
122 * @param aId Request ID for the operation |
|
123 */ |
|
124 void ThumbnailPreviewReady( |
|
125 MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
126 |
|
127 /** |
|
128 * Final thumbnail bitmap generation or loading is complete. |
|
129 * @since S60 v5.0 |
|
130 * @param aError Error code. |
|
131 * @param aThumbnail An object representing the resulting thumbnail. |
|
132 * @param aId Request ID for the operation. |
|
133 */ |
|
134 void ThumbnailReady( |
|
135 TInt aError, |
|
136 MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
137 |
|
138 /** |
|
139 * Stop the wait loop. |
|
140 */ |
|
141 void StopWaitLoop(); |
|
142 |
|
143 /** |
|
144 * Cancel timer. |
|
145 */ |
|
146 void CancelTimeoutTimer(); |
|
147 |
|
148 /** |
|
149 * Callback when the timer times out. |
|
150 */ |
|
151 static TInt TimeoutTimerCallback(TAny* aPtr); |
|
152 |
|
153 /** |
|
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 * @since 5.0 |
|
165 * @param aMedia |
|
166 */ |
|
167 void AddMediaAlbumArtL( CMPXMedia& aMedia, |
|
168 const TDesC& aFile, |
|
169 TDesC8& aValue); |
|
170 |
|
171 private: |
|
172 |
|
173 /** |
|
174 * Private Two-Phased constuctor. |
|
175 * @since 3.2.3 |
|
176 * @param aFs file path. |
|
177 * @param aAppArc address for the session application information. |
|
178 * @param array of supported types |
|
179 */ |
|
180 CMPXMetadataExtractor( RFs& aFs, RApaLsSession& aAppArc, |
|
181 RPointerArray<CMPXCollectionType>& aTypes ); |
|
182 |
|
183 void ConstructL(); |
|
184 |
|
185 private: // data |
|
186 CMetaDataUtility* iMetadataUtility; // extract metadata from file |
|
187 CMPXDrmMediaUtility* iDrmMediaUtility; // extra drm data from file |
|
188 CMPXFileInfoUtility* iFileInfoUtil; // extract duration/bitrate etc from file |
|
189 RFs& iFs; |
|
190 RApaLsSession& iAppArc; |
|
191 RPointerArray<CMPXCollectionType>& iSupportedTypes; // not owned |
|
192 |
|
193 CThumbnailManager* iTNManager; |
|
194 CActiveSchedulerWait* iTNSyncWait; // wait loop use to sync thumbnail |
|
195 CPeriodic* iTimer; // backup timer to stop wait loop |
|
196 TInt iOutstandingThumbnailRequest; |
|
197 TInt iTNMBlockCount; |
|
198 }; |
|
199 |
|
200 #endif // CMPXMETADATAEXTRACTOR_H |