mmserv/thumbnailengine/TneProcessorInc/Parser.h
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2002 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:   Definition of an abstract base class for file format parsers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __PARSER_H__
       
    22 #define __PARSER_H__
       
    23 
       
    24 //  INCLUDES
       
    25 #ifndef __E32BASE_H__
       
    26 #include <e32base.h>
       
    27 #endif
       
    28 
       
    29 // CONSTANTS
       
    30 // MACROS
       
    31 // DATA TYPES
       
    32 // FUNCTION PROTOTYPES
       
    33 // FORWARD DECLARATIONS
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  Base class for file format parser
       
    38 *  ?other_description_lines
       
    39 */
       
    40 class CParser : public CBase
       
    41 {
       
    42 	
       
    43 public: // Constants
       
    44 	
       
    45 	enum TErrorCode 
       
    46 	{
       
    47 		EInternalAssertionFailure   = -2200,
       
    48 			EParserNotEnoughData = -2201,
       
    49 			EParserEndOfStream = -2202,
       
    50 			EParserBufferTooSmall = -2203,
       
    51 			EParserUnsupportedFormat = -2204,
       
    52 			EParserStreamCorrupted = -2205,
       
    53 			EParserFailure = -2206
       
    54 	};
       
    55 
       
    56 	// file format
       
    57 	enum TFileFormat {
       
    58 		EFileFormatUnrecognized = 0,
       
    59 	    EFileFormat3GP,
       
    60 		EFileFormatMP4
       
    61 	};
       
    62 	
       
    63 	// video format
       
    64 	enum TVideoFormat {
       
    65 		EVideoFormatNone = 0,
       
    66 		EVideoFormatH263Profile0Level10,
       
    67 		EVideoFormatH263Profile0Level45,        
       
    68         EVideoFormatMPEG4,
       
    69         EVideoFormatAVCProfileBaseline,
       
    70         EVideoFormatAVCProfileMain,
       
    71         EVideoFormatAVCProfileExtended
       
    72 	};
       
    73 	
       
    74 	
       
    75 #ifdef __VIDEOEDIT__
       
    76 		enum TProcessingMode
       
    77 		{
       
    78 			EParseOnly = 1,
       
    79 				EParseAndDecode,
       
    80 				EDecodeOnly
       
    81 		};
       
    82 #endif
       
    83 		
       
    84 public: // Data structures
       
    85 	
       
    86 	// common stream parameters
       
    87 	struct TStreamParameters 
       
    88 	{
       
    89 		TBool iHaveVideo;  // is there video in the stream ?
       
    90 		TFileFormat iFileFormat;  // file format
       
    91 		TVideoFormat iVideoFormat;  // video format
       
    92 		    
       
    93 		TUint iVideoWidth;  // width of a video frame
       
    94 		TUint iVideoHeight;   // height of a video frame
       
    95 		TInt64 iVideoPicturePeriodNsec;  // one PCF tick period in nanoseconds
       
    96 		TUint iVideoIntraFrequency;  // intra frame frequency in stream
       
    97 		
       
    98 		TUint iStreamLength;  // stream length in milliseconds
       
    99 		TUint iVideoLength;
       
   100 		
       
   101 		TBool iCanSeek;   // TRUE if seeking in file is possible
       
   102 		
       
   103 		TUint iStreamSize;  // stream size in bytes
       
   104 		TUint iStreamBitrate;  // stream average bitrate            
       
   105 		
       
   106 		TUint iMaxPacketSize; // The maximum media packet size
       
   107 		TUint iLogicalChannelNumberVideo; // Logical channel number for video data
       
   108 		TUint iReferencePicturesNeeded; // Number of reference pictures
       
   109 		// the video decoder needs to store.
       
   110 		TUint iNumScalabilityLayers; // The number of different scalability layers used
       
   111 		
       
   112 		TReal iFrameRate;
       
   113 		TUint iVideoTimeScale; 
       
   114 		
       
   115 	};
       
   116 		
       
   117 	public: // New functions
       
   118 				
       
   119 		/**
       
   120 		* Parses the stream header.
       
   121 		* @param aStreamParameters Stream parameters        
       
   122 		*/	
       
   123         
       
   124         virtual TInt ParseHeaderL(TStreamParameters& aStreamParameters) = 0;
       
   125 				
       
   126         /**
       
   127         * Resets the parser to initial state.
       
   128         * => If input stream is in a file, rewinds it.
       
   129         * => If input is written to parser, all buffered bytes are flushed
       
   130         * @param aStreamParameters Stream parameters        
       
   131         */
       
   132         virtual TInt Reset() = 0; 				        
       
   133 
       
   134         /**
       
   135         * Gets the number of frames in the current clip
       
   136         *
       
   137         * @return Number of frames
       
   138         */
       
   139         inline TInt GetNumberOfFramesInClip() { return iNumberOfFrames; }
       
   140         
       
   141         virtual	TInt GetNumberOfVideoFrames() = 0; 
       
   142 
       
   143   //      virtual TInt GetNumberOfFrames() = 0;
       
   144 
       
   145         /**
       
   146         * Seeks to intra frame before given time
       
   147         *
       
   148         * @param aStartTime Time in microseconds to seek
       
   149         * @param aIndex Index of the frame at aStartTime, if known. 0 otherwise
       
   150         *
       
   151         * @return Number of frames
       
   152         */
       
   153 		virtual	TInt SeekOptimalIntraFrame(TTimeIntervalMicroSeconds aStartTime, TInt aIndex) = 0; 
       
   154 
       
   155         /**
       
   156         * Gets the size of video frame at given index
       
   157         *
       
   158         * @param aIndex Index of the frame
       
   159         *
       
   160         * @return Size of frame in bytes
       
   161         */
       
   162         virtual	TInt GetVideoFrameSize(TInt aIndex) = 0;
       
   163 
       
   164         /**
       
   165         * Gets the timestamp of video frame at given index
       
   166         *
       
   167         * @param aIndex Index of the frame
       
   168         * @param aTimeStamp Output: timestamp in ticks
       
   169         *
       
   170         * @return Timestamp in milliseconds
       
   171         */
       
   172         virtual	TInt GetVideoFrameStartTime(TInt aIndex, TInt* aTimeStampInTicks) = 0;
       
   173 
       
   174         /**
       
   175         * Gets the type of video frame at given index
       
   176         *
       
   177         * @param aIndex Index of the frame
       
   178         *
       
   179         * @return Frame type: 1 = INTRA, 0 = INTER
       
   180         */
       
   181         virtual	TInt8 GetVideoFrameType(TInt aIndex) = 0;			        
       
   182         
       
   183         /**
       
   184         * Gets the start frame index of the current clip                
       
   185         *
       
   186         * @return Frame index
       
   187         */
       
   188         inline TInt GetStartFrameIndex() { return iStartFrameIndex; }
       
   189 
       
   190 
       
   191     public:  // Data
       
   192 
       
   193         // stream parameters
       
   194         TStreamParameters iStreamParameters;
       
   195         // ETrue if parsing this clip for the first time
       
   196         TBool iFirstTimeClipParsing;
       
   197          // number of frames in output clip
       
   198         TInt iOutputNumberOfFrames; 
       
   199 
       
   200     protected:  // Data
       
   201 
       
   202         // current frame number
       
   203         TInt iFrameNumber;  
       
   204         // number of frames in current clip
       
   205         TInt iNumberOfFrames; 
       
   206         // index of the first included frame
       
   207         TInt iStartFrameIndex;
       
   208 		
       
   209     };
       
   210 		
       
   211 #endif      // __PARSER_H__   
       
   212 		
       
   213 // End of File