multimediacommsengine/tsrc/mccstub/src/mmcccodeccn.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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:    MCC Comfort Noise CodecInformation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "mmcccodeccn.h"
       
    23 #include "mccuids.hrh"
       
    24 #include "mmccinterfacelogs.h"
       
    25 
       
    26 
       
    27 // ============================= LOCAL FUNCTIONS ===============================
       
    28 
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CMccCodecCn::CMccCodecCn
       
    34 // default constructor
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CMccCodecCn::CMccCodecCn() : CMccCodecInformation()
       
    38     {
       
    39     
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CMccCodecCn::ConstructL
       
    44 // Symbian 2nd phase constructor can leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CMccCodecCn::ConstructL()
       
    48     {
       
    49     iSdpName.Copy( KCnSdpName );
       
    50 
       
    51     iFmtpAttr = HBufC8::NewL( 1 );
       
    52     TPtr8 ptr = iFmtpAttr->Des();
       
    53     ptr.Append( KNullDesC );
       
    54     
       
    55     SetSamplingFreq( KCnSamplingFreq );
       
    56     EnableVAD( EFalse );
       
    57     SetMaxPTime( KCnMaxPTime ); // recommended "limit" 200ms
       
    58     SetPTime( KCnPTime ); // default 20ms 
       
    59     SetPayloadType( KCnPayloadType );  
       
    60     
       
    61     iFourCC = KMccFourCCIdCN;
       
    62     iCodecMode = ENothing;
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CMccCodecCn::NewLC
       
    67 // Static constructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CMccCodecCn* CMccCodecCn::NewL()
       
    71     {
       
    72     CMccCodecCn* self = new (ELeave) CMccCodecCn;
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop( self ); 
       
    76     return self;
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CMccCodecCn::~CMccCodecCn
       
    81 // Destructor
       
    82 // -----------------------------------------------------------------------------   
       
    83 //
       
    84 CMccCodecCn::~CMccCodecCn()
       
    85     {
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CMccCodecCn::RequireSignalling
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 TBool CMccCodecCn::RequireSignalling(
       
    93     const CMccCodecInformation& aCandidate ) const      
       
    94     {
       
    95     return CMccCodecInformation::RequireSignalling( aCandidate );
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CMccCodecCn::SetBitrate
       
   100 // Sets the bitrate used with codec.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TInt CMccCodecCn::SetBitrate( TUint aBitrate )
       
   104     {
       
   105     iBitrate = aBitrate;
       
   106     return KErrNone;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CMccCodecCn::SetSamplingFreq
       
   111 // Sets the sampling frequency. 
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 TInt CMccCodecCn::SetSamplingFreq( TUint32 aSamplingFreq )
       
   115     {
       
   116     iSamplingFreq = aSamplingFreq;
       
   117     return KErrNone;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMccCodecCn::SetSdpName
       
   122 // Sets the SDP name
       
   123 // -----------------------------------------------------------------------------
       
   124 TInt CMccCodecCn::SetSdpName( const TDesC8& aSdpName )
       
   125     {
       
   126     if ( !aSdpName.CompareF( KCnSdpName ) )
       
   127         {
       
   128         iSdpName.Copy( aSdpName );
       
   129         }
       
   130     else 
       
   131         {
       
   132         return KErrNotSupported;
       
   133         }
       
   134     
       
   135     return KErrNone;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CMccCodecCn::PayloadType
       
   140 // Sets the payload type
       
   141 // -----------------------------------------------------------------------------
       
   142 TInt CMccCodecCn::SetPayloadType( TUint8 aPayloadType )
       
   143     {
       
   144     if ( aPayloadType == KCnPayloadType ||
       
   145          aPayloadType == KCnPayloadTypeReserved ) 
       
   146         {
       
   147         iPayloadType = aPayloadType;
       
   148         return KErrNone;
       
   149         }
       
   150     return KErrNotSupported;
       
   151     }
       
   152     
       
   153 // -----------------------------------------------------------------------------
       
   154 // CMccCodecCn::SetCodecMode
       
   155 // Sets the codec mode
       
   156 // -----------------------------------------------------------------------------
       
   157 TInt CMccCodecCn::SetCodecMode( TCodecMode aCodecMode )
       
   158     {
       
   159     if ( ENothing == aCodecMode )
       
   160         {
       
   161         iCodecMode = aCodecMode;
       
   162         return KErrNone;
       
   163         }
       
   164     else
       
   165         {
       
   166         return KErrNotSupported;
       
   167         }
       
   168     }
       
   169      
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMccCodecCn::EnableVAD
       
   172 // 
       
   173 // -----------------------------------------------------------------------------
       
   174 TInt CMccCodecCn::EnableVAD( TBool aEnableVAD ) 
       
   175     {
       
   176     iEnableVAD = aEnableVAD;        
       
   177     return KErrNone;
       
   178     }    
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CMccCodecCn::SetPTime
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CMccCodecCn::SetPTime( TUint aPTime )
       
   186     {
       
   187     if ( aPTime && ( KMinPtime <= aPTime ) &&  ( aPTime <= KMaxPtime ) && 
       
   188         (( aPTime % KMinPtime )  == 0 ))
       
   189         {
       
   190         iPTime = aPTime;
       
   191         return KErrNone;    
       
   192         }
       
   193     else
       
   194         {
       
   195         return KErrNotSupported;
       
   196         }
       
   197     }
       
   198     
       
   199 // -----------------------------------------------------------------------------
       
   200 // CMccCodecCn::SetMaxPTime
       
   201 //
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 TInt CMccCodecCn::SetMaxPTime( TUint aMaxPTime )
       
   205     {
       
   206     if ( aMaxPTime && ( iPTime <= aMaxPTime )&& ( KMinPtime <= aMaxPTime ) && 
       
   207         ( aMaxPTime <= KMaxPtime ) && (( aMaxPTime % KMinPtime )  == 0 ) )
       
   208         {
       
   209         iMaxPTime = aMaxPTime;
       
   210         return KErrNone;    
       
   211         }
       
   212     else
       
   213         {
       
   214         return KErrNotSupported;
       
   215         }
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CMccCodecCn::SetAllowedBitrates
       
   220 // -----------------------------------------------------------------------------
       
   221 // 
       
   222 TInt CMccCodecCn::SetAllowedBitrates( TUint /*aBitrateMask*/ )
       
   223     {
       
   224     return KErrNone;           
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CMccCodecCn::CloneDefaultsL
       
   229 // Make a default setting clone from this codec
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 CMccCodecInformation* CMccCodecCn::CloneDefaultsL()
       
   233     {
       
   234     return CMccCodecCn::NewL();
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CMCCAMRCodec::CloneDetailedL
       
   239 // Make a detailed clone from this codec
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 CMccCodecInformation* CMccCodecCn::CloneDetailedL()
       
   243     {
       
   244     CMccCodecCn* newCodec = CMccCodecCn::NewL();
       
   245     CleanupStack::PushL( newCodec );   
       
   246     newCodec->SetBitrate( this->Bitrate() );
       
   247     newCodec->SetCodecMode( this->CodecMode() );
       
   248     newCodec->SetMaxPTime( this->MaxPTime() );
       
   249     newCodec->SetPayloadType( this->PayloadType() );
       
   250     newCodec->SetPTime( this->PTime() );
       
   251     newCodec->SetSamplingFreq( this->SamplingFreq() );
       
   252     newCodec->SetSdpName( this->SdpName() );
       
   253     newCodec->ParseFmtpAttrL( this->GetFmtpL() );
       
   254     CleanupStack::Pop( newCodec );       
       
   255     return newCodec;
       
   256     }
       
   257     
       
   258 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   259 
       
   260 
       
   261 //  End of File