multimediacommscontroller/mmccinterface/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     __INTERFACE( "CMccCodecCn::RequireSignalling" )
       
    96     
       
    97     const CMccCodecCn& candidate = static_cast<const CMccCodecCn&>( aCandidate );
       
    98     
       
    99     TBool ret = EFalse;
       
   100     
       
   101     if ( iPTime != candidate.PTime() )
       
   102         {
       
   103         __INTERFACE( "CMccCodecCn::RequireSignalling, PTime changed" )
       
   104         ret = ETrue;
       
   105         }
       
   106         
       
   107     if ( iMaxPTime != candidate.MaxPTime() )
       
   108         {
       
   109         __INTERFACE( "CMccCodecCn::RequireSignalling, MaxPTime changed" )
       
   110         ret = ETrue;
       
   111         }
       
   112         
       
   113     if ( iPayloadType != candidate.PayloadType() )
       
   114         {
       
   115         __INTERFACE( "CMccCodecCn::RequireSignalling, PayloadType changed" )
       
   116         ret = ETrue;
       
   117         }
       
   118 
       
   119     if ( iCodecMode != candidate.CodecMode() )
       
   120         {
       
   121         __INTERFACE( "CMccCodecCn::RequireSignalling, CodecMode changed" )
       
   122         ret = ETrue;
       
   123         }     
       
   124         
       
   125     __INTERFACE_INT1( "CMccCodecCn::RequireSignalling, exit with", ret )
       
   126     return ret;          
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CMccCodecCn::SetBitrate
       
   131 // Sets the bitrate used with codec.
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 TInt CMccCodecCn::SetBitrate( TUint aBitrate )
       
   135     {
       
   136     iBitrate = aBitrate;
       
   137     return KErrNone;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CMccCodecCn::SetSamplingFreq
       
   142 // Sets the sampling frequency. 
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CMccCodecCn::SetSamplingFreq( TUint32 aSamplingFreq )
       
   146     {
       
   147     iSamplingFreq = aSamplingFreq;
       
   148     return KErrNone;
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CMccCodecCn::SetSdpName
       
   153 // Sets the SDP name
       
   154 // -----------------------------------------------------------------------------
       
   155 TInt CMccCodecCn::SetSdpName( const TDesC8& aSdpName )
       
   156     {
       
   157     if ( !aSdpName.CompareF( KCnSdpName ) )
       
   158         {
       
   159         iSdpName.Copy( aSdpName );
       
   160         }
       
   161     else 
       
   162         {
       
   163         return KErrNotSupported;
       
   164         }
       
   165     
       
   166     return KErrNone;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CMccCodecCn::PayloadType
       
   171 // Sets the payload type
       
   172 // -----------------------------------------------------------------------------
       
   173 TInt CMccCodecCn::SetPayloadType( TUint8 aPayloadType )
       
   174     {
       
   175     if ( aPayloadType == KCnPayloadType ||
       
   176          aPayloadType == KCnPayloadTypeReserved ) 
       
   177         {
       
   178         iPayloadType = aPayloadType;
       
   179         return KErrNone;
       
   180         }
       
   181     return KErrNotSupported;
       
   182     }
       
   183     
       
   184 // -----------------------------------------------------------------------------
       
   185 // CMccCodecCn::SetCodecMode
       
   186 // Sets the codec mode
       
   187 // -----------------------------------------------------------------------------
       
   188 TInt CMccCodecCn::SetCodecMode( TCodecMode aCodecMode )
       
   189     {
       
   190     if ( ENothing == aCodecMode )
       
   191         {
       
   192         iCodecMode = aCodecMode;
       
   193         return KErrNone;
       
   194         }
       
   195     else
       
   196         {
       
   197         return KErrNotSupported;
       
   198         }
       
   199     }
       
   200      
       
   201 // -----------------------------------------------------------------------------
       
   202 // CMccCodecCn::EnableVAD
       
   203 // 
       
   204 // -----------------------------------------------------------------------------
       
   205 TInt CMccCodecCn::EnableVAD( TBool aEnableVAD ) 
       
   206     {
       
   207     iEnableVAD = aEnableVAD;        
       
   208     return KErrNone;
       
   209     }    
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CMccCodecCn::SetPTime
       
   213 //
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 TInt CMccCodecCn::SetPTime( TUint aPTime )
       
   217     {
       
   218     if ( aPTime && ( KMinPtime <= aPTime ) &&  ( aPTime <= KMaxPtime ) && 
       
   219         (( aPTime % KMinPtime )  == 0 ))
       
   220         {
       
   221         iPTime = aPTime;
       
   222         return KErrNone;    
       
   223         }
       
   224     else
       
   225         {
       
   226         return KErrNotSupported;
       
   227         }
       
   228     }
       
   229     
       
   230 // -----------------------------------------------------------------------------
       
   231 // CMccCodecCn::SetMaxPTime
       
   232 //
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 TInt CMccCodecCn::SetMaxPTime( TUint aMaxPTime )
       
   236     {
       
   237     if ( aMaxPTime && ( iPTime <= aMaxPTime )&& ( KMinPtime <= aMaxPTime ) && 
       
   238         ( aMaxPTime <= KMaxPtime ) && (( aMaxPTime % KMinPtime )  == 0 ) )
       
   239         {
       
   240         iMaxPTime = aMaxPTime;
       
   241         return KErrNone;    
       
   242         }
       
   243     else
       
   244         {
       
   245         return KErrNotSupported;
       
   246         }
       
   247     }
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CMccCodecCn::SetAllowedBitrates
       
   251 // -----------------------------------------------------------------------------
       
   252 // 
       
   253 TInt CMccCodecCn::SetAllowedBitrates( TUint /*aBitrateMask*/ )
       
   254     {
       
   255     return KErrNone;           
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CMccCodecCn::CloneDefaultsL
       
   260 // Make a default setting clone from this codec
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 CMccCodecInformation* CMccCodecCn::CloneDefaultsL()
       
   264     {
       
   265     return CMccCodecCn::NewL();
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CMCCAMRCodec::CloneDetailedL
       
   270 // Make a detailed clone from this codec
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 CMccCodecInformation* CMccCodecCn::CloneDetailedL()
       
   274     {
       
   275     CMccCodecCn* newCodec = CMccCodecCn::NewL();
       
   276     CleanupStack::PushL( newCodec );   
       
   277     newCodec->SetBitrate( this->Bitrate() );
       
   278     newCodec->SetCodecMode( this->CodecMode() );
       
   279     newCodec->SetMaxPTime( this->MaxPTime() );
       
   280     newCodec->SetPayloadType( this->PayloadType() );
       
   281     newCodec->SetPTime( this->PTime() );
       
   282     newCodec->SetSamplingFreq( this->SamplingFreq() );
       
   283     newCodec->SetSdpName( this->SdpName() );
       
   284     newCodec->ParseFmtpAttrL( this->GetFmtpL() );
       
   285     CleanupStack::Pop( newCodec );       
       
   286     return newCodec;
       
   287     }
       
   288     
       
   289 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   290 
       
   291 
       
   292 //  End of File