aaclc_enc/ariaaclcencmmfcodec/inc/ariaaclcencmmfcodec.h
changeset 0 bb31fbe78861
equal deleted inserted replaced
-1:000000000000 0:bb31fbe78861
       
     1 /*
       
     2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Aricent - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Plugin class for AacLC encoder. This class inherits CMMFCodec
       
    16 * class and implements the pure virtual functions of CMMFCodec.
       
    17 * The class also has a few private funtions.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef ARIAACLCENCMMFCODEC_H
       
    23 #define ARIAACLCENCMMFCODEC_H
       
    24 
       
    25 #include <mmfcodec.h>
       
    26 
       
    27 //Enum representing the output file format
       
    28 enum TOutputFormat
       
    29     {
       
    30     EFormatRaw = 0,
       
    31     EFormatADIF = 1,
       
    32     EFormatADTS = 2
       
    33     };
       
    34 
       
    35 //Class to hold encoder parameters
       
    36 class TAacEncParam
       
    37     {
       
    38 public:
       
    39     TUint iNumberOfChannels;
       
    40     TUint iSamplingFrequency;
       
    41     TUint iTurnOnPns;
       
    42     TUint iTurnOnTns;
       
    43     TUint iVersionInfo;
       
    44     TOutputFormat iOutputFormat;
       
    45     TUint iOutputBitRate;
       
    46     };
       
    47 
       
    48 //Forward Declaration
       
    49 class CAriAacLCEncWrapper;
       
    50 
       
    51 //Class Declaration
       
    52 class CAriAacLCEncMmfCodec:public CMMFCodec
       
    53     {
       
    54 public: //constructors and destructors
       
    55 	/**
       
    56 	 * Two-phased constructor.
       
    57 	 * @return pointer to an instance of CMMFCodec
       
    58 	 */
       
    59 	static CMMFCodec* NewL();
       
    60 
       
    61 	/**> Destructor */
       
    62 	~CAriAacLCEncMmfCodec();
       
    63 
       
    64 public: // From CMMFCodec
       
    65 
       
    66     /**
       
    67      * From CMMFCodec
       
    68      * Sets codec configuration.
       
    69      * The configuration data is passed in as a descriptor of type TDesC8.
       
    70      * @param aConfigType
       
    71      * The UID of the configuration data.
       
    72      * @param aParam
       
    73      * Descriptor with frame info parameters in the form of RArray
       
    74      */
       
    75     virtual void ConfigureL( TUid aConfigType, const TDesC8& aParam );
       
    76 
       
    77     /**
       
    78     * From CMMFCodec
       
    79     * Codec reset function used to flush out status information when a
       
    80     * reposition occurs.
       
    81     * This is used if the codec requires resetting prior to use.
       
    82     */
       
    83     virtual void ResetL();
       
    84 
       
    85     /**
       
    86     * From CMMFCodec
       
    87     * Processes the data in the specified source buffer and writes the
       
    88     * processed data to the specified destination buffer.
       
    89     * This function is synchronous, when the function returns the data
       
    90     * has been processed. The source buffer is converted to the appropriate
       
    91     * coding type in the destination buffer. The buffers can be of any size,
       
    92     * therefore there is no guarantee that all the source buffer can be
       
    93     * processed to fill the destination buffer or that all the source buffer
       
    94     * may be processed before the destination is full. This function
       
    95     * therefore returns the number of source, and destination, bytes processed
       
    96     * along with a process result code indicating completion status.This
       
    97     * function is synchronous, when the function returns the data has been
       
    98     * processed. The source buffer is converted to the appropriate coding type
       
    99     * in the destination buffer. The buffers can be of any size, therefore
       
   100     * there is no guarantee that all the source buffer can be processed to
       
   101     * fill the destination buffer or that all the source buffer may be
       
   102     * processed before the destination is full. This function therefore
       
   103     * returns the number of source, and destination, bytes processed along
       
   104     * with a process result code indicating completion status.The aSource and
       
   105     * aSink buffers passed in are derived from CMMFBuffer. The buffer type
       
   106     * (e.g. a CMMFDataBuffer) passed in should be supported by the codec
       
   107     * otherwise this function should leave with KErrNotSupported. The
       
   108     * position of the source buffer should be checked by calling the source
       
   109     * buffer's Position() member which indicates the current source read
       
   110     * position in bytes. The codec should start processing from the current
       
   111     * source buffer read position. The position of the destination buffer
       
   112     * should be checked by calling the destination buffer's Position() method
       
   113     * which indicates the current destination write position in bytes.
       
   114     * The codec should start writing to the destination buffer at the current
       
   115     * destination buffer write position.This is a virtual function that each
       
   116     * derived class must implement.
       
   117     * @see enum TCodecProcessResult
       
   118     * @param  aSource
       
   119     *         The source buffer containing data to encode or decode.
       
   120     * @param  aDestination
       
   121     *         The destination buffer to hold the data after encoding or
       
   122     *         decoding.
       
   123     * @return The result of the processing.
       
   124     * @pre    The function ConfigureL() should have been called.
       
   125     */
       
   126     virtual TCodecProcessResult ProcessL( const CMMFBuffer& aSource,
       
   127                                                 CMMFBuffer& aDestination );
       
   128 
       
   129 private:
       
   130 
       
   131 	/**
       
   132 	 *  Default Constructor
       
   133 	 */
       
   134 	CAriAacLCEncMmfCodec();
       
   135 
       
   136 	/**
       
   137 	 *  Symbian 2nd phase constructor
       
   138 	 */
       
   139 	void ConstructL();
       
   140 
       
   141 	/**
       
   142      * Update the result with result status, source bytes consumed
       
   143      * and destination bytes added.
       
   144      * @param   aStatus
       
   145      *          status of the result like EProcessComplete
       
   146      * @param   aSrcBytesConsumed
       
   147      *          total bytes consumed from the source buffer
       
   148      * @param   aDstBytesAdded
       
   149      *          total bytes added to the destination buffer
       
   150      * @return  result of the processing
       
   151      */
       
   152     TCodecProcessResult Result(
       
   153             TCodecProcessResult::TCodecProcessResultStatus aStatus,
       
   154             TInt aSrcBytesConsumed, TInt aDstBytesAdded );
       
   155 
       
   156     /**
       
   157      * Copy the bytes from internal output buffer to destination buffer
       
   158      * @param   aDst
       
   159      *          pointer to the destination buffer
       
   160      * @param   aDstBytesConsumed
       
   161      *          total bytes added to the destination buffer
       
   162      * @return  number of bytes copied to the destination buffer.
       
   163      */
       
   164     TInt CopyToDstBuffer( CMMFDataBuffer* aDst, TInt& aDstBytesConsumed );
       
   165 
       
   166     /**
       
   167      * Copy the bytes from the source buffer to the internal input burrer
       
   168      * @param   aSrc
       
   169      *          pointer to the source buffer
       
   170      * @param   aSrcBytesConsumed
       
   171      *          total bytes consumed from the source buffer
       
   172      * @return  number bytes copied from the source buffer
       
   173      */
       
   174     TInt CopyFromSrcBuffer(const CMMFDataBuffer* aSrc,
       
   175                         TInt& aSrcBytesConsumed );
       
   176     /**
       
   177      * Shifts the data in the input internal buffer to start position
       
   178      * @param   aFromPos
       
   179      *          position from where data has to shift
       
   180      * @param   aToPos
       
   181      *          position to where data has to shift
       
   182      */
       
   183     void ShiftData( TInt aFromPos, TInt aToPos );
       
   184 
       
   185 private: //Data
       
   186 
       
   187 	// Handle TO wrapper class
       
   188     CAriAacLCEncWrapper*    iCodec;
       
   189 
       
   190     TBool                   iConfigured;
       
   191     TBool                   iHeaderGenerated;
       
   192     TAacEncParam            iParam;
       
   193     //No of bytes of source to be provided to encoder to encode one frame
       
   194     TInt                    iSrclenToProcess;
       
   195 
       
   196     /**
       
   197      * Setting this flag indicates whether only one frame has to encoded at a
       
   198      * time or encode till destination buffer is full
       
   199      */
       
   200     TBool                   iFillBuffer;
       
   201     TInt                    iInternalInputBufferResidueLen;
       
   202     TInt                    iInternalOutputBufferResidueLen;
       
   203     TUint8*                 iInternalInputBuffer;
       
   204     TUint8*                 iInternalOutputBuffer;
       
   205     TInt                    iInternalOutputBufferPos;
       
   206 
       
   207     };
       
   208 
       
   209 #endif /* ARIAACLCENCMMFCODEC_H */