os/mm/devsoundextensions/mmfcustominterfaces/EAacPlusDecoderIntfc/EAacPlusDecoderIntfcProxy/src/EAacPlusDecoderIntfcProxy.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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:   Interface proxy for Enhanced AAC+ decoder configuration CI.
    15 *
    16 */
    17 
    18 
    19 
    20 // INCLUDE FILES
    21 #include <CustomCommandUtility.h>
    22 #include <CustomInterfaceUtility.h>
    23 #include "EAacPlusDecoderIntfcMsgs.h"
    24 #include "EAacPlusDecoderIntfcProxy.h"
    25 
    26 // EXTERNAL DATA STRUCTURES
    27 
    28 // EXTERNAL FUNCTION PROTOTYPES
    29 
    30 // CONSTANTS
    31 const CEAacPlusDecoderIntfc::TAudioObjectType
    32             KAacAudioObjectTypeINVALID = CEAacPlusDecoderIntfc::ENull;
    33 const TInt  KAacInputSampleRateINVALID = 0;
    34 const TInt  KAacNumOfChannelsINVALID   = 0;
    35 
    36 // MACROS
    37 
    38 // LOCAL CONSTANTS AND MACROS
    39 
    40 // MODULE DATA STRUCTURES
    41 
    42 // LOCAL FUNCTION PROTOTYPES
    43 
    44 // FORWARD DECLARATIONS
    45 
    46 // ============================= LOCAL FUNCTIONS ===============================
    47 
    48 // ============================= MEMBER FUNCTIONS ==============================
    49 
    50 /**
    51  * CEAacPlusDecoderIntfcProxy::CEAacPlusDecoderIntfcProxy
    52  * C++ default constructor can NOT contain any code, that
    53  * might leave.
    54  */
    55 CEAacPlusDecoderIntfcProxy::CEAacPlusDecoderIntfcProxy(
    56                             TMMFMessageDestinationPckg aMessageHandler,
    57                             MCustomCommand& aCustomCommand,
    58                             CCustomInterfaceUtility* aCustomInterfaceUtility) :
    59     iCustomCommand(aCustomCommand),
    60     iMessageHandler(aMessageHandler),
    61     iCustomInterfaceUtility(aCustomInterfaceUtility)
    62     {
    63     }
    64 
    65 /**
    66  * CEAacPlusDecoderIntfcProxy::ConstructL
    67  * Symbian 2nd phase constructor can leave.
    68  */
    69 void CEAacPlusDecoderIntfcProxy::ConstructL()
    70     {
    71     iAudioObjectType        = KAacAudioObjectTypeINVALID;
    72     iInputSamplingFrequency = KAacInputSampleRateINVALID;
    73     iNumOfChannels          = KAacNumOfChannelsINVALID;
    74     iSbrEnabled             = EFalse;
    75     iDsmEnabled             = EFalse;
    76     iHasBeenApplied         = EFalse;
    77     }
    78 
    79 
    80 /**
    81  * CEAacPlusDecoderIntfcProxy::NewL
    82  * Two-phased constructor.
    83  */
    84 EXPORT_C CEAacPlusDecoderIntfcProxy* CEAacPlusDecoderIntfcProxy::NewL(
    85                               TMMFMessageDestinationPckg aMessageHandler,
    86                               MCustomCommand& aCustomCommand,
    87                               CCustomInterfaceUtility* aCustomInterfaceUtility)
    88     {
    89     CEAacPlusDecoderIntfcProxy* self = new(ELeave) CEAacPlusDecoderIntfcProxy(
    90                                                    aMessageHandler,
    91                                                    aCustomCommand,
    92                                                    aCustomInterfaceUtility);
    93     CleanupStack::PushL( self );
    94     self->ConstructL();
    95     CleanupStack::Pop( self );
    96     return self;
    97     }
    98 
    99 /**
   100  * Destructor
   101  */
   102 EXPORT_C CEAacPlusDecoderIntfcProxy::~CEAacPlusDecoderIntfcProxy()
   103     {
   104     iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
   105     delete iCustomInterfaceUtility;
   106     }
   107 
   108 
   109 // From CEAacPlusDecoderIntfc
   110 
   111 /**
   112  * Configures decoder's profile defined by TAudioObjectType.
   113  * (other items defined in the header)
   114  */
   115 EXPORT_C void CEAacPlusDecoderIntfcProxy::SetAudioObjectType(
   116                                           TAudioObjectType aAudioObjectType)
   117 	{
   118 	iAudioObjectType = aAudioObjectType;
   119 	}
   120 
   121 /**
   122  * Configures decoder's input sampling frequency.
   123  * (other items defined in the header)
   124  */
   125 EXPORT_C void CEAacPlusDecoderIntfcProxy::SetInputSamplingFrequency(
   126                                           TUint aInputSamplingFrequency)
   127     {
   128     iInputSamplingFrequency = aInputSamplingFrequency;
   129     }
   130 
   131 /**
   132  * Configures decoder's channel settings.
   133  * (other items defined in the header)
   134  */
   135 EXPORT_C void CEAacPlusDecoderIntfcProxy::SetNumOfChannels(
   136                                           TUint aNumOfChannels)
   137     {
   138     iNumOfChannels = aNumOfChannels;
   139     }
   140 
   141 /**
   142  * Configures decoder's SBR settings.
   143  * (other items defined in the header)
   144  */
   145 EXPORT_C void CEAacPlusDecoderIntfcProxy::SetSbr(TBool aSbrEnabled)
   146     {
   147     iSbrEnabled = aSbrEnabled;
   148     }
   149 
   150 /**
   151  * Configures decoder's DSM settings.
   152  * (other items defined in the header)
   153  */
   154 EXPORT_C void CEAacPlusDecoderIntfcProxy::SetDownSampledMode(TBool aDsmEnabled)
   155     {
   156     iDsmEnabled = aDsmEnabled;
   157     }
   158 
   159 /**
   160  * Returns decoder's AAC profile settings.
   161  * (other items defined in the header)
   162  */
   163 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetAudioObjectType(
   164                                           TAudioObjectType& aAudioObjectType)
   165 	{
   166     TInt status = KErrNone;
   167 
   168     if (iHasBeenApplied)
   169         {
   170     	aAudioObjectType = iCurrentAudioObjectType;
   171         }
   172     else
   173         {
   174         status = KErrArgument;
   175         }
   176 
   177     return status;
   178 	}
   179 
   180 /**
   181  * Returns decoder's input sampling frequency settings.
   182  * (other items defined in the header)
   183  */
   184 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetInputSamplingFrequency(
   185                                           TUint& aInputSamplingFrequency)
   186     {
   187     TInt status = KErrNone;
   188 
   189     if (iHasBeenApplied)
   190         {
   191     	aInputSamplingFrequency = iCurrentInputSamplingFrequency;
   192         }
   193     else
   194         {
   195         status = KErrArgument;
   196         }
   197 
   198     return status;
   199     }
   200 
   201 /**
   202  * Returns decoder's channel settings.
   203  * (other items defined in the header)
   204  */
   205 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetNumOfChannels(
   206                                           TUint& aNumOfChannels)
   207     {
   208     TInt status = KErrNone;
   209 
   210     if (iHasBeenApplied)
   211         {
   212     	aNumOfChannels = iCurrentNumOfChannels;
   213         }
   214     else
   215         {
   216         status = KErrArgument;
   217         }
   218 
   219     return status;
   220     }
   221 
   222 /**
   223  * Returns decoder's SBR settings.
   224  * (other items defined in the header)
   225  */
   226 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetSbr(TBool& aSbrEnabled)
   227     {
   228     TInt status = KErrNone;
   229 
   230     if (iHasBeenApplied)
   231         {
   232     	aSbrEnabled = iCurrentSbrEnabled;
   233         }
   234     else
   235         {
   236         status = KErrArgument;
   237         }
   238 
   239     return status;
   240     }
   241 
   242 /**
   243  * Returns decoder's DSM settings.
   244  * (other items defined in the header)
   245  */
   246 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetDownSampledMode(TBool& aDsmEnabled)
   247     {
   248     TInt status = KErrNone;
   249 
   250     if (iHasBeenApplied)
   251         {
   252     	aDsmEnabled = iCurrentDsmEnabled;
   253         }
   254     else
   255         {
   256         status = KErrArgument;
   257         }
   258 
   259     return status;
   260     }
   261 
   262 /**
   263  * Applies configuration settings to the decoder.
   264  * (other items defined in the header)
   265  */
   266 EXPORT_C TInt CEAacPlusDecoderIntfcProxy::ApplyConfig()
   267     {
   268     TInt status = KErrNone;
   269 
   270     if (!iHasBeenApplied)
   271         {
   272         // Make sure Set() methods for these params were called at least once
   273         if (iAudioObjectType == KAacAudioObjectTypeINVALID ||
   274             iInputSamplingFrequency == KAacInputSampleRateINVALID ||
   275             iNumOfChannels == KAacNumOfChannelsINVALID)
   276             {
   277             status = KErrArgument;
   278             }
   279         }
   280 
   281     if (status == KErrNone)
   282         {
   283         TEAacPlusDecoderConfig configParams;
   284 
   285     	configParams.iAudioObjectType        = iAudioObjectType;
   286     	configParams.iInputSamplingFrequency = iInputSamplingFrequency;
   287     	configParams.iNumOfChannels          = iNumOfChannels;
   288     	configParams.iSbrEnabled             = iSbrEnabled;
   289     	configParams.iDsmEnabled             = iDsmEnabled;
   290 
   291     	TPckgBuf<TEAacPlusDecoderConfig> pckgBuf(configParams);
   292     	TInt status = iCustomCommand.CustomCommandSync(iMessageHandler,
   293     	                                               EEaacpdimApplyConfig,
   294     	                                               pckgBuf,
   295     	                                               KNullDesC8);
   296     	if (status == KErrNone)
   297     		{
   298             iCurrentAudioObjectType        = iAudioObjectType;
   299             iCurrentInputSamplingFrequency = iInputSamplingFrequency;
   300             iCurrentNumOfChannels          = iNumOfChannels;
   301             iCurrentSbrEnabled             = iSbrEnabled;
   302             iCurrentDsmEnabled             = iDsmEnabled;
   303     		iHasBeenApplied = ETrue;
   304     		}
   305         }
   306 
   307 	return status;
   308     }
   309 
   310 // End of File