os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/ilbcencoderconfigci.cpp
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <ecom/implementationproxy.h>
17 #include <ecom/implementationproxy.h>
18 #include <ecom/ecom.h>
21 #include "ilbcencoderconfigci.h"
26 TInt CMMFIlbcEncoderIntfcMux::OpenInterface(TUid /*aInterfaceId*/)
28 // attempt to open the interface link with the
29 // remote slave device
31 TUid slaveId = {KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux};
33 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
36 iRemoteHandle = handle;
43 void CMMFIlbcEncoderIntfcMux::Release()
45 // close the slave device if it exists
46 if (iRemoteHandle > 0)
48 // we assume the slave is closed correctly
49 iUtility->CloseSlave(iRemoteHandle);
55 // tell ECom to destroy us
56 REComSession::DestroyedImplementation(key);
60 void CMMFIlbcEncoderIntfcMux::PassDestructorKey(TUid aDestructorKey)
62 // store the destructor key
63 iKey = aDestructorKey;
67 void CMMFIlbcEncoderIntfcMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
69 // store a pointer to the utility
70 iUtility = aCustomUtility;
74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFIlbcEncoderIntfcMux::NewL()
76 CMMFIlbcEncoderIntfcMux* self = new (ELeave) CMMFIlbcEncoderIntfcMux;
81 TAny* CMMFIlbcEncoderIntfcMux::CustomInterface(TUid /*aInterfaceId*/)
83 MIlbcEncoderIntfc* interface = this;
88 CMMFIlbcEncoderIntfcMux::CMMFIlbcEncoderIntfcMux() :
94 CMMFIlbcEncoderIntfcMux::~CMMFIlbcEncoderIntfcMux()
99 // from MIlbcEncoderIntfc
100 TInt CMMFIlbcEncoderIntfcMux::SetEncoderMode(TEncodeMode aEncodeMode)
102 TInt result = KErrBadHandle;
104 if (iRemoteHandle > 0)
106 // send encodeMode in the sync command.
107 TPckgBuf<TEncodeMode> encodeMode(aEncodeMode);
109 // any return code other than zero is an error
110 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
111 EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode,
119 // from MIlbcEncoderIntfc
120 TInt CMMFIlbcEncoderIntfcMux::GetEncoderMode(TEncodeMode& aEncodeMode)
122 TInt result = KErrBadHandle;
124 if (iRemoteHandle > 0)
126 // send encodeMode in the sync command.
127 TPckgBuf<TEncodeMode> retEncodeMode;
129 // any return code other than zero is an error
130 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
131 EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode,
135 // assign return values to aEncodeMode. Do nothing if there is an error
136 if(result == KErrNone)
138 aEncodeMode = retEncodeMode();
146 // from MIlbcEncoderIntfc
147 TInt CMMFIlbcEncoderIntfcMux::SetVadMode (TBool aVadModeOn)
149 TInt result = KErrBadHandle;
151 if (iRemoteHandle > 0)
153 // send vadModeOn in the sync command.
154 TPckgBuf<TBool> vadModeOn(aVadModeOn);
156 // any return code other than zero is an error
157 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
158 EMMFDevSoundCIIlbcEncoderIntfcSetVadMode,
166 // from MIlbcEncoderIntfc
167 TInt CMMFIlbcEncoderIntfcMux::GetVadMode (TBool& aVadModeOn)
169 TInt result = KErrBadHandle;
171 if (iRemoteHandle > 0)
173 // holds the returned value.
174 TPckgBuf<TBool> retVadModeOn;
176 // any return code other than zero is an error
177 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
178 EMMFDevSoundCIIlbcEncoderIntfcGetVadMode,
182 // assign return values to aVadModeOn. Do nothing if there is an error
183 if(result == KErrNone)
185 aVadModeOn = retVadModeOn();
196 TInt CMMFIlbcEncoderIntfcDeMux::OpenInterface(TUid /*aInterfaceId*/)
202 void CMMFIlbcEncoderIntfcDeMux::Release()
208 // tell ECom to destroy us
209 REComSession::DestroyedImplementation(key);
213 void CMMFIlbcEncoderIntfcDeMux::PassDestructorKey(TUid aDestructorKey)
215 // store the destructor key
216 iKey = aDestructorKey;
220 void CMMFIlbcEncoderIntfcDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
226 void CMMFIlbcEncoderIntfcDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
228 // store a pointer to the utility
229 iUtility = aCustomUtility;
233 void CMMFIlbcEncoderIntfcDeMux::RefreshL()
235 // refetch the Ilbc encoder intfc custom interface if we already have a target
238 iInterfaceIlbcEncoderIntfc = static_cast <MIlbcEncoderIntfc*> (iTarget->CustomInterface(KUidIlbcEncoderIntfc));
240 if (!iInterfaceIlbcEncoderIntfc)
242 iInterfaceIlbcEncoderIntfc = NULL;
243 User::Leave(KErrNotSupported);
249 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFIlbcEncoderIntfcDeMux::NewL()
251 CMMFIlbcEncoderIntfcDeMux* self = new (ELeave) CMMFIlbcEncoderIntfcDeMux;
256 CMMFIlbcEncoderIntfcDeMux::CMMFIlbcEncoderIntfcDeMux()
261 CMMFIlbcEncoderIntfcDeMux::~CMMFIlbcEncoderIntfcDeMux()
266 TInt CMMFIlbcEncoderIntfcDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
268 // fetch the Ilbc encoder intfc Hw Device custom interface
269 iInterfaceIlbcEncoderIntfc = static_cast<MIlbcEncoderIntfc*> (iTarget->CustomInterface(KUidIlbcEncoderIntfc));
271 if (!iInterfaceIlbcEncoderIntfc)
273 iInterfaceIlbcEncoderIntfc = NULL;
274 User::Leave(KErrNotSupported);
281 void CMMFIlbcEncoderIntfcDeMux::DoCloseSlaveL(TInt /*aHandle*/)
287 // original RMessage is supplied so that remote demux plugin can extract necessary details
288 // using DeMux utility
289 TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
291 TMMFDevSoundCIMessageData data;
292 TInt result = KErrGeneral;
295 iUtility->GetSyncMessageDataL(aMessage, data);
297 switch (data.iCommand)
299 case EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode:
301 TPckgBuf<MIlbcEncoderIntfc::TEncodeMode> encodeMode;
302 iUtility->ReadFromInputDesL(aMessage, &encodeMode);
304 result = DoSetEncoderModeL(encodeMode());
308 case EMMFDevSoundCIIlbcEncoderIntfcSetVadMode:
310 TPckgBuf<TBool> vadModeOn;
311 iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
313 result = DoSetVadModeL(vadModeOn());
319 User::Leave(KErrNotSupported);
327 // original RMessage is supplied so that remote demux plugin can extract necessary details
328 // using DeMux utility
329 TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
331 TMMFDevSoundCIMessageData data;
332 TInt result = KErrNone;
335 iUtility->GetSyncMessageDataL(aMessage, data);
337 switch (data.iCommand)
339 case EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode:
341 TPckgBuf<MIlbcEncoderIntfc::TEncodeMode> encodeMode;
342 iUtility->ReadFromInputDesL(aMessage, &encodeMode);
344 result = DoGetEncoderModeL(encodeMode());
346 TPckgBuf<TBool> des(encodeMode());
347 iUtility->WriteToOutputDesL(aMessage, des);
351 case EMMFDevSoundCIIlbcEncoderIntfcGetVadMode:
353 TPckgBuf<TBool> vadModeOn;
354 iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
356 result = DoGetVadModeL(vadModeOn());
358 TPckgBuf<TBool> des(vadModeOn());
359 iUtility->WriteToOutputDesL(aMessage, des);
365 User::Leave(KErrNotSupported);
373 void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
375 // not used in this interface
379 void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
381 // not used in this interface
385 // Ilbc encoder intfc custom interface implementation
386 TInt CMMFIlbcEncoderIntfcDeMux::DoSetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode aEncodeMode)
388 TInt result = KErrNotFound;
390 if (iInterfaceIlbcEncoderIntfc)
392 result = iInterfaceIlbcEncoderIntfc->SetEncoderMode(aEncodeMode);
399 // Ilbc encoder intfc custom interface implementation
400 TInt CMMFIlbcEncoderIntfcDeMux::DoGetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode& aEncodeMode)
402 TInt result = KErrNotFound;
404 if (iInterfaceIlbcEncoderIntfc)
406 result = iInterfaceIlbcEncoderIntfc->GetEncoderMode(aEncodeMode);
413 // Ilbc encoder intfc custom interface implementation
414 TInt CMMFIlbcEncoderIntfcDeMux::DoSetVadModeL(TBool aVadModeOn)
416 TInt result = KErrNotFound;
418 if (iInterfaceIlbcEncoderIntfc)
420 result = iInterfaceIlbcEncoderIntfc->SetVadMode(aVadModeOn);
427 // Ilbc encoder intfc custom interface implementation
428 TInt CMMFIlbcEncoderIntfcDeMux::DoGetVadModeL(TBool& aVadModeOn)
430 TInt result = KErrNotFound;
432 if (iInterfaceIlbcEncoderIntfc)
434 result = iInterfaceIlbcEncoderIntfc->GetVadMode(aVadModeOn);
442 // ImplementationTable
444 const TImplementationProxy ImplementationTable[] =
446 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcMux, CMMFIlbcEncoderIntfcMux::NewL),
447 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux, CMMFIlbcEncoderIntfcDeMux::NewL),
451 // ImplementationGroupProxy
453 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
455 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
457 return ImplementationTable;