harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
branchRCL_3
changeset 8 50de4d668bb6
parent 7 3cebc1a84278
child 9 82c0024438c8
equal deleted inserted replaced
7:3cebc1a84278 8:50de4d668bb6
    18 #include <e32base.h>
    18 #include <e32base.h>
    19 #include <e32std.h>
    19 #include <e32std.h>
    20 #include <3gplibrary/mp4lib.h>
    20 #include <3gplibrary/mp4lib.h>
    21 #include <hxmetadatautil.h>
    21 #include <hxmetadatautil.h>
    22 #include <hxmetadatakeys.h>
    22 #include <hxmetadatakeys.h>
       
    23 #include <caf/caf.h>
    23 
    24 
    24 #include "mdsutils.h"
    25 #include "mdsutils.h"
    25 #include "harvestervideoplugin.h"
    26 #include "harvestervideoplugin.h"
    26 #include "harvesterlog.h"
    27 #include "harvesterlog.h"
    27 #include "harvesterblacklist.h"
    28 #include "harvesterblacklist.h"
   107 	iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
   108 	iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
   108 	iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty );
   109 	iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty );
   109 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty );
   110 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty );
   110 	iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
   111 	iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
   111 	iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
   112 	iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
       
   113     iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty );
   112 	
   114 	
   113 	iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty );
   115 	iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty );
   114 
   116 
   115 	// Video property definitions
   117 	// Video property definitions
   116 	CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject );
   118 	CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject );
   552     if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling )
   554     if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling )
   553     	{
   555     	{
   554     	// doesn't own pointers to MIME types
   556     	// doesn't own pointers to MIME types
   555     	RPointerArray<HBufC> mimes;
   557     	RPointerArray<HBufC> mimes;
   556     	CleanupClosePushL( mimes );
   558     	CleanupClosePushL( mimes );
       
   559 
       
   560         TPtrC ext;
       
   561         MdsUtils::GetExt( uri, ext );
       
   562         
       
   563         // Check for possibly protected content
       
   564         if( ext.CompareF( KExtensionWmv ) == 0 )
       
   565             {
       
   566             ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
       
   567             ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
       
   568             
       
   569             data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
       
   570             CleanupStack::PopAndDestroy( 2 ); // content, data
       
   571             }
   557     	
   572     	
   558     	CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
   573     	CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
   559         CleanupStack::PushL( helixMetadata );
   574         CleanupStack::PushL( helixMetadata );
   560         
   575         
   561         TRAP( error, helixMetadata->OpenFileL( file ) );        
   576         TRAP( error, helixMetadata->OpenFileL( file ) );        
   744         helixMetadata->ResetL();
   759         helixMetadata->ResetL();
   745         CleanupStack::PopAndDestroy( helixMetadata );
   760         CleanupStack::PopAndDestroy( helixMetadata );
   746         
   761         
   747         // don't destory mime type pointers just clean array
   762         // don't destory mime type pointers just clean array
   748         CleanupStack::PopAndDestroy( &mimes );
   763         CleanupStack::PopAndDestroy( &mimes );
       
   764         
       
   765         // If parsing failed, check for possible protected content
       
   766         if( error == KErrNotSupported || 
       
   767             error == KErrAccessDenied ||
       
   768             error == KErrPermissionDenied )
       
   769             {
       
   770             ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
       
   771             ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
       
   772         
       
   773             if( !aVHD.iDrmProtected )
       
   774                 {
       
   775                 data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
       
   776                 }
       
   777             if( aVHD.iDrmProtected )
       
   778                 {
       
   779                 ContentAccess::RStringAttributeSet attrSet;
       
   780                 CleanupClosePushL( attrSet );
       
   781                 
       
   782                 attrSet.AddL( ContentAccess::EDescription );
       
   783                 attrSet.AddL( ContentAccess::ETitle );
       
   784                 attrSet.AddL( ContentAccess::EAuthor );
       
   785                 attrSet.AddL( ContentAccess::EGenre );
       
   786 
       
   787                 if( data->GetStringAttributeSet(attrSet) == KErrNone )
       
   788                     {
       
   789                     TBuf<KMaxDataTypeLength> value;
       
   790                     
       
   791                     TInt err = attrSet.GetValue( ContentAccess::EDescription, value );
       
   792                     if ( err != KErrNone)
       
   793                         {
       
   794                         WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting description failed %d", err );
       
   795                         }
       
   796                     else if( value.Length() > 0 )
       
   797                         {
       
   798                         aVHD.iDescription = value.Alloc();
       
   799                         }
       
   800                 
       
   801                     err = attrSet.GetValue( ContentAccess::ETitle, value );
       
   802                     if ( err != KErrNone)
       
   803                         {
       
   804                         WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting title failed %d", err );
       
   805                         }
       
   806                     else if( value.Length() > 0 )
       
   807                         {
       
   808                         aVHD.iTitle = value.Alloc();
       
   809                         }
       
   810                 
       
   811                     err = attrSet.GetValue( ContentAccess::EAuthor, value );
       
   812                     if ( err != KErrNone)
       
   813                         {
       
   814                         WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting author failed %d", err );
       
   815                         }
       
   816                     else if( value.Length() > 0 )
       
   817                         {
       
   818                         aVHD.iAuthor = value.Alloc();
       
   819                         }
       
   820 
       
   821                     err = attrSet.GetValue( ContentAccess::EGenre, value );
       
   822                     if ( err != KErrNone)
       
   823                         {
       
   824                         WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting genre failed %d", err );
       
   825                         }
       
   826                     else if( value.Length() > 0 )
       
   827                         {
       
   828                         aVHD.iGenre = value.Alloc();
       
   829                         }
       
   830                     }
       
   831                 CleanupStack::PopAndDestroy(); // attrSet
       
   832                 }
       
   833             CleanupStack::PopAndDestroy( 2 ); // content, data
       
   834             }
   749         }
   835         }
   750     else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling )
   836     else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling )
   751         {
   837         {
   752         MP4Handle handle( 0 );
   838         MP4Handle handle( 0 );
   753         MP4Err mp4err = MP4_OK;
   839         MP4Err mp4err = MP4_OK;
   944     	}
  1030     	}
   945     else
  1031     else
   946     	{
  1032     	{
   947     	if( aVHD.iVideoObject )
  1033     	if( aVHD.iVideoObject )
   948     		{
  1034     		{
   949     		CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd );
  1035     	    if( aVHD.iVideoBitrate != 0 )
       
  1036     	        {
       
  1037     		    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd );
       
  1038     	        }
   950     		}
  1039     		}
   951     	else // audio object
  1040     	else // audio object
   952     		{
  1041     		{
   953     		CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd );
  1042     	    if( aVHD.iAudioBitrate != 0 )
       
  1043     	        {
       
  1044     		    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd );
       
  1045     	        }
   954     		}
  1046     		}
   955     	}
  1047     	}
   956 
  1048 
   957     // Copyright
  1049     // Copyright
   958     if( aVHD.iCopyright )
  1050     if( aVHD.iCopyright )
   992     
  1084     
   993     // Title
  1085     // Title
   994     if( aVHD.iTitle )
  1086     if( aVHD.iTitle )
   995         {
  1087         {
   996         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
  1088         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
       
  1089         }
       
  1090     
       
  1091     // DRM protection
       
  1092     if( aVHD.iDrmProtected )
       
  1093         {
       
  1094         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
   997         }
  1095         }
   998     }
  1096     }
   999 
  1097 
  1000 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
  1098 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
  1001 	{
  1099 	{