os/mm/devsoundextensions/mmfcustominterfaces/G711EncoderIntfc/G711EncoderIntfcMsgHdlr/src/G711EncoderIntfcMsgHdlr.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/G711EncoderIntfc/G711EncoderIntfcMsgHdlr/src/G711EncoderIntfcMsgHdlr.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,200 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2004 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: Message handler for G711 encoder interface
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "G711EncoderIntfcMsgHdlr.h"
1.25 +#include "G711EncoderIntfcMsgs.h"
1.26 +#include <G711EncoderIntfc.h>
1.27 +
1.28 +// EXTERNAL DATA STRUCTURES
1.29 +
1.30 +// EXTERNAL FUNCTION PROTOTYPES
1.31 +
1.32 +// CONSTANTS
1.33 +
1.34 +// MACROS
1.35 +
1.36 +// LOCAL CONSTANTS AND MACROS
1.37 +
1.38 +// MODULE DATA STRUCTURES
1.39 +
1.40 +// LOCAL FUNCTION PROTOTYPES
1.41 +
1.42 +// FORWARD DECLARATIONS
1.43 +
1.44 +// ============================= LOCAL FUNCTIONS ===============================
1.45 +
1.46 +// ============================ MEMBER FUNCTIONS ===============================
1.47 +
1.48 +// -----------------------------------------------------------------------------
1.49 +// CG711EncoderIntfcMsgHdlr::CG711EncoderIntfcMsgHdlr
1.50 +// C++ default constructor can NOT contain any code, that
1.51 +// might leave.
1.52 +// -----------------------------------------------------------------------------
1.53 +//
1.54 +CG711EncoderIntfcMsgHdlr::CG711EncoderIntfcMsgHdlr(
1.55 + CG711EncoderIntfc* aG711EncoderIntfcCI) :
1.56 + CMMFObject(KUidG711EncoderIntfc)
1.57 + {
1.58 + iG711EncoderIntfcCI = aG711EncoderIntfcCI;
1.59 + }
1.60 +
1.61 +// -----------------------------------------------------------------------------
1.62 +// CG711EncoderIntfcMsgHdlr::ConstructL
1.63 +// Symbian 2nd phase constructor can leave.
1.64 +// -----------------------------------------------------------------------------
1.65 +//
1.66 +void CG711EncoderIntfcMsgHdlr::ConstructL()
1.67 + {
1.68 + }
1.69 +
1.70 +// -----------------------------------------------------------------------------
1.71 +// CG711EncoderIntfcMsgHdlr::NewL
1.72 +// Two-phased constructor.
1.73 +// -----------------------------------------------------------------------------
1.74 +//
1.75 +EXPORT_C CG711EncoderIntfcMsgHdlr* CG711EncoderIntfcMsgHdlr::NewL(
1.76 + TAny* aG711EncoderIntfcCI)
1.77 + {
1.78 + CG711EncoderIntfc* errorConcealmentIntfcCI =
1.79 + (CG711EncoderIntfc*)aG711EncoderIntfcCI;
1.80 + CG711EncoderIntfcMsgHdlr* self =
1.81 + new (ELeave) CG711EncoderIntfcMsgHdlr(errorConcealmentIntfcCI);
1.82 + CleanupStack::PushL( self );
1.83 + self->ConstructL();
1.84 + CleanupStack::Pop( self );
1.85 +
1.86 + return self;
1.87 + }
1.88 +
1.89 +// Destructor
1.90 +EXPORT_C CG711EncoderIntfcMsgHdlr::~CG711EncoderIntfcMsgHdlr()
1.91 + {
1.92 + delete iG711EncoderIntfcCI;
1.93 + }
1.94 +
1.95 +// ---------------------------------------------------------
1.96 +// CG711EncoderIntfcMsgHdlr::HandleRequest
1.97 +// Handles the messages from the proxy.
1.98 +// Calls a subfunction which determines which custom interface to call.
1.99 +// A subfunction is used to contain multiple leaving functions for a single
1.100 +// trap.
1.101 +// (other items were commented in a header).
1.102 +// ---------------------------------------------------------
1.103 +//
1.104 +EXPORT_C void CG711EncoderIntfcMsgHdlr::HandleRequest(
1.105 + TMMFMessage& aMessage)
1.106 + {
1.107 + ASSERT(aMessage.Destination().InterfaceId() == KUidG711EncoderIntfc);
1.108 + TRAPD(error,DoHandleRequestL(aMessage));
1.109 + if(error)
1.110 + {
1.111 + aMessage.Complete(error);
1.112 + }
1.113 + }
1.114 +
1.115 +// ---------------------------------------------------------
1.116 +// CG711EncoderIntfcMsgHdlr::DoHandleRequestL
1.117 +// Determines which custom interface to call.
1.118 +// (other items were commented in a header).
1.119 +// ---------------------------------------------------------
1.120 +//
1.121 +void CG711EncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
1.122 + {
1.123 + switch(aMessage.Function())
1.124 + {
1.125 + case EG711eimSetEncoderMode:
1.126 + {
1.127 + DoSetEncoderModeL(aMessage);
1.128 + break;
1.129 + }
1.130 + case EG711eimSetVadMode:
1.131 + {
1.132 + DoSetVadModeL(aMessage);
1.133 + break;
1.134 + }
1.135 + case EG711eimGetVadMode:
1.136 + {
1.137 + DoGetVadModeL(aMessage);
1.138 + break;
1.139 + }
1.140 + default:
1.141 + {
1.142 + aMessage.Complete(KErrNotSupported);
1.143 + }
1.144 + }
1.145 + }
1.146 +
1.147 +// ---------------------------------------------------------
1.148 +// CG711EncoderIntfcMsgHdlr::DoSetEncoderModeL
1.149 +// Handles the message from the proxy and calls the custom interface method.
1.150 +// The data passed from the proxy is read from the message and passed to
1.151 +// the custom interface.
1.152 +// (other items were commented in a header).
1.153 +// ---------------------------------------------------------
1.154 +//
1.155 +void CG711EncoderIntfcMsgHdlr::DoSetEncoderModeL(TMMFMessage& aMessage)
1.156 + {
1.157 + TPckgBuf<CG711EncoderIntfc::TEncodeMode> pckgBuf;
1.158 + aMessage.ReadData1FromClientL(pckgBuf);
1.159 + TInt status = iG711EncoderIntfcCI->SetEncoderMode(pckgBuf());
1.160 + aMessage.Complete(status);
1.161 + }
1.162 +
1.163 +// ---------------------------------------------------------
1.164 +// CG711EncoderIntfcMsgHdlr::DoSetVadModeL
1.165 +// Handles the message from the proxy and calls the custom interface method.
1.166 +// The data passed from the proxy is read from the message and passed to
1.167 +// the custom interface.
1.168 +// (other items were commented in a header).
1.169 +// ---------------------------------------------------------
1.170 +//
1.171 +void CG711EncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
1.172 + {
1.173 + TPckgBuf<TBool> pckgBuf;
1.174 + aMessage.ReadData1FromClientL(pckgBuf);
1.175 + TInt status = iG711EncoderIntfcCI->SetVadMode(pckgBuf());
1.176 + aMessage.Complete(status);
1.177 + }
1.178 +
1.179 +// ---------------------------------------------------------
1.180 +// CG711EncoderIntfcMsgHdlr::DoGetVadModeL
1.181 +// Handles the message from the proxy and calls the custom interface.
1.182 +// The custom interface returns the data requested and this function
1.183 +// writes it back to the proxy.
1.184 +// (other items were commented in a header).
1.185 +// ---------------------------------------------------------
1.186 +//
1.187 +void CG711EncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
1.188 + {
1.189 + TBool vadMode;
1.190 + TInt status = iG711EncoderIntfcCI->GetVadMode(vadMode);
1.191 + if (status == KErrNone)
1.192 + {
1.193 + TPckgBuf<TBool> pckgBuf;
1.194 + pckgBuf() = vadMode;
1.195 + aMessage.WriteDataToClientL(pckgBuf);
1.196 + }
1.197 + aMessage.Complete(status);
1.198 + }
1.199 +
1.200 +
1.201 +
1.202 +
1.203 +// End of File