os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/advancedaacencodesettingsci.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <ecom/implementationproxy.h>
    17 #include <ecom/implementationproxy.h>
    18 #include <ecom/ecom.h>
    19 
    20 #include "advancedaacencodesettingsci.h"
    21 
    22 
    23 // MUX //
    24 /*****************************************************************************/
    25 
    26 TInt CMMFAdvancedAACEncodeSettingsMux::OpenInterface(TUid /*aInterfaceId*/)
    27 	{
    28 	// attempt to open the interface link with the
    29 	// remote slave device
    30 	iRemoteHandle = -1;
    31 	TUid slaveId = {KMmfUidCustomInterfaceAdvancedAACEncodeSettingsDeMux};
    32 		
    33 	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
    34 	if (handle >= 0)
    35 		{
    36 		iRemoteHandle = handle;
    37 		}
    38 		
    39 	return iRemoteHandle;
    40 	}
    41 
    42 /*****************************************************************************/
    43 void CMMFAdvancedAACEncodeSettingsMux::Release()
    44 	{
    45 	// close the slave device if it exists
    46 	if (iRemoteHandle > 0)
    47 		{
    48 		// we assume the slave is closed correctly
    49 		iUtility->CloseSlave(iRemoteHandle);
    50 		}
    51 	
    52 	TUid key = iDestructorKey;
    53 	delete this;
    54 	
    55 	// tell ECom to destroy us
    56 	REComSession::DestroyedImplementation(key);
    57 	}
    58 
    59 /*****************************************************************************/	
    60 void CMMFAdvancedAACEncodeSettingsMux::PassDestructorKey(TUid aDestructorKey)
    61 	{
    62 	// store the destructor key
    63 	iDestructorKey = aDestructorKey;
    64 	}
    65 
    66 /*****************************************************************************/
    67 void CMMFAdvancedAACEncodeSettingsMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
    68 	{
    69 	// store a pointer to the utility
    70 	iUtility = aCustomUtility;
    71 	}
    72 
    73 /*****************************************************************************/	
    74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFAdvancedAACEncodeSettingsMux::NewL()
    75 	{
    76 	CMMFAdvancedAACEncodeSettingsMux* self = new (ELeave) CMMFAdvancedAACEncodeSettingsMux;
    77 	return self;
    78 	}
    79 
    80 /*****************************************************************************/	
    81 TAny* CMMFAdvancedAACEncodeSettingsMux::CustomInterface(TUid /*aInterfaceId*/)
    82 	{
    83 	MMMFAdvancedAACEncodeSettings* interface = this;
    84 	return interface;
    85 	}
    86 	
    87 /*****************************************************************************/
    88 CMMFAdvancedAACEncodeSettingsMux::CMMFAdvancedAACEncodeSettingsMux() :
    89 	iRemoteHandle(-1)
    90 	{	
    91 	}
    92 
    93 /*****************************************************************************/
    94 CMMFAdvancedAACEncodeSettingsMux::~CMMFAdvancedAACEncodeSettingsMux()
    95 	{	
    96 	}
    97 
    98 /*****************************************************************************/
    99 // from MMMFAdvancedAACEncodeSettings
   100 TInt CMMFAdvancedAACEncodeSettingsMux::SetAACEncodeBitrateMode(TAACBitrateMode aBitrateMode)
   101 	{
   102 	TInt result = KErrNotReady;
   103 	
   104 	if (iRemoteHandle > 0)
   105 		{
   106 		// send the bitrate mode in the sync command
   107 		TPckgBuf<TAACBitrateMode> mode(aBitrateMode);
   108 		
   109 		// any return code other than zero is an error
   110 		result = iUtility->SendSlaveSyncCommand(iRemoteHandle, 
   111 												EMMFDevSoundCIAdvancedAACEncodeSettings, 
   112 												mode);
   113 		}
   114 	return result;
   115 	}
   116 
   117 TInt CMMFAdvancedAACEncodeSettingsMux::GetAACEncodeBitrateMode(TAACBitrateMode& aBitrateMode)
   118 	{
   119 	TInt result = KErrNotReady;
   120 	
   121 	if (iRemoteHandle > 0)
   122 		{
   123 		// send the bitrate mode in the sync command
   124 		TPckgBuf<TAACBitrateMode> mode;//(aBitrateMode);
   125 		
   126 		// any return code other than zero is an error
   127 		result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, 
   128 													EMMFDevSoundCIAdvancedAACEncodeGetSettings, 
   129 													KNullDesC8,
   130 													mode);
   131 		if (result == KErrNone)
   132 			{
   133 			aBitrateMode = mode();
   134 			}
   135 		}
   136 	return result;
   137 	}
   138 
   139 // DEMUX //	
   140 /*****************************************************************************/
   141 TInt CMMFAdvancedAACEncodeSettingsDeMux::OpenInterface(TUid /*aInterfaceId*/)
   142 	{
   143 	return KErrNone;
   144 	}
   145 
   146 /*****************************************************************************/	
   147 void CMMFAdvancedAACEncodeSettingsDeMux::Release()
   148 	{
   149 	TUid key = iDestructorKey;
   150 	
   151 	delete this;
   152 	
   153 	// tell ECom to destroy us
   154 	REComSession::DestroyedImplementation(key);
   155 	}
   156 	
   157 /*****************************************************************************/	
   158 void CMMFAdvancedAACEncodeSettingsDeMux::PassDestructorKey(TUid aDestructorKey)
   159 	{
   160 	// store the destructor key
   161 	iDestructorKey = aDestructorKey;
   162 	}
   163 	
   164 /*****************************************************************************/	
   165 void CMMFAdvancedAACEncodeSettingsDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
   166 	{
   167 	iTarget = aTarget;
   168 	}
   169 
   170 /*****************************************************************************/	
   171 void CMMFAdvancedAACEncodeSettingsDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
   172 	{
   173 	// store a pointer to the utility
   174 	iUtility = aCustomUtility;
   175 	}
   176 
   177 /*****************************************************************************/
   178 void CMMFAdvancedAACEncodeSettingsDeMux::RefreshL()
   179 	{
   180 	// refetch the custom interface if we already have a target
   181 	if (iTarget)
   182 		{
   183 		MMMFAdvancedAACEncodeSettings* ptr = NULL;
   184 
   185 		ptr = static_cast <MMMFAdvancedAACEncodeSettings*> (iTarget->CustomInterface(KUidAdvancedAACEncoderSettings));
   186 	
   187 		if (!ptr)
   188 			{
   189 			iInterfaceAdvAACEncodeSettings = NULL;
   190 			User::Leave(KErrNotSupported);
   191 			}
   192 		else
   193 			{
   194 			iInterfaceAdvAACEncodeSettings = ptr;
   195 			}	
   196 		}
   197 	}
   198 
   199 /*****************************************************************************/
   200 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFAdvancedAACEncodeSettingsDeMux::NewL()
   201 	{
   202 	CMMFAdvancedAACEncodeSettingsDeMux* self = new (ELeave) CMMFAdvancedAACEncodeSettingsDeMux;
   203 	return self;
   204 	}
   205 
   206 /*****************************************************************************/	
   207 CMMFAdvancedAACEncodeSettingsDeMux::CMMFAdvancedAACEncodeSettingsDeMux()
   208 	{	
   209 	}
   210 
   211 /*****************************************************************************/
   212 CMMFAdvancedAACEncodeSettingsDeMux::~CMMFAdvancedAACEncodeSettingsDeMux()
   213 	{
   214 	}
   215 
   216 /*****************************************************************************/
   217 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
   218 	{
   219 	// fetch the Hw Device custom interface
   220 	MMMFAdvancedAACEncodeSettings* ptr = NULL;
   221 
   222 	ptr = static_cast<MMMFAdvancedAACEncodeSettings*> (iTarget->CustomInterface(KUidAdvancedAACEncoderSettings)); 
   223 	
   224 	if (!ptr)
   225 		{
   226 		iInterfaceAdvAACEncodeSettings = NULL;
   227 		User::Leave(KErrNotSupported);
   228 		}
   229 	else
   230 		{
   231 		iInterfaceAdvAACEncodeSettings = ptr;
   232 		}
   233 	return KErrNone;
   234 	}
   235 	
   236 /*****************************************************************************/	
   237 void CMMFAdvancedAACEncodeSettingsDeMux::DoCloseSlaveL(TInt /*aHandle*/)
   238 	{
   239 	// nothing to do
   240 	}
   241 
   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)
   246 	{
   247 	TInt retVal = KErrNone;
   248 	
   249 	TMMFDevSoundCIMessageData data;
   250 	
   251 	// decode message
   252 	iUtility->GetSyncMessageDataL(aMessage, data);
   253 	
   254 	switch (data.iCommand)
   255 		{
   256 		case EMMFDevSoundCIAdvancedAACEncodeSettings:
   257 			{
   258 			TPckgBuf<MMMFAdvancedAACEncodeSettings::TAACBitrateMode> mode; 
   259 			iUtility->ReadFromInputDesL(aMessage, &mode);
   260 
   261 			retVal = DoSetAACEncodeBitrateMode(mode());
   262 
   263 			break;
   264 			}
   265 		default:
   266 			{
   267 			User::Leave(KErrNotSupported);
   268 			}
   269 		}
   270 	return retVal;
   271 	}
   272 	
   273 /*****************************************************************************/	
   274 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
   275 	{
   276 	TInt retVal = KErrNone;
   277 	TMMFDevSoundCIMessageData data;
   278 	
   279 	// decode message
   280 	iUtility->GetSyncMessageDataL(aMessage, data);
   281 	
   282 	switch (data.iCommand)
   283 		{
   284 		case EMMFDevSoundCIAdvancedAACEncodeGetSettings:
   285 			{
   286 			MMMFAdvancedAACEncodeSettings::TAACBitrateMode mode; 
   287 			retVal = DoGetAACEncodeBitrateMode(mode);
   288 			
   289 			if (retVal == KErrNone)
   290 				{
   291 				TPckgBuf<MMMFAdvancedAACEncodeSettings::TAACBitrateMode> pckg(mode);
   292 				iUtility->WriteToOutputDesL(aMessage, pckg);
   293 				}
   294 
   295 			break;
   296 			}
   297 		default:
   298 			{
   299 			User::Leave(KErrNotSupported);
   300 			}
   301 		}	
   302 	return retVal;
   303 	}
   304 	
   305 /*****************************************************************************/	
   306 void CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
   307 	{
   308 	// not used in this interface
   309 	}
   310 	
   311 /*****************************************************************************/	
   312 void CMMFAdvancedAACEncodeSettingsDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
   313 	{
   314 	// not used in this interface
   315 	}
   316 
   317 /*****************************************************************************/
   318 // Play Back Status custom interface implementation
   319 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoSetAACEncodeBitrateMode(MMMFAdvancedAACEncodeSettings::
   320 																	TAACBitrateMode aBitrateMode)
   321 	{
   322 	if (!iInterfaceAdvAACEncodeSettings)
   323 		{
   324 		return KErrNotReady;
   325 		}
   326 	else
   327 		{
   328 		return iInterfaceAdvAACEncodeSettings->SetAACEncodeBitrateMode(aBitrateMode);
   329 		}		
   330 	}
   331 
   332 TInt CMMFAdvancedAACEncodeSettingsDeMux::DoGetAACEncodeBitrateMode(MMMFAdvancedAACEncodeSettings::
   333 																	TAACBitrateMode& aBitrateMode)
   334 	{
   335 	if (!iInterfaceAdvAACEncodeSettings)
   336 		{
   337 		return KErrNotReady;
   338 		}
   339 	else
   340 		{
   341 		return iInterfaceAdvAACEncodeSettings->GetAACEncodeBitrateMode(aBitrateMode);
   342 		}		
   343 	}
   344 
   345 /*****************************************************************************/
   346 //
   347 // ImplementationTable
   348 //
   349 
   350 const TImplementationProxy ImplementationTable[] = 
   351 	{
   352 	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceAdvancedAACEncodeSettingsMux,	CMMFAdvancedAACEncodeSettingsMux::NewL),
   353 	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceAdvancedAACEncodeSettingsDeMux, CMMFAdvancedAACEncodeSettingsDeMux::NewL),
   354 	};
   355 
   356 /*****************************************************************************/
   357 //
   358 // ImplementationGroupProxy
   359 //
   360 //
   361 
   362 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   363 	{
   364 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   365 
   366 	return ImplementationTable;
   367 	}
   368 
   369