harvester/harvesterplugins/VideoPlugin/inc/harvestervideoplugin.h
changeset 0 c53acadfccc6
child 3 6752808b2036
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Harvests meta data from video file.*
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef __CHARVESTERVIDEOPLUGIN_H__
       
    19 #define __CHARVESTERVIDEOPLUGIN_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "harvesterplugin.h"
       
    23 
       
    24 #include "mimetypemapping.h"
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 class CMdEObjectDef;
       
    28 class CMdEPropertyDef;
       
    29 class CMdEObject;
       
    30 class CHarvesterData;
       
    31 
       
    32 class TVideoMetadataHandling
       
    33 	{
       
    34 	public:
       
    35 		enum TVideoMetadataHandlingLibrary
       
    36 			{
       
    37 			EMp4LibHandling,
       
    38 			EHexilMetadataHandling
       
    39 			};
       
    40 
       
    41 		TVideoMetadataHandlingLibrary iLibrary;
       
    42 		TPtrC iObjectDef;
       
    43 		TPtrC iVideoMime;
       
    44 		TPtrC iAudioMime;
       
    45 
       
    46 		TVideoMetadataHandling()
       
    47 			{		
       
    48 			}
       
    49 		
       
    50 		TVideoMetadataHandling(TVideoMetadataHandlingLibrary aLibrary, 
       
    51 				TPtrC aObjectDef, TPtrC aVideoMime, TPtrC aAudioMime) :
       
    52 			iLibrary( aLibrary ), iObjectDef( aObjectDef ),
       
    53 			iVideoMime( aVideoMime ), iAudioMime( aAudioMime ) 
       
    54 			{		
       
    55 			}
       
    56 		
       
    57 		TVideoMetadataHandling(const TVideoMetadataHandling& aHandling) :
       
    58 			iLibrary( aHandling.iLibrary ), iObjectDef( aHandling.iObjectDef ),
       
    59 			iVideoMime( aHandling.iVideoMime ), iAudioMime( aHandling.iAudioMime )
       
    60 			{
       
    61 			}
       
    62 	};
       
    63 
       
    64 typedef TMimeTypeMapping<TVideoMetadataHandling> THarvestingHandling;
       
    65 	
       
    66 /**
       
    67 * A data transfer class for harvested video metadata.
       
    68 */
       
    69 class CVideoHarvestData : public CBase
       
    70     {
       
    71     public:
       
    72     	TBool iVideoObject; // Is object video or audio
       
    73 
       
    74     	TTime iModified;
       
    75     	TInt64 iFileSize; // in bytes
       
    76         TReal32 iDuration; // in seconds
       
    77         TReal32 iFrameRate; // in frames per second
       
    78         TReal32 iSamplingFrequency; // in kHz 
       
    79         TInt iVideoBitrate; // in kbps
       
    80         TInt iAudioBitrate; // in kbps
       
    81         TInt iClipBitrate; // in kbps
       
    82         TInt16 iFrameWidth;
       
    83         TInt16 iFrameHeight;
       
    84         HBufC* iCopyright;
       
    85         HBufC* iAuthor;
       
    86         HBufC* iGenre;
       
    87         HBufC* iPerformer; // Artist
       
    88         HBufC* iDescription;
       
    89 
       
    90         HBufC* iMimeBuf;
       
    91         TUint32 iCodec;
       
    92 
       
    93         CVideoHarvestData() : CBase()
       
    94         	{
       
    95         	}
       
    96 
       
    97         ~CVideoHarvestData()
       
    98         	{
       
    99         	delete iCopyright;
       
   100             delete iAuthor;
       
   101             delete iGenre;
       
   102             delete iPerformer;
       
   103             delete iDescription;
       
   104 
       
   105         	delete iMimeBuf;
       
   106         	}
       
   107     };
       
   108 
       
   109 /**
       
   110  * Helper class to hold all property definitions 
       
   111  * (pointers are not owned) used in harvester video plug-in.
       
   112  */
       
   113 class CHarvesterVideoPluginPropertyDefs : public CBase
       
   114 	{
       
   115 	public:
       
   116 		// Common property definitions
       
   117 		CMdEPropertyDef* iCreationDatePropertyDef;
       
   118 		CMdEPropertyDef* iLastModifiedDatePropertyDef;
       
   119 		CMdEPropertyDef* iSizePropertyDef;
       
   120 		CMdEPropertyDef* iTimeOffsetPropertyDef;
       
   121 		CMdEPropertyDef* iItemTypePropertyDef;
       
   122 	
       
   123 		// Media property definitions
       
   124 		CMdEPropertyDef* iReleaseDatePropertyDef;
       
   125 		CMdEPropertyDef* iCaptureDatePropertyDef;
       
   126 		CMdEPropertyDef* iDurationPropertyDef;
       
   127 		CMdEPropertyDef* iWidthPropertyDef;
       
   128 		CMdEPropertyDef* iHeightPropertyDef;
       
   129 		CMdEPropertyDef* iBitratePropertyDef;
       
   130 		CMdEPropertyDef* iCopyrightPropertyDef;
       
   131 		CMdEPropertyDef* iAuthorPropertyDef;
       
   132 		CMdEPropertyDef* iGenrePropertyDef;
       
   133 		CMdEPropertyDef* iArtistPropertyDef;
       
   134 		CMdEPropertyDef* iDescriptionPropertyDef;
       
   135 		
       
   136 		CMdEPropertyDef* iAudioFourCCDef;
       
   137 	
       
   138 		// Video property definitions
       
   139 		CMdEPropertyDef* iFrameratePropertyDef;
       
   140 	
       
   141 		// Audio property definitions
       
   142 		CMdEPropertyDef* iSamplingFrequencyPropertyDef;
       
   143 	
       
   144 	private:
       
   145 		CHarvesterVideoPluginPropertyDefs();
       
   146 	
       
   147 		void ConstructL(CMdEObjectDef& aObjectDef);
       
   148 
       
   149 	public:	
       
   150 		static CHarvesterVideoPluginPropertyDefs* NewL(CMdEObjectDef& aObjectDef);
       
   151 	};
       
   152 
       
   153 class CHarvesterVideoPlugin : public CHarvesterPlugin
       
   154   	{
       
   155 	public:
       
   156 		/**
       
   157 		* Constructs a new CHarvesterVideoPlugin implementation.
       
   158 		*
       
   159 		* @return A pointer to the new CHarvesterVideoPlugin implementation
       
   160 		*/
       
   161 		static CHarvesterVideoPlugin* NewL();
       
   162 		
       
   163 		/**
       
   164 		* Destructor
       
   165 		*/
       
   166 		virtual ~CHarvesterVideoPlugin();
       
   167 		
       
   168 		void GetObjectType( const TDesC& aUri, TDes& aObjectType );
       
   169 
       
   170 		/**
       
   171 		* Harvests several files. Inherited from CHarvestPlugin.
       
   172 		*
       
   173 		* @param aHarvesterData  CHarvesterData datatype containing needed harvest data
       
   174  		* @param aClientData  TAny* to client specific data
       
   175 		*/
       
   176 		void HarvestL( CHarvesterData* aHD );
       
   177 				
       
   178 	private:
       
   179 		/**
       
   180 		* C++ constructor - not exported;
       
   181 		* implicitly called from NewL()
       
   182 		*
       
   183 		* @return an instance of CHarvesterVideoPlugin.
       
   184 		*/
       
   185 		CHarvesterVideoPlugin();
       
   186 		
       
   187 		/**
       
   188 		* 2nd phase construction, called by NewLC()
       
   189 		*/
       
   190 		void ConstructL();
       
   191 		
       
   192 		/**
       
   193         * Gathers data from file to meta data object.
       
   194         *
       
   195         * @param aMetadataObject  A reference to meta data object to gather the data.
       
   196         * @param aHarvestData  An object to store harvested video file data.
       
   197         */
       
   198         void GatherDataL( CMdEObject& aMetadataObject, CVideoHarvestData& aHarvestData );
       
   199 		
       
   200         /**
       
   201          * Handle addition of new mde video objects.
       
   202          *
       
   203          * @param aMetadataObject  A reference to meta data object to gather the data.
       
   204          * @param aHarvestData  An object containing harvested video file data.
       
   205          */
       
   206         void HandleObjectPropertiesL( CHarvesterData& aHD, CVideoHarvestData& aVHD, TBool aIsAdd );
       
   207           
       
   208 	private:
       
   209 		void GetMp4Type( RFile64& aFile, TDes& aType );
       
   210 		
       
   211 		void GetRmTypeL( RFile64& aFile, TDes& aType );
       
   212 	
       
   213 		const THarvestingHandling* FindHandler( const TDesC& aUri );
       
   214 		
       
   215 		void CheckForCodecSupport( HBufC* aMimeBuffer, CVideoHarvestData& aVHD );
       
   216 		
       
   217 	private:
       
   218 		RArray<THarvestingHandling> iMimeTypeMappings;
       
   219 		
       
   220 		CHarvesterVideoPluginPropertyDefs* iPropDefs;
       
   221 	};
       
   222 
       
   223 #endif // __CHARVESTERVIDEOPLUGIN_H__