os/mm/devsoundextensions/mmfcustominterfaces/IlbcEncoderIntfc/IlbcEncoderIntfcMsgHdlr/src/IlbcEncoderIntfcMsgHdlr.cpp
First public contribution.
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Message handler for Ilbc encoder interface
21 #include "IlbcEncoderIntfcMsgHdlr.h"
22 #include "IlbcEncoderIntfcMsgs.h"
23 #include <IlbcEncoderIntfc.h>
25 // EXTERNAL DATA STRUCTURES
27 // EXTERNAL FUNCTION PROTOTYPES
33 // LOCAL CONSTANTS AND MACROS
35 // MODULE DATA STRUCTURES
37 // LOCAL FUNCTION PROTOTYPES
39 // FORWARD DECLARATIONS
41 // ============================= LOCAL FUNCTIONS ===============================
43 // ============================ MEMBER FUNCTIONS ===============================
45 // -----------------------------------------------------------------------------
46 // CIlbcEncoderIntfcMsgHdlr::CIlbcEncoderIntfcMsgHdlr
47 // C++ default constructor can NOT contain any code, that
49 // -----------------------------------------------------------------------------
51 CIlbcEncoderIntfcMsgHdlr::CIlbcEncoderIntfcMsgHdlr(
52 CIlbcEncoderIntfc* aIlbcEncoderIntfcCI) :
53 CMMFObject(KUidIlbcEncoderIntfc)
55 iIlbcEncoderIntfcCI = aIlbcEncoderIntfcCI;
58 // -----------------------------------------------------------------------------
59 // CIlbcEncoderIntfcMsgHdlr::ConstructL
60 // Symbian 2nd phase constructor can leave.
61 // -----------------------------------------------------------------------------
63 void CIlbcEncoderIntfcMsgHdlr::ConstructL()
67 // -----------------------------------------------------------------------------
68 // CIlbcEncoderIntfcMsgHdlr::NewL
69 // Two-phased constructor.
70 // -----------------------------------------------------------------------------
72 EXPORT_C CIlbcEncoderIntfcMsgHdlr* CIlbcEncoderIntfcMsgHdlr::NewL(
73 TAny* aIlbcEncoderIntfcCI)
75 CIlbcEncoderIntfc* errorConcealmentIntfcCI =
76 (CIlbcEncoderIntfc*)aIlbcEncoderIntfcCI;
77 CIlbcEncoderIntfcMsgHdlr* self =
78 new (ELeave) CIlbcEncoderIntfcMsgHdlr(errorConcealmentIntfcCI);
79 CleanupStack::PushL( self );
81 CleanupStack::Pop( self );
87 EXPORT_C CIlbcEncoderIntfcMsgHdlr::~CIlbcEncoderIntfcMsgHdlr()
89 delete iIlbcEncoderIntfcCI;
92 // ---------------------------------------------------------
93 // CIlbcEncoderIntfcMsgHdlr::HandleRequest
94 // Handles the messages from the proxy.
95 // Calls a subfunction which determines which custom interface to call.
96 // A subfunction is used to contain multiple leaving functions for a single
98 // (other items were commented in a header).
99 // ---------------------------------------------------------
101 EXPORT_C void CIlbcEncoderIntfcMsgHdlr::HandleRequest(
102 TMMFMessage& aMessage)
104 ASSERT(aMessage.Destination().InterfaceId() == KUidIlbcEncoderIntfc);
105 TRAPD(error,DoHandleRequestL(aMessage));
108 aMessage.Complete(error);
112 // ---------------------------------------------------------
113 // CIlbcEncoderIntfcMsgHdlr::DoHandleRequestL
114 // Determines which custom interface to call.
115 // (other items were commented in a header).
116 // ---------------------------------------------------------
118 void CIlbcEncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
120 switch(aMessage.Function())
122 case EIlbceimSetEncoderMode:
124 DoSetEncoderModeL(aMessage);
127 case EIlbceimSetVadMode:
129 DoSetVadModeL(aMessage);
132 case EIlbceimGetVadMode:
134 DoGetVadModeL(aMessage);
139 aMessage.Complete(KErrNotSupported);
144 // ---------------------------------------------------------
145 // CIlbcEncoderIntfcMsgHdlr::DoSetEncoderModeL
146 // Handles the message from the proxy and calls the custom interface method.
147 // The data passed from the proxy is read from the message and passed to
148 // the custom interface.
149 // (other items were commented in a header).
150 // ---------------------------------------------------------
152 void CIlbcEncoderIntfcMsgHdlr::DoSetEncoderModeL(TMMFMessage& aMessage)
154 TPckgBuf<CIlbcEncoderIntfc::TEncodeMode> pckgBuf;
155 aMessage.ReadData1FromClientL(pckgBuf);
156 TInt status = iIlbcEncoderIntfcCI->SetEncoderMode(pckgBuf());
157 aMessage.Complete(status);
160 // ---------------------------------------------------------
161 // CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL
162 // Handles the message from the proxy and calls the custom interface method.
163 // The data passed from the proxy is read from the message and passed to
164 // the custom interface.
165 // (other items were commented in a header).
166 // ---------------------------------------------------------
168 void CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
170 TPckgBuf<TBool> pckgBuf;
171 aMessage.ReadData1FromClientL(pckgBuf);
172 TInt status = iIlbcEncoderIntfcCI->SetVadMode(pckgBuf());
173 aMessage.Complete(status);
176 // ---------------------------------------------------------
177 // CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL
178 // Handles the message from the proxy and calls the custom interface.
179 // The custom interface returns the data requested and this function
180 // writes it back to the proxy.
181 // (other items were commented in a header).
182 // ---------------------------------------------------------
184 void CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
187 TInt status = iIlbcEncoderIntfcCI->GetVadMode(vadMode);
188 if (status == KErrNone)
190 TPckgBuf<TBool> pckgBuf;
192 aMessage.WriteDataToClientL(pckgBuf);
194 aMessage.Complete(status);