sl@0: /* sl@0: * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Interface proxy for speech encoder configuration. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "SpeechEncoderConfigProxy.h" sl@0: #include "SpeechEncoderConfigMsgs.h" sl@0: #include sl@0: #include sl@0: sl@0: // EXTERNAL DATA STRUCTURES sl@0: sl@0: // EXTERNAL FUNCTION PROTOTYPES sl@0: sl@0: // CONSTANTS sl@0: sl@0: // MACROS sl@0: sl@0: // LOCAL CONSTANTS AND MACROS sl@0: sl@0: // MODULE DATA STRUCTURES sl@0: sl@0: // LOCAL FUNCTION PROTOTYPES sl@0: sl@0: // FORWARD DECLARATIONS sl@0: sl@0: // ============================= LOCAL FUNCTIONS =============================== sl@0: sl@0: // ================= MEMBER FUNCTIONS ======================= sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::CSpeechEncoderConfigProxy sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CSpeechEncoderConfigProxy::CSpeechEncoderConfigProxy( sl@0: TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility) : sl@0: iCustomCommand(aCustomCommand), sl@0: iMessageHandler(aMessageHandler), sl@0: iCustomInterfaceUtility(aCustomInterfaceUtility) sl@0: { sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CSpeechEncoderConfigProxy::ConstructL() sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::NewL sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C CSpeechEncoderConfigProxy* CSpeechEncoderConfigProxy::NewL( sl@0: TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility) sl@0: { sl@0: CSpeechEncoderConfigProxy* self = new(ELeave) CSpeechEncoderConfigProxy( sl@0: aMessageHandler, sl@0: aCustomCommand, sl@0: aCustomInterfaceUtility); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return self; sl@0: } sl@0: sl@0: // Destructor sl@0: EXPORT_C CSpeechEncoderConfigProxy::~CSpeechEncoderConfigProxy() sl@0: { sl@0: iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); sl@0: delete iCustomInterfaceUtility; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::GetSupportedBitrates sl@0: // Calls a subfunction which sends the appropriate custom command for this sl@0: // function to its message handler. A subfunction is used sl@0: // to contain multiple leaving functions for a single trap. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CSpeechEncoderConfigProxy::GetSupportedBitrates( sl@0: RArray& aSupportedBitrates) sl@0: { sl@0: TInt status; sl@0: TRAP(status, GetSupportedBitratesL(aSupportedBitrates)); sl@0: return status; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::GetSupportedBitratesL sl@0: // Sends the custom command for this function to its message handler. sl@0: // This requires two commands. The first is a request for the number of sl@0: // supported bitrates. A buffer is allocated locally to hold this number of sl@0: // bitrates that will be returned. A pointer to this buffer is sent with the sl@0: // next command which is a request for the bitrates. This buffer will be filled sl@0: // with the bitrate values. These bitrates are then copied into the array sl@0: // provided to this function and the local buffer is deleted. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CSpeechEncoderConfigProxy::GetSupportedBitratesL( sl@0: RArray& aSupportedBitrates) sl@0: { sl@0: aSupportedBitrates.Reset(); sl@0: sl@0: TPckgBuf numberOfBitratesPckg; sl@0: User::LeaveIfError(iCustomCommand.CustomCommandSync( sl@0: iMessageHandler, sl@0: ESecmGetNumOfSupportedBitrates, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: numberOfBitratesPckg)); sl@0: HBufC8* buf = HBufC8::NewLC(numberOfBitratesPckg()*sizeof(TUint)); sl@0: // buf is left on cleanup sl@0: TPtr8 ptr = buf->Des(); sl@0: sl@0: User::LeaveIfError(iCustomCommand.CustomCommandSync( sl@0: iMessageHandler, sl@0: ESecmGetSupportedBitrates, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: ptr)); sl@0: RDesReadStream stream(ptr); sl@0: CleanupClosePushL(stream); // stream on cleanup sl@0: for (TInt i=0; i bitratePckg(aBitrate); sl@0: TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, sl@0: ESecmSetBitrate, sl@0: bitratePckg, sl@0: KNullDesC8); sl@0: return status; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::GetBitrate sl@0: // Sends the custom command for this function to its message handler. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CSpeechEncoderConfigProxy::GetBitrate(TUint& aBitrate) sl@0: { sl@0: TInt bitrate = 0; sl@0: TPckgBuf bitratePckg(bitrate); sl@0: TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, sl@0: ESecmGetBitrate, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: bitratePckg); sl@0: if (status == KErrNone) sl@0: aBitrate = bitratePckg(); sl@0: return status; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::SetVadMode sl@0: // Sends the custom command for this function to its message handler. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CSpeechEncoderConfigProxy::SetVadMode(TBool aVadMode) sl@0: { sl@0: TPckgBuf pckgBuf(aVadMode); sl@0: TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, sl@0: ESecmSetVadMode, sl@0: pckgBuf, sl@0: KNullDesC8); sl@0: return status; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigProxy::GetVadMode sl@0: // Sends the custom command for this function to its message handler. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CSpeechEncoderConfigProxy::GetVadMode(TBool& aVadMode) sl@0: { sl@0: TInt vadMode = EFalse; sl@0: TPckgBuf pckgBuf(vadMode); sl@0: TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, sl@0: ESecmGetVadMode, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: pckgBuf); sl@0: if (status == KErrNone) sl@0: aVadMode = pckgBuf(); sl@0: return status; sl@0: } sl@0: sl@0: sl@0: sl@0: // End of File