os/mm/mmlibs/mmfw/src/ControllerFramework/mmfcontrollerclient.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-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 "mmfcontroller.h"
sl@0
    17
#include "mmfcontrollerpluginresolver.h"
sl@0
    18
sl@0
    19
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    20
#include <mmf/common/mmfcontrollerextendeddata.h>
sl@0
    21
#include <mmf/common/mmfcustomcommandparsermanager.h>
sl@0
    22
#endif
sl@0
    23
sl@0
    24
/**
sl@0
    25
Constructor.
sl@0
    26
sl@0
    27
@since 7.0s
sl@0
    28
*/
sl@0
    29
EXPORT_C RMMFController::RMMFController() :
sl@0
    30
	iDestinationPckg(TMMFMessageDestination(KUidInterfaceMMFController, KMMFObjectHandleController))
sl@0
    31
	{
sl@0
    32
	}
sl@0
    33
sl@0
    34
/**
sl@0
    35
Loads a controller plugin by specifying the UID of the plugin to load.
sl@0
    36
sl@0
    37
Creates a new thread and loads the specified controller into the new thread.  Use the classes
sl@0
    38
CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters
sl@0
    39
to find the uid of the controller to load.
sl@0
    40
sl@0
    41
@param  aControllerUid
sl@0
    42
        The UID of the controller plugin to be loaded.
sl@0
    43
@param  aPrioritySettings
sl@0
    44
        The priority settings for this plugin, used by the policy
sl@0
    45
        component to arbitrate between different controllers that are
sl@0
    46
        attempting to use the same hardware resource simultaneously.
sl@0
    47
@param	aUseSharedHeap
sl@0
    48
		If this value is EFalse each controller is created with its own heap. The alternative,
sl@0
    49
		if the value is ETrue, is that controllers share a special heap with other controllers
sl@0
    50
		created the same way. Each heap uses a chunk, so this avoids situations where the
sl@0
    51
		number of chunks per process is limited. The default behaviour is generally to be
sl@0
    52
		preferred, and should give lower overall memory usage. However, if many controllers are
sl@0
    53
		to be created for a particular thread, then ETrue should be provided to prevent running
sl@0
    54
		out of heaps or chunks.
sl@0
    55
sl@0
    56
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
    57
        another of the system-wide error codes.
sl@0
    58
sl@0
    59
@see    CMMFControllerPluginSelectionParamters
sl@0
    60
@since  7.0s
sl@0
    61
sl@0
    62
*/
sl@0
    63
EXPORT_C TInt RMMFController::Open(TUid aControllerUid, const TMMFPrioritySettings& aPrioritySettings, TBool aUseSharedHeap)
sl@0
    64
	{
sl@0
    65
	// Load Controller
sl@0
    66
	TInt err = iControllerProxy.LoadController(aControllerUid, aUseSharedHeap);
sl@0
    67
	if (!err)
sl@0
    68
		{
sl@0
    69
		err = SetPrioritySettings(aPrioritySettings);
sl@0
    70
		}
sl@0
    71
	return err;
sl@0
    72
	}
sl@0
    73
sl@0
    74
/**
sl@0
    75
Loads a controller plugin by specifying a CMMFControllerImplementationInformation object.
sl@0
    76
sl@0
    77
CMMFControllerImplementationInformation is passed as a parameter to allow
sl@0
    78
the controller thread's heap size to be determined without a further query to ECOM.
sl@0
    79
sl@0
    80
The function creates a new thread and loads the specified controller into the new thread.  The classes
sl@0
    81
CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters are used
sl@0
    82
to find the UID of the controller to load.
sl@0
    83
sl@0
    84
@param  aControllerInfo
sl@0
    85
        A reference to a CMMFControllerImplementationInformation object
sl@0
    86
        used for determining the controller's UID & heap size
sl@0
    87
@param  aPrioritySettings
sl@0
    88
        The priority settings for this plugin, used by the policy
sl@0
    89
        component to arbitrate between different controllers that are
sl@0
    90
        attempting to use the same hardware resource simultaneously.
sl@0
    91
@param	aUseSharedHeap
sl@0
    92
		If this value is EFalse each controller is created with its own heap. The alternative,
sl@0
    93
		if the value is ETrue, is that controllers share a special heap with other controllers
sl@0
    94
		created the same way. Each heap uses a chunk, so this avoids situations where the
sl@0
    95
		number of chunks per process is limited. The default behaviour is generally to be
sl@0
    96
		preferred, and should give lower overall memory usage. However, if many controllers are
sl@0
    97
		to be created for a particular thread, then ETrue should be provided to prevent running
sl@0
    98
		out of heaps or chunks.
sl@0
    99
sl@0
   100
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   101
        another of the system-wide error codes.
sl@0
   102
sl@0
   103
@see CMMFControllerPluginSelectionParamters
sl@0
   104
@since 7.0s
sl@0
   105
sl@0
   106
*/
sl@0
   107
EXPORT_C TInt RMMFController::Open(
sl@0
   108
	const CMMFControllerImplementationInformation& aControllerInfo,
sl@0
   109
	const TMMFPrioritySettings& aPrioritySettings,
sl@0
   110
	TBool aUseSharedHeap)
sl@0
   111
	{
sl@0
   112
	// Load Controller
sl@0
   113
	TInt err = iControllerProxy.LoadController(aControllerInfo, aUseSharedHeap);
sl@0
   114
	if (!err)
sl@0
   115
		err = SetPrioritySettings(aPrioritySettings);
sl@0
   116
	return err;
sl@0
   117
	}
sl@0
   118
sl@0
   119
/**
sl@0
   120
Loads a controller plugin by specifying the UID of the plugin to load.
sl@0
   121
sl@0
   122
Creates a new thread and loads the specified controller into the new thread.  Use the classes
sl@0
   123
CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters
sl@0
   124
to find the uid of the controller to load.
sl@0
   125
This version of Open() will give each controller its own heap which will consume one chunk. Use the
sl@0
   126
overloaded version of Open() to create controllers that share a single heap.
sl@0
   127
sl@0
   128
@param  aControllerUid
sl@0
   129
        The UID of the controller plugin to be loaded.
sl@0
   130
@param  aPrioritySettings
sl@0
   131
        The priority settings for this plugin, used by the policy
sl@0
   132
        component to arbitrate between different controllers that are
sl@0
   133
        attempting to use the same hardware resource simultaneously.
sl@0
   134
sl@0
   135
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   136
        another of the system-wide error codes.
sl@0
   137
sl@0
   138
@see    CMMFControllerPluginSelectionParamters
sl@0
   139
@since  7.0s
sl@0
   140
sl@0
   141
*/
sl@0
   142
EXPORT_C TInt RMMFController::Open(TUid aControllerUid, const TMMFPrioritySettings& aPrioritySettings)
sl@0
   143
	{
sl@0
   144
	// Load Controller
sl@0
   145
	return Open( aControllerUid, aPrioritySettings, EFalse ); // give controllers their own heaps
sl@0
   146
	}
sl@0
   147
sl@0
   148
/**
sl@0
   149
Loads a controller plugin by specifying a CMMFControllerImplementationInformation object.
sl@0
   150
sl@0
   151
CMMFControllerImplementationInformation is passed as a parameter to allow
sl@0
   152
the controller thread's heap size to be determined without a further query to ECOM.
sl@0
   153
sl@0
   154
The function creates a new thread and loads the specified controller into the new thread.  The classes
sl@0
   155
CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters are used
sl@0
   156
to find the UID of the controller to load.
sl@0
   157
This version of Open() will give each controller its own heap which will consume one chunk. Use the
sl@0
   158
overloaded version of Open() to create controllers that share a single heap.
sl@0
   159
sl@0
   160
@param  aControllerInfo
sl@0
   161
        A reference to a CMMFControllerImplementationInformation object
sl@0
   162
        used for determining the controller's UID & heap size
sl@0
   163
@param  aPrioritySettings
sl@0
   164
        The priority settings for this plugin, used by the policy
sl@0
   165
        component to arbitrate between different controllers that are
sl@0
   166
        attempting to use the same hardware resource simultaneously.
sl@0
   167
sl@0
   168
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   169
        another of the system-wide error codes.
sl@0
   170
sl@0
   171
@see CMMFControllerPluginSelectionParamters
sl@0
   172
@since 7.0s
sl@0
   173
sl@0
   174
*/
sl@0
   175
EXPORT_C TInt RMMFController::Open(
sl@0
   176
		const CMMFControllerImplementationInformation& aControllerInfo,
sl@0
   177
		const TMMFPrioritySettings& aPrioritySettings)
sl@0
   178
	{
sl@0
   179
		// Load Controller
sl@0
   180
		return Open( aControllerInfo, aPrioritySettings, EFalse ); // give controllers their own heaps
sl@0
   181
	}
sl@0
   182
sl@0
   183
/**
sl@0
   184
Same as RMMFController::Open(TUid, const TMMFPrioritySettings&) which loads a controller plugin by 
sl@0
   185
specifying the UID of the plugin to load, except that this is expected to be called by user thread 
sl@0
   186
without DRM Capability.
sl@0
   187
sl@0
   188
Creates a new thread through DRM Plugin Server and loads the specified controller into the new thread.  
sl@0
   189
Use the classes CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters
sl@0
   190
to find the uid of the controller to load.
sl@0
   191
This version of Open() will give each controller its own heap which will consume one chunk. Use the
sl@0
   192
overloaded version of Open() to create controllers that share a single heap.
sl@0
   193
sl@0
   194
@param  aControllerUid
sl@0
   195
        The UID of the controller plugin to be loaded.
sl@0
   196
@param  aPrioritySettings
sl@0
   197
        The priority settings for this plugin, used by the policy
sl@0
   198
        component to arbitrate between different controllers that are
sl@0
   199
        attempting to use the same hardware resource simultaneously.
sl@0
   200
sl@0
   201
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   202
        another of the system-wide error codes.
sl@0
   203
sl@0
   204
@see    CMMFControllerPluginSelectionParamters
sl@0
   205
sl@0
   206
*/
sl@0
   207
EXPORT_C TInt RMMFController::OpenInSecureDRMProcess(TUid aControllerUid, const TMMFPrioritySettings& aPrioritySettings)
sl@0
   208
	{
sl@0
   209
	return OpenInSecureDRMProcess(aControllerUid, aPrioritySettings, EFalse);
sl@0
   210
	}
sl@0
   211
sl@0
   212
/**
sl@0
   213
Same as Open(const CMMFControllerImplementationInformation&, const TMMFPrioritySettings&) which loads a 
sl@0
   214
controller plugin by specifying a CMMFControllerImplementationInformation object.
sl@0
   215
sl@0
   216
CMMFControllerImplementationInformation is passed as a parameter to allow
sl@0
   217
the controller thread's heap size to be determined without a further query to ECOM.
sl@0
   218
sl@0
   219
The function creates a new thread through DRM Plugin server and loads the specified controller into 
sl@0
   220
the new thread.  The classes CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters are used
sl@0
   221
to find the UID of the controller to load.
sl@0
   222
This version of Open() will give each controller its own heap which will consume one chunk. Use the
sl@0
   223
overloaded version of Open() to create controllers that share a single heap.
sl@0
   224
sl@0
   225
@param  aControllerInfo
sl@0
   226
        A reference to a CMMFControllerImplementationInformation object
sl@0
   227
        used for determining the controller's UID & heap size
sl@0
   228
@param  aPrioritySettings
sl@0
   229
        The priority settings for this plugin, used by the policy
sl@0
   230
        component to arbitrate between different controllers that are
sl@0
   231
        attempting to use the same hardware resource simultaneously.
sl@0
   232
sl@0
   233
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   234
        another of the system-wide error codes.
sl@0
   235
sl@0
   236
@see CMMFControllerPluginSelectionParamters
sl@0
   237
sl@0
   238
*/	
sl@0
   239
EXPORT_C TInt RMMFController::OpenInSecureDRMProcess(const CMMFControllerImplementationInformation& aControllerInfo, const TMMFPrioritySettings& aPrioritySettings)
sl@0
   240
	{
sl@0
   241
	return OpenInSecureDRMProcess(aControllerInfo, aPrioritySettings, EFalse);
sl@0
   242
	}
sl@0
   243
sl@0
   244
/**
sl@0
   245
Same as RMMFController::Open(TUid, const TMMFPrioritySettings&, TBool) which loads a controller 
sl@0
   246
plugin by specifying the UID of the plugin to load, except that this is expected to be called by user thread 
sl@0
   247
without DRM Capability.
sl@0
   248
sl@0
   249
Creates a new thread through DRM Plugin server and loads the specified controller into the new thread.  
sl@0
   250
Use the classes CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters
sl@0
   251
to find the uid of the controller to load.
sl@0
   252
sl@0
   253
@param  aControllerUid
sl@0
   254
        The UID of the controller plugin to be loaded.
sl@0
   255
@param  aPrioritySettings
sl@0
   256
        The priority settings for this plugin, used by the policy
sl@0
   257
        component to arbitrate between different controllers that are
sl@0
   258
        attempting to use the same hardware resource simultaneously.
sl@0
   259
@param	aUseSharedHeap
sl@0
   260
		If this value is EFalse each controller is created with its own heap. The alternative,
sl@0
   261
		if the value is ETrue, is that controllers share a special heap with other controllers
sl@0
   262
		created the same way. Each heap uses a chunk, so this avoids situations where the
sl@0
   263
		number of chunks per process is limited. The default behaviour is generally to be
sl@0
   264
		preferred, and should give lower overall memory usage. However, if many controllers are
sl@0
   265
		to be created for a particular thread, then ETrue should be provided to prevent running
sl@0
   266
		out of heaps or chunks.
sl@0
   267
sl@0
   268
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   269
        another of the system-wide error codes.
sl@0
   270
sl@0
   271
@see    CMMFControllerPluginSelectionParamters
sl@0
   272
sl@0
   273
*/
sl@0
   274
EXPORT_C TInt RMMFController::OpenInSecureDRMProcess(TUid aControllerUid, const TMMFPrioritySettings& aPrioritySettings, TBool aUseSharedHeap )
sl@0
   275
	{
sl@0
   276
	// Load Controller
sl@0
   277
	TInt err = iControllerProxy.LoadControllerInSecureDRMProcess(aControllerUid, aUseSharedHeap);
sl@0
   278
	if (!err)
sl@0
   279
		{
sl@0
   280
		err = SetPrioritySettings(aPrioritySettings);
sl@0
   281
		}
sl@0
   282
	return err;
sl@0
   283
	}
sl@0
   284
sl@0
   285
/**
sl@0
   286
Same as Open(const CMMFControllerImplementationInformation&, const TMMFPrioritySettings&, TBool) which 
sl@0
   287
loads a controller plugin by specifying a CMMFControllerImplementationInformation object.
sl@0
   288
sl@0
   289
CMMFControllerImplementationInformation is passed as a parameter to allow
sl@0
   290
the controller thread's heap size to be determined without a further query to ECOM.
sl@0
   291
sl@0
   292
The function creates a new thread through DRM Plugin Server and loads the specified controller into 
sl@0
   293
the new thread.  The classes CMMFControllerPluginSelectionParameters and CMMFFormatSelectionParamters are used
sl@0
   294
to find the UID of the controller to load.
sl@0
   295
sl@0
   296
@param  aControllerInfo
sl@0
   297
        A reference to a CMMFControllerImplementationInformation object
sl@0
   298
        used for determining the controller's UID & heap size
sl@0
   299
@param  aPrioritySettings
sl@0
   300
        The priority settings for this plugin, used by the policy
sl@0
   301
        component to arbitrate between different controllers that are
sl@0
   302
        attempting to use the same hardware resource simultaneously.
sl@0
   303
@param	aUseSharedHeap
sl@0
   304
		If this value is EFalse each controller is created with its own heap. The alternative,
sl@0
   305
		if the value is ETrue, is that controllers share a special heap with other controllers
sl@0
   306
		created the same way. Each heap uses a chunk, so this avoids situations where the
sl@0
   307
		number of chunks per process is limited. The default behaviour is generally to be
sl@0
   308
		preferred, and should give lower overall memory usage. However, if many controllers are
sl@0
   309
		to be created for a particular thread, then ETrue should be provided to prevent running
sl@0
   310
		out of heaps or chunks.
sl@0
   311
sl@0
   312
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   313
        another of the system-wide error codes.
sl@0
   314
sl@0
   315
@see CMMFControllerPluginSelectionParamters
sl@0
   316
sl@0
   317
*/
sl@0
   318
EXPORT_C TInt RMMFController::OpenInSecureDRMProcess(const CMMFControllerImplementationInformation& aControllerInfo, const TMMFPrioritySettings& aPrioritySettings, TBool aUseSharedHeap )
sl@0
   319
	{
sl@0
   320
	// Load Controller
sl@0
   321
	TInt err = iControllerProxy.LoadControllerInSecureDRMProcess(aControllerInfo, aUseSharedHeap);
sl@0
   322
	if (!err)
sl@0
   323
		err = SetPrioritySettings(aPrioritySettings);
sl@0
   324
	return err;
sl@0
   325
	
sl@0
   326
	}
sl@0
   327
	
sl@0
   328
/**
sl@0
   329
Closes the controller plugin.
sl@0
   330
sl@0
   331
Calling this method will unload the controller plugin and close down the controller thread.
sl@0
   332
sl@0
   333
@since	7.0s
sl@0
   334
*/
sl@0
   335
EXPORT_C void RMMFController::Close()
sl@0
   336
	{
sl@0
   337
	iControllerProxy.Close();
sl@0
   338
	}
sl@0
   339
sl@0
   340
/**
sl@0
   341
Sets the priority settings for this controller.
sl@0
   342
sl@0
   343
@param  aPrioritySettings
sl@0
   344
        The priority settings for this plugin, used by the policy
sl@0
   345
        component to arbitrate between different controllers that are
sl@0
   346
        attempting to use the same hardware resource simultaneously.
sl@0
   347
sl@0
   348
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   349
        another of the system-wide error codes.
sl@0
   350
@since	7.0s
sl@0
   351
sl@0
   352
*/
sl@0
   353
EXPORT_C TInt RMMFController::SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings) const
sl@0
   354
	{
sl@0
   355
	TMMFPrioritySettingsPckg pckg(aPrioritySettings);
sl@0
   356
	return iControllerProxy.SendSync(iDestinationPckg, 
sl@0
   357
									 EMMFControllerSetPrioritySettings, 
sl@0
   358
									 pckg, 
sl@0
   359
									 KNullDesC8);
sl@0
   360
	}
sl@0
   361
sl@0
   362
/**
sl@0
   363
Adds a data source to the controller.
sl@0
   364
sl@0
   365
A typical data source would be a file, descriptor, audio input (microphone) or camera.
sl@0
   366
A controller plugin may require multiple data sources to be added (for example a video
sl@0
   367
recorder controller would require two); the exact number is plugin-specific.
sl@0
   368
Data sources are plugins themselves, and are loaded by the controller framework
sl@0
   369
inside the controller thread.
sl@0
   370
sl@0
   371
@param  aSourceUid
sl@0
   372
        The uid of the data source to be added. For more information,
sl@0
   373
        see the documentation for the data source you wish to add.
sl@0
   374
@param  aSourceInitData
sl@0
   375
        The data used to initialise the data source.  The exact contents
sl@0
   376
        of this data are dependent on the type of data source. For more
sl@0
   377
        information, see the documentation for the data source you wish
sl@0
   378
        to add.
sl@0
   379
sl@0
   380
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   381
        another of the system-wide error codes.
sl@0
   382
@since	7.0s
sl@0
   383
*/
sl@0
   384
EXPORT_C TInt RMMFController::AddDataSource(TUid aSourceUid, const TDesC8& aSourceInitData)
sl@0
   385
	{
sl@0
   386
	TMMFMessageDestination handleInfo;
sl@0
   387
	return AddDataSource(aSourceUid, aSourceInitData, handleInfo);
sl@0
   388
	}
sl@0
   389
sl@0
   390
/**
sl@0
   391
Adds a data sink to the controller.
sl@0
   392
sl@0
   393
A typical data sink would be a file, descriptor, audio output (speaker) or display.
sl@0
   394
A controller plugin may require multiple data sinks to be added (for example a video
sl@0
   395
playing controller would require two); the exact number is plugin-specific.
sl@0
   396
Data sinks are plugins themselves, and are loaded by the controller framework
sl@0
   397
inside the controller thread.
sl@0
   398
sl@0
   399
@param  aSinkUid
sl@0
   400
        The UID of the data sink to be added. For more information,
sl@0
   401
        see the documentation for the data sink you wish to add.
sl@0
   402
@param  aSinkInitData
sl@0
   403
        The data used to initialise the data sink.  The exact contents
sl@0
   404
        of this data are dependent on the type of data sink. For more
sl@0
   405
        information, see the documentation for the data sink you wish
sl@0
   406
        to add.
sl@0
   407
sl@0
   408
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   409
        another of the system-wide error codes.
sl@0
   410
@since  7.0s
sl@0
   411
*/
sl@0
   412
EXPORT_C TInt RMMFController::AddDataSink(TUid aSinkUid, const TDesC8& aSinkInitData)
sl@0
   413
	{
sl@0
   414
	TMMFMessageDestination handleInfo;
sl@0
   415
	return AddDataSink(aSinkUid, aSinkInitData, handleInfo);
sl@0
   416
	}
sl@0
   417
sl@0
   418
/**
sl@0
   419
Adds a data source to the controller, and receive a handle to allow removal and direct
sl@0
   420
communication with that data source.
sl@0
   421
sl@0
   422
A typical data source would be a file, descriptor, audio input (microphone) or camera.
sl@0
   423
A controller plugin may require multiple data sources to be added (for example a video
sl@0
   424
recorder controller would require two); the exact number is plugin-specific.
sl@0
   425
Data sources are plugins themselves, and are loaded by the controller framework
sl@0
   426
inside the controller thread.
sl@0
   427
sl@0
   428
@param  aSourceUid
sl@0
   429
        The uid of the data source to be added. For more information,
sl@0
   430
        see the documentation for the data source you wish to add.
sl@0
   431
@param  aSourceInitData
sl@0
   432
        Data used to initialise the data source.  The exact contents
sl@0
   433
        of this data is dependent on the type of data source. For more
sl@0
   434
        information, see the documentation for the data source you wish
sl@0
   435
        to add.
sl@0
   436
@param  aHandleInfo
sl@0
   437
        This object is filled in by the controller framework, and identifies
sl@0
   438
        the data source inside the controller framework.  This allows
sl@0
   439
        the caller to send custom commands directly to the data source, and
sl@0
   440
        to also remove the data source from the controller.  Note that
sl@0
   441
        not all data sources support custom commands, and not all
sl@0
   442
        controller plugins support the removal of a data source.
sl@0
   443
sl@0
   444
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   445
        another of the system-wide error codes.
sl@0
   446
@since  7.0s
sl@0
   447
*/
sl@0
   448
EXPORT_C TInt RMMFController::AddDataSource(TUid aSourceUid, const TDesC8& aSourceInitData,
sl@0
   449
											TMMFMessageDestination& aHandleInfo)
sl@0
   450
	{
sl@0
   451
	TMMFMessageDestinationPckg pckg;
sl@0
   452
	TMMFUidPckg uidPckg(aSourceUid);
sl@0
   453
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   454
										   EMMFControllerAddDataSource,
sl@0
   455
										   uidPckg,
sl@0
   456
										   aSourceInitData,
sl@0
   457
										   pckg);
sl@0
   458
	if (!error)
sl@0
   459
		{
sl@0
   460
		aHandleInfo = pckg();
sl@0
   461
		}
sl@0
   462
	return error;
sl@0
   463
	}
sl@0
   464
sl@0
   465
/**
sl@0
   466
Add a file handle data source, together with its source info, to the controller asynchronously, 
sl@0
   467
and receive a handle to allow removal and directcommunication with that data source.
sl@0
   468
sl@0
   469
Note: only one call to this method can be outstanding at any time.
sl@0
   470
sl@0
   471
The data source would be a file for this API.
sl@0
   472
A controller plugin may require multiple data sources to be added (for example a video
sl@0
   473
recorder controller would require two); the exact number is plugin-specific.
sl@0
   474
Data sources are plugins themselves, and are loaded by the controller framework
sl@0
   475
inside the controller thread.
sl@0
   476
sl@0
   477
@param "aFile"				"The shared session file handle source to be added."
sl@0
   478
@param "aSourceInitData"	"Data used to initialise the data source.  The reference must remain valid 
sl@0
   479
							until the command has been completed or cancelled. The exact contents
sl@0
   480
							of this data is dependent on the type of data source. For more
sl@0
   481
							information, see the documentation for the data source you wish
sl@0
   482
							to add."
sl@0
   483
@param "aHandleInfoPckg"	"This object is filled in by the controller framework, and identifies
sl@0
   484
							the data source inside the controller framework.  This allows
sl@0
   485
							the caller to send custom commands directly to the data source, and
sl@0
   486
							to also remove the data source from the controller.  Note that
sl@0
   487
							not all data sources support custom commands, and not all
sl@0
   488
							controller plugins support the removal of a data source."
sl@0
   489
@param "aStatus"			"TRequestStatus of the active object to be signalled on completion
sl@0
   490
							of this request."
sl@0
   491
sl@0
   492
@return An error code indicating if the function call was successful. 
sl@0
   493
		KErrBadHandle if the file handle is not shared through the call RFs::ShareProtected().
sl@0
   494
		KErrNone on success, otherwise another of the system-wide error codes.
sl@0
   495
*/
sl@0
   496
EXPORT_C void RMMFController::AddFileHandleDataSource(const RFile& aFile, const TDesC8& aSourceInitData, 
sl@0
   497
													  TMMFMessageDestinationPckg& aHandleInfoPckg, 
sl@0
   498
													  TRequestStatus& aStatus)
sl@0
   499
	{
sl@0
   500
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   501
										   EMMFControllerSourceSinkInitDataPreload,
sl@0
   502
										   aSourceInitData,
sl@0
   503
										   KNullDesC8);
sl@0
   504
	TIpcArgs ipcArgs(&iDestinationPckg, NULL, NULL, &aHandleInfoPckg);
sl@0
   505
	if (error == KErrNone)
sl@0
   506
		{
sl@0
   507
		error = aFile.TransferToServer(ipcArgs, 1, 2);
sl@0
   508
		}
sl@0
   509
		
sl@0
   510
	if (error == KErrNone)
sl@0
   511
		{
sl@0
   512
		iControllerProxy.SendAsync(EMMFControllerAddFileHandleDataSourceWithInitData,
sl@0
   513
								   ipcArgs,
sl@0
   514
								   aStatus);
sl@0
   515
		}
sl@0
   516
	else
sl@0
   517
		{
sl@0
   518
		TRequestStatus* status = &aStatus;
sl@0
   519
		User::RequestComplete(status, error);
sl@0
   520
		}
sl@0
   521
	}
sl@0
   522
	
sl@0
   523
/**
sl@0
   524
Add a file handle data source to the controller asynchronously, and receive a handle to allow 
sl@0
   525
removal and directcommunication with that data source.
sl@0
   526
sl@0
   527
Note: only one call to this method can be outstanding at any time.
sl@0
   528
sl@0
   529
The data source would be a file for this API.
sl@0
   530
A controller plugin may require multiple data sources to be added (for example a video
sl@0
   531
recorder controller would require two); the exact number is plugin-specific.
sl@0
   532
Data sources are plugins themselves, and are loaded by the controller framework
sl@0
   533
inside the controller thread.
sl@0
   534
sl@0
   535
@param "aFile"				"The shared session file handle source to be added."
sl@0
   536
@param "aHandleInfoPckg"	"This object is filled in by the controller framework, and identifies
sl@0
   537
							the data source inside the controller framework.  This allows
sl@0
   538
							the caller to send custom commands directly to the data source, and
sl@0
   539
							to also remove the data source from the controller.  Note that
sl@0
   540
							not all data sources support custom commands, and not all
sl@0
   541
							controller plugins support the removal of a data source."
sl@0
   542
@param "aStatus"			"TRequestStatus of the active object to be signalled on completion
sl@0
   543
							of this request."
sl@0
   544
sl@0
   545
@return An error code indicating if the function call was successful. 
sl@0
   546
		KErrBadHandle if the file handle is not shared through the call RFs::ShareProtected().
sl@0
   547
		KErrNone on success, otherwise another of the system-wide error codes.
sl@0
   548
*/
sl@0
   549
EXPORT_C void RMMFController::AddFileHandleDataSource(const RFile& aFile,
sl@0
   550
											TMMFMessageDestinationPckg& aHandleInfo, TRequestStatus& aStatus)
sl@0
   551
	{
sl@0
   552
	TIpcArgs ipcArgs(&iDestinationPckg, NULL, NULL, &aHandleInfo);
sl@0
   553
	TInt error = aFile.TransferToServer(ipcArgs, 1, 2);
sl@0
   554
	
sl@0
   555
	if (!error)
sl@0
   556
		{
sl@0
   557
		iControllerProxy.SendAsync(EMMFControllerAddFileHandleDataSource,
sl@0
   558
											   ipcArgs,
sl@0
   559
											   aStatus);		
sl@0
   560
		}
sl@0
   561
	else
sl@0
   562
		{
sl@0
   563
		TRequestStatus* status = &aStatus;
sl@0
   564
		User::RequestComplete(status, error);
sl@0
   565
		}
sl@0
   566
sl@0
   567
	}
sl@0
   568
sl@0
   569
/**
sl@0
   570
Adds a file handle data sink, together with its source info, to the controller, and receives 
sl@0
   571
a handle to allow removal and direct communication with that data sink.
sl@0
   572
sl@0
   573
Note: only one call to this method can be outstanding at any time.
sl@0
   574
sl@0
   575
The data sink would be a file for this API.
sl@0
   576
A controller plugin may require multiple data sinks to be added (for example a video
sl@0
   577
playing controller would require two); the exact number is plugin-specific.
sl@0
   578
Data sinks are plugins themselves, and are loaded by the controller framework
sl@0
   579
inside the controller thread.
sl@0
   580
sl@0
   581
@param  aFile
sl@0
   582
        The shared session file handle sink to be added.
sl@0
   583
@param  aSinkInitData
sl@0
   584
        Data used to initialise the data sink.  The exact contents
sl@0
   585
        of this data are dependent on the type of data sink. For more
sl@0
   586
        information, see the documentation for the data sink you wish
sl@0
   587
        to add.
sl@0
   588
@param  aHandleInfo
sl@0
   589
        This object is filled in by the controller framework, and identifies
sl@0
   590
        the data sink inside the controller framework.  This allows
sl@0
   591
        the caller to send custom commands directly to the data sink, and
sl@0
   592
        to also remove the data sink from the controller.  Note that
sl@0
   593
        not all data sinks support custom commands, and not all
sl@0
   594
        controller plugins support the removal of a data sink.
sl@0
   595
@param 	aStatus
sl@0
   596
		TRequestStatus of the active object to be signalled on completion
sl@0
   597
		of this request.
sl@0
   598
sl@0
   599
@return An error code indicating if the function call was successful. 
sl@0
   600
		KErrBadHandle if the file handle is not shared through the call RFs::ShareProtected().
sl@0
   601
		KErrNone on success, otherwise another of the system-wide error codes.
sl@0
   602
*/
sl@0
   603
EXPORT_C void RMMFController::AddFileHandleDataSink(const RFile& aFile, const TDesC8& aSinkInitData, 
sl@0
   604
													TMMFMessageDestinationPckg& aHandleInfoPckg, 
sl@0
   605
													TRequestStatus& aStatus)
sl@0
   606
	{
sl@0
   607
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   608
										   EMMFControllerSourceSinkInitDataPreload,
sl@0
   609
										   aSinkInitData,
sl@0
   610
										   KNullDesC8);
sl@0
   611
	TIpcArgs ipcArgs(&iDestinationPckg, NULL, NULL, &aHandleInfoPckg);
sl@0
   612
	if (!error)
sl@0
   613
		{
sl@0
   614
		error = aFile.TransferToServer(ipcArgs, 1, 2);
sl@0
   615
		}
sl@0
   616
 	
sl@0
   617
	if (!error)
sl@0
   618
		{
sl@0
   619
		iControllerProxy.SendAsync(EMMFControllerAddFileHandleDataSinkWithInitData,
sl@0
   620
								   ipcArgs,
sl@0
   621
								   aStatus);
sl@0
   622
		}
sl@0
   623
	else
sl@0
   624
		{
sl@0
   625
		TRequestStatus* status = &aStatus;
sl@0
   626
		User::RequestComplete(status, error);
sl@0
   627
		}
sl@0
   628
	}
sl@0
   629
sl@0
   630
/**
sl@0
   631
Adds a file handle data sink, together with its source info, to the controller, and receives 
sl@0
   632
a handle to allow removal and direct communication with that data sink.
sl@0
   633
sl@0
   634
Note: only one call to this method can be outstanding at any time.
sl@0
   635
sl@0
   636
The data sink would be a file for this API.
sl@0
   637
A controller plugin may require multiple data sinks to be added (for example a video
sl@0
   638
playing controller would require two); the exact number is plugin-specific.
sl@0
   639
Data sinks are plugins themselves, and are loaded by the controller framework
sl@0
   640
inside the controller thread.
sl@0
   641
sl@0
   642
@param  aFile
sl@0
   643
        The shared session file handle sink to be added.
sl@0
   644
@param  aHandleInfo
sl@0
   645
        This object is filled in by the controller framework, and identifies
sl@0
   646
        the data sink inside the controller framework.  This allows
sl@0
   647
        the caller to send custom commands directly to the data sink, and
sl@0
   648
        to also remove the data sink from the controller.  Note that
sl@0
   649
        not all data sinks support custom commands, and not all
sl@0
   650
        controller plugins support the removal of a data sink.
sl@0
   651
@param 	aStatus
sl@0
   652
		TRequestStatus of the active object to be signalled on completion
sl@0
   653
		of this request.
sl@0
   654
sl@0
   655
@return An error code indicating if the function call was successful. 
sl@0
   656
		KErrBadHandle if the file handle is not shared through the call RFs::ShareProtected().
sl@0
   657
		KErrNone on success, otherwise another of the system-wide error codes.
sl@0
   658
*/
sl@0
   659
EXPORT_C void RMMFController::AddFileHandleDataSink(const RFile& aFile,
sl@0
   660
											TMMFMessageDestinationPckg& aHandleInfo, TRequestStatus& aStatus)
sl@0
   661
	{
sl@0
   662
	TIpcArgs ipcArgs(&iDestinationPckg, NULL, NULL, &aHandleInfo);
sl@0
   663
	TInt error = aFile.TransferToServer(ipcArgs, 1, 2);
sl@0
   664
	
sl@0
   665
	if (!error)
sl@0
   666
		{
sl@0
   667
		iControllerProxy.SendAsync(EMMFControllerAddFileHandleDataSink,
sl@0
   668
											   ipcArgs,
sl@0
   669
											   aStatus);		
sl@0
   670
		}
sl@0
   671
	else
sl@0
   672
		{
sl@0
   673
		TRequestStatus* status = &aStatus;
sl@0
   674
		User::RequestComplete(status, error);
sl@0
   675
		}
sl@0
   676
sl@0
   677
	}
sl@0
   678
sl@0
   679
sl@0
   680
/**
sl@0
   681
Adds a data sink to the controller, and receives a handle to allow removal and direct
sl@0
   682
communication with that data sink.
sl@0
   683
sl@0
   684
A typical data sink would be a file, descriptor, audio output (speaker) or display.
sl@0
   685
A controller plugin may require multiple data sinks to be added (for example a video
sl@0
   686
playing controller would require two); the exact number is plugin-specific.
sl@0
   687
Data sinks are plugins themselves, and are loaded by the controller framework
sl@0
   688
inside the controller thread.
sl@0
   689
sl@0
   690
@param  aSinkUid
sl@0
   691
        The UID of the data sink to be added. For more information,
sl@0
   692
        see the documentation for the data sink you wish to add.
sl@0
   693
@param  aSinkInitData
sl@0
   694
        Data used to initialise the data sink.  The exact contents
sl@0
   695
        of this data are dependent on the type of data sink. For more
sl@0
   696
        information, see the documentation for the data sink you wish
sl@0
   697
        to add.
sl@0
   698
@param  aHandleInfo
sl@0
   699
        This object is filled in by the controller framework, and identifies
sl@0
   700
        the data sink inside the controller framework.  This allows
sl@0
   701
        the caller to send custom commands directly to the data sink, and
sl@0
   702
        to also remove the data sink from the controller.  Note that
sl@0
   703
        not all data sinks support custom commands, and not all
sl@0
   704
        controller plugins support the removal of a data sink.
sl@0
   705
sl@0
   706
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   707
        another of the system-wide error codes.
sl@0
   708
@since  7.0s
sl@0
   709
*/
sl@0
   710
EXPORT_C TInt RMMFController::AddDataSink(TUid aSinkUid, const TDesC8& aSinkInitData,
sl@0
   711
										  TMMFMessageDestination& aHandleInfo)
sl@0
   712
	{
sl@0
   713
	TMMFMessageDestinationPckg pckg;
sl@0
   714
	TMMFUidPckg uidPckg(aSinkUid);
sl@0
   715
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   716
										   EMMFControllerAddDataSink,
sl@0
   717
										   uidPckg,
sl@0
   718
										   aSinkInitData,
sl@0
   719
										   pckg);
sl@0
   720
	if (!error)
sl@0
   721
		{
sl@0
   722
		aHandleInfo = pckg();
sl@0
   723
		}
sl@0
   724
	return error;
sl@0
   725
	}
sl@0
   726
sl@0
   727
sl@0
   728
/**
sl@0
   729
Add a data source to the controller asynchronously, and receive a handle to allow removal and direct
sl@0
   730
communication with that data source.
sl@0
   731
sl@0
   732
Note: only one call to this method can be outstanding at any time.
sl@0
   733
sl@0
   734
A typical data source would be a file, descriptor, audio input (microphone) or camera.
sl@0
   735
A controller plugin may require multiple data sources to be added (for example a video
sl@0
   736
recorder controller would require two); the exact number is plugin-specific.
sl@0
   737
Data sources are plugins themselves, and are loaded by the controller framework
sl@0
   738
inside the controller thread.
sl@0
   739
sl@0
   740
@param "aSourceUid"			"The uid of the data source to be added, packaged for async data transfer. 
sl@0
   741
							The reference must remain valid until the command has been completed or 
sl@0
   742
							cancelled."
sl@0
   743
@param "aSourceInitData"	"Data used to initialise the data source.  The reference must remain valid 
sl@0
   744
							until the command has been completed or cancelled. The exact contents
sl@0
   745
							of this data is dependent on the type of data source. For more
sl@0
   746
							information, see the documentation for the data source you wish
sl@0
   747
							to add."
sl@0
   748
@param "aHandleInfoPckg"	"This object is filled in by the controller framework, and identifies
sl@0
   749
							the data source inside the controller framework.  This allows
sl@0
   750
							the caller to send custom commands directly to the data source, and
sl@0
   751
							to also remove the data source from the controller.  Note that
sl@0
   752
							not all data sources support custom commands, and not all
sl@0
   753
							controller plugins support the removal of a data source."
sl@0
   754
@param "aStatus"			"TRequestStatus of the active object to be signalled on completion
sl@0
   755
							of this request."
sl@0
   756
@since	8.0
sl@0
   757
*/
sl@0
   758
EXPORT_C void RMMFController::AddDataSource(const TMMFUidPckg& aSourceUid, const TDesC8& aSourceInitData, 
sl@0
   759
											TMMFMessageDestinationPckg& aHandleInfoPckg, 
sl@0
   760
											TRequestStatus& aStatus)
sl@0
   761
	{
sl@0
   762
	iControllerProxy.SendAsync(iDestinationPckg,
sl@0
   763
							   EMMFControllerAddDataSource,
sl@0
   764
							   aSourceUid,
sl@0
   765
							   aSourceInitData,
sl@0
   766
							   aHandleInfoPckg,
sl@0
   767
							   aStatus);
sl@0
   768
	}
sl@0
   769
sl@0
   770
/**
sl@0
   771
Cancels an outstanding call to the asynchronous version of AddDataSource().
sl@0
   772
@since	8.0
sl@0
   773
*/
sl@0
   774
EXPORT_C void RMMFController::CancelAddDataSource()
sl@0
   775
	{
sl@0
   776
	iControllerProxy.SendSync(iDestinationPckg,
sl@0
   777
							  EMMFControllerCancelAddDataSource,
sl@0
   778
							  KNullDesC8,
sl@0
   779
							  KNullDesC8);
sl@0
   780
	}
sl@0
   781
sl@0
   782
/**
sl@0
   783
Add a data sink to the controller asynchronously, and receive a handle to allow removal and direct
sl@0
   784
communication with that data sink.
sl@0
   785
sl@0
   786
A typical data sink would be a file, descriptor, audio output (speaker) or display.
sl@0
   787
A controller plugin may require multiple data sinks to be added (for example a video
sl@0
   788
playing controller would require two); the exact number is plugin-specific.
sl@0
   789
Data sinks are plugins themselves, and are loaded by the controller framework
sl@0
   790
inside the controller thread.
sl@0
   791
sl@0
   792
@param "aSinkUid"			"The uid of the data sink to be added, packaged for async data transfer. 
sl@0
   793
							The reference must remain valid until the command has been completed or 
sl@0
   794
							cancelled."
sl@0
   795
@param "aSinkInitData"		"Data used to initialise the data sink.  The reference must remain valid 
sl@0
   796
							until the command has been completed or cancelled. The exact contents
sl@0
   797
							of this data are dependent on the type of data sink. For more
sl@0
   798
							information, see the documentation for the data sink you wish
sl@0
   799
							to add."
sl@0
   800
@param "aHandleInfoPckg"	"This object is filled in by the controller framework, and identifies
sl@0
   801
							the data sink inside the controller framework.  This allows
sl@0
   802
							the caller to send custom commands directly to the data sink, and
sl@0
   803
							to also remove the data sink from the controller.  Note that
sl@0
   804
							not all data sinks support custom commands, and not all
sl@0
   805
							controller plugins support the removal of a data sink."
sl@0
   806
@param "aStatus"			"TRequestStatus of the active object to be signalled on completion
sl@0
   807
							of this request."
sl@0
   808
@since	8.0
sl@0
   809
*/
sl@0
   810
EXPORT_C void RMMFController::AddDataSink(const TMMFUidPckg& aSinkUid, const TDesC8& aSinkInitData, 
sl@0
   811
										  TMMFMessageDestinationPckg& aHandleInfoPckg, 
sl@0
   812
										  TRequestStatus& aStatus)
sl@0
   813
	{
sl@0
   814
	iControllerProxy.SendAsync(iDestinationPckg,
sl@0
   815
							   EMMFControllerAddDataSink,
sl@0
   816
							   aSinkUid,
sl@0
   817
							   aSinkInitData,
sl@0
   818
							   aHandleInfoPckg,
sl@0
   819
							   aStatus);
sl@0
   820
	}
sl@0
   821
sl@0
   822
sl@0
   823
/**
sl@0
   824
Cancels an outstanding call to the asynchronous version of AddDataSink().
sl@0
   825
@since	8.0
sl@0
   826
*/
sl@0
   827
EXPORT_C void RMMFController::CancelAddDataSink()
sl@0
   828
	{
sl@0
   829
	iControllerProxy.SendSync(iDestinationPckg,
sl@0
   830
							  EMMFControllerCancelAddDataSink,
sl@0
   831
							  KNullDesC8,
sl@0
   832
							  KNullDesC8);
sl@0
   833
	}
sl@0
   834
sl@0
   835
/**
sl@0
   836
Removes a data source from the controller.
sl@0
   837
sl@0
   838
In certain situations, it may be necessary to remove a data source from a controller, for
sl@0
   839
example when you need to play a different file of the same format as the current one.
sl@0
   840
sl@0
   841
It should be noted that not all controller plugins will support the removal of a data source.
sl@0
   842
sl@0
   843
@param  aHandleInfo
sl@0
   844
        The handle object returned by the controller framework when the
sl@0
   845
        data source was added.
sl@0
   846
sl@0
   847
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   848
        another of the system-wide error codes.
sl@0
   849
@since  7.0s
sl@0
   850
*/
sl@0
   851
EXPORT_C TInt RMMFController::RemoveDataSource(const TMMFMessageDestination& aHandleInfo)
sl@0
   852
	{
sl@0
   853
	TMMFMessageDestinationPckg pckg(aHandleInfo);
sl@0
   854
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   855
										   EMMFControllerRemoveDataSource,
sl@0
   856
										   pckg,
sl@0
   857
										   KNullDesC8);
sl@0
   858
	return error;
sl@0
   859
	}
sl@0
   860
sl@0
   861
/**
sl@0
   862
Removes a data sink from the controller.
sl@0
   863
sl@0
   864
In certain situations, it may be necessary to remove a data sink from a controller, for
sl@0
   865
example when you need change output devices on the fly.
sl@0
   866
sl@0
   867
It should be noted that not all controller plugins will support the removal of a data sink.
sl@0
   868
sl@0
   869
@param  aHandleInfo
sl@0
   870
        The handle object returned by the controller framework when the
sl@0
   871
        data sink was added.
sl@0
   872
sl@0
   873
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   874
        another of the system-wide error codes.
sl@0
   875
@since  7.0s
sl@0
   876
*/
sl@0
   877
EXPORT_C TInt RMMFController::RemoveDataSink(const TMMFMessageDestination& aHandleInfo)
sl@0
   878
	{
sl@0
   879
	TMMFMessageDestinationPckg pckg(aHandleInfo);
sl@0
   880
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
   881
										   EMMFControllerRemoveDataSink,
sl@0
   882
										   pckg,
sl@0
   883
										   KNullDesC8);
sl@0
   884
	return error;
sl@0
   885
	}
sl@0
   886
sl@0
   887
/**
sl@0
   888
Reverts the controller plugin back to the state it was in just after it had been Opened.
sl@0
   889
sl@0
   890
Note: All sources and sinks will be removed from the controller.
sl@0
   891
sl@0
   892
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   893
        another of the system-wide error codes.
sl@0
   894
@since  7.0s
sl@0
   895
*/
sl@0
   896
EXPORT_C TInt RMMFController::Reset()
sl@0
   897
	{
sl@0
   898
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
   899
									 EMMFControllerReset,
sl@0
   900
									 KNullDesC8,
sl@0
   901
									 KNullDesC8);
sl@0
   902
	}
sl@0
   903
sl@0
   904
/**
sl@0
   905
Prepares the controller to start playing.
sl@0
   906
sl@0
   907
The controller should initialise its sources, sinks and buffers. This moves the controller
sl@0
   908
from the STOPPED to the PRIMED state.
sl@0
   909
sl@0
   910
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   911
        another of the system-wide error codes.
sl@0
   912
@since  7.0s
sl@0
   913
*/
sl@0
   914
EXPORT_C TInt RMMFController::Prime()
sl@0
   915
	{
sl@0
   916
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
   917
									 EMMFControllerPrime,
sl@0
   918
									 KNullDesC8,
sl@0
   919
									 KNullDesC8);
sl@0
   920
	}
sl@0
   921
sl@0
   922
/**
sl@0
   923
Starts the controller playing.
sl@0
   924
The controller will begin transferring data from its data source(s) to its data sink(s).
sl@0
   925
sl@0
   926
This moves the controller from the PRIMED to the PLAYING state.
sl@0
   927
sl@0
   928
Play() means "Start Playing" - i.e. this method will return as soon as
sl@0
   929
playback has begun.
sl@0
   930
sl@0
   931
If the data transfer comes to an end due to an internal event (e.g. source runs out of data),
sl@0
   932
the caller will be notified via the ReceiveEvents() interface.
sl@0
   933
sl@0
   934
Note: 
sl@0
   935
Prime() must have been called prior to calling Play().
sl@0
   936
sl@0
   937
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   938
        another of the system-wide error codes.
sl@0
   939
@since  7.0s
sl@0
   940
*/
sl@0
   941
EXPORT_C TInt RMMFController::Play()
sl@0
   942
	{
sl@0
   943
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
   944
									 EMMFControllerPlay,
sl@0
   945
									 KNullDesC8,
sl@0
   946
									 KNullDesC8);
sl@0
   947
	}
sl@0
   948
sl@0
   949
/**
sl@0
   950
Pauses the controller.
sl@0
   951
sl@0
   952
The controller will cease transferring data from its data source(s) to its data sink(s).
sl@0
   953
A subsequent call to Play() will result in the data transfer resuming from the
sl@0
   954
same place as when the Pause() was called.
sl@0
   955
sl@0
   956
This moves the controller from the PLAYING back to the PRIMED state.
sl@0
   957
sl@0
   958
Note: 
sl@0
   959
Play() must have been called prior to calling Pause().
sl@0
   960
sl@0
   961
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   962
        another of the system-wide error codes.
sl@0
   963
@since  7.0s
sl@0
   964
*/
sl@0
   965
EXPORT_C TInt RMMFController::Pause()
sl@0
   966
	{
sl@0
   967
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
   968
									 EMMFControllerPause,
sl@0
   969
									 KNullDesC8,
sl@0
   970
									 KNullDesC8);
sl@0
   971
	}
sl@0
   972
sl@0
   973
/**
sl@0
   974
Stops the controller.
sl@0
   975
sl@0
   976
The controller will cease transferring data from its data source(s) to its data sink(s), reset
sl@0
   977
its position and delete any allocated buffers.
sl@0
   978
In effect, calling Stop() undoes any actions performed by the controller
sl@0
   979
during the call to Prime().
sl@0
   980
sl@0
   981
This moves the controller from the PRIMED back to the STOPPED state.
sl@0
   982
sl@0
   983
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
   984
        another of the system-wide error codes.
sl@0
   985
@since	7.0s
sl@0
   986
*/
sl@0
   987
EXPORT_C TInt RMMFController::Stop()
sl@0
   988
	{
sl@0
   989
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
   990
									 EMMFControllerStop,
sl@0
   991
									 KNullDesC8,
sl@0
   992
									 KNullDesC8);
sl@0
   993
	}
sl@0
   994
	
sl@0
   995
/**
sl@0
   996
Gets the current position microseconds.
sl@0
   997
sl@0
   998
Note: The controller must be in the PRIMED or PLAYING state before this can be called.
sl@0
   999
sl@0
  1000
@param  aPosition
sl@0
  1001
        The current position in microseconds, filled in by the controller framework.
sl@0
  1002
sl@0
  1003
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
  1004
        another of the system-wide error codes.
sl@0
  1005
@since	7.0s
sl@0
  1006
*/
sl@0
  1007
EXPORT_C TInt RMMFController::GetPosition(TTimeIntervalMicroSeconds& aPosition) const
sl@0
  1008
	{
sl@0
  1009
	TMMFTimeIntervalMicroSecondsPckg pckg;
sl@0
  1010
	TInt err = iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1011
										 EMMFControllerGetPosition,
sl@0
  1012
										 KNullDesC8,
sl@0
  1013
										 KNullDesC8,
sl@0
  1014
										 pckg);
sl@0
  1015
	if (!err)
sl@0
  1016
		aPosition = pckg();
sl@0
  1017
	return err;
sl@0
  1018
	}
sl@0
  1019
sl@0
  1020
/**
sl@0
  1021
Sets the current position microseconds.
sl@0
  1022
sl@0
  1023
Note: The controller must be in the PRIMED or PLAYING state before this can be called.
sl@0
  1024
sl@0
  1025
@param  aPosition
sl@0
  1026
        The new transfer position in microseconds.
sl@0
  1027
sl@0
  1028
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
  1029
        another of the system-wide error codes.
sl@0
  1030
@since  7.0s
sl@0
  1031
*/
sl@0
  1032
EXPORT_C TInt RMMFController::SetPosition(const TTimeIntervalMicroSeconds& aPosition) const
sl@0
  1033
	{
sl@0
  1034
	TMMFTimeIntervalMicroSecondsPckg pckg(aPosition);
sl@0
  1035
	return iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1036
									 EMMFControllerSetPosition,
sl@0
  1037
									 pckg,
sl@0
  1038
									 KNullDesC8);
sl@0
  1039
	}
sl@0
  1040
sl@0
  1041
/**
sl@0
  1042
Gets the duration of the clip in microseconds.
sl@0
  1043
sl@0
  1044
Note: The controller must be in the PRIMED or PLAYING state before this can be called.
sl@0
  1045
sl@0
  1046
@param  aDuration
sl@0
  1047
        The duration of the clip in microseconds, filled in by the
sl@0
  1048
        controller framework.
sl@0
  1049
sl@0
  1050
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
  1051
        another of the system-wide error codes.
sl@0
  1052
@since	7.0s
sl@0
  1053
*/
sl@0
  1054
EXPORT_C TInt RMMFController::GetDuration(TTimeIntervalMicroSeconds& aDuration) const
sl@0
  1055
	{
sl@0
  1056
	TMMFTimeIntervalMicroSecondsPckg pckg;
sl@0
  1057
	TInt err = iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1058
										 EMMFControllerGetDuration,
sl@0
  1059
										 KNullDesC8,
sl@0
  1060
										 KNullDesC8,
sl@0
  1061
										 pckg);
sl@0
  1062
	if (!err)
sl@0
  1063
		aDuration = pckg();
sl@0
  1064
	return err;
sl@0
  1065
	}
sl@0
  1066
sl@0
  1067
/**
sl@0
  1068
Sends a custom command synchronously to the controller plugin.
sl@0
  1069
sl@0
  1070
Custom commands allow controller plugins to extend the standard API.
sl@0
  1071
sl@0
  1072
Note: This method will not return until the controller plugin has serviced the command.
sl@0
  1073
sl@0
  1074
@param  aDestination
sl@0
  1075
        The destination of the custom command, consisting of the UID of
sl@0
  1076
        the interface of this custom command and a special handle ID,
sl@0
  1077
        KMMFObjectHandleController to indicate that the custom
sl@0
  1078
        command is to be handled by the controller plugin.
sl@0
  1079
@param  aFunction
sl@0
  1080
        The function number to indicate which function is to be called
sl@0
  1081
        on the controller's custom command interface.
sl@0
  1082
@param  aDataTo1
sl@0
  1083
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1084
        contents of the data are dependent on the custom command interface
sl@0
  1085
        of the controller.  Use a value of KNullDesC8 if you have no data to send.
sl@0
  1086
@param  aDataTo2
sl@0
  1087
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1088
        contents of the data are dependent on the custom command interface
sl@0
  1089
        of the controller.  Use a value of KNullDesC8 if you have no data to send.
sl@0
  1090
@param  aDataFrom
sl@0
  1091
        A reference to an area of memory to which the controller plugin will
sl@0
  1092
        write any data to be passed back to the client.
sl@0
  1093
sl@0
  1094
@return The result of the custom command. Exact range of values is dependent on the custom command interface.
sl@0
  1095
@since  7.0s
sl@0
  1096
*/
sl@0
  1097
EXPORT_C TInt RMMFController::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom)
sl@0
  1098
	{
sl@0
  1099
	return iControllerProxy.SendSync(aDestination,
sl@0
  1100
									 aFunction,
sl@0
  1101
									 aDataTo1,
sl@0
  1102
									 aDataTo2,
sl@0
  1103
									 aDataFrom);
sl@0
  1104
	}
sl@0
  1105
sl@0
  1106
/**
sl@0
  1107
Sends a custom command synchronously to the controller plugin.
sl@0
  1108
sl@0
  1109
Custom commands allow controller plugins to extend the standard API.
sl@0
  1110
sl@0
  1111
Note: This method will not return until the controller plugin has serviced the command.
sl@0
  1112
sl@0
  1113
@param  aDestination
sl@0
  1114
        The destination of the custom command, consisting of the UID of
sl@0
  1115
        the interface of this custom command and a special handle ID,
sl@0
  1116
        KMMFObjectHandleController to indicate that the custom
sl@0
  1117
        command is to be handled by the controller plugin.
sl@0
  1118
@param  aFunction
sl@0
  1119
        The function number to indicate which function is to be called
sl@0
  1120
        on the controller's custom command interface.
sl@0
  1121
@param  aDataTo1
sl@0
  1122
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1123
        contents of the data are dependent on the custom command interface
sl@0
  1124
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1125
@param  aDataTo2
sl@0
  1126
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1127
        contents of the data are dependent on the custom command interface
sl@0
  1128
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1129
sl@0
  1130
@return The result of the custom command. Exact range of values is dependent on the custom command interface.
sl@0
  1131
@since  7.0s
sl@0
  1132
*/
sl@0
  1133
EXPORT_C TInt RMMFController::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2)
sl@0
  1134
	{
sl@0
  1135
	return iControllerProxy.SendSync(aDestination,
sl@0
  1136
									 aFunction,
sl@0
  1137
									 aDataTo1,
sl@0
  1138
									 aDataTo2);
sl@0
  1139
	}
sl@0
  1140
sl@0
  1141
/**
sl@0
  1142
Sends a custom command asynchronously to the controller plugin.
sl@0
  1143
sl@0
  1144
Custom commands allow controller plugins to extend the standard API.
sl@0
  1145
sl@0
  1146
Note: This method will return immediately.  The RunL of the active object owning the aStatus
sl@0
  1147
parameter will be called when the command is completed by the controller plugin.
sl@0
  1148
sl@0
  1149
@param  aDestination
sl@0
  1150
        The destination of the custom command, consisting of the UID of
sl@0
  1151
        the interface of this custom command and a special handle ID,
sl@0
  1152
        KMMFObjectHandleController to indicate that the custom
sl@0
  1153
        command is to be handled by the controller plugin.
sl@0
  1154
@param  aFunction
sl@0
  1155
        The function number to indicate which function is to be called
sl@0
  1156
        on the controller's custom command interface.
sl@0
  1157
@param  aDataTo1
sl@0
  1158
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1159
        contents of the data are dependent on the custom command interface
sl@0
  1160
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1161
@param  aDataTo2
sl@0
  1162
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1163
        contents of the data are dependent on the custom command interface
sl@0
  1164
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1165
@param  aDataFrom
sl@0
  1166
        A reference to an area of memory to which the controller plugin will
sl@0
  1167
        write any data to be passed back to the client.
sl@0
  1168
@param  aStatus
sl@0
  1169
        The TRequestStatus of an active object. This will  contain the
sl@0
  1170
        result of the custom command on completion. The exact range of
sl@0
  1171
        result values is dependent on the custom command interface.
sl@0
  1172
sl@0
  1173
@since  7.0s
sl@0
  1174
*/
sl@0
  1175
EXPORT_C void RMMFController::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus)
sl@0
  1176
	{
sl@0
  1177
	iControllerProxy.SendAsync(aDestination,
sl@0
  1178
							   aFunction,
sl@0
  1179
							   aDataTo1,
sl@0
  1180
							   aDataTo2,
sl@0
  1181
							   aDataFrom,
sl@0
  1182
							   aStatus);
sl@0
  1183
	}
sl@0
  1184
sl@0
  1185
/**
sl@0
  1186
Sends a custom command asynchronously to the controller plugin.
sl@0
  1187
sl@0
  1188
Custom commands allow controller plugins to extend the standard API.
sl@0
  1189
sl@0
  1190
Note: This method will return immediately.  The RunL() of the active object owning the aStatus
sl@0
  1191
parameter will be called when the command is completed by the controller plugin.
sl@0
  1192
sl@0
  1193
@param  aDestination
sl@0
  1194
        The destination of the custom command, consisting of the UID of
sl@0
  1195
        the interface of this custom command and a special handle ID,
sl@0
  1196
        KMMFObjectHandleController to indicate that the custom
sl@0
  1197
        command is to be handled by the controller plugin.
sl@0
  1198
@param  aFunction
sl@0
  1199
        The function number to indicate which function is to be called
sl@0
  1200
        on the controller's custom command interface.
sl@0
  1201
@param  aDataTo1
sl@0
  1202
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1203
        contents of the data are dependent on the custom command interface
sl@0
  1204
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1205
@param  aDataTo2
sl@0
  1206
        A reference to data to be copied to the controller plugin. The exact
sl@0
  1207
        contents of the data are dependent on the custom command interface
sl@0
  1208
        of the controller. Use a value of KNullDesC8 if you have no data to send.
sl@0
  1209
@param  aStatus
sl@0
  1210
        The TRequestStatus of an active object. This will  contain the
sl@0
  1211
        result of the custom command on completion. The exact range of
sl@0
  1212
        result values is dependent on the custom command interface.
sl@0
  1213
sl@0
  1214
@since	7.0s
sl@0
  1215
*/
sl@0
  1216
EXPORT_C void RMMFController::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus)
sl@0
  1217
	{
sl@0
  1218
	iControllerProxy.SendAsync(aDestination,
sl@0
  1219
							   aFunction,
sl@0
  1220
							   aDataTo1,
sl@0
  1221
							   aDataTo2,
sl@0
  1222
							   aStatus);
sl@0
  1223
	}
sl@0
  1224
sl@0
  1225
/**
sl@0
  1226
Registers to receive events from the controller plugin.
sl@0
  1227
sl@0
  1228
Events can be generated at any time, and are generally associated with things that occur
sl@0
  1229
due to something happening internally within the controller. For example, an event will
sl@0
  1230
be generated if the controller stops playing due to reaching the end of a file.
sl@0
  1231
sl@0
  1232
@param  aEventPckg
sl@0
  1233
        A reference to a TMMFEventPckg object that must be member data
sl@0
  1234
        of the active object calling this method.  The details of the event
sl@0
  1235
        will be copied into this object when an event occurs.
sl@0
  1236
@param  aStatus
sl@0
  1237
        The TRequestStatus of the active object calling this method.
sl@0
  1238
sl@0
  1239
@see    TMMFEvent
sl@0
  1240
@see    CMMFControllerEventMonitor
sl@0
  1241
@since  7.0s
sl@0
  1242
*/
sl@0
  1243
EXPORT_C void RMMFController::ReceiveEvents(TMMFEventPckg& aEventPckg, TRequestStatus& aStatus)
sl@0
  1244
	{
sl@0
  1245
	iControllerProxy.ReceiveEvents(aEventPckg, aStatus);
sl@0
  1246
	}
sl@0
  1247
sl@0
  1248
/**
sl@0
  1249
Cancels a previous registration to receive events from the controller plugin.
sl@0
  1250
sl@0
  1251
This must be called from the DoCancel() method of the active object using the
sl@0
  1252
ReceiveEvents() API function.
sl@0
  1253
sl@0
  1254
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
  1255
        another of the system-wide error codes.
sl@0
  1256
@see    TMMFEvent
sl@0
  1257
@since  7.0s
sl@0
  1258
*/
sl@0
  1259
EXPORT_C TInt RMMFController::CancelReceiveEvents()
sl@0
  1260
	{
sl@0
  1261
	return iControllerProxy.CancelReceiveEvents();
sl@0
  1262
	}
sl@0
  1263
sl@0
  1264
/**
sl@0
  1265
Gets the number a meta data entries in the clip.
sl@0
  1266
sl@0
  1267
A clip may contain zero or more entries of meta data, e.g Author, Copyright etc.
sl@0
  1268
sl@0
  1269
@param  aNumberOfEntries
sl@0
  1270
        The number of meta data entries in the clip, filled in by the controller framework.
sl@0
  1271
sl@0
  1272
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
sl@0
  1273
        another of the system-wide error codes.
sl@0
  1274
@since  7.0s
sl@0
  1275
*/
sl@0
  1276
EXPORT_C TInt RMMFController::GetNumberOfMetaDataEntries(TInt& aNumberOfEntries) const
sl@0
  1277
	{
sl@0
  1278
	TPckgBuf<TInt> pckg;
sl@0
  1279
	TInt error = iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1280
										   EMMFControllerGetNumberOfMetaDataEntries,
sl@0
  1281
										   KNullDesC8,
sl@0
  1282
										   KNullDesC8,
sl@0
  1283
										   pckg);
sl@0
  1284
	if (!error)
sl@0
  1285
		aNumberOfEntries = pckg();
sl@0
  1286
	return error;
sl@0
  1287
	}
sl@0
  1288
sl@0
  1289
/**
sl@0
  1290
Returns a particular meta data entry from the clip.
sl@0
  1291
sl@0
  1292
All meta data entries can be retrieved by multiple calls to this method, iterating
sl@0
  1293
aIndex from 0 to the value returned by GetNumberOfMetaDataEntries().
sl@0
  1294
sl@0
  1295
@param  aIndex
sl@0
  1296
        The index of the meta data entry to retrieve.
sl@0
  1297
sl@0
  1298
@return The meta data entry retrieved from the controller plugin. Ownership of the entry is
sl@0
  1299
		passed to the caller.
sl@0
  1300
sl@0
  1301
@see    CMMFMetaDataEntry
sl@0
  1302
@since  7.0s
sl@0
  1303
*/
sl@0
  1304
EXPORT_C CMMFMetaDataEntry* RMMFController::GetMetaDataEntryL(TInt aIndex) const
sl@0
  1305
	{
sl@0
  1306
	// Get the size of the entry
sl@0
  1307
	TPckgBuf<TInt> indexPckg(aIndex);
sl@0
  1308
	TPckgBuf<TInt> sizePckg;
sl@0
  1309
	User::LeaveIfError(iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1310
												 EMMFControllerGetSizeOfMetaDataEntry,
sl@0
  1311
												 indexPckg,
sl@0
  1312
												 KNullDesC8,
sl@0
  1313
												 sizePckg));
sl@0
  1314
	// Create a buffer of appropriate size and get the entry data
sl@0
  1315
	HBufC8* buf = HBufC8::NewLC(sizePckg());
sl@0
  1316
	TPtr8 ptr = buf->Des();
sl@0
  1317
	User::LeaveIfError(iControllerProxy.SendSync(iDestinationPckg,
sl@0
  1318
												 EMMFControllerGetMetaDataEntry,
sl@0
  1319
												 KNullDesC8,
sl@0
  1320
												 KNullDesC8,
sl@0
  1321
												 ptr));
sl@0
  1322
	// Create the entry and internalize the data
sl@0
  1323
	CMMFMetaDataEntry* entry = CMMFMetaDataEntry::NewL();
sl@0
  1324
	CleanupStack::PushL(entry);
sl@0
  1325
	RDesReadStream stream(ptr);
sl@0
  1326
	CleanupClosePushL(stream);
sl@0
  1327
sl@0
  1328
	entry->InternalizeL(stream);
sl@0
  1329
sl@0
  1330
	CleanupStack::PopAndDestroy();//stream
sl@0
  1331
	CleanupStack::Pop(entry);//entry
sl@0
  1332
	CleanupStack::PopAndDestroy(buf);//buf
sl@0
  1333
sl@0
  1334
	return entry;	
sl@0
  1335
	}
sl@0
  1336
sl@0
  1337
/**
sl@0
  1338
Set the priority of the controller's sub thread.
sl@0
  1339
sl@0
  1340
This can be used to increase the responsiveness of the audio plugin to minimise
sl@0
  1341
any lag in processing. This function should be used with care as it may have knock-on
sl@0
  1342
effects elsewhere in the system.
sl@0
  1343
sl@0
  1344
@param	aPriority
sl@0
  1345
		The TThreadPriority that the thread should run under.  The default is EPriorityNormal.
sl@0
  1346
@return	TInt
sl@0
  1347
		A standard error code: KErrNone if successful, KErrNotReady if the thread does not have a
sl@0
  1348
		valid handle.
sl@0
  1349
*/
sl@0
  1350
EXPORT_C TInt RMMFController::SetThreadPriority(const TThreadPriority& aPriority) const
sl@0
  1351
	{
sl@0
  1352
	return iControllerProxy.SetThreadPriority(aPriority);
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
/**
sl@0
  1356
Create a new Controller Event Monitor.
sl@0
  1357
sl@0
  1358
@param aObserver "The observer to notify whenever an event is received.
sl@0
  1359
@param aMMFController "A reference to the controller that is to be monitored for events.
sl@0
  1360
@return "A pointer to the object created."
sl@0
  1361
*/
sl@0
  1362
EXPORT_C CMMFControllerEventMonitor* CMMFControllerEventMonitor::NewL(MMMFControllerEventMonitorObserver& aObserver, 
sl@0
  1363
															 RMMFController& aMMFController)
sl@0
  1364
	{
sl@0
  1365
	return (new(ELeave) CMMFControllerEventMonitor(aObserver, aMMFController));
sl@0
  1366
	}
sl@0
  1367
sl@0
  1368
CMMFControllerEventMonitor::CMMFControllerEventMonitor(MMMFControllerEventMonitorObserver& aObserver, 
sl@0
  1369
													   RMMFController& aMMFController) :
sl@0
  1370
	CActive(EPriorityStandard),
sl@0
  1371
	iObserver(aObserver), 
sl@0
  1372
	iMMFController(aMMFController)
sl@0
  1373
	{
sl@0
  1374
	CActiveScheduler::Add(this);
sl@0
  1375
	}
sl@0
  1376
sl@0
  1377
CMMFControllerEventMonitor::~CMMFControllerEventMonitor()
sl@0
  1378
	{
sl@0
  1379
	Cancel();
sl@0
  1380
	}
sl@0
  1381
sl@0
  1382
sl@0
  1383
/**
sl@0
  1384
Start receiving events from the controller.
sl@0
  1385
This can only be called once the controller is open.
sl@0
  1386
*/
sl@0
  1387
EXPORT_C void CMMFControllerEventMonitor::Start()
sl@0
  1388
	{
sl@0
  1389
	iMMFController.ReceiveEvents(iEventPckg, iStatus);
sl@0
  1390
	SetActive();
sl@0
  1391
	}
sl@0
  1392
sl@0
  1393
void CMMFControllerEventMonitor::RunL()
sl@0
  1394
	{
sl@0
  1395
	if (iStatus.Int() == KErrNone)
sl@0
  1396
		{
sl@0
  1397
		// Save the package buf as calling Start() will overwrite the contents of iEventPckg
sl@0
  1398
		TMMFEventPckg packageBuf = iEventPckg;
sl@0
  1399
		Start();
sl@0
  1400
		iObserver.HandleEvent(packageBuf());
sl@0
  1401
		}
sl@0
  1402
	else
sl@0
  1403
		{
sl@0
  1404
		//something's gone wrong with trying to receive events (e.g. server died etc)
sl@0
  1405
		TMMFEvent event(KMMFErrorCategoryControllerGeneralError, iStatus.Int());
sl@0
  1406
		iObserver.HandleEvent(event);
sl@0
  1407
		//we don't want to receive events again here...
sl@0
  1408
		}
sl@0
  1409
	}
sl@0
  1410
sl@0
  1411
void CMMFControllerEventMonitor::DoCancel()
sl@0
  1412
	{
sl@0
  1413
	iMMFController.CancelReceiveEvents();
sl@0
  1414
	}
sl@0
  1415
sl@0
  1416
/**
sl@0
  1417
Constructs a CMMFAddDataSourceSinkAsync object.
sl@0
  1418
sl@0
  1419
@param aObs A reference to the observer of the active object.  The observer will be
sl@0
  1420
						notified when the AddDataSource/Sink command is complete.
sl@0
  1421
@return	 A pointer to the new object.
sl@0
  1422
@leave	This method can leave with one of the standard system-wide error codes.
sl@0
  1423
@since 7.0s
sl@0
  1424
*/
sl@0
  1425
EXPORT_C CMMFAddDataSourceSinkAsync* CMMFAddDataSourceSinkAsync::NewL(MMMFAddDataSourceSinkAsyncObserver& aObs)
sl@0
  1426
	{
sl@0
  1427
	return new(ELeave) CMMFAddDataSourceSinkAsync(aObs);
sl@0
  1428
	}
sl@0
  1429
sl@0
  1430
CMMFAddDataSourceSinkAsync::CMMFAddDataSourceSinkAsync(MMMFAddDataSourceSinkAsyncObserver& aObserver) :
sl@0
  1431
	CActive(EPriorityNormal),
sl@0
  1432
	iObserver(aObserver)
sl@0
  1433
	{
sl@0
  1434
	CActiveScheduler::Add(this);
sl@0
  1435
	iCurrentAction = EIdle;
sl@0
  1436
	}
sl@0
  1437
/**
sl@0
  1438
Destructor.
sl@0
  1439
*/
sl@0
  1440
CMMFAddDataSourceSinkAsync::~CMMFAddDataSourceSinkAsync()
sl@0
  1441
	{
sl@0
  1442
	Cancel();
sl@0
  1443
	delete iSourceSinkInitData;
sl@0
  1444
	}
sl@0
  1445
/**
sl@0
  1446
Add a data source to the controller.  The caller will be signalled on completion via the
sl@0
  1447
MMMFAddDataSourceSinkAsyncObserver interface.
sl@0
  1448
sl@0
  1449
Only one method call may be outstanding on this object at any one time.
sl@0
  1450
sl@0
  1451
@param aMMFController		A reference to the client controller interface class.
sl@0
  1452
@param aSourceUid			The uid of the data source to be added. For more information, 
sl@0
  1453
							see the documentation for the data source you wish to add.
sl@0
  1454
@param aSourceInitData	    Data used to initialise the data source.  The exact contents
sl@0
  1455
							of this data are dependent on the type of data source. For more
sl@0
  1456
							information, see the documentation for the data source you wish
sl@0
  1457
							to add.
sl@0
  1458
@since	7.0s
sl@0
  1459
*/
sl@0
  1460
EXPORT_C void CMMFAddDataSourceSinkAsync::AddDataSource(RMMFController& aMMFController, TUid aSourceUid, const TDesC8& aSourceInitData)
sl@0
  1461
	{
sl@0
  1462
	ASSERT(iCurrentAction == EIdle);
sl@0
  1463
sl@0
  1464
	iMMFController = &aMMFController;
sl@0
  1465
	iSourceSinkUidPckg() = aSourceUid;
sl@0
  1466
	delete iSourceSinkInitData;
sl@0
  1467
	iSourceSinkInitData = NULL;
sl@0
  1468
	iSourceSinkInitData = aSourceInitData.Alloc();
sl@0
  1469
	if (!iSourceSinkInitData)
sl@0
  1470
		{
sl@0
  1471
		iObserver.MadssaoAddDataSourceSinkAsyncComplete(KErrNoMemory, iHandleInfoPckg());
sl@0
  1472
		}
sl@0
  1473
	else
sl@0
  1474
		{
sl@0
  1475
		iMMFController->AddDataSource(iSourceSinkUidPckg, *iSourceSinkInitData, iHandleInfoPckg, iStatus);
sl@0
  1476
		SetActive();
sl@0
  1477
		iCurrentAction = EAddingDataSource;
sl@0
  1478
		}
sl@0
  1479
	}
sl@0
  1480
	
sl@0
  1481
/**
sl@0
  1482
Add a data sink to the controller.  The caller will be signalled on completion via the
sl@0
  1483
MMMFAddDataSourceSinkAsyncObserver interface.
sl@0
  1484
sl@0
  1485
Only one method call may be outstanding on this object at any one time.
sl@0
  1486
sl@0
  1487
@param aMMFController		A reference to the client controller interface class.
sl@0
  1488
@param aSinkUid			    The uid of the data sink to be added. For more information, 
sl@0
  1489
							see the documentation for the data sink you wish to add.
sl@0
  1490
@param aSinkInitData		Data used to initialise the data sink.  The exact contents
sl@0
  1491
							of this data are dependent on the type of data sink. For more
sl@0
  1492
							information, see the documentation for the data sink you wish
sl@0
  1493
							to add.
sl@0
  1494
@since	7.0s
sl@0
  1495
*/
sl@0
  1496
EXPORT_C void CMMFAddDataSourceSinkAsync::AddDataSink(RMMFController& aMMFController, TUid aSinkUid, const TDesC8& aSinkInitData)
sl@0
  1497
	{
sl@0
  1498
	ASSERT(iCurrentAction == EIdle);
sl@0
  1499
sl@0
  1500
	iMMFController = &aMMFController;
sl@0
  1501
	iSourceSinkUidPckg() = aSinkUid;
sl@0
  1502
	delete iSourceSinkInitData;
sl@0
  1503
	iSourceSinkInitData = NULL;
sl@0
  1504
	iSourceSinkInitData = aSinkInitData.Alloc();
sl@0
  1505
	if (!iSourceSinkInitData)
sl@0
  1506
		{
sl@0
  1507
		iObserver.MadssaoAddDataSourceSinkAsyncComplete(KErrNoMemory, iHandleInfoPckg());
sl@0
  1508
		}
sl@0
  1509
	else
sl@0
  1510
		{
sl@0
  1511
		iMMFController->AddDataSink(iSourceSinkUidPckg, *iSourceSinkInitData, iHandleInfoPckg, iStatus);
sl@0
  1512
		SetActive();
sl@0
  1513
		iCurrentAction = EAddingDataSink;
sl@0
  1514
		}
sl@0
  1515
	}
sl@0
  1516
	
sl@0
  1517
sl@0
  1518
void CMMFAddDataSourceSinkAsync::RunL()
sl@0
  1519
	{
sl@0
  1520
	iCurrentAction = EIdle;
sl@0
  1521
	iMMFController = NULL;
sl@0
  1522
	delete iSourceSinkInitData;
sl@0
  1523
	iSourceSinkInitData = NULL;
sl@0
  1524
sl@0
  1525
	iObserver.MadssaoAddDataSourceSinkAsyncComplete(iStatus.Int(), iHandleInfoPckg());
sl@0
  1526
	}
sl@0
  1527
sl@0
  1528
void CMMFAddDataSourceSinkAsync::DoCancel()
sl@0
  1529
	{
sl@0
  1530
	// although the server does nothing with the cancel message,
sl@0
  1531
	// by calling it we can at least be assured that by the time it completes, 
sl@0
  1532
	// the async AddSource/Sink message will have been completed too
sl@0
  1533
	// so we don't get any stray events.
sl@0
  1534
	if (iCurrentAction == EAddingDataSource)
sl@0
  1535
		iMMFController->CancelAddDataSource();
sl@0
  1536
	else if (iCurrentAction == EAddingDataSink)
sl@0
  1537
		iMMFController->CancelAddDataSink();
sl@0
  1538
sl@0
  1539
	iCurrentAction = EIdle;
sl@0
  1540
	iMMFController = NULL;
sl@0
  1541
	delete iSourceSinkInitData;
sl@0
  1542
	iSourceSinkInitData = NULL;
sl@0
  1543
	}
sl@0
  1544
	
sl@0
  1545
sl@0
  1546
EXPORT_C void CMMFAddDataSourceSinkAsync::AddFileHandleDataSource(RMMFController& aMMFController, const RFile& aFile)
sl@0
  1547
	{
sl@0
  1548
	ASSERT(iCurrentAction == EIdle);
sl@0
  1549
sl@0
  1550
	iMMFController = &aMMFController;
sl@0
  1551
	iMMFController->AddFileHandleDataSource(aFile,iHandleInfoPckg, iStatus);
sl@0
  1552
	SetActive();
sl@0
  1553
	iCurrentAction = EAddingDataSource;
sl@0
  1554
	}
sl@0
  1555
sl@0
  1556
EXPORT_C void CMMFAddDataSourceSinkAsync::AddFileHandleDataSource(RMMFController& aController, const RFile& aFile, 
sl@0
  1557
																  const TDesC8& aSourceInitData)
sl@0
  1558
	{
sl@0
  1559
	if (aSourceInitData.Length() == 0)
sl@0
  1560
		{
sl@0
  1561
		AddFileHandleDataSource(aController, aFile);
sl@0
  1562
		}
sl@0
  1563
	else
sl@0
  1564
		{
sl@0
  1565
		ASSERT(iCurrentAction == EIdle);
sl@0
  1566
sl@0
  1567
		iMMFController = &aController;
sl@0
  1568
		delete iSourceSinkInitData;
sl@0
  1569
		iSourceSinkInitData = NULL;
sl@0
  1570
		iSourceSinkInitData = aSourceInitData.Alloc();
sl@0
  1571
		if (!iSourceSinkInitData)
sl@0
  1572
			{
sl@0
  1573
			iObserver.MadssaoAddDataSourceSinkAsyncComplete(KErrNoMemory, iHandleInfoPckg());
sl@0
  1574
			}
sl@0
  1575
		else
sl@0
  1576
			{
sl@0
  1577
			iMMFController->AddFileHandleDataSource(aFile, *iSourceSinkInitData, iHandleInfoPckg, iStatus);
sl@0
  1578
			SetActive();
sl@0
  1579
			iCurrentAction = EAddingDataSource;
sl@0
  1580
			}
sl@0
  1581
		}
sl@0
  1582
	}
sl@0
  1583
	
sl@0
  1584
EXPORT_C void CMMFAddDataSourceSinkAsync::AddFileHandleDataSink(RMMFController& aMMFController, const RFile& aFile)
sl@0
  1585
	{
sl@0
  1586
	ASSERT(iCurrentAction == EIdle);
sl@0
  1587
sl@0
  1588
	iMMFController = &aMMFController;
sl@0
  1589
	iMMFController->AddFileHandleDataSink(aFile,iHandleInfoPckg, iStatus);
sl@0
  1590
	SetActive();
sl@0
  1591
	iCurrentAction = EAddingDataSink;
sl@0
  1592
	}
sl@0
  1593
sl@0
  1594
EXPORT_C void CMMFAddDataSourceSinkAsync::AddFileHandleDataSink(RMMFController& aController, const RFile& aFile, 
sl@0
  1595
																const TDesC8& aSinkInitData)
sl@0
  1596
	{
sl@0
  1597
	if (aSinkInitData.Length() == 0)
sl@0
  1598
		{
sl@0
  1599
		AddFileHandleDataSink(aController, aFile);
sl@0
  1600
		}
sl@0
  1601
	else
sl@0
  1602
		{
sl@0
  1603
		ASSERT(iCurrentAction == EIdle);
sl@0
  1604
sl@0
  1605
		iMMFController = &aController;
sl@0
  1606
		delete iSourceSinkInitData;
sl@0
  1607
		iSourceSinkInitData = NULL;
sl@0
  1608
		iSourceSinkInitData = aSinkInitData.Alloc();
sl@0
  1609
		if (!iSourceSinkInitData)
sl@0
  1610
			{
sl@0
  1611
			iObserver.MadssaoAddDataSourceSinkAsyncComplete(KErrNoMemory, iHandleInfoPckg());
sl@0
  1612
			}
sl@0
  1613
		else
sl@0
  1614
			{
sl@0
  1615
			iMMFController->AddFileHandleDataSink(aFile, *iSourceSinkInitData, iHandleInfoPckg, iStatus);
sl@0
  1616
			SetActive();
sl@0
  1617
			iCurrentAction = EAddingDataSink;
sl@0
  1618
			}	
sl@0
  1619
		}
sl@0
  1620
	}
sl@0
  1621