multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdModifyAudioCodec.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:    Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "MCEConstants.h"
       
    21 #include "TCmdModifyAudioCodec.h"
       
    22 #include "CTcMCEContext.h"
       
    23 
       
    24 #include <MCEAudioCodec.h>
       
    25 #include <MCEAMRCodec.h>
       
    26 
       
    27 void TCmdModifyAudioCodec::ExecuteL()
       
    28 	{	
       
    29 	// ---------- Setup --------------------------------------------------------
       
    30 
       
    31 	// Get codec 
       
    32 	CMceAudioCodec* codec = 
       
    33 		reinterpret_cast<CMceAudioCodec*>(GetObjectForIdL(KCodecId, ETrue));
       
    34 	/*CMceAmrCodec* codec = 
       
    35 		reinterpret_cast<CMceAmrCodec*>(GetObjectForIdL(KCodecId, ETrue));*/
       
    36 	
       
    37 	// ---------- Execution ----------------------------------------------------
       
    38 
       
    39 
       
    40     // VAD
       
    41     TBool enableVad = EFalse; 
       
    42     TRAPD( err, enableVad = ExtractBooleanL( KParamVAD, ETrue ) );
       
    43     if ( err != KTcErrMandatoryParameterNotFound )
       
    44         {
       
    45         codec->EnableVAD( enableVad );
       
    46         }
       
    47     
       
    48     // Bitrate
       
    49     TInt bitrate( 0 );
       
    50     TRAP( err, bitrate = ExtractIntegerL( KParamBitrates, 0, ETrue ));
       
    51     if ( err != KTcErrMandatoryParameterNotFound )
       
    52         {
       
    53         codec->SetBitrate( bitrate );
       
    54         }   
       
    55     
       
    56     // SamplingFrequency
       
    57     TInt samplingFrequency( 0 );
       
    58     TRAP( err, 
       
    59           samplingFrequency = ExtractIntegerL( KParamSamplingFreq, 0, ETrue ));
       
    60     if ( err != KTcErrMandatoryParameterNotFound )
       
    61         {
       
    62         codec->SetSamplingFreq( samplingFrequency );
       
    63         }   
       
    64             
       
    65     // PayloadType
       
    66     TInt payloadType( 0 );
       
    67     TRAP( err, payloadType = ExtractIntegerL( KParamPayloadType, 0, ETrue ));
       
    68     if ( err != KTcErrMandatoryParameterNotFound )
       
    69         {
       
    70         codec->SetPayloadType( payloadType );
       
    71         }   
       
    72             
       
    73     // CodecMode
       
    74     TInt codecMode( 0 );
       
    75     TRAP( err, codecMode = ExtractIntegerL( KParamCodecMode, 0, ETrue ));
       
    76     if ( err != KTcErrMandatoryParameterNotFound )
       
    77         {
       
    78         codec->SetCodecMode( codecMode );
       
    79         }   
       
    80             
       
    81     // PTime
       
    82     TInt pTime( 0 );
       
    83     TRAP( err, pTime = ExtractIntegerL( KParamPTime, 0, ETrue ));
       
    84     if ( err != KTcErrMandatoryParameterNotFound )
       
    85         {
       
    86         codec->SetPTime( pTime );
       
    87         }   
       
    88             
       
    89     // MaxPTime
       
    90     TInt maxPTime( 0 );
       
    91     TRAP( err, maxPTime = ExtractIntegerL( KParamMaxPTime, 0, ETrue ));
       
    92     if ( err != KTcErrMandatoryParameterNotFound )
       
    93         {
       
    94         codec->SetMaxPTime( maxPTime );
       
    95         }       
       
    96         
       
    97     //SetAllowedBiTRates
       
    98     TInt allowedBitRate( 0 );
       
    99     TRAP(err, allowedBitRate = ExtractIntegerL(KParamAllowedBitRate, 0, ETrue));
       
   100     if(err != KTcErrMandatoryParameterNotFound)
       
   101     	{
       
   102     	codec->SetAllowedBitrates(allowedBitRate);	
       
   103     	}
       
   104     
       
   105 	// ---------- Response creation --------------------------------------------
       
   106  
       
   107     AddIdResponseL( KCodecId, *codec );
       
   108     
       
   109  	AddTextResponseL( KResponseCodecName, codec->SdpName() );
       
   110 
       
   111  	AddIntegerResponseL( KResponseBitrates, codec->Bitrate() );
       
   112  	
       
   113  	AddIntegerResponseL( KResponseSamplingFreq, codec->SamplingFreq() );
       
   114  	
       
   115  	AddIntegerResponseL( KResponseCodecMode, codec->CodecMode() );
       
   116 
       
   117  	AddIntegerResponseL( KResponseFourCC, codec->FourCC() );
       
   118  	
       
   119   	AddIntegerResponseL( KResponsePayloadType, codec->PayloadType() );
       
   120  	
       
   121  	AddIntegerResponseL( KResponsePTime, codec->PTime() );
       
   122 
       
   123  	AddIntegerResponseL( KResponseMaxPTime, codec->MaxPTime() );
       
   124  	
       
   125  	AddIntegerResponseL (KResponseAllowedBitRate, codec->AllowedBitrates());
       
   126 
       
   127 	AddBooleanResponseL( KResponseVAD, codec->VAD() );	
       
   128 
       
   129 	}
       
   130 	
       
   131 TBool TCmdModifyAudioCodec::Match( const TTcIdentifier& aId )
       
   132 	{
       
   133 	return TTcMceCommandBase::Match( aId, _L8("ModifyAudioCodec") );
       
   134 	}
       
   135 
       
   136 TTcCommandBase* TCmdModifyAudioCodec::CreateL( MTcTestContext& aContext )
       
   137 	{
       
   138 	return new( ELeave ) TCmdModifyAudioCodec( aContext );
       
   139 	}