harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 25 8e4539ab1889
child 41 2290317b9ec5
equal deleted inserted replaced
21:50bf9db68373 23:33ae025ac1e8
   159 */
   159 */
   160 CHarvesterVideoPlugin::~CHarvesterVideoPlugin()
   160 CHarvesterVideoPlugin::~CHarvesterVideoPlugin()
   161 	{
   161 	{
   162 	delete iPropDefs;
   162 	delete iPropDefs;
   163 	iMimeTypeMappings.Close();
   163 	iMimeTypeMappings.Close();
       
   164     RMediaIdUtil::ReleaseInstance();
   164 
   165 
   165 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
   166 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
   166 	}
   167 	}
   167 
   168 
   168 /**
   169 /**
   175 	TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction );
   176 	TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction );
   176 
   177 
   177 	// MPEG4
   178 	// MPEG4
   178 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   179 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   179     		KExtensionMp4(), KNullDesC(), 
   180     		KExtensionMp4(), KNullDesC(), 
   180     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   181     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   181     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   182     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   182     		cmp ) );
   183     		cmp ) );
   183 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   184 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   184     		KExtensionMpg4(), KNullDesC(), 
   185     		KExtensionMpg4(), KNullDesC(), 
   185     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   186     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   186     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   187     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   187     		cmp ) );
   188     		cmp ) );
   188 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   189 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   189     		KExtensionMpeg4(), KNullDesC(), 
   190     		KExtensionMpeg4(), KNullDesC(), 
   190     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   191     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   191     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   192     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   192     		cmp ) );
   193     		cmp ) );
   193 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   194 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   194     		KExtensionM4v(), KMimeTypeVideoMp4(), 
   195     		KExtensionM4v(), KMimeTypeVideoMp4(), 
   195     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KVideo(),
   196     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   196     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   197     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   197     		cmp ) );
   198     		cmp ) );
   198 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   199 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   199     		KExtensionM4a(), KMimeTypeAudioMp4(), 
   200     		KExtensionM4a(), KMimeTypeAudioMp4(), 
   200     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KAudio(),
   201     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KAudio(),
   201     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   202     				KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), 
   202     		cmp ) );
   203     		cmp ) );
   203 
   204 
   204 	// 3GP
   205 	// 3GP
   205 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   206 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   206     		KExtension3gp(), KNullDesC(), 
   207     		KExtension3gp(), KNullDesC(), 
   207     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   208     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   208     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   209     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   209     		cmp ) );
   210     		cmp ) );
   210 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   211 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   211     		KExtension3gpp(), KNullDesC(), 
   212     		KExtension3gpp(), KNullDesC(), 
   212     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   213     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   213     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   214     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   214     		cmp ) );
   215     		cmp ) );
   215 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   216 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   216     		KExtension3g2(), KNullDesC(), 
   217     		KExtension3g2(), KNullDesC(), 
   217     		TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(),
   218     		TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   218     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   219     				KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), 
   219     		cmp ) );
   220     		cmp ) );
   220 
   221 
   221 	// RealMedia
   222 	// RealMedia
   222 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   223 	User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   266             KExtensionWmv(), KMimeTypeWmv(), 
   267             KExtensionWmv(), KMimeTypeWmv(), 
   267             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   268             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   268                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
   269                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
   269             cmp ) );
   270             cmp ) );
   270     
   271     
       
   272     iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
   271     }
   273     }
   272 
   274 
   273 
   275 
   274 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   275 // GetObjectType
   277 // GetObjectType
   833             CleanupStack::PopAndDestroy( 2 ); // content, data
   835             CleanupStack::PopAndDestroy( 2 ); // content, data
   834             }
   836             }
   835         }
   837         }
   836     else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling )
   838     else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling )
   837         {
   839         {
       
   840 #ifdef MDS_MP4LIB_USAGE
   838         MP4Handle handle( 0 );
   841         MP4Handle handle( 0 );
   839         MP4Err mp4err = MP4_OK;
   842         MP4Err mp4err = MP4_OK;
   840         
   843         
   841         WRITELOG( "CHarvesterVideoPlugin - Before open file handle to parse" );
   844         WRITELOG( "CHarvesterVideoPlugin - Before open file handle to parse" );
   842         
   845         
   922         WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseClose - ready" );            
   925         WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseClose - ready" );            
   923         if ( mp4err != MP4_OK )
   926         if ( mp4err != MP4_OK )
   924             {
   927             {
   925             WRITELOG( "CHarvesterVideoPlugin - Error closing file handle" );
   928             WRITELOG( "CHarvesterVideoPlugin - Error closing file handle" );
   926             }
   929             }
       
   930 #endif
   927         }
   931         }
   928     WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
   932     WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
   929     CleanupStack::PopAndDestroy( &file );        
   933     CleanupStack::PopAndDestroy( &file );        
   930 
   934 
   931     WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
   935     WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
   946 
   950 
   947     if( !iPropDefs )
   951     if( !iPropDefs )
   948     	{
   952     	{
   949     	CMdEObjectDef& objectDef = mdeObject.Def();
   953     	CMdEObjectDef& objectDef = mdeObject.Def();
   950     	iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL( objectDef );
   954     	iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL( objectDef );
       
   955     	// Prefetch max text lengt for validity checking
       
   956     	iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
   951     	}
   957     	}
   952 
   958 
   953     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   959     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   954     TTime localModifiedDate = aVHD.iModified + timeOffsetSeconds;
   960     TTime localModifiedDate = aVHD.iModified + timeOffsetSeconds;
   955 
   961 
  1045     	        }
  1051     	        }
  1046     		}
  1052     		}
  1047     	}
  1053     	}
  1048 
  1054 
  1049     // Copyright
  1055     // Copyright
  1050     if( aVHD.iCopyright )
  1056     if( aVHD.iCopyright && aVHD.iCopyright->Length() < iMaxTextLength )
  1051     	{
  1057     	{
  1052     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCopyrightPropertyDef, aVHD.iCopyright, aIsAdd );
  1058     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCopyrightPropertyDef, aVHD.iCopyright, aIsAdd );
  1053     	}
  1059     	}
  1054 
  1060 
  1055     // Author
  1061     // Author
  1056     if( aVHD.iAuthor )
  1062     if( aVHD.iAuthor && aVHD.iAuthor->Length() < iMaxTextLength )
  1057     	{
  1063     	{
  1058     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAuthorPropertyDef, aVHD.iAuthor, aIsAdd );
  1064     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAuthorPropertyDef, aVHD.iAuthor, aIsAdd );
  1059     	}
  1065     	}
  1060 
  1066 
  1061     // Genre
  1067     // Genre
  1062     if( aVHD.iGenre )
  1068     if( aVHD.iGenre && aVHD.iGenre->Length() < iMaxTextLength )
  1063     	{
  1069     	{
  1064     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iGenrePropertyDef, aVHD.iGenre, aIsAdd );
  1070     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iGenrePropertyDef, aVHD.iGenre, aIsAdd );
  1065     	}
  1071     	}
  1066 
  1072 
  1067     // Artist
  1073     // Artist
  1068     if( aVHD.iPerformer )
  1074     if( aVHD.iPerformer && aVHD.iPerformer->Length() < iMaxTextLength )
  1069     	{
  1075     	{
  1070     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iArtistPropertyDef, aVHD.iPerformer, aIsAdd );
  1076     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iArtistPropertyDef, aVHD.iPerformer, aIsAdd );
  1071     	}
  1077     	}
  1072 
  1078 
  1073     // Description
  1079     // Description
  1074     if( aVHD.iDescription )
  1080     if( aVHD.iDescription && aVHD.iDescription->Length() < iMaxTextLength )
  1075     	{
  1081     	{
  1076     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDescriptionPropertyDef, aVHD.iDescription, aIsAdd );
  1082     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDescriptionPropertyDef, aVHD.iDescription, aIsAdd );
  1077     	}
  1083     	}
  1078     
  1084     
  1079     // Codec
  1085     // Codec
  1081         {
  1087         {
  1082         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
  1088         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
  1083         }
  1089         }
  1084     
  1090     
  1085     // Title
  1091     // Title
  1086     if( aVHD.iTitle )
  1092     if( aVHD.iTitle && aVHD.iTitle->Length() < iMaxTextLength )
  1087         {
  1093         {
  1088         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
  1094         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
  1089         }
  1095         }
  1090     
  1096     
  1091     // DRM protection
  1097     // DRM protection
  1093         {
  1099         {
  1094         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
  1100         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
  1095         }
  1101         }
  1096     }
  1102     }
  1097 
  1103 
       
  1104 #ifdef MDS_MP4LIB_USAGE 
  1098 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
  1105 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
  1099 	{
  1106     {
  1100     WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseOpenFileHandle - start" );
  1107     WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseOpenFileHandle - start" );
  1101     MP4Handle handle;
  1108     MP4Handle handle;
  1102 
  1109 
  1103     MP4Err mp4err = MP4ParseOpenFileHandle64( &handle, &aFile );
  1110     MP4Err mp4err = MP4ParseOpenFileHandle64( &handle, &aFile );
  1104     
  1111     
  1133     	aType.Copy( KVideo() );
  1140     	aType.Copy( KVideo() );
  1134     	}
  1141     	}
  1135 
  1142 
  1136     MP4ParseClose( handle );
  1143     MP4ParseClose( handle );
  1137 	}
  1144 	}
       
  1145 #else
       
  1146 void CHarvesterVideoPlugin::GetMp4Type( RFile64& /*aFile*/, TDes& /*aType*/ )
       
  1147     {
       
  1148     }
       
  1149 #endif
  1138 
  1150 
  1139 void CHarvesterVideoPlugin::GetRmTypeL( RFile64& aFile, TDes& aType )
  1151 void CHarvesterVideoPlugin::GetRmTypeL( RFile64& aFile, TDes& aType )
  1140 	{
  1152 	{
  1141 	TBool possibleVideo = EFalse;
  1153 	TBool possibleVideo = EFalse;
  1142 
  1154 
  1143 	CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
  1155 	CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
  1144 	CleanupStack::PushL( helixMetadata );
  1156 	CleanupStack::PushL( helixMetadata );
  1145 
  1157 
       
  1158 	TFileName tempName;
       
  1159 	TUint32 mediaId( 0 );
       
  1160 	TInt blackListError( KErrNone );
       
  1161 	
       
  1162     if( iBlacklist )
       
  1163         {
       
  1164         WRITELOG( "CHarvesterVideoPlugin::GetRmTypeL - Adding URI to blacklist" );
       
  1165         blackListError = aFile.FullName( tempName );
       
  1166         if( blackListError == KErrNone )
       
  1167             {
       
  1168             blackListError = iMediaIdUtil->GetMediaId( tempName, mediaId );
       
  1169             if( blackListError == KErrNone )
       
  1170                 {
       
  1171                 TTime modified ( 0 );
       
  1172                 blackListError = iFs.Modified( tempName, modified );
       
  1173                 if( blackListError == KErrNone )
       
  1174                     {
       
  1175                     iBlacklist->AddFile( tempName, mediaId, modified );
       
  1176                     }
       
  1177                 }
       
  1178             }
       
  1179         }
       
  1180 	
  1146 	TRAPD( err, helixMetadata->OpenFileL( aFile ) );
  1181 	TRAPD( err, helixMetadata->OpenFileL( aFile ) );
  1147 
  1182 
  1148 	if( err == KErrNone )
  1183 	if( err == KErrNone )
  1149 		{
  1184 		{
  1150 		// doesn't own pointers to MIME types
  1185 		// doesn't own pointers to MIME types
  1224 	// Set to Video, regardless how badly file is corrupted
  1259 	// Set to Video, regardless how badly file is corrupted
  1225 	else
  1260 	else
  1226 		{
  1261 		{
  1227 		aType.Copy( KVideo );
  1262 		aType.Copy( KVideo );
  1228 		}
  1263 		}
       
  1264 	
       
  1265     if ( iBlacklist && blackListError == KErrNone )
       
  1266         {
       
  1267         WRITELOG( "CHarvesterVideoPlugin::GetRmTypeL - Removing URI from blacklist" );
       
  1268         iBlacklist->RemoveFile( tempName, mediaId );
       
  1269         }
  1229     
  1270     
  1230 	helixMetadata->ResetL();
  1271 	helixMetadata->ResetL();
  1231     CleanupStack::PopAndDestroy( helixMetadata );
  1272     CleanupStack::PopAndDestroy( helixMetadata );
  1232 	}
  1273 	}
  1233 
  1274