os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/ilbcencoderconfigci.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <ecom/implementationproxy.h>
sl@0
    17
#include <ecom/implementationproxy.h>
sl@0
    18
#include <ecom/ecom.h>
sl@0
    19
#include <s32mem.h>
sl@0
    20
sl@0
    21
#include "ilbcencoderconfigci.h"
sl@0
    22
sl@0
    23
sl@0
    24
// MUX //
sl@0
    25
sl@0
    26
TInt CMMFIlbcEncoderIntfcMux::OpenInterface(TUid /*aInterfaceId*/)
sl@0
    27
	{
sl@0
    28
	// attempt to open the interface link with the
sl@0
    29
	// remote slave device
sl@0
    30
	iRemoteHandle = -1;
sl@0
    31
	TUid slaveId = {KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux};
sl@0
    32
sl@0
    33
	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
sl@0
    34
	if (handle >= 0)
sl@0
    35
		{
sl@0
    36
		iRemoteHandle = handle;
sl@0
    37
		}
sl@0
    38
sl@0
    39
	return iRemoteHandle;
sl@0
    40
	}
sl@0
    41
sl@0
    42
sl@0
    43
void CMMFIlbcEncoderIntfcMux::Release()
sl@0
    44
	{
sl@0
    45
	// close the slave device if it exists
sl@0
    46
	if (iRemoteHandle > 0)
sl@0
    47
		{
sl@0
    48
		// we assume the slave is closed correctly
sl@0
    49
		iUtility->CloseSlave(iRemoteHandle);
sl@0
    50
		}
sl@0
    51
sl@0
    52
	TUid key = iKey;
sl@0
    53
	delete this;
sl@0
    54
sl@0
    55
	// tell ECom to destroy us
sl@0
    56
	REComSession::DestroyedImplementation(key);
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
void CMMFIlbcEncoderIntfcMux::PassDestructorKey(TUid aDestructorKey)
sl@0
    61
	{
sl@0
    62
	// store the destructor key
sl@0
    63
	iKey = aDestructorKey;
sl@0
    64
	}
sl@0
    65
sl@0
    66
sl@0
    67
void CMMFIlbcEncoderIntfcMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
sl@0
    68
	{
sl@0
    69
	// store a pointer to the utility
sl@0
    70
	iUtility = aCustomUtility;
sl@0
    71
	}
sl@0
    72
sl@0
    73
sl@0
    74
MMMFDevSoundCustomInterfaceMuxPlugin* CMMFIlbcEncoderIntfcMux::NewL()
sl@0
    75
	{
sl@0
    76
	CMMFIlbcEncoderIntfcMux* self = new (ELeave) CMMFIlbcEncoderIntfcMux;
sl@0
    77
	return self;
sl@0
    78
	}
sl@0
    79
sl@0
    80
sl@0
    81
TAny* CMMFIlbcEncoderIntfcMux::CustomInterface(TUid /*aInterfaceId*/)
sl@0
    82
	{
sl@0
    83
	MIlbcEncoderIntfc* interface = this;
sl@0
    84
	return interface;
sl@0
    85
	}
sl@0
    86
sl@0
    87
sl@0
    88
CMMFIlbcEncoderIntfcMux::CMMFIlbcEncoderIntfcMux() :
sl@0
    89
	iRemoteHandle(-1)
sl@0
    90
	{
sl@0
    91
	}
sl@0
    92
sl@0
    93
sl@0
    94
CMMFIlbcEncoderIntfcMux::~CMMFIlbcEncoderIntfcMux()
sl@0
    95
	{
sl@0
    96
	}
sl@0
    97
sl@0
    98
sl@0
    99
// from MIlbcEncoderIntfc
sl@0
   100
TInt CMMFIlbcEncoderIntfcMux::SetEncoderMode(TEncodeMode aEncodeMode)
sl@0
   101
	{
sl@0
   102
	TInt result = KErrBadHandle;
sl@0
   103
sl@0
   104
	if (iRemoteHandle > 0)
sl@0
   105
		{
sl@0
   106
		// send encodeMode in the sync command.
sl@0
   107
		TPckgBuf<TEncodeMode> encodeMode(aEncodeMode);
sl@0
   108
sl@0
   109
		// any return code other than zero is an error
sl@0
   110
		result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
sl@0
   111
												EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode,
sl@0
   112
												encodeMode);
sl@0
   113
		}
sl@0
   114
sl@0
   115
	return result;
sl@0
   116
	}
sl@0
   117
sl@0
   118
sl@0
   119
// from MIlbcEncoderIntfc
sl@0
   120
TInt CMMFIlbcEncoderIntfcMux::GetEncoderMode(TEncodeMode& aEncodeMode)
sl@0
   121
	{
sl@0
   122
	TInt result = KErrBadHandle;
sl@0
   123
sl@0
   124
	if (iRemoteHandle > 0)
sl@0
   125
		{
sl@0
   126
		// send encodeMode in the sync command.
sl@0
   127
		TPckgBuf<TEncodeMode> retEncodeMode;
sl@0
   128
sl@0
   129
		// any return code other than zero is an error
sl@0
   130
		result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
sl@0
   131
													  EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode,
sl@0
   132
													  KNullDesC8,
sl@0
   133
													  retEncodeMode);
sl@0
   134
sl@0
   135
		// assign return values to aEncodeMode. Do nothing if there is an error
sl@0
   136
		if(result == KErrNone)
sl@0
   137
			{
sl@0
   138
			aEncodeMode = retEncodeMode();
sl@0
   139
			}
sl@0
   140
		}
sl@0
   141
sl@0
   142
	return result;
sl@0
   143
	}
sl@0
   144
sl@0
   145
sl@0
   146
// from MIlbcEncoderIntfc
sl@0
   147
TInt CMMFIlbcEncoderIntfcMux::SetVadMode (TBool aVadModeOn)
sl@0
   148
	{
sl@0
   149
	TInt result = KErrBadHandle;
sl@0
   150
sl@0
   151
	if (iRemoteHandle > 0)
sl@0
   152
		{
sl@0
   153
		// send vadModeOn in the sync command.
sl@0
   154
		TPckgBuf<TBool> vadModeOn(aVadModeOn);
sl@0
   155
sl@0
   156
		// any return code other than zero is an error
sl@0
   157
		result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
sl@0
   158
												EMMFDevSoundCIIlbcEncoderIntfcSetVadMode,
sl@0
   159
												vadModeOn);
sl@0
   160
		}
sl@0
   161
sl@0
   162
	return result;
sl@0
   163
	}
sl@0
   164
sl@0
   165
sl@0
   166
// from MIlbcEncoderIntfc
sl@0
   167
TInt CMMFIlbcEncoderIntfcMux::GetVadMode (TBool& aVadModeOn)
sl@0
   168
	{
sl@0
   169
	TInt result = KErrBadHandle;
sl@0
   170
sl@0
   171
	if (iRemoteHandle > 0)
sl@0
   172
		{
sl@0
   173
		// holds the returned value.
sl@0
   174
		TPckgBuf<TBool> retVadModeOn;
sl@0
   175
sl@0
   176
		// any return code other than zero is an error
sl@0
   177
		result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
sl@0
   178
													  EMMFDevSoundCIIlbcEncoderIntfcGetVadMode,
sl@0
   179
													  KNullDesC8,
sl@0
   180
													  retVadModeOn);
sl@0
   181
sl@0
   182
		// assign return values to aVadModeOn. Do nothing if there is an error
sl@0
   183
		if(result == KErrNone)
sl@0
   184
			{
sl@0
   185
			aVadModeOn = retVadModeOn();
sl@0
   186
			}
sl@0
   187
		}
sl@0
   188
sl@0
   189
	return result;
sl@0
   190
	}
sl@0
   191
sl@0
   192
sl@0
   193
sl@0
   194
// DEMUX //	
sl@0
   195
sl@0
   196
TInt CMMFIlbcEncoderIntfcDeMux::OpenInterface(TUid /*aInterfaceId*/)
sl@0
   197
	{
sl@0
   198
	return KErrNone;
sl@0
   199
	}
sl@0
   200
sl@0
   201
sl@0
   202
void CMMFIlbcEncoderIntfcDeMux::Release()
sl@0
   203
	{
sl@0
   204
	TUid key = iKey;
sl@0
   205
sl@0
   206
	delete this;
sl@0
   207
sl@0
   208
	// tell ECom to destroy us
sl@0
   209
	REComSession::DestroyedImplementation(key);
sl@0
   210
	}
sl@0
   211
sl@0
   212
sl@0
   213
void CMMFIlbcEncoderIntfcDeMux::PassDestructorKey(TUid aDestructorKey)
sl@0
   214
	{
sl@0
   215
	// store the destructor key
sl@0
   216
	iKey = aDestructorKey;
sl@0
   217
	}
sl@0
   218
sl@0
   219
sl@0
   220
void CMMFIlbcEncoderIntfcDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
sl@0
   221
	{
sl@0
   222
	iTarget = aTarget;
sl@0
   223
	}
sl@0
   224
sl@0
   225
sl@0
   226
void CMMFIlbcEncoderIntfcDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
sl@0
   227
	{
sl@0
   228
	// store a pointer to the utility
sl@0
   229
	iUtility = aCustomUtility;
sl@0
   230
	}
sl@0
   231
sl@0
   232
sl@0
   233
void CMMFIlbcEncoderIntfcDeMux::RefreshL()
sl@0
   234
	{
sl@0
   235
	// refetch the Ilbc encoder intfc custom interface if we already have a target
sl@0
   236
	if (iTarget)
sl@0
   237
		{
sl@0
   238
		iInterfaceIlbcEncoderIntfc = static_cast <MIlbcEncoderIntfc*> (iTarget->CustomInterface(KUidIlbcEncoderIntfc));
sl@0
   239
sl@0
   240
		if (!iInterfaceIlbcEncoderIntfc)
sl@0
   241
			{
sl@0
   242
			iInterfaceIlbcEncoderIntfc = NULL;
sl@0
   243
			User::Leave(KErrNotSupported);
sl@0
   244
			}
sl@0
   245
		}
sl@0
   246
	}
sl@0
   247
sl@0
   248
sl@0
   249
MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFIlbcEncoderIntfcDeMux::NewL()
sl@0
   250
	{
sl@0
   251
	CMMFIlbcEncoderIntfcDeMux* self = new (ELeave) CMMFIlbcEncoderIntfcDeMux;
sl@0
   252
	return self;
sl@0
   253
	}
sl@0
   254
sl@0
   255
sl@0
   256
CMMFIlbcEncoderIntfcDeMux::CMMFIlbcEncoderIntfcDeMux()
sl@0
   257
	{
sl@0
   258
	}
sl@0
   259
sl@0
   260
sl@0
   261
CMMFIlbcEncoderIntfcDeMux::~CMMFIlbcEncoderIntfcDeMux()
sl@0
   262
	{
sl@0
   263
	}
sl@0
   264
sl@0
   265
sl@0
   266
TInt CMMFIlbcEncoderIntfcDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
sl@0
   267
	{
sl@0
   268
	// fetch the Ilbc encoder intfc Hw Device custom interface
sl@0
   269
	iInterfaceIlbcEncoderIntfc = static_cast<MIlbcEncoderIntfc*> (iTarget->CustomInterface(KUidIlbcEncoderIntfc)); 
sl@0
   270
sl@0
   271
	if (!iInterfaceIlbcEncoderIntfc)
sl@0
   272
		{
sl@0
   273
		iInterfaceIlbcEncoderIntfc = NULL;
sl@0
   274
		User::Leave(KErrNotSupported);
sl@0
   275
		}
sl@0
   276
sl@0
   277
	return KErrNone;
sl@0
   278
	}
sl@0
   279
sl@0
   280
sl@0
   281
void CMMFIlbcEncoderIntfcDeMux::DoCloseSlaveL(TInt /*aHandle*/)
sl@0
   282
	{
sl@0
   283
	// nothing to do
sl@0
   284
	}
sl@0
   285
sl@0
   286
sl@0
   287
// original RMessage is supplied so that remote demux plugin can extract necessary details
sl@0
   288
// using DeMux utility
sl@0
   289
TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
sl@0
   290
	{
sl@0
   291
	TMMFDevSoundCIMessageData data;
sl@0
   292
	TInt result = KErrGeneral;
sl@0
   293
sl@0
   294
	// decode message
sl@0
   295
	iUtility->GetSyncMessageDataL(aMessage, data);
sl@0
   296
sl@0
   297
	switch (data.iCommand)
sl@0
   298
		{
sl@0
   299
		case EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode:
sl@0
   300
			{
sl@0
   301
			TPckgBuf<MIlbcEncoderIntfc::TEncodeMode> encodeMode; 
sl@0
   302
			iUtility->ReadFromInputDesL(aMessage, &encodeMode);
sl@0
   303
sl@0
   304
			result = DoSetEncoderModeL(encodeMode());
sl@0
   305
sl@0
   306
			break;
sl@0
   307
			}
sl@0
   308
		case EMMFDevSoundCIIlbcEncoderIntfcSetVadMode:
sl@0
   309
			{
sl@0
   310
			TPckgBuf<TBool> vadModeOn; 
sl@0
   311
			iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
sl@0
   312
sl@0
   313
			result = DoSetVadModeL(vadModeOn());
sl@0
   314
sl@0
   315
			break;
sl@0
   316
			}
sl@0
   317
		default:
sl@0
   318
			{
sl@0
   319
			User::Leave(KErrNotSupported);
sl@0
   320
			}
sl@0
   321
		}
sl@0
   322
sl@0
   323
	return result;
sl@0
   324
	}
sl@0
   325
sl@0
   326
sl@0
   327
// original RMessage is supplied so that remote demux plugin can extract necessary details
sl@0
   328
// using DeMux utility
sl@0
   329
TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
sl@0
   330
	{
sl@0
   331
	TMMFDevSoundCIMessageData data;
sl@0
   332
	TInt result = KErrNone;
sl@0
   333
sl@0
   334
	// decode message
sl@0
   335
	iUtility->GetSyncMessageDataL(aMessage, data);
sl@0
   336
sl@0
   337
	switch (data.iCommand)
sl@0
   338
		{
sl@0
   339
		case EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode:
sl@0
   340
			{
sl@0
   341
			TPckgBuf<MIlbcEncoderIntfc::TEncodeMode> encodeMode; 
sl@0
   342
			iUtility->ReadFromInputDesL(aMessage, &encodeMode);
sl@0
   343
sl@0
   344
			result = DoGetEncoderModeL(encodeMode());
sl@0
   345
sl@0
   346
			TPckgBuf<TBool> des(encodeMode());
sl@0
   347
			iUtility->WriteToOutputDesL(aMessage, des);
sl@0
   348
sl@0
   349
			break;
sl@0
   350
			}
sl@0
   351
		case EMMFDevSoundCIIlbcEncoderIntfcGetVadMode:
sl@0
   352
			{
sl@0
   353
			TPckgBuf<TBool> vadModeOn; 
sl@0
   354
			iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
sl@0
   355
sl@0
   356
			result = DoGetVadModeL(vadModeOn());
sl@0
   357
sl@0
   358
			TPckgBuf<TBool> des(vadModeOn());
sl@0
   359
			iUtility->WriteToOutputDesL(aMessage, des);
sl@0
   360
sl@0
   361
			break;
sl@0
   362
			}
sl@0
   363
		default:
sl@0
   364
			{
sl@0
   365
			User::Leave(KErrNotSupported);
sl@0
   366
			}
sl@0
   367
		}
sl@0
   368
sl@0
   369
	return result;
sl@0
   370
	}
sl@0
   371
sl@0
   372
sl@0
   373
void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
sl@0
   374
	{
sl@0
   375
	// not used in this interface
sl@0
   376
	}
sl@0
   377
sl@0
   378
sl@0
   379
void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
sl@0
   380
	{
sl@0
   381
	// not used in this interface
sl@0
   382
	}
sl@0
   383
sl@0
   384
sl@0
   385
// Ilbc encoder intfc custom interface implementation
sl@0
   386
TInt CMMFIlbcEncoderIntfcDeMux::DoSetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode aEncodeMode)
sl@0
   387
	{
sl@0
   388
	TInt result = KErrNotFound;
sl@0
   389
sl@0
   390
	if (iInterfaceIlbcEncoderIntfc)
sl@0
   391
		{
sl@0
   392
		result = iInterfaceIlbcEncoderIntfc->SetEncoderMode(aEncodeMode);
sl@0
   393
		}
sl@0
   394
sl@0
   395
	return result;
sl@0
   396
	}
sl@0
   397
sl@0
   398
sl@0
   399
// Ilbc encoder intfc custom interface implementation
sl@0
   400
TInt CMMFIlbcEncoderIntfcDeMux::DoGetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode& aEncodeMode)
sl@0
   401
	{
sl@0
   402
	TInt result = KErrNotFound;
sl@0
   403
sl@0
   404
	if (iInterfaceIlbcEncoderIntfc)
sl@0
   405
		{
sl@0
   406
		result = iInterfaceIlbcEncoderIntfc->GetEncoderMode(aEncodeMode);
sl@0
   407
		}
sl@0
   408
sl@0
   409
	return result;
sl@0
   410
	}
sl@0
   411
sl@0
   412
sl@0
   413
// Ilbc encoder intfc custom interface implementation
sl@0
   414
TInt CMMFIlbcEncoderIntfcDeMux::DoSetVadModeL(TBool aVadModeOn)
sl@0
   415
	{
sl@0
   416
	TInt result = KErrNotFound;
sl@0
   417
sl@0
   418
	if (iInterfaceIlbcEncoderIntfc)
sl@0
   419
		{
sl@0
   420
		result = iInterfaceIlbcEncoderIntfc->SetVadMode(aVadModeOn);
sl@0
   421
		}
sl@0
   422
sl@0
   423
	return result;
sl@0
   424
	}
sl@0
   425
sl@0
   426
sl@0
   427
// Ilbc encoder intfc custom interface implementation
sl@0
   428
TInt CMMFIlbcEncoderIntfcDeMux::DoGetVadModeL(TBool& aVadModeOn)
sl@0
   429
	{
sl@0
   430
	TInt result = KErrNotFound;
sl@0
   431
sl@0
   432
	if (iInterfaceIlbcEncoderIntfc)
sl@0
   433
		{
sl@0
   434
		result = iInterfaceIlbcEncoderIntfc->GetVadMode(aVadModeOn);
sl@0
   435
		}
sl@0
   436
sl@0
   437
	return result;
sl@0
   438
	}
sl@0
   439
sl@0
   440
sl@0
   441
//
sl@0
   442
// ImplementationTable
sl@0
   443
//
sl@0
   444
const TImplementationProxy ImplementationTable[] = 
sl@0
   445
	{
sl@0
   446
	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcMux,	CMMFIlbcEncoderIntfcMux::NewL),
sl@0
   447
	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux,	CMMFIlbcEncoderIntfcDeMux::NewL),
sl@0
   448
	};
sl@0
   449
sl@0
   450
//
sl@0
   451
// ImplementationGroupProxy
sl@0
   452
//
sl@0
   453
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   454
	{
sl@0
   455
	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   456
sl@0
   457
	return ImplementationTable;
sl@0
   458
	}
sl@0
   459
sl@0
   460