os/mm/devsoundextensions/mmfcustominterfaces/G711DecoderIntfc/G711DecoderIntfcMsgHdlr/src/G711DecoderIntfcMsgHdlr.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 G711 decoder interface
21 #include "G711DecoderIntfcMsgHdlr.h"
22 #include "G711DecoderIntfcMsgs.h"
23 #include <G711DecoderIntfc.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 // CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr
47 // C++ default constructor can NOT contain any code, that
49 // -----------------------------------------------------------------------------
51 CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr(
52 CG711DecoderIntfc* aG711DecoderIntfcCI) :
53 CMMFObject(KUidG711DecoderIntfc)
55 iG711DecoderIntfcCI = aG711DecoderIntfcCI;
58 // -----------------------------------------------------------------------------
59 // CG711DecoderIntfcMsgHdlr::ConstructL
60 // Symbian 2nd phase constructor can leave.
61 // -----------------------------------------------------------------------------
63 void CG711DecoderIntfcMsgHdlr::ConstructL()
67 // -----------------------------------------------------------------------------
68 // CG711DecoderIntfcMsgHdlr::NewL
69 // Two-phased constructor.
70 // -----------------------------------------------------------------------------
72 EXPORT_C CG711DecoderIntfcMsgHdlr* CG711DecoderIntfcMsgHdlr::NewL(
73 TAny* aG711DecoderIntfcCI)
75 CG711DecoderIntfc* errorConcealmentIntfcCI =
76 (CG711DecoderIntfc*)aG711DecoderIntfcCI;
77 CG711DecoderIntfcMsgHdlr* self =
78 new (ELeave) CG711DecoderIntfcMsgHdlr(errorConcealmentIntfcCI);
79 CleanupStack::PushL( self );
81 CleanupStack::Pop( self );
87 EXPORT_C CG711DecoderIntfcMsgHdlr::~CG711DecoderIntfcMsgHdlr()
89 delete iG711DecoderIntfcCI;
92 // ---------------------------------------------------------
93 // CG711DecoderIntfcMsgHdlr::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 CG711DecoderIntfcMsgHdlr::HandleRequest(
102 TMMFMessage& aMessage)
104 ASSERT(aMessage.Destination().InterfaceId() == KUidG711DecoderIntfc);
105 TRAPD(error,DoHandleRequestL(aMessage));
108 aMessage.Complete(error);
112 // ---------------------------------------------------------
113 // CG711DecoderIntfcMsgHdlr::DoHandleRequestL
114 // Determines which custom interface to call.
115 // (other items were commented in a header).
116 // ---------------------------------------------------------
118 void CG711DecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
120 switch(aMessage.Function())
122 case EG711dimSetDecoderMode:
124 DoSetDecoderModeL(aMessage);
144 aMessage.Complete(KErrNotSupported);
149 // ---------------------------------------------------------
150 // CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL
151 // Handles the message from the proxy and calls the custom interface method.
152 // The data passed from the proxy is read from the message and passed to
153 // the custom interface.
154 // (other items were commented in a header).
155 // ---------------------------------------------------------
157 void CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage)
159 TPckgBuf<CG711DecoderIntfc::TDecodeMode> pckgBuf;
160 aMessage.ReadData1FromClientL(pckgBuf);
161 TInt status = iG711DecoderIntfcCI->SetDecoderMode(pckgBuf());
162 aMessage.Complete(status);
165 // ---------------------------------------------------------
166 // CG711DecoderIntfcMsgHdlr::DoSetCngL
167 // Handles the message from the proxy and calls the custom interface method.
168 // The data passed from the proxy is read from the message and passed to
169 // the custom interface.
170 // (other items were commented in a header).
171 // ---------------------------------------------------------
173 void CG711DecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage)
175 TPckgBuf<TBool> pckgBuf;
176 aMessage.ReadData1FromClientL(pckgBuf);
177 TInt status = iG711DecoderIntfcCI->SetCng(pckgBuf());
178 aMessage.Complete(status);
181 // ---------------------------------------------------------
182 // CG711DecoderIntfcMsgHdlr::DoGetCngL
183 // Handles the message from the proxy and calls the custom interface method.
184 // The custom interface returns the data requested and this function
185 // writes it back to the proxy.
186 // (other items were commented in a header).
187 // ---------------------------------------------------------
189 void CG711DecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage)
192 TInt status = iG711DecoderIntfcCI->GetCng(cng);
193 if (status == KErrNone)
195 TPckgBuf<TBool> pckgBuf;
197 aMessage.WriteDataToClientL(pckgBuf);
199 aMessage.Complete(status);
202 // ---------------------------------------------------------
203 // CG711DecoderIntfcMsgHdlr::DoSetPlcL
204 // Handles the message from the proxy and calls the custom interface method.
205 // The data passed from the proxy is read from the message and passed to
206 // the custom interface.
207 // (other items were commented in a header).
208 // ---------------------------------------------------------
210 void CG711DecoderIntfcMsgHdlr::DoSetPlcL(TMMFMessage& aMessage)
212 TPckgBuf<TBool> pckgBuf;
213 aMessage.ReadData1FromClientL(pckgBuf);
214 TInt status = iG711DecoderIntfcCI->SetPlc(pckgBuf());
215 aMessage.Complete(status);