multimediacommscontroller/mmccdtmfpayloadformat/inc/dtmfpayloadencoder.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:    Formatter class for encoding of RTP payload format for named
       
    15 *                telephone events and tones.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef CDTMFPAYLOADENCODER_H
       
    23 #define CDTMFPAYLOADENCODER_H
       
    24 
       
    25 //  INCLUDES
       
    26 #include <e32base.h>
       
    27 #include "dtmfpayloadformatdefs.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CMMFBuffer;
       
    31 class CMMFDataBuffer;
       
    32 class TDTMFEventPayloadInfo;
       
    33 class TDTMFTonePayloadInfo;
       
    34 
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39  * Provides functionality to encode Tone and Event Payload according
       
    40  * to RFC 2833.
       
    41  *
       
    42  *  @lib mmccdtmfplformat.dll
       
    43  *  @since Series 60 3.2
       
    44  */
       
    45 class CDTMFPayloadEncoder : public CBase
       
    46     {
       
    47     public: // Constructors and destructor
       
    48         
       
    49         /**
       
    50          * Two-phased constructor.
       
    51          */
       
    52         static CDTMFPayloadEncoder* NewL();
       
    53         
       
    54         /**
       
    55          * Destructor.
       
    56          */
       
    57         virtual ~CDTMFPayloadEncoder();
       
    58 
       
    59     public: // New functions
       
    60         
       
    61         /**
       
    62          * Encodes DTMF digit into Payload Format for Named Events.
       
    63          *
       
    64          * @since    Series 60 3.2
       
    65          * @param    aEventInfo      Object containing values to encode
       
    66          * @param    aOutputBuffer   Buffer where to place encoded payload
       
    67          * @return   System wide error code
       
    68          */
       
    69         TInt EncodeEvent( const TDTMFEventPayloadInfo& aEventInfo,
       
    70                           CMMFBuffer* aOutputBuffer );
       
    71         
       
    72         /**
       
    73          * Encodes DTMF tone to Tone Payload Format packet.
       
    74          *
       
    75          * @since    Series 60 3.2
       
    76          * @param    aToneInfo       Object containing values to encode
       
    77          * @param    aOutputBuffer   Buffer where to place encoded payload
       
    78          * @return   System wide error code
       
    79          */
       
    80         TInt EncodeTone( const TDTMFTonePayloadInfo& aToneInfo,
       
    81                          CMMFDataBuffer* aOutputBuffer ) const;
       
    82 
       
    83         /**
       
    84          * Forms update Event Payload packet.
       
    85          *
       
    86          * @since    Series 60 3.2
       
    87          * @param    aFinalPacket    Indicates whether this is final packet
       
    88          * @param    aDuration       Updated duration of the event
       
    89          * @param    aOutputBuffer   Buffer where to place encoded payload
       
    90          * @return   System wide error code
       
    91          */
       
    92         TInt UpdateEventPayload( const TBool aFinalPacket,
       
    93                                  const TUint aDuration,
       
    94                                  CMMFDataBuffer* aOutputBuffer ) const;
       
    95 
       
    96         /**
       
    97          * Updates field(s) of previously created Tone Payload packet.
       
    98          *
       
    99          * @since    Series 60 3.2
       
   100          * @param    aToneDuration   Updated duration of the tone
       
   101          * @param    aOutputBuffer   Buffer where to place encoded payload
       
   102          * @return   System wide error code
       
   103          */
       
   104         TInt UpdateTonePayload( const TUint aToneDuration,
       
   105                                 CMMFDataBuffer* aOutputBuffer ) const;
       
   106 
       
   107         /**
       
   108          * Returns type of the payload format.
       
   109          *
       
   110          * @since    Series 60 3.2
       
   111          * @return   Type of the payload
       
   112          */
       
   113         TDTMFPayloadFormat PayloadFormat() const;
       
   114 
       
   115         /**
       
   116          * Set payload format used.
       
   117          *
       
   118          * @since    Series 60 3.2
       
   119          * @param    aPayloadFormat  Payload format to use.
       
   120          * @return   System wide error code
       
   121          */
       
   122         TInt SetPayloadFormat( TDTMFPayloadFormat aPayloadFormat );
       
   123         
       
   124         /**
       
   125          * Get payload type used within redundancy headers.
       
   126          *
       
   127          * @since    Series 60 3.2
       
   128          * @return   Payload type
       
   129          */
       
   130         TUint8 PayloadType() const;
       
   131         
       
   132         /**
       
   133         * Set payload type used within redundancy headers.
       
   134         *
       
   135         * @since    Series 60 3.2
       
   136         * @param    aPayloadType    Payload type
       
   137         * @return   void
       
   138         */        
       
   139         void SetPayloadType( TUint8 aPayloadType );
       
   140 
       
   141     private:
       
   142 
       
   143         /**
       
   144          * C++ default constructor.
       
   145          */
       
   146         CDTMFPayloadEncoder();
       
   147 
       
   148         /**
       
   149          * Converts DTMF digit / Tone represented as a TChar to the
       
   150          * integer encoding used in payload.
       
   151          *
       
   152          * @since    Series 60 3.2
       
   153          * @param    aEvent     DTMF digit to convert
       
   154          * @return   Integer presenting digit
       
   155          */
       
   156         TInt EventAsInteger( const TChar& aEvent ) const;
       
   157         
       
   158         /**
       
   159          * Encodes DTMF digit into Payload Format for Named Events using
       
   160          * redundancy.
       
   161          *
       
   162          * @since    Series 60 3.2
       
   163          * @param    aEventInfo      Object containing values to encode
       
   164          * @param    aOutputBuffer   Buffer where to place encoded payload
       
   165          * @return   System wide error code
       
   166          */
       
   167         TInt EncodeRedundantEventPayload( 
       
   168             const TDTMFEventPayloadInfo& aEventInfo,
       
   169             CMMFBuffer* aOutputBuffer );        
       
   170 
       
   171     private: // Data
       
   172 
       
   173          /**
       
   174           * Payload format used in encoding
       
   175           */ 
       
   176          TDTMFPayloadFormat iPayloadFormat;
       
   177 
       
   178          /**
       
   179           * Payload type, needed for redundancy headers
       
   180           */         
       
   181          TUint8 iPayloadType;
       
   182 
       
   183          /**
       
   184           * Array used to for redundant events encoding
       
   185           */         
       
   186          RArray<TDTMFEventPayloadInfo> iEventArray;
       
   187     
       
   188     private:
       
   189         #ifdef TEST_EUNIT
       
   190             friend class UT_CDTMFPayloadEncoder;
       
   191         #endif
       
   192     };
       
   193 
       
   194 #endif      // CDTMFPAYLOADENCODER_H
       
   195 
       
   196 // End of File