amrnb_enc/ariamrnbencmmfcodec/inc/ariamrnbencmmfcodec.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 AmrNb 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 #ifndef ARIAMRNBENCMMFCODEC_H
       
    22 #define ARIAMRNBENCMMFCODEC_H
       
    23 
       
    24 #include <mmfcodec.h>
       
    25 
       
    26 //Class to hold encoding parameters
       
    27 class TAmrNbEncParam
       
    28     {
       
    29 public:
       
    30     //encoding mode to specify bitrate(takes values 0 to 7)
       
    31     TInt16	iMode;
       
    32     //discontinuous transmission flag(1-true/0-false)
       
    33     TInt16  iDtx;
       
    34     //type of file(0-RTP/1-3GPP);need not be set(By default-RTP)
       
    35     TInt16	iFileFormat;
       
    36     };
       
    37 
       
    38 //Forward Declaration
       
    39 class CAriAmrNbEncWrapper;
       
    40 
       
    41 // Class declaration
       
    42 class CAriAmrNbEncMmfCodec:public CMMFCodec
       
    43     {
       
    44 public: //constructors and destructors
       
    45     /**
       
    46      * Two-phased constructor.
       
    47      * @return pointer to an instance of CMMFCodec
       
    48      */
       
    49 	static CMMFCodec* NewL();
       
    50 
       
    51 	/**> Destructor */
       
    52 	~CAriAmrNbEncMmfCodec();
       
    53 
       
    54 public: // From CMMFCodec
       
    55 
       
    56     /**
       
    57      * From CMMFCodec
       
    58      * Sets codec configuration.
       
    59      * The configuration data is passed in as a descriptor of type TDesC8.
       
    60      * @param aConfigType
       
    61      * The UID of the configuration data.
       
    62      * @param aParam
       
    63      * Descriptor with frame info parameters in the form of RArray
       
    64      */
       
    65     virtual void ConfigureL( TUid aConfigType, const TDesC8& aParam );
       
    66 
       
    67     /**
       
    68      * From CMMFCodec
       
    69      * Codec reset function used to flush out status information when a
       
    70       * reposition occurs.
       
    71      * This is used if the codec requires resetting prior to use.
       
    72      */
       
    73     virtual void ResetL();
       
    74 
       
    75     /**
       
    76      * From CMMFCodec
       
    77      * Processes the data in the specified source buffer and writes the
       
    78      * processed data to the specified destination buffer.
       
    79      * This function is synchronous, when the function returns the data
       
    80      * has been processed. The source buffer is converted to the appropriate
       
    81      * coding type in the destination buffer. The buffers can be of any size,
       
    82      * therefore there is no guarantee that all the source buffer can be
       
    83      * processed to fill the destination buffer or that all the source buffer
       
    84      * may be processed before the destination is full. This function
       
    85      * therefore returns the number of source, and destination, bytes
       
    86      * processed along with a process result code indicating completion
       
    87      * status. This function is synchronous, when the function returns the
       
    88      * data has been processed. The source buffer is converted to the
       
    89      * appropriate coding type in the destination buffer. The buffers can be
       
    90      * of any size, therefore there is no guarantee that all the source buffer
       
    91      * can be processed to fill the destination buffer or that all the source
       
    92      * buffer may be processed before the destination is full. This function
       
    93      * therefore returns the number of source, and destination, bytes
       
    94      * processed along with a process result code indicating completion
       
    95      * status. The aSource and aSink buffers passed in are derived from
       
    96      * CMMFBuffer. The buffer type (e.g. a CMMFDataBuffer) passed in should be
       
    97      * supported by the codec otherwise this function should leave with
       
    98      * KErrNotSupported. The position of the source buffer should be checked
       
    99      * by calling the source buffer's Position() member which indicates the
       
   100      * current source read position in bytes. The codec should start
       
   101      * processing from the current source buffer read position. The position
       
   102      * of the destination buffer should be checked by
       
   103      * calling the destination buffer's Position() method which indicates the
       
   104      * current destination write position in bytes. The codec should start
       
   105      * writing to the destination buffer at the current destination buffer
       
   106      * write position.
       
   107      * This is a virtual function that each derived class must implement.
       
   108      * @see enum TCodecProcessResult
       
   109      * @param  aSource
       
   110      *         The source buffer containing data to encode or decode.
       
   111      * @param  aDestination
       
   112      *         The destination buffer to hold the data after encoding or
       
   113      *         decoding.
       
   114      * @return The result of the processing.
       
   115      * @pre    The function ConfigureL() should have been called.
       
   116      */
       
   117     virtual TCodecProcessResult ProcessL( const CMMFBuffer& aSource,
       
   118                                                 CMMFBuffer& aDestination );
       
   119 
       
   120 private:
       
   121 
       
   122     /**
       
   123      *  Default Constructor
       
   124      */
       
   125 	CAriAmrNbEncMmfCodec();
       
   126 
       
   127 	/**
       
   128      *  Symbian 2nd phase constructor .
       
   129      */
       
   130 	void ConstructL();
       
   131 
       
   132 	/**
       
   133      * Update the result with result status, source bytes consumed
       
   134      * and destination bytes added.
       
   135      * @param   aStatus
       
   136      *          status of the result like EProcessComplete
       
   137      * @param   aSrcBytesConsumed
       
   138      *          total bytes consumed from the source buffer
       
   139      * @param   aDstBytesAdded
       
   140      *          total bytes added to the destination buffer
       
   141      * @return  result of the processing
       
   142      */
       
   143     TCodecProcessResult Result(
       
   144             TCodecProcessResult::TCodecProcessResultStatus aStatus,
       
   145             TInt aSrcBytesConsumed,TInt aDstBytesAdded );
       
   146 
       
   147     /**
       
   148      * Copy the bytes from internal output buffer to destination buffer
       
   149      * @param   aDst
       
   150      *          pointer to the destination buffer
       
   151      * @param   aDstBytesConsumed
       
   152      *          total bytes added to the destination buffer
       
   153      * @return  number of bytes copied to the destination buffer.
       
   154      */
       
   155     TInt CopyToDstBuffer( CMMFDataBuffer* aDst, TInt& aDstBytesConsumed );
       
   156 
       
   157     /**
       
   158      * Copy the bytes from the source buffer to the internal input burrer
       
   159      * @param   aSrc
       
   160      *          pointer to the source buffer
       
   161      * @param   aSrcBytesConsumed
       
   162      *          total bytes consumed from the source buffer
       
   163      * @return  number bytes copied from the source buffer
       
   164      */
       
   165     TInt CopyFromSrcBuffer(const CMMFDataBuffer* aSrc,
       
   166                         TInt& aSrcBytesConsumed );
       
   167     /**
       
   168      * Shifts the data in the input internal buffer to start position
       
   169      * @param   aFromPos
       
   170      *          position from where data has to shift
       
   171      * @param   aToPos
       
   172      *          position to where data has to shift
       
   173      */
       
   174     void ShiftData( TInt aFromPos, TInt aToPos );
       
   175 
       
   176 private: //Data
       
   177 
       
   178 	// Handle to wrapper class
       
   179     CAriAmrNbEncWrapper*    iCodec;
       
   180 
       
   181     TBool 			        iConfigured;
       
   182     TAmrNbEncParam          iParam;
       
   183     TInt 			        iSrclenToProcess;
       
   184     TInt			        iInternalInputBufferResidueLen;
       
   185     TInt                    iInternalOutputBufferResidueLen;
       
   186     TUint8*                 iInternalInputBuffer;
       
   187     TUint8*                 iInternalOutputBuffer;
       
   188     TInt 			        iInternalOutputBufferPos;
       
   189 
       
   190     };
       
   191 
       
   192 #endif /* ARIAMRNBENCMMFCODEC_H */