multimediacommscontroller/mmccinterface/src/mmcccodecilbc.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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 iLBC CodecInformation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "mmcccodecilbc.h"
       
    23 #include "mmccinterfacelogs.h"
       
    24 #include "mccuids.hrh"
       
    25 
       
    26 // LOCAL CONSTANTS AND MACROS
       
    27 _LIT8( KIlbcMode20ms, "mode=20" );
       
    28 _LIT8( KIlbcMode30ms, "mode=30" );
       
    29 
       
    30 const TUint8 KiLBCKAPayloadSize20ms = 38;
       
    31 const TUint8 KiLBCKeepAlivePayload20ms[KiLBCKAPayloadSize20ms] = 
       
    32     {
       
    33     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    34     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    35     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    36     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
       
    37     };
       
    38 
       
    39 const TUint8 KiLBCKAPayloadSize30ms = 50;
       
    40 const TUint8 KiLBCKeepAlivePayload30ms[KiLBCKAPayloadSize30ms] = 
       
    41     {
       
    42     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    43     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    44     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    45     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       
    46     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
       
    47     };
       
    48 
       
    49 // Mask for 'allow all' bitrates. (defined in header)
       
    50 const TUint KIlbcAllowAllBitrates = 0x00FF;
       
    51 
       
    52 // ============================= LOCAL FUNCTIONS ===============================
       
    53 
       
    54 
       
    55 // ============================ MEMBER FUNCTIONS ===============================
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CMCCCodecILBC::CMCCCodecILBC
       
    59 // default constructor
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CMCCCodecILBC::CMCCCodecILBC() : CMccCodecInformation()
       
    63     {
       
    64     iBitrateMask = KIlbcAllowAllBitrates;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CMCCCodecILBC::ConstructL
       
    69 // Symbian 2nd phase constructor can leave.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CMCCCodecILBC::ConstructL()
       
    73     {
       
    74     __INTERFACE( "CMCCCodecILBC::ConstructL()" )
       
    75      
       
    76     SetSdpName( KILBCSdpName );
       
    77     iKeepAliveData.Copy( KiLBCKeepAlivePayload30ms ); 
       
    78     
       
    79     SetSamplingFreq( KIlbcSampleRate );
       
    80     iHwFrameTime = KIlbcHwFrameTime; // default 30ms    
       
    81     SetBitrate( KIlbcBitrate30 ); // 30ms framesize used as default
       
    82     EnableVAD( EFalse );
       
    83     SetPayloadType( KDefaultIlbcPT );
       
    84     SetMaxPTime( KIlbcMaxPTime );
       
    85     SetPTime( KIlbcPTime );
       
    86         
       
    87     iFourCC = KMccFourCCIdILBC;
       
    88     iCodecMode = ENothing;
       
    89     
       
    90     iPayloadFormatEncoder = KImplUidiLBCPayloadFormatEncode;
       
    91     iPayloadFormatDecoder = KImplUidiLBCPayloadFormatDecode;
       
    92     }
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CMCCCodecILBC::NewL
       
    97 // Static constructor.
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CMCCCodecILBC* CMCCCodecILBC::NewL()
       
   101     {
       
   102     CMCCCodecILBC* self = new (ELeave) CMCCCodecILBC;
       
   103     CleanupStack::PushL( self );
       
   104     self->ConstructL();
       
   105     CleanupStack::Pop( self ); 
       
   106     return self;
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CMCCCodecILBC::~CMCCCodecILBC
       
   112 // Destructor
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 CMCCCodecILBC::~CMCCCodecILBC()
       
   116     {
       
   117     __INTERFACE( "CMCCCodecILBC::~CMCCCodecILBC()" )
       
   118     }
       
   119     
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMCCCodecILBC::EnableVAD
       
   122 // Enable / Disable VAD
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 TInt CMCCCodecILBC::EnableVAD( TBool aEnableVAD )
       
   126     {
       
   127     iEnableVAD = aEnableVAD;
       
   128     return KErrNone;
       
   129     }
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CMCCCodecILBC::SetBitrate
       
   134 // Set Bitrate
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TInt CMCCCodecILBC::SetBitrate( TUint aBitrate )
       
   138     {
       
   139     __INTERFACE_INT1( "CMCCCodecILBC::SetBitrate aBitrate", aBitrate )
       
   140     __INTERFACE_INT1( "CMCCCodecILBC::SetBitrate iBitrate", iBitrate )
       
   141     
       
   142     TBool isValid( ETrue );
       
   143     
       
   144     switch ( aBitrate )
       
   145         {
       
   146         case KIlbcBitrate20:
       
   147             iHwFrameTime = KIlbcPTime20; // 20ms frame  
       
   148             iKeepAliveData.Copy( KiLBCKeepAlivePayload20ms );
       
   149             break;
       
   150         case KIlbcBitrate30:
       
   151             iHwFrameTime = KIlbcPTime30; // 30ms frame
       
   152             iKeepAliveData.Copy( KiLBCKeepAlivePayload30ms );
       
   153             break;
       
   154         default:
       
   155             isValid = EFalse;
       
   156             break;
       
   157         }
       
   158     
       
   159     if ( isValid )
       
   160         {
       
   161         __INTERFACE( "CMCCCodecILBC::SetBitrate valid, adjusting" )
       
   162         
       
   163         iBitrate = aBitrate;
       
   164         AdjustCodec();
       
   165         return KErrNone;
       
   166         }
       
   167     else
       
   168         {
       
   169         __INTERFACE( "CMCCCodecILBC::SetBitrate KErrNotSupported" )
       
   170         
       
   171         return KErrNotSupported;
       
   172         }
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CMCCCodecILBC::SetSamplingFreq
       
   177 // Set Sampling Frequency
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 TInt CMCCCodecILBC::SetSamplingFreq( TUint32 aSamplingFreq )
       
   181     {
       
   182     if ( KIlbcSampleRate == aSamplingFreq )
       
   183         {
       
   184         iSamplingFreq = aSamplingFreq;
       
   185         return KErrNone;
       
   186         }
       
   187     else
       
   188         {
       
   189         return KErrNotSupported;
       
   190         }
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CMCCCodecILBC::SetSdpName
       
   195 // Set SDP Name
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TInt CMCCCodecILBC::SetSdpName( const TDesC8& aSdpName )
       
   199     {
       
   200     if ( !aSdpName.CompareF( KILBCSdpName ) )
       
   201         {
       
   202         iSdpName.Copy( aSdpName );
       
   203         }
       
   204     else 
       
   205         {
       
   206         return KErrNotSupported;        
       
   207         }
       
   208         
       
   209     return KErrNone;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CMCCCodecILBC::SetPayloadType
       
   214 // Set PayloadType
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 TInt CMCCCodecILBC::SetPayloadType( TUint8 aPayloadType )
       
   218     {
       
   219     if ( aPayloadType > KMaxPayloadType || aPayloadType < KMinDynamicPT )
       
   220         {
       
   221         return KErrArgument;
       
   222         }
       
   223     else 
       
   224         {
       
   225         iPayloadType = aPayloadType;
       
   226         return KErrNone;
       
   227         }
       
   228     }
       
   229  
       
   230 // -----------------------------------------------------------------------------
       
   231 // CMCCCodecILBC::SetCodecMode
       
   232 // Set Codec Mode
       
   233 // -----------------------------------------------------------------------------
       
   234 //   
       
   235 TInt CMCCCodecILBC::SetCodecMode( TCodecMode aCodecMode )
       
   236     {
       
   237     __INTERFACE_INT1( "CMCCCodecILBC::SetCodecMode aCodecMode", aCodecMode )
       
   238     
       
   239     if ( ENothing == aCodecMode )
       
   240         {
       
   241         iCodecMode = aCodecMode;
       
   242         return KErrNone;
       
   243         }
       
   244     else
       
   245         {
       
   246         return KErrNotSupported;
       
   247         }
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CMCCCodecILBC::CreateFmtpAttrListL
       
   252 // Builds fmtp line according to current parameters.
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 void CMCCCodecILBC::CreateFmtpAttrListL()
       
   256     {
       
   257     HBufC8* buf = HBufC8::NewLC( KMaxFmtpLen ); 
       
   258     TPtr8 bufPtr = buf->Des();
       
   259 
       
   260     // By default there is no need to construct the 30ms fmtp line. So
       
   261     // let's do it only in 20ms mode.
       
   262     if ( KIlbcBitrate20 == iBitrate )
       
   263         {
       
   264         bufPtr.Append( KIlbcMode20ms );
       
   265         }
       
   266     else
       
   267         {
       
   268         bufPtr.Append( KNullDesC8 );
       
   269         }
       
   270      
       
   271     // Update iFmtpAttr
       
   272     SetFmtpAttrL( bufPtr, EFalse );
       
   273     
       
   274     CleanupStack::PopAndDestroy( buf );
       
   275     }
       
   276     
       
   277 // -----------------------------------------------------------------------------
       
   278 // CMCCCodecILBC::ParseFmtpAttrL
       
   279 // Parse FMTP attribute
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 TBool CMCCCodecILBC::ParseFmtpAttrL( const TDesC8& aFmtp )
       
   283     {
       
   284     __INTERFACE( "CMCCCodecILBC::ParseFmtpAttrL, Entry" )
       
   285     
       
   286     TPtrC8 curToken;
       
   287     TLex8 fmtpLex( aFmtp );
       
   288     TBool updated( EFalse );
       
   289     
       
   290     curToken.Set( fmtpLex.NextToken() );
       
   291 
       
   292     // Set bitrate according to mode indicated with fmtp attribute
       
   293     if ( !curToken.Length() ||
       
   294          KErrNotFound != curToken.Find( KIlbcMode30ms ) )
       
   295         {
       
   296         SetBitrate( KIlbcBitrate30 );
       
   297         AdjustCodec();
       
   298         updated = ETrue;    
       
   299         }
       
   300     else if ( KErrNotFound != curToken.Find( KIlbcMode20ms ) )
       
   301         {
       
   302         SetBitrate( KIlbcBitrate20 );
       
   303         AdjustCodec();
       
   304         updated = ETrue;    
       
   305         }
       
   306     else
       
   307         {
       
   308         __INTERFACE( "CMCCCodecILBC::ParseFmtpAttrL, KErrArgument" )
       
   309         
       
   310         User::Leave( KErrArgument );
       
   311         }
       
   312     
       
   313     __INTERFACE_INT1( "CMCCCodecILBC::ParseFmtpAttrL, Exit updated", updated )
       
   314     
       
   315     return updated;
       
   316     }
       
   317    
       
   318 // -----------------------------------------------------------------------------
       
   319 // CMCCCodecILBC::GetFmtpL
       
   320 // Gets the fmtp attribute
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 TDesC8& CMCCCodecILBC::GetFmtpL()
       
   324     {
       
   325     __INTERFACE( "CMCCCodecILBC::GetFmtpL" )
       
   326     
       
   327     if ( iFmtpAttr )
       
   328         {
       
   329         delete iFmtpAttr;
       
   330         iFmtpAttr = NULL;
       
   331         }
       
   332     
       
   333     CreateFmtpAttrListL();
       
   334     
       
   335     __INTERFACE( "CMCCCodecILBC::GetFmtpL, exit" )
       
   336     
       
   337     return *iFmtpAttr;
       
   338     }    
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CMCCCodecILBC::SetPTime
       
   342 // Sets the packet time
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 TInt CMCCCodecILBC::SetPTime( TUint aPTime )
       
   346     {
       
   347     __INTERFACE_INT1( "CMCCCodecILBC::SetPTime, Entry aPTime", aPTime )
       
   348     __INTERFACE_INT1( "CMCCCodecILBC::SetPTime, Entry iPTime", iPTime )
       
   349         
       
   350     if ( iMaxPTime < aPTime )
       
   351         {
       
   352         __INTERFACE( "CMCCCodecILBC::SetPTime, KErrArgument 1" )
       
   353         
       
   354         return KErrArgument;
       
   355         }      
       
   356     else if( KMinPtime > aPTime )
       
   357         {
       
   358         __INTERFACE( "CMCCCodecILBC::SetPTime, KErrArgument 2" )
       
   359         
       
   360         return KErrArgument;
       
   361         }  
       
   362     else
       
   363         {
       
   364         if ( aPTime == KIlbcPTime20 || aPTime == KIlbcPTime30 )
       
   365             {
       
   366             iPTime = aPTime;
       
   367             
       
   368             // Do not allow ptime vs. bitrate mismatch
       
   369             AdjustCodec();
       
   370             
       
   371             return KErrNone;
       
   372             }
       
   373         else if( ( KIlbcBitrate20 == iBitrate ) &&
       
   374             ( aPTime % KDefaultPtime == 0 ) )
       
   375             {
       
   376             iPTime = aPTime;
       
   377             TInt mod = iMaxPTime % KDefaultPtime;
       
   378             while( mod != 0 )
       
   379                 {
       
   380                 iMaxPTime = iMaxPTime - KMinPtime;
       
   381                 mod = iMaxPTime % KDefaultPtime;
       
   382                 }
       
   383             
       
   384             if( iMaxPTime == 0 )
       
   385                 {
       
   386                 iMaxPTime = KMaxPtime;
       
   387                 }
       
   388                 
       
   389             return KErrNone;
       
   390             }
       
   391         else if( ( KIlbcBitrate30 == iBitrate ) &&
       
   392             ( aPTime % KIlbcPTime30 == 0 ) )
       
   393             {
       
   394             iPTime = aPTime;
       
   395             TInt mod = iMaxPTime % KIlbcPTime30;
       
   396             while( mod != 0 )
       
   397                 {
       
   398                 iMaxPTime = iMaxPTime - KMinPtime;
       
   399                 mod = iMaxPTime % KIlbcPTime30;
       
   400                 }
       
   401             
       
   402             if( iMaxPTime == 0 )
       
   403                 {
       
   404                 iMaxPTime = KIlbcMaxPTime30;
       
   405                 }
       
   406                 
       
   407             return KErrNone;
       
   408             }
       
   409         else
       
   410             {
       
   411             __INTERFACE( "CMCCCodecILBC::SetPTime, KErrArgument 3" )
       
   412             
       
   413             return KErrArgument;
       
   414             }
       
   415         }
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // CMCCCodecILBC::SetMaxPTime
       
   420 // Set Max PTime
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 TInt CMCCCodecILBC::SetMaxPTime( TUint aMaxPTime )
       
   424     {
       
   425     __INTERFACE_INT1( "CMCCCodecILBC::SetMaxPTime, Entry aMaxPTime", aMaxPTime )
       
   426     __INTERFACE_INT1( "CMCCCodecILBC::SetMaxPTime, Entry iMaxPTime", iMaxPTime )
       
   427     
       
   428     if ( aMaxPTime < iPTime )
       
   429         {
       
   430         __INTERFACE( "CMCCCodecILBC::SetMaxPTime, KErrArgument 1" )
       
   431         
       
   432         return KErrArgument;
       
   433         }
       
   434     else
       
   435         {
       
   436         if ( aMaxPTime && ( KIlbcBitrate20 == iBitrate ) &&
       
   437             ( aMaxPTime % KDefaultPtime == 0 ) )
       
   438             {
       
   439             if ( KMaxPtime < aMaxPTime )
       
   440                 {
       
   441                 __INTERFACE( "CMCCCodecILBC::SetMaxPTime, KErrArgument 2" )
       
   442                 
       
   443                 return KErrArgument;
       
   444                 }
       
   445             else
       
   446                 {
       
   447                 iMaxPTime = aMaxPTime;
       
   448                 return KErrNone;
       
   449                 }
       
   450             }
       
   451         else if ( aMaxPTime && ( KIlbcBitrate30 == iBitrate ) &&
       
   452             ( aMaxPTime % KIlbcPTime30 == 0 ) )
       
   453             {
       
   454             if ( KIlbcMaxPTime30 < aMaxPTime )
       
   455                 {
       
   456                 __INTERFACE( "CMCCCodecILBC::SetMaxPTime, KErrArgument 3" )
       
   457                 
       
   458                 return KErrArgument;
       
   459                 }
       
   460             else
       
   461                 {
       
   462                 iMaxPTime = aMaxPTime;
       
   463                 return KErrNone;
       
   464                 }
       
   465             }
       
   466         else
       
   467             {
       
   468             __INTERFACE( "CMCCCodecILBC::SetMaxPTime, KErrArgument 4" )
       
   469             
       
   470             return KErrArgument;
       
   471             }
       
   472         }
       
   473     }
       
   474 
       
   475 // -----------------------------------------------------------------------------
       
   476 // CMCCCodecILBC::CloneDefaultsL
       
   477 // Make a default setting clone from this iLBC codec
       
   478 // -----------------------------------------------------------------------------
       
   479 //
       
   480 CMccCodecInformation* CMCCCodecILBC::CloneDefaultsL()
       
   481     {
       
   482     return CMCCCodecILBC::NewL();
       
   483     };
       
   484 
       
   485 // -----------------------------------------------------------------------------
       
   486 // CMCCCodecILBC::CloneDetailedL
       
   487 // Make a detailed clone from this iLBC codec
       
   488 // -----------------------------------------------------------------------------
       
   489 //
       
   490 CMccCodecInformation* CMCCCodecILBC::CloneDetailedL()
       
   491     {
       
   492     CMCCCodecILBC* newCodec = CMCCCodecILBC::NewL();
       
   493     CleanupStack::PushL( newCodec );            
       
   494     newCodec->SetBitrate( this->Bitrate() );
       
   495     newCodec->SetCodecMode( this->CodecMode() );
       
   496     newCodec->SetMaxPTime( this->MaxPTime() );
       
   497     newCodec->SetPayloadType( this->PayloadType() );
       
   498     newCodec->SetPTime( this->PTime() );
       
   499     newCodec->SetSamplingFreq( this->SamplingFreq() );
       
   500     newCodec->SetSdpName( this->SdpName() );
       
   501     
       
   502     TDesC8& fmtp( this->GetFmtpL() );
       
   503     if ( fmtp.Length() )
       
   504         {
       
   505         newCodec->ParseFmtpAttrL( this->GetFmtpL() );
       
   506         }
       
   507 
       
   508     CleanupStack::Pop( newCodec );                
       
   509     return newCodec;
       
   510     };
       
   511 
       
   512 // -----------------------------------------------------------------------------
       
   513 // CMCCCodecILBC::RequireSignalling
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 TBool CMCCCodecILBC::RequireSignalling(
       
   517     const CMccCodecInformation& aCandidate ) const      
       
   518     {
       
   519     __INTERFACE( "CMCCCodecILBC::RequireSignalling" )
       
   520     TBool ret = EFalse;
       
   521               
       
   522     if ( iPTime != aCandidate.PTime() )
       
   523         {
       
   524         __INTERFACE( "CMCCCodecILBC::RequireSignalling, PTime changed" )
       
   525         ret = ETrue;
       
   526         }
       
   527         
       
   528     if ( iMaxPTime != aCandidate.MaxPTime() )
       
   529         {
       
   530         __INTERFACE( "CMCCCodecILBC::RequireSignalling, MaxPTime changed" )
       
   531         ret = ETrue;
       
   532         }
       
   533         
       
   534     if ( iPayloadType != aCandidate.PayloadType() )
       
   535         {
       
   536         __INTERFACE( "CMCCCodecILBC::RequireSignalling, PayloadType changed" )
       
   537         ret = ETrue;
       
   538         }
       
   539 
       
   540     if ( iBitrate != aCandidate.Bitrate() )
       
   541         {
       
   542         __INTERFACE( "CMCCCodecILBC::RequireSignalling, Bitrate changed" )
       
   543         ret = ETrue;
       
   544         }
       
   545 
       
   546     if ( iCodecMode != aCandidate.CodecMode() )
       
   547         {
       
   548         __INTERFACE( "CMCCCodecILBC::RequireSignalling, CodecMode changed" )
       
   549         ret = ETrue;
       
   550         }
       
   551         
       
   552     __INTERFACE_INT1( "CMCCCodecILBC::RequireSignalling, exit with", ret )
       
   553     return ret;          
       
   554     }
       
   555     
       
   556 // -----------------------------------------------------------------------------
       
   557 // CMCCCodecILBC::SetComfortNoiseGeneration
       
   558 // -----------------------------------------------------------------------------
       
   559 // 
       
   560 TInt CMCCCodecILBC::SetComfortNoiseGeneration( TUint8 aComfortNoisePT )
       
   561     {
       
   562     iComfortNoiseGenerationPt = aComfortNoisePT;
       
   563     return KErrNone;
       
   564     }
       
   565     
       
   566 // -----------------------------------------------------------------------------
       
   567 // CMCCCodecILBC::SetAllowedBitrates
       
   568 // -----------------------------------------------------------------------------
       
   569 // 
       
   570 
       
   571 TInt CMCCCodecILBC::SetAllowedBitrates( TUint /*aBitrateMask*/ )
       
   572     {
       
   573     // iLBC does not really need the concept of 'allowed' bitrates because
       
   574     // the bitrate setting handles assertion for bitrate correctness.
       
   575     return KErrNone;
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 // CMCCCodecILBC::AdjustCodec
       
   580 // -----------------------------------------------------------------------------
       
   581 //     
       
   582 void CMCCCodecILBC::AdjustCodec()
       
   583     {
       
   584     __INTERFACE_INT1( "CMCCCodecILBC::AdjustCodec Entry iPTime",
       
   585         iPTime )
       
   586     __INTERFACE_INT1( "CMCCCodecILBC::AdjustCodec Entry iHwFrameTime",
       
   587         iHwFrameTime )
       
   588     
       
   589     // If default ptime is in use, it is adjusted based on mode of the codec
       
   590     if ( iPTime == KIlbcPTime20 || iPTime == KIlbcPTime30 || !iPTime )
       
   591         {
       
   592         iPTime = ( KIlbcBitrate20 == iBitrate ) ? KIlbcPTime20 : KIlbcPTime30;
       
   593         }
       
   594     else if ( iPTime )
       
   595         {
       
   596         __INTERFACE( "CMCCCodecILBC::AdjustCodec ptime to closest possible" )
       
   597         
       
   598         // Default ptime is not in use, we must adjust it to closest possible
       
   599         // according to current iHwFrameTime (bitrate specific).
       
   600         TInt ptmul = (TInt) iPTime / (TInt) iHwFrameTime;
       
   601         iPTime = ptmul *
       
   602             ( ( KIlbcBitrate20 == iBitrate ) ? KIlbcPTime20 : KIlbcPTime30 );
       
   603         }
       
   604     
       
   605     __INTERFACE_INT1( "CMCCCodecILBC::AdjustCodec Exit iPTime",
       
   606         iPTime )
       
   607     }
       
   608     
       
   609 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   610 
       
   611 //  End of File