--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Fri Mar 19 09:38:01 2010 +0200
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Fri Apr 16 15:23:55 2010 +0300
@@ -20,6 +20,7 @@
#include <3gplibrary/mp4lib.h>
#include <hxmetadatautil.h>
#include <hxmetadatakeys.h>
+#include <caf/caf.h>
#include "mdsutils.h"
#include "harvestervideoplugin.h"
@@ -109,6 +110,7 @@
iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty );
iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
+ iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty );
iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty );
@@ -304,6 +306,47 @@
WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error );
if( error == KErrInUse )
{
+#ifdef _DEBUG
+ TPtrC fileName( aUri.Mid(2) );
+ WRITELOG1( "CHarvesterVideoPlugin :: Checking open file handles to %S", &fileName );
+
+ CFileList* fileList = 0;
+ TOpenFileScan fileScan( iFs );
+
+ TRAP_IGNORE( fileScan.NextL( fileList ) );
+
+ while ( fileList )
+ {
+ const TInt count( fileList->Count() );
+ for (TInt i = 0; i < count; i++ )
+ {
+ if ( (*fileList)[i].iName == aUri.Mid(2) )
+ {
+ TFullName processName;
+ TFindThread find(_L("*"));
+ while( find.Next( processName ) == KErrNone )
+ {
+ RThread thread;
+ TInt err = thread.Open( processName );
+
+ if ( err == KErrNone )
+ {
+ if ( thread.Id().Id() == fileScan.ThreadId() )
+ {
+ processName = thread.Name();
+ thread.Close();
+ WRITELOG1( "CHarvesterVideoPlugin:: %S has a file handle open", &processName );
+ break;
+ }
+ thread.Close();
+ }
+ }
+ }
+ }
+ fileList = NULL;
+ TRAP_IGNORE( fileScan.NextL( fileList ) );
+ }
+#endif
aObjectType.Copy( KInUse() );
}
return;
@@ -399,6 +442,46 @@
error == KErrLocked )
{
WRITELOG( "CHarvesterVideoPlugin - File is open!" );
+#ifdef _DEBUG
+ TPtrC fileName( uri.Mid(2) );
+ WRITELOG1( "CHarvesterVideoPlugin :: Checking open file handles to %S", &fileName );
+
+ CFileList* fileList = 0;
+ TOpenFileScan fileScan( iFs );
+
+ fileScan.NextL( fileList );
+
+ while ( fileList )
+ {
+ const TInt count( fileList->Count() );
+ for (TInt i = 0; i < count; i++ )
+ {
+ if ( (*fileList)[i].iName == uri.Mid(2) )
+ {
+ TFullName processName;
+ TFindThread find(_L("*"));
+ while( find.Next( processName ) == KErrNone )
+ {
+ RThread thread;
+ TInt err = thread.Open( processName );
+
+ if ( err == KErrNone )
+ {
+ if ( thread.Id().Id() == fileScan.ThreadId() )
+ {
+ processName = thread.Name();
+ thread.Close();
+ WRITELOG1( "CHarvesterVideoPlugin:: %S has a file handle open", &processName );
+ break;
+ }
+ thread.Close();
+ }
+ }
+ }
+ }
+ fileScan.NextL( fileList );
+ }
+#endif
CleanupStack::PopAndDestroy( &file );
User::Leave( KErrInUse );
}
@@ -418,16 +501,6 @@
{
CMdEProperty* prop = NULL;
CMdEObjectDef& objectDef = aMetadataObject.Def();
- CMdEPropertyDef& sizeDef = objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
- aMetadataObject.Property( sizeDef, prop );
- if( prop )
- {
- aVHD.iFileSize = prop->Uint32ValueL();
- }
- else
- {
- dataExtracted = EFalse;
- }
CMdEPropertyDef& modifiedDef = objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
aMetadataObject.Property( modifiedDef, prop );
if( prop )
@@ -454,9 +527,9 @@
aVHD.iModified = entry.iModified;
aVHD.iFileSize = (TUint)entry.iSize;
+
+ WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize );
}
-
- WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize );
// now the minimum information has been harvested
// from now on the harvested data should always be stored
@@ -483,6 +556,19 @@
// doesn't own pointers to MIME types
RPointerArray<HBufC> mimes;
CleanupClosePushL( mimes );
+
+ TPtrC ext;
+ MdsUtils::GetExt( uri, ext );
+
+ // Check for possibly protected content
+ if( ext.CompareF( KExtensionWmv ) == 0 )
+ {
+ ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
+ ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
+
+ data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
+ CleanupStack::PopAndDestroy( 2 ); // content, data
+ }
CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
CleanupStack::PushL( helixMetadata );
@@ -675,6 +761,77 @@
// don't destory mime type pointers just clean array
CleanupStack::PopAndDestroy( &mimes );
+
+ // If parsing failed, check for possible protected content
+ if( error == KErrNotSupported ||
+ error == KErrAccessDenied ||
+ error == KErrPermissionDenied )
+ {
+ ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
+ ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
+
+ if( !aVHD.iDrmProtected )
+ {
+ data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
+ }
+ if( aVHD.iDrmProtected )
+ {
+ ContentAccess::RStringAttributeSet attrSet;
+ CleanupClosePushL( attrSet );
+
+ attrSet.AddL( ContentAccess::EDescription );
+ attrSet.AddL( ContentAccess::ETitle );
+ attrSet.AddL( ContentAccess::EAuthor );
+ attrSet.AddL( ContentAccess::EGenre );
+
+ if( data->GetStringAttributeSet(attrSet) == KErrNone )
+ {
+ TBuf<KMaxDataTypeLength> value;
+
+ TInt err = attrSet.GetValue( ContentAccess::EDescription, value );
+ if ( err != KErrNone)
+ {
+ WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting description failed %d", err );
+ }
+ else if( value.Length() > 0 )
+ {
+ aVHD.iDescription = value.Alloc();
+ }
+
+ err = attrSet.GetValue( ContentAccess::ETitle, value );
+ if ( err != KErrNone)
+ {
+ WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting title failed %d", err );
+ }
+ else if( value.Length() > 0 )
+ {
+ aVHD.iTitle = value.Alloc();
+ }
+
+ err = attrSet.GetValue( ContentAccess::EAuthor, value );
+ if ( err != KErrNone)
+ {
+ WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting author failed %d", err );
+ }
+ else if( value.Length() > 0 )
+ {
+ aVHD.iAuthor = value.Alloc();
+ }
+
+ err = attrSet.GetValue( ContentAccess::EGenre, value );
+ if ( err != KErrNone)
+ {
+ WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting genre failed %d", err );
+ }
+ else if( value.Length() > 0 )
+ {
+ aVHD.iGenre = value.Alloc();
+ }
+ }
+ CleanupStack::PopAndDestroy(); // attrSet
+ }
+ CleanupStack::PopAndDestroy( 2 ); // content, data
+ }
}
else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling )
{
@@ -875,11 +1032,17 @@
{
if( aVHD.iVideoObject )
{
- CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd );
+ if( aVHD.iVideoBitrate != 0 )
+ {
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd );
+ }
}
else // audio object
{
- CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd );
+ if( aVHD.iAudioBitrate != 0 )
+ {
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd );
+ }
}
}
@@ -924,6 +1087,12 @@
{
CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
}
+
+ // DRM protection
+ if( aVHD.iDrmProtected )
+ {
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
+ }
}
void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )