9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Harvests metadata from wmv video file |
14 * Description: Harvests metadata from wm video file |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <e32std.h> |
18 #include <e32std.h> |
19 #include <caf/content.h> |
19 #include <caf/caf.h> |
20 |
20 |
21 #include "mdsutils.h" |
21 #include "mdsutils.h" |
22 #include "harvesterdata.h" |
22 #include "harvesterdata.h" |
23 #include "harvesterlog.h" |
23 #include "harvesterlog.h" |
|
24 #include "harvestercommon.h" |
24 #include "harvesterwmvplugin.h" |
25 #include "harvesterwmvplugin.h" |
25 #include <mdenamespacedef.h> |
26 #include <mdenamespacedef.h> |
26 #include <mdeobjectdef.h> |
27 #include <mdeobjectdef.h> |
27 #include "mdeobject.h" |
28 #include "mdeobject.h" |
28 #include "mdetextproperty.h" |
29 #include "mdetextproperty.h" |
40 CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
41 CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
41 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); |
42 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); |
42 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
43 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
43 iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
44 iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
44 iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
45 iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
|
46 iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
47 |
|
48 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject ); |
|
49 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty ); |
|
50 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty ); |
|
51 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty ); |
|
52 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty ); |
45 } |
53 } |
46 |
54 |
47 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef) |
55 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef) |
48 { |
56 { |
49 CHarvesterWmvPluginPropertyDefs* self = |
57 CHarvesterWmvPluginPropertyDefs* self = |
176 aClipDetails.iFileSize = (TUint)entry->iSize; |
185 aClipDetails.iFileSize = (TUint)entry->iSize; |
177 |
186 |
178 CleanupStack::PopAndDestroy( entry ); |
187 CleanupStack::PopAndDestroy( entry ); |
179 |
188 |
180 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
189 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
181 |
190 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
182 //Mime type check |
191 |
183 error = content->GetStringAttribute( ContentAccess::EMimeType, aClipDetails.iMimeType ); |
192 ContentAccess::RStringAttributeSet attrSet; |
184 if ( error != KErrNone ) |
193 CleanupClosePushL( attrSet ); |
185 { |
194 |
186 WRITELOG( "CHarvesterWMVPlugin - Could not resolve mime type, leave!" ); |
195 attrSet.AddL( ContentAccess::EDescription ); |
187 User::Leave( KErrNotSupported ); |
196 attrSet.AddL( ContentAccess::EMimeType ); |
188 } |
197 attrSet.AddL( ContentAccess::ETitle ); |
189 |
198 attrSet.AddL( ContentAccess::EAuthor ); |
190 CleanupStack::PopAndDestroy( content ); |
199 attrSet.AddL( ContentAccess::EGenre ); |
|
200 |
|
201 User::LeaveIfError( data->GetStringAttributeSet(attrSet) ); |
|
202 |
|
203 TInt err = attrSet.GetValue( ContentAccess::EMimeType, aClipDetails.iMimeType ); |
|
204 if ( err != KErrNone) |
|
205 { |
|
206 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting mimetype failed %d", err ); |
|
207 } |
|
208 |
|
209 if ( aClipDetails.iMimeType.Length() <= 0 ) |
|
210 { |
|
211 WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no mimetype" ); |
|
212 } |
|
213 |
|
214 err = attrSet.GetValue( ContentAccess::EDescription, aClipDetails.iDescription ); |
|
215 if ( err != KErrNone) |
|
216 { |
|
217 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting description failed %d", err ); |
|
218 } |
|
219 |
|
220 if ( aClipDetails.iDescription.Length() <= 0 ) |
|
221 { |
|
222 WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no description" ); |
|
223 } |
|
224 |
|
225 err = attrSet.GetValue( ContentAccess::ETitle, aClipDetails.iTitle ); |
|
226 if ( err != KErrNone) |
|
227 { |
|
228 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting title failed %d", err ); |
|
229 } |
|
230 |
|
231 if ( aClipDetails.iTitle.Length() <= 0 ) |
|
232 { |
|
233 WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no title" ); |
|
234 } |
|
235 |
|
236 err = attrSet.GetValue( ContentAccess::EAuthor, aClipDetails.iAuthor ); |
|
237 if ( err != KErrNone) |
|
238 { |
|
239 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting author failed %d", err ); |
|
240 } |
|
241 |
|
242 if ( aClipDetails.iAuthor.Length() <= 0 ) |
|
243 { |
|
244 WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no author" ); |
|
245 } |
|
246 |
|
247 err = attrSet.GetValue( ContentAccess::EGenre, aClipDetails.iGenre ); |
|
248 if ( err != KErrNone) |
|
249 { |
|
250 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting genre failed %d", err ); |
|
251 } |
|
252 |
|
253 if ( aClipDetails.iGenre.Length() <= 0 ) |
|
254 { |
|
255 WRITELOG( "CHarvesterWMVPlugin::GatherDataL - no genre" ); |
|
256 } |
|
257 |
|
258 err = content->GetAttribute( ContentAccess::EIsProtected, aClipDetails.iDrmProtected ); |
|
259 if ( err != KErrNone) |
|
260 { |
|
261 WRITELOG1( "CHarvesterWMVPlugin::GatherDataL - ERROR: getting protection info failed %d", err ); |
|
262 } |
|
263 |
|
264 CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet |
191 } |
265 } |
192 |
266 |
193 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |
194 // Handle object properties |
268 // Handle object properties |
195 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
224 *iPropDefs->iSizePropertyDef, &aClipDetails.iFileSize, aIsAdd ); |
298 *iPropDefs->iSizePropertyDef, &aClipDetails.iFileSize, aIsAdd ); |
225 // Mime Type |
299 // Mime Type |
226 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
300 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
227 *iPropDefs->iItemTypePropertyDef, &aClipDetails.iMimeType, aIsAdd ); |
301 *iPropDefs->iItemTypePropertyDef, &aClipDetails.iMimeType, aIsAdd ); |
228 } |
302 } |
229 } |
303 |
230 |
304 // DRM protection |
|
305 if( aClipDetails.iDrmProtected ) |
|
306 { |
|
307 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
|
308 *iPropDefs->iDrmPropertyDef, &aClipDetails.iDrmProtected, aIsAdd ); |
|
309 } |
|
310 // Title (is set from URI by default) |
|
311 if(aClipDetails.iTitle.Length() > 0) |
|
312 { |
|
313 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
|
314 *iPropDefs->iTitlePropertyDef, &aClipDetails.iTitle, EFalse ); |
|
315 } |
|
316 // Description |
|
317 if(aClipDetails.iDescription.Length() > 0) |
|
318 { |
|
319 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
|
320 *iPropDefs->iDescriptionPropertyDef, &aClipDetails.iDescription, aIsAdd ); |
|
321 } |
|
322 // Author |
|
323 if(aClipDetails.iAuthor.Length() > 0) |
|
324 { |
|
325 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
|
326 *iPropDefs->iAuthorPropertyDef, &aClipDetails.iAuthor, aIsAdd ); |
|
327 } |
|
328 // Genre |
|
329 if(aClipDetails.iGenre.Length() > 0) |
|
330 { |
|
331 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
|
332 *iPropDefs->iGenrePropertyDef, &aClipDetails.iGenre, aIsAdd ); |
|
333 } |
|
334 } |
|
335 |