harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
branchRCL_3
changeset 3 6752808b2036
parent 1 acef663c1218
child 6 646a02f170b9
equal deleted inserted replaced
2:b73a2e62868f 3:6752808b2036
    23 
    23 
    24 #include "mdsutils.h"
    24 #include "mdsutils.h"
    25 #include "harvestervideoplugin.h"
    25 #include "harvestervideoplugin.h"
    26 #include "harvesterlog.h"
    26 #include "harvesterlog.h"
    27 #include "harvesterblacklist.h"
    27 #include "harvesterblacklist.h"
       
    28 #include "harvestercommon.h"
    28 #include "mdeobjectwrapper.h"
    29 #include "mdeobjectwrapper.h"
    29 
    30 
    30 #include <mdenamespacedef.h>
    31 #include <mdenamespacedef.h>
    31 #include <mdeobjectdef.h>
    32 #include <mdeobjectdef.h>
    32 #include <mdepropertydef.h>
    33 #include <mdepropertydef.h>
    45 _LIT( KMimeTypeRv,        "video/vnd.rn-realvideo" );
    46 _LIT( KMimeTypeRv,        "video/vnd.rn-realvideo" );
    46 _LIT( KMimeTypeRa,        "audio/vnd.rn-realaudio" );
    47 _LIT( KMimeTypeRa,        "audio/vnd.rn-realaudio" );
    47 _LIT( KMimeTypeAvi,        "video/avi");
    48 _LIT( KMimeTypeAvi,        "video/avi");
    48 _LIT( KMimeTypeVideoMatroska, "video/x-matroska");
    49 _LIT( KMimeTypeVideoMatroska, "video/x-matroska");
    49 _LIT( KMimeTypeAudioMatroska, "audio/x-matroska");
    50 _LIT( KMimeTypeAudioMatroska, "audio/x-matroska");
       
    51 _LIT( KMimeTypeWmv, "video/x-ms-wmv");
       
    52 _LIT( KMimeTypeDivx, "video/x-hx-divx");
    50 
    53 
    51 _LIT( KExtensionMp4,   "mp4" );
    54 _LIT( KExtensionMp4,   "mp4" );
    52 _LIT( KExtensionMpg4,  "mpg4" );
    55 _LIT( KExtensionMpg4,  "mpg4" );
    53 _LIT( KExtensionMpeg4, "mpeg4" );
    56 _LIT( KExtensionMpeg4, "mpeg4" );
    54 _LIT( KExtensionM4v,   "m4v" );
    57 _LIT( KExtensionM4v,   "m4v" );
    60 _LIT( KExtensionRmvb,  "rmvb" );
    63 _LIT( KExtensionRmvb,  "rmvb" );
    61 _LIT( KExtensionRv,    "rv" );
    64 _LIT( KExtensionRv,    "rv" );
    62 _LIT( KExtensionAvi,    "avi" );
    65 _LIT( KExtensionAvi,    "avi" );
    63 _LIT( KExtensionMkv,    "mkv" );
    66 _LIT( KExtensionMkv,    "mkv" );
    64 _LIT( KExtensionRa,     "ra" );
    67 _LIT( KExtensionRa,     "ra" );
       
    68 _LIT( KExtensionWmv,     "wmv" );
       
    69 _LIT( KExtensionDivx,     "divx" );
    65 
    70 
    66 _LIT(KVideo, "Video");
    71 _LIT(KVideo, "Video");
    67 _LIT(KAudio, "Audio");
    72 _LIT(KAudio, "Audio");
    68 
    73 
    69 _LIT(KAudioAC3, "audio/AC3");
    74 _LIT(KAudioAC3, "audio/AC3");
    89 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
    94 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
    90 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    95 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    91 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    96 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    92 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    97 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    93 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
    98 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
       
    99 	iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
    94 
   100 
    95 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
   101 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
    96 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
   102 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
    97 	iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
   103 	iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
    98 	iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
   104 	iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
   237             KExtensionAvi(), KMimeTypeAvi(), 
   243             KExtensionAvi(), KMimeTypeAvi(), 
   238             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   244             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   239                     KMimeTypeAvi(), KMimeTypeAvi() ) ), 
   245                     KMimeTypeAvi(), KMimeTypeAvi() ) ), 
   240             cmp ) );
   246             cmp ) );
   241     
   247     
       
   248     // Divx
       
   249     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
       
   250             KExtensionDivx(), KMimeTypeDivx(), 
       
   251             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
       
   252                     KMimeTypeDivx(), KMimeTypeDivx() ) ), 
       
   253             cmp ) );
       
   254     
   242     // Matroska
   255     // Matroska
   243     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   256     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   244             KExtensionMkv(), KNullDesC(), 
   257             KExtensionMkv(), KNullDesC(), 
   245             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   258             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(),
   246                     KMimeTypeVideoMatroska(), KMimeTypeAudioMatroska() ) ), 
   259                     KMimeTypeVideoMatroska(), KMimeTypeAudioMatroska() ) ), 
   247             cmp ) );
   260             cmp ) );
       
   261     
       
   262     // Wmv
       
   263     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
       
   264             KExtensionWmv(), KMimeTypeWmv(), 
       
   265             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
       
   266                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
       
   267             cmp ) );
       
   268     
       
   269     SetPriority( KHarvesterPriorityHarvestingPlugin + 1 );
   248     }
   270     }
   249 
   271 
   250 
   272 
   251 // ---------------------------------------------------------------------------
   273 // ---------------------------------------------------------------------------
   252 // GetObjectType
   274 // GetObjectType
   338         aHD->SetErrorCode( convertedError );
   360         aHD->SetErrorCode( convertedError );
   339         }
   361         }
   340 
   362 
   341     CleanupStack::PopAndDestroy( fileData );
   363     CleanupStack::PopAndDestroy( fileData );
   342 	}
   364 	}
       
   365 
       
   366 // ---------------------------------------------------------------------------
       
   367 // CHarvesterVideoPlugin::GetMimeType (from CHarvesterPlugin)
       
   368 // ---------------------------------------------------------------------------
       
   369 //    
       
   370 void CHarvesterVideoPlugin::GetMimeType( const TDesC& aUri, TDes& aMimeType )
       
   371     {
       
   372     aMimeType.Zero();
       
   373     
       
   374     const THarvestingHandling* mapping = FindHandler( aUri );
       
   375 
       
   376     // no matching extension found
       
   377     if( !mapping )
       
   378         {
       
   379         return;
       
   380         }
       
   381 
       
   382     aMimeType = mapping->iMimeType;
       
   383     }
   343 
   384 
   344 // ---------------------------------------------------------------------------
   385 // ---------------------------------------------------------------------------
   345 // GatherDataL
   386 // GatherDataL
   346 // ---------------------------------------------------------------------------
   387 // ---------------------------------------------------------------------------
   347 //
   388 //
   459         	for ( TUint i = 0; i < metacount; i++ )
   500         	for ( TUint i = 0; i < metacount; i++ )
   460         		{        		
   501         		{        		
   461         		helixMetadata->GetMetaDataAt( i, metaid, buf );
   502         		helixMetadata->GetMetaDataAt( i, metaid, buf );
   462         		switch (metaid)
   503         		switch (metaid)
   463         			{
   504         			{
       
   505                     case HXMetaDataKeys::EHXTitle:
       
   506                         {
       
   507                         aVHD.iTitle = buf->Alloc();
       
   508                         break;
       
   509                         }
   464         			case HXMetaDataKeys::EHXVideoBitRate:
   510         			case HXMetaDataKeys::EHXVideoBitRate:
   465 	        			{
   511 	        			{
   466         				WRITELOG( "CHarvesterVideoPlugin - found videobitrate" );
   512         				WRITELOG( "CHarvesterVideoPlugin - found videobitrate" );
   467 	        			if( aVHD.iVideoObject )
   513 	        			if( aVHD.iVideoObject )
   468 	        				{
   514 	        				{
   757     
   803     
   758     	// File size
   804     	// File size
   759     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
   805     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
   760     	}
   806     	}
   761 
   807 
       
   808     // Item Type
       
   809     if( aVHD.iMimeBuf )
       
   810         {
       
   811         TBool isAdd( EFalse );
       
   812         CMdEProperty* prop = NULL;
       
   813         TInt index = mdeObject.Property( *iPropDefs->iItemTypePropertyDef, prop );
       
   814         if( index < 0 )
       
   815             {
       
   816             isAdd = ETrue;
       
   817             }
       
   818             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, aVHD.iMimeBuf, isAdd );
       
   819         }
       
   820     
   762     // Release date
   821     // Release date
   763 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iReleaseDatePropertyDef, &localModifiedDate, aIsAdd );
   822 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iReleaseDatePropertyDef, &localModifiedDate, aIsAdd );
   764 
   823 
   765 	// Capture date
   824 	// Capture date
   766 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCaptureDatePropertyDef, &localModifiedDate, aIsAdd );
   825 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCaptureDatePropertyDef, &localModifiedDate, aIsAdd );
   767 
   826 
   768 	// Time offset
   827 	// Time offset
   769 	TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   828 	TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   770 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
   829 	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
   771 
       
   772     // Item Type
       
   773 	if( aVHD.iMimeBuf )
       
   774 		{
       
   775 		CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, aVHD.iMimeBuf, aIsAdd );
       
   776 		}
       
   777 
   830 
   778     // Duration
   831     // Duration
   779 	if( aVHD.iDuration != 0.0f )
   832 	if( aVHD.iDuration != 0.0f )
   780 		{
   833 		{
   781 		CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDurationPropertyDef, &aVHD.iDuration, aIsAdd );
   834 		CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDurationPropertyDef, &aVHD.iDuration, aIsAdd );
   859     
   912     
   860     // Codec
   913     // Codec
   861     if( aVHD.iCodec != 0 )
   914     if( aVHD.iCodec != 0 )
   862         {
   915         {
   863         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
   916         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
       
   917         }
       
   918     
       
   919     // Title
       
   920     if( aVHD.iTitle )
       
   921         {
       
   922         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
   864         }
   923         }
   865     }
   924     }
   866 
   925 
   867 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
   926 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType )
   868 	{
   927 	{