1 /* |
|
2 * Copyright (c) 2002 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: CMMAAudioStreamMetaDataControl is a concrete class for getting |
|
15 * metadata from an audio media. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <logger.h> |
|
22 |
|
23 #include "cmmaaudiostreammetadatacontrol.h" |
|
24 |
|
25 CMMAAudioStreamMetaDataControl::CMMAAudioStreamMetaDataControl( |
|
26 CMetaDataUtility* aMetadaDataUtility) |
|
27 { |
|
28 LOG( EJavaMMAPI, EInfo, "CMMAAudioStreamMetaDataControl constructor called."); |
|
29 // this class gets the ownership of MetaDataUtility |
|
30 iMetaDataUtility = aMetadaDataUtility; |
|
31 } |
|
32 |
|
33 CMMAAudioStreamMetaDataControl::~CMMAAudioStreamMetaDataControl() |
|
34 { |
|
35 LOG( EJavaMMAPI, EInfo, "~CMMAAudioStreamMetaDataControl called."); |
|
36 delete iMetaDataUtility; |
|
37 } |
|
38 |
|
39 TInt CMMAAudioStreamMetaDataControl::KeyCountL() |
|
40 { |
|
41 TInt entries = iMetaDataUtility->MetaDataCount(); |
|
42 LOG1( EJavaMMAPI, EInfo, "MMA:CMMAAudioStreamMetaDataControl::KeyCountL, count = %d", entries); |
|
43 |
|
44 return entries; |
|
45 } |
|
46 |
|
47 HBufC* CMMAAudioStreamMetaDataControl::KeyL(TInt aIndex) |
|
48 { |
|
49 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::KeyL +"); |
|
50 HBufC* key = NULL; |
|
51 |
|
52 if (KeyCountL() > 0) |
|
53 { |
|
54 TMetaDataFieldId fieldId; |
|
55 const CMetaDataFieldContainer& fieldcontainer = |
|
56 iMetaDataUtility->MetaDataFieldsL(); |
|
57 fieldcontainer.FieldIdAt(aIndex, fieldId); |
|
58 LOG1( EJavaMMAPI, EInfo, "MMA:CMMAAudioStreamMetaDataControl::KeyL, fieldId = %d", fieldId); |
|
59 key = GetKeyL(fieldId); |
|
60 } |
|
61 |
|
62 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::KeyL -"); |
|
63 return key; |
|
64 } |
|
65 |
|
66 /* |
|
67 * Get the value of given audio metadata key. The ownership of the created value |
|
68 * (descriptor) is passed to the caller. |
|
69 */ |
|
70 HBufC* CMMAAudioStreamMetaDataControl::KeyValueL(const TDesC& aKey) |
|
71 { |
|
72 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::KeyValueL +"); |
|
73 HBufC* retVal = NULL; |
|
74 |
|
75 if (KeyCountL() > 0) |
|
76 { |
|
77 TBool found; |
|
78 TMetaDataFieldId fieldId = GetFieldId(aKey, found); |
|
79 if (found) |
|
80 { |
|
81 const CMetaDataFieldContainer& fieldcontainer = |
|
82 iMetaDataUtility->MetaDataFieldsL(); |
|
83 retVal = (fieldcontainer.Field(fieldId)).AllocL(); |
|
84 } |
|
85 } |
|
86 |
|
87 User::LeaveIfNull(retVal); |
|
88 ELOG1( EJavaMMAPI, "MMA::CMMAAudioStreamMetaDataControl::KeyValueL, retVal = %S", retVal->Des().PtrZ()); |
|
89 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::KeyValueL -"); |
|
90 return retVal; |
|
91 } |
|
92 |
|
93 /* |
|
94 * Get key string for the given fieldId |
|
95 */ |
|
96 HBufC* CMMAAudioStreamMetaDataControl::GetKeyL(TMetaDataFieldId aFieldId) |
|
97 { |
|
98 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::GetKeyL +"); |
|
99 HBufC* keyString = NULL; |
|
100 TBuf<KKeyStringMaxLength> tempBuf; |
|
101 |
|
102 switch (aFieldId) |
|
103 { |
|
104 case EMetaDataSongTitle: |
|
105 tempBuf.Copy(KMetaDataSongTitle); |
|
106 keyString = tempBuf.AllocL(); |
|
107 break; |
|
108 case EMetaDataArtist: |
|
109 tempBuf.Copy(KMetaDataArtist); |
|
110 keyString = tempBuf.AllocL(); |
|
111 break; |
|
112 case EMetaDataAlbum: |
|
113 tempBuf.Copy(KMetaDataAlbum); |
|
114 keyString = tempBuf.AllocL(); |
|
115 break; |
|
116 case EMetaDataYear: |
|
117 tempBuf.Copy(KMetaDataYear); |
|
118 keyString = tempBuf.AllocL(); |
|
119 break; |
|
120 case EMetaDataAlbumTrack: |
|
121 tempBuf.Copy(KMetaDataAlbumTrack); |
|
122 keyString = tempBuf.AllocL(); |
|
123 break; |
|
124 case EMetaDataGenre: |
|
125 tempBuf.Copy(KMetaDataGenre); |
|
126 keyString = tempBuf.AllocL(); |
|
127 break; |
|
128 case EMetaDataComposer: |
|
129 tempBuf.Copy(KMetaDataComposer); |
|
130 keyString = tempBuf.AllocL(); |
|
131 break; |
|
132 case EMetaDataCopyright: |
|
133 tempBuf.Copy(KMetaDataCopyright); |
|
134 keyString = tempBuf.AllocL(); |
|
135 break; |
|
136 case EMetaDataOriginalArtist: |
|
137 tempBuf.Copy(KMetaDataOriginalArtist); |
|
138 keyString = tempBuf.AllocL(); |
|
139 break; |
|
140 case EMetaDataUrl: |
|
141 tempBuf.Copy(KMetaDataUrl); |
|
142 keyString = tempBuf.AllocL(); |
|
143 break; |
|
144 case EMetaDataUserUrl: |
|
145 tempBuf.Copy(KMetaDataUserUrl); |
|
146 keyString = tempBuf.AllocL(); |
|
147 break; |
|
148 case EMetaDataJpeg: |
|
149 tempBuf.Copy(KMetaDataJpeg); |
|
150 keyString = tempBuf.AllocL(); |
|
151 break; |
|
152 case EMetaDataVendor: |
|
153 tempBuf.Copy(KMetaDataVendor); |
|
154 keyString = tempBuf.AllocL(); |
|
155 break; |
|
156 case EMetaDataRating: |
|
157 tempBuf.Copy(KMetaDataRating); |
|
158 keyString = tempBuf.AllocL(); |
|
159 break; |
|
160 case EMetaDataUniqueFileIdentifier: |
|
161 tempBuf.Copy(KMetaDataUniqueFileIdentifier); |
|
162 keyString = tempBuf.AllocL(); |
|
163 break; |
|
164 case EMetaDataDuration: |
|
165 tempBuf.Copy(KMetaDataDuration); |
|
166 keyString = tempBuf.AllocL(); |
|
167 break; |
|
168 case EMetaDataDate: |
|
169 tempBuf.Copy(KMetaDataDate); |
|
170 keyString = tempBuf.AllocL(); |
|
171 break; |
|
172 default: |
|
173 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::GetKeyL, default case should not occur"); |
|
174 } |
|
175 |
|
176 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::GetKeyL -"); |
|
177 return keyString; |
|
178 } |
|
179 |
|
180 /* |
|
181 * Get fieldId for the given key string |
|
182 */ |
|
183 TMetaDataFieldId CMMAAudioStreamMetaDataControl::GetFieldId(const TDesC& aKey, TBool& aCompare) |
|
184 { |
|
185 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::GetFieldId +"); |
|
186 TMetaDataFieldId fieldId = EUnknownMetaDataField; |
|
187 aCompare = true; // found |
|
188 |
|
189 if (0 == aKey.Compare(KMetaDataSongTitle())) |
|
190 { |
|
191 fieldId = EMetaDataSongTitle; |
|
192 } |
|
193 else if (0 == aKey.Compare(KMetaDataArtist())) |
|
194 { |
|
195 fieldId = EMetaDataArtist; |
|
196 } |
|
197 else if (0 == aKey.Compare(KMetaDataAlbum())) |
|
198 { |
|
199 fieldId = EMetaDataAlbum; |
|
200 } |
|
201 else if (0 == aKey.Compare(KMetaDataArtist())) |
|
202 { |
|
203 fieldId = EMetaDataArtist; |
|
204 } |
|
205 else if (0 == aKey.Compare(KMetaDataYear())) |
|
206 { |
|
207 fieldId = EMetaDataYear; |
|
208 } |
|
209 else if (0 == aKey.Compare(KMetaDataComment())) |
|
210 { |
|
211 fieldId = EMetaDataComment; |
|
212 } |
|
213 else if (0 == aKey.Compare(KMetaDataAlbumTrack())) |
|
214 { |
|
215 fieldId = EMetaDataAlbumTrack; |
|
216 } |
|
217 else if (0 == aKey.Compare(KMetaDataGenre())) |
|
218 { |
|
219 fieldId = EMetaDataGenre; |
|
220 } |
|
221 else if (0 == aKey.Compare(KMetaDataComposer())) |
|
222 { |
|
223 fieldId = EMetaDataComposer; |
|
224 } |
|
225 else if (0 == aKey.Compare(KMetaDataCopyright())) |
|
226 { |
|
227 fieldId = EMetaDataCopyright; |
|
228 } |
|
229 else if (0 == aKey.Compare(KMetaDataOriginalArtist())) |
|
230 { |
|
231 fieldId = EMetaDataOriginalArtist; |
|
232 } |
|
233 else if (0 == aKey.Compare(KMetaDataUrl())) |
|
234 { |
|
235 fieldId = EMetaDataUrl; |
|
236 } |
|
237 else if (0 == aKey.Compare(KMetaDataUserUrl())) |
|
238 { |
|
239 fieldId = EMetaDataUserUrl; |
|
240 } |
|
241 else if (0 == aKey.Compare(KMetaDataJpeg())) |
|
242 { |
|
243 fieldId = EMetaDataJpeg; |
|
244 } |
|
245 else if (0 == aKey.Compare(KMetaDataVendor())) |
|
246 { |
|
247 fieldId = EMetaDataVendor; |
|
248 } |
|
249 else if (0 == aKey.Compare(KMetaDataRating())) |
|
250 { |
|
251 fieldId = EMetaDataRating; |
|
252 } |
|
253 else if (0 == aKey.Compare(KMetaDataUniqueFileIdentifier())) |
|
254 { |
|
255 fieldId = EMetaDataUniqueFileIdentifier; |
|
256 } |
|
257 else if (0 == aKey.Compare(KMetaDataDuration())) |
|
258 { |
|
259 fieldId = EMetaDataDuration; |
|
260 } |
|
261 else if (0 == aKey.Compare(KMetaDataDate())) |
|
262 { |
|
263 fieldId = EMetaDataDate; |
|
264 } |
|
265 else |
|
266 { |
|
267 aCompare = false; // not found |
|
268 } |
|
269 |
|
270 LOG( EJavaMMAPI, EInfo, "MMA::CMMAAudioStreamMetaDataControl::GetFieldId -"); |
|
271 return fieldId; |
|
272 } |
|
273 |
|
274 // END OF FILE |
|