os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/advancedaacencodesettingsci.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>
20 #include "advancedaacencodesettingsci.h"
24 /*****************************************************************************/
26 TInt CMMFAdvancedAACEncodeSettingsMux::OpenInterface(TUid /*aInterfaceId*/)
28 // attempt to open the interface link with the
29 // remote slave device
31 TUid slaveId = {KMmfUidCustomInterfaceAdvancedAACEncodeSettingsDeMux};
33 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
36 iRemoteHandle = handle;
42 /*****************************************************************************/
43 void CMMFAdvancedAACEncodeSettingsMux::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);
52 TUid key = iDestructorKey;
55 // tell ECom to destroy us
56 REComSession::DestroyedImplementation(key);
59 /*****************************************************************************/
60 void CMMFAdvancedAACEncodeSettingsMux::PassDestructorKey(TUid aDestructorKey)
62 // store the destructor key
63 iDestructorKey = aDestructorKey;
66 /*****************************************************************************/
67 void CMMFAdvancedAACEncodeSettingsMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
69 // store a pointer to the utility
70 iUtility = aCustomUtility;
73 /*****************************************************************************/
74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFAdvancedAACEncodeSettingsMux::NewL()
76 CMMFAdvancedAACEncodeSettingsMux* self = new (ELeave) CMMFAdvancedAACEncodeSettingsMux;
80 /*****************************************************************************/
81 TAny* CMMFAdvancedAACEncodeSettingsMux::CustomInterface(TUid /*aInterfaceId*/)
83 MMMFAdvancedAACEncodeSettings* interface = this;
87 /*****************************************************************************/
88 CMMFAdvancedAACEncodeSettingsMux::CMMFAdvancedAACEncodeSettingsMux() :
93 /*****************************************************************************/
94 CMMFAdvancedAACEncodeSettingsMux::~CMMFAdvancedAACEncodeSettingsMux()
98 /*****************************************************************************/
99 // from MMMFAdvancedAACEncodeSettings
100 TInt CMMFAdvancedAACEncodeSettingsMux::SetAACEncodeBitrateMode(TAACBitrateMode aBitrateMode)
102 TInt result = KErrNotReady;
104 if (iRemoteHandle > 0)
106 // send the bitrate mode in the sync command
107 TPckgBuf<TAACBitrateMode> mode(aBitrateMode);
109 // any return code other than zero is an error
110 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
111 EMMFDevSoundCIAdvancedAACEncodeSettings,
117 TInt CMMFAdvancedAACEncodeSettingsMux::GetAACEncodeBitrateMode(TAACBitrateMode& aBitrateMode)
119 TInt result = KErrNotReady;
121 if (iRemoteHandle > 0)
123 // send the bitrate mode in the sync command
124 TPckgBuf<TAACBitrateMode> mode;//(aBitrateMode);
126 // any return code other than zero is an error
127 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
128 EMMFDevSoundCIAdvancedAACEncodeGetSettings,
131 if (result == KErrNone)
133 aBitrateMode = mode();
140 /*****************************************************************************/
141 TInt CMMFAdvancedAACEncodeSettingsDeMux::OpenInterface(TUid /*aInterfaceId*/)
146 /*****************************************************************************/
147 void CMMFAdvancedAACEncodeSettingsDeMux::Release()
149 TUid key = iDestructorKey;
153 // tell ECom to destroy us
154 REComSession::DestroyedImplementation(key);
157 /*****************************************************************************/
158 void CMMFAdvancedAACEncodeSettingsDeMux::PassDestructorKey(TUid aDestructorKey)
160 // store the destructor key
161 iDestructorKey = aDestructorKey;
164 /*****************************************************************************/
165 void CMMFAdvancedAACEncodeSettingsDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
170 /*****************************************************************************/
171 void CMMFAdvancedAACEncodeSettingsDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
173 // store a pointer to the utility
174 iUtility = aCustomUtility;
177 /*****************************************************************************/
178 void CMMFAdvancedAACEncodeSettingsDeMux::RefreshL()
180 // refetch the custom interface if we already have a target
183 MMMFAdvancedAACEncodeSettings* ptr = NULL;
185 ptr = static_cast <MMMFAdvancedAACEncodeSettings*> (iTarget->CustomInterface(KUidAdvancedAACEncoderSettings));
189 iInterfaceAdvAACEncodeSettings = NULL;
190 User::Leave(KErrNotSupported);
194 iInterfaceAdvAACEncodeSettings = ptr;
199 /*****************************************************************************/
200 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFAdvancedAACEncodeSettingsDeMux::NewL()
202 CMMFAdvancedAACEncodeSettingsDeMux* self = new (ELeave) CMMFAdvancedAACEncodeSettingsDeMux;
206 /*****************************************************************************/
207 CMMFAdvancedAACEncodeSettingsDeMux::CMMFAdvancedAACEncodeSettingsDeMux()
211 /*****************************************************************************/
212 CMMFAdvancedAACEncodeSettingsDeMux::~CMMFAdvancedAACEncodeSettingsDeMux()
216 /*****************************************************************************/
217 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
219 // fetch the Hw Device custom interface
220 MMMFAdvancedAACEncodeSettings* ptr = NULL;
222 ptr = static_cast<MMMFAdvancedAACEncodeSettings*> (iTarget->CustomInterface(KUidAdvancedAACEncoderSettings));
226 iInterfaceAdvAACEncodeSettings = NULL;
227 User::Leave(KErrNotSupported);
231 iInterfaceAdvAACEncodeSettings = ptr;
236 /*****************************************************************************/
237 void CMMFAdvancedAACEncodeSettingsDeMux::DoCloseSlaveL(TInt /*aHandle*/)
242 /*****************************************************************************/
243 // original RMessage is supplied so that remote demux plugin can extract necessary details
244 // using DeMux utility
245 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
247 TInt retVal = KErrNone;
249 TMMFDevSoundCIMessageData data;
252 iUtility->GetSyncMessageDataL(aMessage, data);
254 switch (data.iCommand)
256 case EMMFDevSoundCIAdvancedAACEncodeSettings:
258 TPckgBuf<MMMFAdvancedAACEncodeSettings::TAACBitrateMode> mode;
259 iUtility->ReadFromInputDesL(aMessage, &mode);
261 retVal = DoSetAACEncodeBitrateMode(mode());
267 User::Leave(KErrNotSupported);
273 /*****************************************************************************/
274 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
276 TInt retVal = KErrNone;
277 TMMFDevSoundCIMessageData data;
280 iUtility->GetSyncMessageDataL(aMessage, data);
282 switch (data.iCommand)
284 case EMMFDevSoundCIAdvancedAACEncodeGetSettings:
286 MMMFAdvancedAACEncodeSettings::TAACBitrateMode mode;
287 retVal = DoGetAACEncodeBitrateMode(mode);
289 if (retVal == KErrNone)
291 TPckgBuf<MMMFAdvancedAACEncodeSettings::TAACBitrateMode> pckg(mode);
292 iUtility->WriteToOutputDesL(aMessage, pckg);
299 User::Leave(KErrNotSupported);
305 /*****************************************************************************/
306 void CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
308 // not used in this interface
311 /*****************************************************************************/
312 void CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
314 // not used in this interface
317 /*****************************************************************************/
318 // Play Back Status custom interface implementation
319 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoSetAACEncodeBitrateMode(MMMFAdvancedAACEncodeSettings::
320 TAACBitrateMode aBitrateMode)
322 if (!iInterfaceAdvAACEncodeSettings)
328 return iInterfaceAdvAACEncodeSettings->SetAACEncodeBitrateMode(aBitrateMode);
332 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoGetAACEncodeBitrateMode(MMMFAdvancedAACEncodeSettings::
333 TAACBitrateMode& aBitrateMode)
335 if (!iInterfaceAdvAACEncodeSettings)
341 return iInterfaceAdvAACEncodeSettings->GetAACEncodeBitrateMode(aBitrateMode);
345 /*****************************************************************************/
347 // ImplementationTable
350 const TImplementationProxy ImplementationTable[] =
352 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceAdvancedAACEncodeSettingsMux, CMMFAdvancedAACEncodeSettingsMux::NewL),
353 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceAdvancedAACEncodeSettingsDeMux, CMMFAdvancedAACEncodeSettingsDeMux::NewL),
356 /*****************************************************************************/
358 // ImplementationGroupProxy
362 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
364 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
366 return ImplementationTable;