os/mm/devsoundextensions/mmfcustominterfaces/EAacPlusDecoderIntfc/EAacPlusDecoderIntfcProxy/src/EAacPlusDecoderIntfcProxy.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/EAacPlusDecoderIntfc/EAacPlusDecoderIntfcProxy/src/EAacPlusDecoderIntfcProxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,310 @@
1.4 +/*
1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Interface proxy for Enhanced AAC+ decoder configuration CI.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include <CustomCommandUtility.h>
1.25 +#include <CustomInterfaceUtility.h>
1.26 +#include "EAacPlusDecoderIntfcMsgs.h"
1.27 +#include "EAacPlusDecoderIntfcProxy.h"
1.28 +
1.29 +// EXTERNAL DATA STRUCTURES
1.30 +
1.31 +// EXTERNAL FUNCTION PROTOTYPES
1.32 +
1.33 +// CONSTANTS
1.34 +const CEAacPlusDecoderIntfc::TAudioObjectType
1.35 + KAacAudioObjectTypeINVALID = CEAacPlusDecoderIntfc::ENull;
1.36 +const TInt KAacInputSampleRateINVALID = 0;
1.37 +const TInt KAacNumOfChannelsINVALID = 0;
1.38 +
1.39 +// MACROS
1.40 +
1.41 +// LOCAL CONSTANTS AND MACROS
1.42 +
1.43 +// MODULE DATA STRUCTURES
1.44 +
1.45 +// LOCAL FUNCTION PROTOTYPES
1.46 +
1.47 +// FORWARD DECLARATIONS
1.48 +
1.49 +// ============================= LOCAL FUNCTIONS ===============================
1.50 +
1.51 +// ============================= MEMBER FUNCTIONS ==============================
1.52 +
1.53 +/**
1.54 + * CEAacPlusDecoderIntfcProxy::CEAacPlusDecoderIntfcProxy
1.55 + * C++ default constructor can NOT contain any code, that
1.56 + * might leave.
1.57 + */
1.58 +CEAacPlusDecoderIntfcProxy::CEAacPlusDecoderIntfcProxy(
1.59 + TMMFMessageDestinationPckg aMessageHandler,
1.60 + MCustomCommand& aCustomCommand,
1.61 + CCustomInterfaceUtility* aCustomInterfaceUtility) :
1.62 + iCustomCommand(aCustomCommand),
1.63 + iMessageHandler(aMessageHandler),
1.64 + iCustomInterfaceUtility(aCustomInterfaceUtility)
1.65 + {
1.66 + }
1.67 +
1.68 +/**
1.69 + * CEAacPlusDecoderIntfcProxy::ConstructL
1.70 + * Symbian 2nd phase constructor can leave.
1.71 + */
1.72 +void CEAacPlusDecoderIntfcProxy::ConstructL()
1.73 + {
1.74 + iAudioObjectType = KAacAudioObjectTypeINVALID;
1.75 + iInputSamplingFrequency = KAacInputSampleRateINVALID;
1.76 + iNumOfChannels = KAacNumOfChannelsINVALID;
1.77 + iSbrEnabled = EFalse;
1.78 + iDsmEnabled = EFalse;
1.79 + iHasBeenApplied = EFalse;
1.80 + }
1.81 +
1.82 +
1.83 +/**
1.84 + * CEAacPlusDecoderIntfcProxy::NewL
1.85 + * Two-phased constructor.
1.86 + */
1.87 +EXPORT_C CEAacPlusDecoderIntfcProxy* CEAacPlusDecoderIntfcProxy::NewL(
1.88 + TMMFMessageDestinationPckg aMessageHandler,
1.89 + MCustomCommand& aCustomCommand,
1.90 + CCustomInterfaceUtility* aCustomInterfaceUtility)
1.91 + {
1.92 + CEAacPlusDecoderIntfcProxy* self = new(ELeave) CEAacPlusDecoderIntfcProxy(
1.93 + aMessageHandler,
1.94 + aCustomCommand,
1.95 + aCustomInterfaceUtility);
1.96 + CleanupStack::PushL( self );
1.97 + self->ConstructL();
1.98 + CleanupStack::Pop( self );
1.99 + return self;
1.100 + }
1.101 +
1.102 +/**
1.103 + * Destructor
1.104 + */
1.105 +EXPORT_C CEAacPlusDecoderIntfcProxy::~CEAacPlusDecoderIntfcProxy()
1.106 + {
1.107 + iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
1.108 + delete iCustomInterfaceUtility;
1.109 + }
1.110 +
1.111 +
1.112 +// From CEAacPlusDecoderIntfc
1.113 +
1.114 +/**
1.115 + * Configures decoder's profile defined by TAudioObjectType.
1.116 + * (other items defined in the header)
1.117 + */
1.118 +EXPORT_C void CEAacPlusDecoderIntfcProxy::SetAudioObjectType(
1.119 + TAudioObjectType aAudioObjectType)
1.120 + {
1.121 + iAudioObjectType = aAudioObjectType;
1.122 + }
1.123 +
1.124 +/**
1.125 + * Configures decoder's input sampling frequency.
1.126 + * (other items defined in the header)
1.127 + */
1.128 +EXPORT_C void CEAacPlusDecoderIntfcProxy::SetInputSamplingFrequency(
1.129 + TUint aInputSamplingFrequency)
1.130 + {
1.131 + iInputSamplingFrequency = aInputSamplingFrequency;
1.132 + }
1.133 +
1.134 +/**
1.135 + * Configures decoder's channel settings.
1.136 + * (other items defined in the header)
1.137 + */
1.138 +EXPORT_C void CEAacPlusDecoderIntfcProxy::SetNumOfChannels(
1.139 + TUint aNumOfChannels)
1.140 + {
1.141 + iNumOfChannels = aNumOfChannels;
1.142 + }
1.143 +
1.144 +/**
1.145 + * Configures decoder's SBR settings.
1.146 + * (other items defined in the header)
1.147 + */
1.148 +EXPORT_C void CEAacPlusDecoderIntfcProxy::SetSbr(TBool aSbrEnabled)
1.149 + {
1.150 + iSbrEnabled = aSbrEnabled;
1.151 + }
1.152 +
1.153 +/**
1.154 + * Configures decoder's DSM settings.
1.155 + * (other items defined in the header)
1.156 + */
1.157 +EXPORT_C void CEAacPlusDecoderIntfcProxy::SetDownSampledMode(TBool aDsmEnabled)
1.158 + {
1.159 + iDsmEnabled = aDsmEnabled;
1.160 + }
1.161 +
1.162 +/**
1.163 + * Returns decoder's AAC profile settings.
1.164 + * (other items defined in the header)
1.165 + */
1.166 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetAudioObjectType(
1.167 + TAudioObjectType& aAudioObjectType)
1.168 + {
1.169 + TInt status = KErrNone;
1.170 +
1.171 + if (iHasBeenApplied)
1.172 + {
1.173 + aAudioObjectType = iCurrentAudioObjectType;
1.174 + }
1.175 + else
1.176 + {
1.177 + status = KErrArgument;
1.178 + }
1.179 +
1.180 + return status;
1.181 + }
1.182 +
1.183 +/**
1.184 + * Returns decoder's input sampling frequency settings.
1.185 + * (other items defined in the header)
1.186 + */
1.187 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetInputSamplingFrequency(
1.188 + TUint& aInputSamplingFrequency)
1.189 + {
1.190 + TInt status = KErrNone;
1.191 +
1.192 + if (iHasBeenApplied)
1.193 + {
1.194 + aInputSamplingFrequency = iCurrentInputSamplingFrequency;
1.195 + }
1.196 + else
1.197 + {
1.198 + status = KErrArgument;
1.199 + }
1.200 +
1.201 + return status;
1.202 + }
1.203 +
1.204 +/**
1.205 + * Returns decoder's channel settings.
1.206 + * (other items defined in the header)
1.207 + */
1.208 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetNumOfChannels(
1.209 + TUint& aNumOfChannels)
1.210 + {
1.211 + TInt status = KErrNone;
1.212 +
1.213 + if (iHasBeenApplied)
1.214 + {
1.215 + aNumOfChannels = iCurrentNumOfChannels;
1.216 + }
1.217 + else
1.218 + {
1.219 + status = KErrArgument;
1.220 + }
1.221 +
1.222 + return status;
1.223 + }
1.224 +
1.225 +/**
1.226 + * Returns decoder's SBR settings.
1.227 + * (other items defined in the header)
1.228 + */
1.229 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetSbr(TBool& aSbrEnabled)
1.230 + {
1.231 + TInt status = KErrNone;
1.232 +
1.233 + if (iHasBeenApplied)
1.234 + {
1.235 + aSbrEnabled = iCurrentSbrEnabled;
1.236 + }
1.237 + else
1.238 + {
1.239 + status = KErrArgument;
1.240 + }
1.241 +
1.242 + return status;
1.243 + }
1.244 +
1.245 +/**
1.246 + * Returns decoder's DSM settings.
1.247 + * (other items defined in the header)
1.248 + */
1.249 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::GetDownSampledMode(TBool& aDsmEnabled)
1.250 + {
1.251 + TInt status = KErrNone;
1.252 +
1.253 + if (iHasBeenApplied)
1.254 + {
1.255 + aDsmEnabled = iCurrentDsmEnabled;
1.256 + }
1.257 + else
1.258 + {
1.259 + status = KErrArgument;
1.260 + }
1.261 +
1.262 + return status;
1.263 + }
1.264 +
1.265 +/**
1.266 + * Applies configuration settings to the decoder.
1.267 + * (other items defined in the header)
1.268 + */
1.269 +EXPORT_C TInt CEAacPlusDecoderIntfcProxy::ApplyConfig()
1.270 + {
1.271 + TInt status = KErrNone;
1.272 +
1.273 + if (!iHasBeenApplied)
1.274 + {
1.275 + // Make sure Set() methods for these params were called at least once
1.276 + if (iAudioObjectType == KAacAudioObjectTypeINVALID ||
1.277 + iInputSamplingFrequency == KAacInputSampleRateINVALID ||
1.278 + iNumOfChannels == KAacNumOfChannelsINVALID)
1.279 + {
1.280 + status = KErrArgument;
1.281 + }
1.282 + }
1.283 +
1.284 + if (status == KErrNone)
1.285 + {
1.286 + TEAacPlusDecoderConfig configParams;
1.287 +
1.288 + configParams.iAudioObjectType = iAudioObjectType;
1.289 + configParams.iInputSamplingFrequency = iInputSamplingFrequency;
1.290 + configParams.iNumOfChannels = iNumOfChannels;
1.291 + configParams.iSbrEnabled = iSbrEnabled;
1.292 + configParams.iDsmEnabled = iDsmEnabled;
1.293 +
1.294 + TPckgBuf<TEAacPlusDecoderConfig> pckgBuf(configParams);
1.295 + TInt status = iCustomCommand.CustomCommandSync(iMessageHandler,
1.296 + EEaacpdimApplyConfig,
1.297 + pckgBuf,
1.298 + KNullDesC8);
1.299 + if (status == KErrNone)
1.300 + {
1.301 + iCurrentAudioObjectType = iAudioObjectType;
1.302 + iCurrentInputSamplingFrequency = iInputSamplingFrequency;
1.303 + iCurrentNumOfChannels = iNumOfChannels;
1.304 + iCurrentSbrEnabled = iSbrEnabled;
1.305 + iCurrentDsmEnabled = iDsmEnabled;
1.306 + iHasBeenApplied = ETrue;
1.307 + }
1.308 + }
1.309 +
1.310 + return status;
1.311 + }
1.312 +
1.313 +// End of File