multimediacommscontroller/mmccinterface/src/mmcccodech263.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <delimitedpathsegment8.h>
       
    24 
       
    25 #include "mmcccodech263.h"
       
    26 #include "mccuids.hrh"
       
    27 #include "mmccinterfacelogs.h"
       
    28 
       
    29 // EXTERNAL DATA STRUCTURES
       
    30 
       
    31 // EXTERNAL FUNCTION PROTOTYPES  
       
    32 
       
    33 // CONSTANTS
       
    34 const TInt KMaxFmtpAttrLength( 50 );
       
    35 const TInt KH263DefaultFrameSize( 3000 );
       
    36 const TInt KH263DefaultMaxBitrate( 64000 );
       
    37 const TInt KH263DefaultBitrate( 64000 );
       
    38 const TInt KH263DefaultAllowedBitrate( 1 );
       
    39 const TInt KH263DefaultFreq( 90000 );
       
    40 
       
    41 const TUint KMccAllowedH263Bitrate1 = 0x0001;
       
    42 const TUint KMccAllowedH263Bitrate2 = 0x0002;
       
    43 const TUint KMccAllowedH263BitrateAll = 0x0003;
       
    44 
       
    45 const TInt  KH263Bitrate64( 64000 );
       
    46 const TInt  KH263Bitrate128( 128000 );
       
    47 
       
    48 
       
    49 // MACROS
       
    50 
       
    51 // LOCAL CONSTANTS AND MACROS
       
    52 
       
    53 // MODULE DATA STRUCTURES
       
    54 
       
    55 // LOCAL FUNCTION PROTOTYPES
       
    56 
       
    57 // FORWARD DECLARATIONS
       
    58 
       
    59 // ============================= LOCAL FUNCTIONS ===============================
       
    60 
       
    61 // ============================ MEMBER FUNCTIONS ===============================
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CMccCodecH263::CMccCodecH263
       
    65 // C++ default constructor can NOT contain any code, that
       
    66 // might leave.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CMccCodecH263::CMccCodecH263() : CMccCodecInformation()
       
    70     {
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CMccCodecH263::ConstructL
       
    75 // Symbian 2nd phase constructor can leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CMccCodecH263::ConstructL()
       
    79     {
       
    80     iSdpName.Copy( KH2632000SdpName );
       
    81 
       
    82     iType = KUidMediaTypeVideo; 
       
    83     iFmtpAttr = HBufC8::NewL( KMaxFmtpAttrLength );
       
    84     iFourCC = KMccFourCCIdH263;
       
    85     iSamplingFreq = KH263DefaultFreq;
       
    86 
       
    87     iPayloadFormatEncoder = KImplUidH263PayloadFormatEncode;
       
    88     iPayloadFormatDecoder = 0;
       
    89     
       
    90     SetCodecMode( KH263FormatModeNew );
       
    91     SetPTime( KH263PTime );
       
    92     SetPayloadType( KH263PayloadType );
       
    93     SetFramerate( KH263Framerate );
       
    94 	SetLevelBasedBitrate( KH263DefaultBitrate );
       
    95     SetMaxBitrate( KH263DefaultMaxBitrate );
       
    96     SetAllowedBitrates( KH263DefaultAllowedBitrate );
       
    97     SetFrameHeight( KH263FrameHeight );
       
    98     SetFrameWidth( KH263FrameWidth );
       
    99     iFrameSize = KH263DefaultFrameSize;
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CMccCodecH263::NewL
       
   104 // Two-phased constructor.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CMccCodecH263* CMccCodecH263::NewL()
       
   108     {
       
   109     CMccCodecH263* self = new( ELeave ) CMccCodecH263;
       
   110     
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL();
       
   113     CleanupStack::Pop( self );
       
   114 
       
   115     return self;
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CMccCodecH263::~CMccCodecH263
       
   120 // 
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CMccCodecH263::~CMccCodecH263()
       
   124     {
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CMccCodecH263::RequireSignalling
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TBool CMccCodecH263::RequireSignalling(
       
   132     const CMccCodecInformation& aCandidate ) const      
       
   133     {
       
   134     __INTERFACE( "CMccCodecH263::RequireSignalling" )
       
   135     TBool ret = EFalse;
       
   136     
       
   137     if ( iPTime != aCandidate.PTime() )
       
   138         {
       
   139         __INTERFACE( "CMccCodecH263::RequireSignalling, PTime changed" )
       
   140         ret = ETrue;
       
   141         }
       
   142         
       
   143     if ( iMaxPTime != aCandidate.MaxPTime() )
       
   144         {
       
   145         __INTERFACE( "CMccCodecH263::RequireSignalling, MaxPTime changed" )
       
   146         ret = ETrue;
       
   147         }
       
   148         
       
   149     if ( iPayloadType != aCandidate.PayloadType() )
       
   150         {
       
   151         __INTERFACE( "CMccCodecH263::RequireSignalling, PayloadType changed" )
       
   152         ret = ETrue;
       
   153         }
       
   154 
       
   155     if ( iBitrateMask != aCandidate.AllowedBitrates() )
       
   156         {
       
   157         __INTERFACE( "CMccCodecH263::RequireSignalling, BitrateMask changed" )
       
   158         ret = ETrue;
       
   159         }
       
   160 
       
   161     if ( iCodecMode != aCandidate.CodecMode() )
       
   162         {
       
   163         __INTERFACE( "CMccCodecH263::RequireSignalling, CodecMode changed" )
       
   164         ret = ETrue;
       
   165         }
       
   166         
       
   167     if ( iSamplingFreq != aCandidate.SamplingFreq() )
       
   168         {
       
   169         __INTERFACE( "CMccCodecH263::RequireSignalling, SamplingFreq changed" )
       
   170         ret = ETrue;
       
   171         }     
       
   172         
       
   173     if ( iMaxBitrate != aCandidate.MaxBitrate() )
       
   174         {
       
   175         __INTERFACE( "CMccCodecH263::RequireSignalling, MaxBitrate changed" )
       
   176         ret = ETrue;
       
   177         }
       
   178         
       
   179     if ( iFramerate < aCandidate.Framerate() )
       
   180         {
       
   181         __INTERFACE( "CMccCodecH263::RequireSignalling, Framerate changed" )
       
   182         ret = ETrue;
       
   183         }
       
   184         
       
   185     if ( iVideoWidth != aCandidate.FrameWidth() )
       
   186         {
       
   187         __INTERFACE( "CMccCodecH263::RequireSignalling, FrameWidth changed" )
       
   188         ret = ETrue;
       
   189         }
       
   190     
       
   191     if ( iVideoHeight != aCandidate.FrameHeight() )
       
   192         {
       
   193         __INTERFACE( "CMccCodecH263::RequireSignalling, FrameHeight changed" )
       
   194         ret = ETrue;
       
   195         }
       
   196         
       
   197     __INTERFACE_INT1( "CMccCodecH263::RequireSignalling, exit with", ret )
       
   198     return ret;          
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CMccCodecH263::SetBitrate
       
   203 // Sets the bitrate used with AMR codec.
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 TInt CMccCodecH263::SetBitrate( TUint aBitrate )
       
   207 	{
       
   208     if ( aBitrate <= KH263Bitrate128 )
       
   209     	{
       
   210     	iBitrate = aBitrate;
       
   211     	iBitrateSet = ETrue;
       
   212     	return KErrNone;
       
   213     	}
       
   214     else
       
   215     	{
       
   216     	return KErrNotSupported;
       
   217     	}
       
   218 	}
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CMccCodecH263::SetSamplingFreq
       
   222 // Sets the sampling frequency. 
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 TInt CMccCodecH263::SetSamplingFreq( TUint32 /*aSamplingFreq*/ )
       
   226     {
       
   227     return KErrNone;
       
   228     }
       
   229     
       
   230 // -----------------------------------------------------------------------------
       
   231 // CMccCodecH263::SetSdpName
       
   232 // Sets the SDP name
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 TInt CMccCodecH263::SetSdpName( const TDesC8& aSdpName )
       
   236     {
       
   237     if ( !aSdpName.CompareF( KH263SdpName ) || 
       
   238          !aSdpName.CompareF( KH2632000SdpName ))
       
   239         {
       
   240         iSdpName.Copy( KH2632000SdpName );
       
   241         if ( iCodecMode != KH263FormatModeNew )
       
   242             {
       
   243             SetCodecMode( KH263FormatModeNew );    
       
   244             }
       
   245         }
       
   246     else if( !aSdpName.CompareF( KH2631998SdpName ))
       
   247         {
       
   248         iSdpName.Copy( KH2631998SdpName );
       
   249         if ( iCodecMode != KH263FormatModeOld )
       
   250             {
       
   251             SetCodecMode( KH263FormatModeOld );    
       
   252             }
       
   253         }
       
   254     else 
       
   255         {
       
   256         return KErrNotSupported;
       
   257         }
       
   258     
       
   259     return KErrNone;
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CMccCodecH263::PayloadType
       
   264 // Sets the payload type
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 TInt CMccCodecH263::SetPayloadType( TUint8 aPayloadType )
       
   268     {
       
   269     if ( aPayloadType < KMinDynamicPT ||
       
   270          aPayloadType > KMaxPayloadType ) 
       
   271         {
       
   272         return KErrNotSupported;
       
   273         }
       
   274     else 
       
   275         {
       
   276         iPayloadType = aPayloadType;
       
   277         }
       
   278               
       
   279     return KErrNone;
       
   280     }
       
   281     
       
   282 // -----------------------------------------------------------------------------
       
   283 // CMccCodecH263::SetCodecMode
       
   284 // Sets the codec mode.
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 TInt CMccCodecH263::SetCodecMode( TCodecMode aCodecMode )
       
   288     {
       
   289     iCodecMode = aCodecMode;
       
   290     
       
   291     if ( iCodecMode == KH263FormatModeNew &&
       
   292          iSdpName.CompareF( KH2632000SdpName ))
       
   293         {
       
   294         SetSdpName( KH2632000SdpName );    
       
   295         }
       
   296     if ( iCodecMode == KH263FormatModeOld &&
       
   297 	     iSdpName.CompareF( KH2631998SdpName ))
       
   298         {
       
   299         SetSdpName( KH2631998SdpName );  
       
   300         
       
   301         // Ensure that default dynamic pt is not the same for two different
       
   302         // codec modes
       
   303         if ( iPayloadType == KH263PayloadType )
       
   304             {
       
   305             SetPayloadType( KH2631998PayloadType );
       
   306             }
       
   307         }
       
   308     
       
   309     return KErrNone;
       
   310     }
       
   311  
       
   312 // -----------------------------------------------------------------------------
       
   313 // CMccCodecH263::EnableVAD
       
   314 // Enable / Disable VAD
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 TInt CMccCodecH263::EnableVAD( TBool /*aEnableVAD*/ ) 
       
   318     {
       
   319     return KErrNotSupported;
       
   320     }
       
   321     
       
   322 // -----------------------------------------------------------------------------
       
   323 // CMccCodecH263::SetPTime
       
   324 // Set PTime
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 TInt CMccCodecH263::SetPTime( TUint aPTime )
       
   328     {
       
   329     if ( aPTime && ( aPTime <= 200 ) && (( aPTime % 10 )  == 0 ))
       
   330         {
       
   331         iPTime = aPTime;
       
   332         return KErrNone;    
       
   333         }
       
   334     else
       
   335         {
       
   336         return KErrNotSupported;
       
   337         }
       
   338     }
       
   339     
       
   340 // -----------------------------------------------------------------------------
       
   341 // CMccCodecH263::SetMaxPTime
       
   342 // Set Max PTime
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 TInt CMccCodecH263::SetMaxPTime( TUint aMaxPTime )
       
   346     {
       
   347     if ( aMaxPTime && ( aMaxPTime <= 200 ) && (( aMaxPTime % 10 )  == 0 ))
       
   348         {
       
   349         iMaxPTime = aMaxPTime;
       
   350         return KErrNone;    
       
   351         }
       
   352     else
       
   353         {
       
   354         return KErrNotSupported;
       
   355         }
       
   356     }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // CMccCodecH263:SetConfigKeyL
       
   360 // -----------------------------------------------------------------------------
       
   361 // 
       
   362 void CMccCodecH263::SetConfigKeyL( const TDesC8& /*aConfigKey*/ )
       
   363     {
       
   364     // NOP
       
   365     }
       
   366     
       
   367 // -----------------------------------------------------------------------------
       
   368 // CMccCodecH263::SetAllowedBitrates
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 TInt CMccCodecH263::SetAllowedBitrates( TUint aBitrateMask )
       
   372     {
       
   373     //Confirm that the bitrate mask is valid
       
   374     //I.e. after all the valid bitrates are set to zero the value should be zero
       
   375     if ( (aBitrateMask >> 8 ) > 0 )
       
   376         {
       
   377         return KErrArgument;
       
   378         }
       
   379     else
       
   380         {
       
   381         /*
       
   382         In the future the allowed bitrates will be fetched from the codec
       
   383         I.e. the KMccAllowedH263BitrateAll will be changed to the bitrates
       
   384         supported by the codec
       
   385         */
       
   386         iBitrateMask = KMccAllowedH263BitrateAll;
       
   387         iBitrateMask &= aBitrateMask;
       
   388         
       
   389         SetMaxBitrateFromBitrateMask( iBitrateMask );
       
   390         }
       
   391     return KErrNone;
       
   392     }
       
   393 
       
   394 // -----------------------------------------------------------------------------
       
   395 // CMccCodecH263::CloneDefaultsL
       
   396 // Make a default setting clone from this codec
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 CMccCodecInformation* CMccCodecH263::CloneDefaultsL()
       
   400     {
       
   401     CMccCodecInformation* codec = CMccCodecH263::NewL();
       
   402     CleanupStack::PushL( codec );
       
   403     
       
   404     if ( 0 == this->SdpName().CompareF( KH2632000SdpName ) )
       
   405         {
       
   406         User::LeaveIfError( codec->SetCodecMode( KH263FormatModeNew ) );
       
   407         }
       
   408     else
       
   409         {
       
   410         User::LeaveIfError( codec->SetCodecMode( KH263FormatModeOld ) );
       
   411         }
       
   412     
       
   413     CleanupStack::Pop( codec );
       
   414     return codec;
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CMccCodecH263::CloneDetailedL
       
   419 // Make a detailed clone from this codec
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 CMccCodecInformation* CMccCodecH263::CloneDetailedL()
       
   423     {
       
   424     CMccCodecH263* newCodec = CMccCodecH263::NewL();
       
   425     CleanupStack::PushL( newCodec );       
       
   426     newCodec->SetBitrate( this->Bitrate() );
       
   427     newCodec->SetCodecMode( this->CodecMode() );
       
   428     newCodec->SetMaxPTime( this->MaxPTime() );
       
   429     newCodec->SetPayloadType( this->PayloadType() );
       
   430     newCodec->SetPTime( this->PTime() );
       
   431     newCodec->SetSamplingFreq( this->SamplingFreq() );
       
   432     newCodec->SetSdpName( this->SdpName() );
       
   433     CleanupStack::Pop( newCodec );   
       
   434     return newCodec;
       
   435     }
       
   436         
       
   437 // -----------------------------------------------------------------------------
       
   438 // CMccCodecH263::GetFmtpL
       
   439 // Gets the fmtp attribute
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 TDesC8& CMccCodecH263::GetFmtpL()
       
   443     {
       
   444     __INTERFACE( "CMccCodecH263::GetFmtpL" )      
       
   445     if ( iFmtpAttr )
       
   446         {
       
   447         delete iFmtpAttr;
       
   448         iFmtpAttr = NULL;
       
   449         }
       
   450 
       
   451     TInt level = KH263Level10;
       
   452     
       
   453     if ( iMaxBitrate > KH263Level10Bitrate && 
       
   454          iMaxBitrate <= KH263Level45Bitrate )  
       
   455         {
       
   456         __INTERFACE( "CMccCodecH263::GetFmtpL, level set 45" )        
       
   457         level = KH263Level45;     
       
   458         }
       
   459         
       
   460     iFmtpAttr = HBufC8::NewL( KMaxFmtpAttrLength );
       
   461     iFmtpAttr->Des().Format( KH263FmtpLine, level );                
       
   462     
       
   463     __INTERFACE( "CMccCodecH263::GetFmtpL, exit" )      
       
   464     return *iFmtpAttr;    
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // CMccCodecH263::SetFmtpAttrL
       
   469 // Gets the fmtp attribute
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 void CMccCodecH263::SetFmtpAttrL( const TDesC8& aFmtp, TBool /*parseFmtp*/ )
       
   473     {
       
   474     __INTERFACE( "CMccCodecH263::SetFmtpAttrL" )      
       
   475     if ( iFmtpAttr )
       
   476         {
       
   477         delete iFmtpAttr;
       
   478         iFmtpAttr = NULL;
       
   479         }
       
   480 
       
   481     iFmtpAttr = HBufC8::NewL( aFmtp.Length() );
       
   482     iFmtpAttr->Des().Copy( aFmtp );
       
   483            
       
   484     ParseFmtpAttrL( *iFmtpAttr );          
       
   485     __INTERFACE( "CMccCodecH263::SetFmtpAttrL, exit" )      
       
   486     }        
       
   487 
       
   488  // -----------------------------------------------------------------------------
       
   489 // CMccCodecH263::ParseFmtpAttrL
       
   490 // Parse the fmtp string, but doesn't update the iFmtpAttr
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 TBool CMccCodecH263::ParseFmtpAttrL( const TDesC8& aFmtp )
       
   494     {
       
   495     __INTERFACE( "CMccCodecH263::ParseFmtpAttrL" )      
       
   496     const TUint8* pointerC = aFmtp.Ptr();
       
   497     TUint8* pointer        = const_cast<TUint8*>( pointerC );
       
   498     TPtr8 descriptor( pointer, aFmtp.Length(), aFmtp.Length() );
       
   499     descriptor.Trim();
       
   500     
       
   501     TDelimitedPathSegmentParser8 parser;
       
   502     parser.Parse( aFmtp );
       
   503     TPtrC8 segment;
       
   504     TBool updated( EFalse );
       
   505     
       
   506     while ( parser.GetNext( segment ) != KErrNotFound )
       
   507         {
       
   508         if ( ParseFmtpSegmentL( segment ) )
       
   509             {
       
   510             updated = ETrue;
       
   511             }
       
   512         }
       
   513     
       
   514     __INTERFACE( "CMccCodecH263::ParseFmtpAttrL, exit" )      
       
   515     return updated;
       
   516     }
       
   517     
       
   518 // -----------------------------------------------------------------------------
       
   519 // CMccCodecH263::ParseFmtpSegmentL
       
   520 // Parse and updates the matched param
       
   521 // -----------------------------------------------------------------------------
       
   522 //    
       
   523 TBool CMccCodecH263::ParseFmtpSegmentL( const TDesC8& aSeg )
       
   524     {
       
   525     __INTERFACE( "CMccCodecH263::ParseFmtpSegmentL" )      
       
   526     TBool success( ETrue );
       
   527     _LIT8( KEqualSign, "=" );
       
   528     
       
   529     // Check for first '=' sign 
       
   530     TInt index = aSeg.Find( KEqualSign );
       
   531     
       
   532     if ( index > 0 )
       
   533         {
       
   534         // Check if match profile
       
   535         if ( aSeg.Left( index).Match( KH263Profile ) != KErrNotFound )
       
   536             {
       
   537             success = ParseProfileL( aSeg.Right( aSeg.Length() - ( index + 1 ) ) );
       
   538             }
       
   539         
       
   540         // Check if match level
       
   541         else 
       
   542             {
       
   543             if ( aSeg.Left( index).Match( KH263Level ) != KErrNotFound )
       
   544                 {
       
   545                 success = ParseLevelL( aSeg.Right( aSeg.Length() - ( index + 1 ) ) );
       
   546                 }
       
   547             }
       
   548         }  
       
   549     __INTERFACE( "CMccCodecH263::ParseFmtpSegmentL, exit" )      
       
   550     return success;
       
   551     }
       
   552     
       
   553 // -----------------------------------------------------------------------------
       
   554 // CMccCodecH263::ParseProfile
       
   555 // -----------------------------------------------------------------------------
       
   556 //    
       
   557 TBool CMccCodecH263::ParseProfileL( const TDesC8& aFmtp )
       
   558     {
       
   559     __INTERFACE( "CMccCodecH263::ParseProfileL, exit" )      
       
   560     TBool success( ETrue );
       
   561     
       
   562     TLex8 myLex( aFmtp );
       
   563     TInt value;
       
   564     TInt err = myLex.Val( value );
       
   565     
       
   566     if ( err == KErrNone )
       
   567         {
       
   568         switch ( value )
       
   569             {
       
   570             case 0:
       
   571                 __INTERFACE( "CMccCodecH263::ParseProfileL, profile 0" )      
       
   572                 break;
       
   573             default:
       
   574                 __INTERFACE( "CMccCodecH263::ParseProfileL, unsupported profile" )      
       
   575                 success = EFalse;
       
   576                 break;
       
   577             }
       
   578         } 
       
   579     else
       
   580         {
       
   581         success = EFalse;
       
   582         }
       
   583  
       
   584     if ( !success )
       
   585         {
       
   586         __INTERFACE( "CMccCodecH263::ParseProfileL, leaving with KErrArgument" )              
       
   587         User::Leave( KErrArgument );
       
   588         }
       
   589 
       
   590     __INTERFACE( "CMccCodecH263::ParseProfileL, exit" )
       
   591     
       
   592     return ETrue;
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // CMccCodecH263::ParseProfile
       
   597 // -----------------------------------------------------------------------------
       
   598 //    
       
   599 TBool CMccCodecH263::ParseLevelL( const TDesC8& aFmtp )
       
   600     {
       
   601     __INTERFACE( "CMccCodecH263::ParseLevelL" )      
       
   602     TBool success( ETrue );
       
   603  
       
   604     TLex8 myLex( aFmtp );
       
   605     TInt value;
       
   606     TInt err = myLex.Val( value );
       
   607     
       
   608     if ( err == KErrNone )
       
   609         {
       
   610         switch ( value )
       
   611             {
       
   612             case KH263Level10:
       
   613                 __INTERFACE( "CMccCodecH263::ParseLevelL, level 10" )      
       
   614                 SetMaxBitrate( KH263Level10Bitrate );
       
   615                 SetLevelBasedBitrate( KH263Level10Bitrate );
       
   616                 SetFramerate ( KH263Level10Framerate );
       
   617                 break;
       
   618             case KH263Level45:
       
   619                 __INTERFACE( "CMccCodecH263::ParseLevelL, level 45" )      
       
   620                 SetMaxBitrate( KH263Level45Bitrate );
       
   621                 SetLevelBasedBitrate( KH263Level45Bitrate );
       
   622                 SetFramerate ( KH263Level45Framerate );
       
   623                 break;
       
   624             default:
       
   625                 __INTERFACE( "CMccCodecH263::ParseLevelL, unsupported level" )      
       
   626                 success = EFalse;
       
   627                 break;
       
   628             }
       
   629         } 
       
   630     else
       
   631         {
       
   632         success = EFalse;
       
   633         }
       
   634  
       
   635     if ( !success )
       
   636         {
       
   637         __INTERFACE( "CMccCodecH263::ParseLevelL, leaving with KErrArgument" )      
       
   638         User::Leave( KErrArgument );
       
   639         }
       
   640 
       
   641     __INTERFACE( "CMccCodecH263::ParseLevelL, exit" )      
       
   642     return success;
       
   643     }
       
   644                 
       
   645 // -----------------------------------------------------------------------------
       
   646 // CMccCodecH263::SetMaxBitrateFromBitrateMask
       
   647 // -----------------------------------------------------------------------------
       
   648 //        
       
   649 void CMccCodecH263::SetMaxBitrateFromBitrateMask( TUint aBitrateMask )
       
   650     {
       
   651     if( aBitrateMask & KMccAllowedH263Bitrate1 )
       
   652         {
       
   653         SetMaxBitrate( KH263Bitrate64 );
       
   654         }
       
   655     else if( aBitrateMask & KMccAllowedH263Bitrate2 )
       
   656         {
       
   657         SetMaxBitrate( KH263Bitrate128 );
       
   658         }
       
   659     else if( aBitrateMask & KMccAllowedH263BitrateAll )
       
   660         {
       
   661         SetMaxBitrate( KH263Bitrate128 );
       
   662         }
       
   663     }
       
   664     
       
   665 // -----------------------------------------------------------------------------
       
   666 // CMccCodecH263::SetMaxBitrate
       
   667 // -----------------------------------------------------------------------------
       
   668 //  
       
   669 TInt CMccCodecH263::SetMaxBitrate( TUint aMaxBitrate )
       
   670     {
       
   671     TBool isValid( ETrue );
       
   672        
       
   673     switch ( aMaxBitrate )
       
   674     	{
       
   675     	case KH263Bitrate64:    	    
       
   676     		break;
       
   677     	case KH263Bitrate128:
       
   678     		break;
       
   679     	default:
       
   680     		isValid = EFalse;
       
   681     		break;
       
   682     	}
       
   683     if ( isValid )
       
   684     	{
       
   685     	iMaxBitrate = aMaxBitrate;
       
   686         SetBitrateMaskFromMaxBitrate( aMaxBitrate );
       
   687     	return KErrNone;
       
   688     	}
       
   689     else
       
   690     	{
       
   691     	return KErrNotSupported;
       
   692     	}
       
   693     }
       
   694 
       
   695 // -----------------------------------------------------------------------------
       
   696 // CMccCodecH263::SetBitrateMaskFromMaxBitrate
       
   697 // -----------------------------------------------------------------------------
       
   698 //      
       
   699 void CMccCodecH263::SetBitrateMaskFromMaxBitrate( TUint aMaxBitrate )
       
   700      {
       
   701      switch ( aMaxBitrate )
       
   702     	{
       
   703     	case KH263Bitrate64:
       
   704     	    iBitrateMask = KMccAllowedH263Bitrate1;   	    
       
   705     		break;
       
   706     	case KH263Bitrate128:
       
   707     	    iBitrateMask = KMccAllowedH263BitrateAll;
       
   708     		break;
       
   709     	default:
       
   710     		break;
       
   711     	}
       
   712      }
       
   713 
       
   714 // -----------------------------------------------------------------------------
       
   715 // CMccCodecH263::SetLevelBasedBitrate
       
   716 // -----------------------------------------------------------------------------
       
   717 //      
       
   718 void CMccCodecH263::SetLevelBasedBitrate( TUint aBitrate )
       
   719     {
       
   720     // Set level based bitrate only if bitrate value has not been set
       
   721     if ( !iBitrateSet )
       
   722         {
       
   723         iBitrate = aBitrate;
       
   724         }
       
   725     }
       
   726     
       
   727 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   728 
       
   729 //  End of File