os/mm/devsound/devsoundrefplugin/src/platsec/server/AudioServer/MmfDevSoundSession.h
Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved.
2 // This component and the accompanying materials are made available
3 // under the terms of "Eclipse Public License v1.0"
4 // which accompanies this distribution, and is available
5 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
7 // Initial Contributors:
8 // Nokia Corporation - initial contribution.
15 #ifndef __MMFDEVSOUNDSESSION_H__
16 #define __MMFDEVSOUNDSESSION_H__
20 #include <mmf/common/mmfbase.h>
21 #include <mmf/common/mmfutilities.h>
22 #include <mmf/common/mmfcontroller.h>
23 #include <mmf/common/mmfipc.h>
24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
25 #include <mmf/common/mmfipcserver.h>
27 #include <mmf/server/sounddevice.h>
28 #include "MmfAudioClientServer.h"
29 #include <mmf/server/mmfdevsoundcustominterface.h>
30 #include "MmfDevSoundCIDeMuxUtility.h"
32 #include <e32msgqueue.h>
34 class CMMFAudioServer;
35 class CMMFDevSoundServer;
36 class CMMFDevSoundSvrImp;
38 class CMMFDevSoundSession : public CMmfIpcSession, public MDevSoundObserver,
39 public MMMFDevSoundCustomInterfaceDeMuxInterface
42 static CMMFDevSoundSession* NewL(RServer2& aPolicyServerHandle);
43 ~CMMFDevSoundSession();
45 void CreateL(const CMmfIpcServer& aServer);
46 void ServiceL(const RMmfIpcMessage& aMessage);
47 TInt DevSoundSessionId(void) {return iDevSoundSessionId;};
48 void SendEventToClient(/*TMMFAudioServerEvent& aEvent*/);
49 TBool CheckClientCapabilities();
52 TBool DoInitialize1L(const RMmfIpcMessage& aMessage);
53 TBool DoInitialize2L(const RMmfIpcMessage& aMessage);
54 TBool DoInitialize3L(const RMmfIpcMessage& aMessage);
55 TBool DoInitialize4L(const RMmfIpcMessage& aMessage);
56 TBool DoCapabilitiesL(const RMmfIpcMessage& aMessage);
57 TBool DoConfigL(const RMmfIpcMessage& aMessage);
58 TBool DoSetConfigL(const RMmfIpcMessage& aMessage);
59 TBool DoMaxVolumeL(const RMmfIpcMessage& aMessage);
60 TBool DoVolumeL(const RMmfIpcMessage& aMessage);
61 TBool DoSetVolumeL(const RMmfIpcMessage& aMessage);
62 TBool DoMaxGainL(const RMmfIpcMessage& aMessage);
63 TBool DoGainL(const RMmfIpcMessage& aMessage);
64 TBool DoSetGainL(const RMmfIpcMessage& aMessage);
65 TBool DoGetPlayBalanceL(const RMmfIpcMessage& aMessage);
66 TBool DoSetPlayBalanceL(const RMmfIpcMessage& aMessage);
67 TBool DoGetRecordBalanceL(const RMmfIpcMessage& aMessage);
68 TBool DoSetRecordBalanceL(const RMmfIpcMessage& aMessage);
69 TBool DoPlayInitL(const RMmfIpcMessage& aMessage);
70 TBool DoRecordInitL(const RMmfIpcMessage& aMessage);
71 TBool DoPlayDataL(const RMmfIpcMessage& aMessage);
72 TBool DoRecordDataL(const RMmfIpcMessage& aMessage);
73 TBool DoStopL(const RMmfIpcMessage& aMessage);
74 TBool DoPauseL(const RMmfIpcMessage& aMessage);
75 TBool DoPlayToneL(const RMmfIpcMessage& aMessage);
76 TBool DoPlayDualToneL(const RMmfIpcMessage& aMessage);
77 TBool DoPlayDTMFStringL(const RMmfIpcMessage& aMessage);
78 TBool DoPlayToneSequenceL(const RMmfIpcMessage& aMessage);
79 TBool DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage);
80 TBool DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage);
81 TBool DoSetVolumeRampL(const RMmfIpcMessage& aMessage);
82 TBool DoGetSupportedInputDataTypesL(const RMmfIpcMessage& aMessage);
83 TBool DoCopyFourCCArrayDataL(const RMmfIpcMessage& aMessage);
84 TBool DoGetRecordedBufferL(const RMmfIpcMessage& aMessage);
85 TBool DoSamplesRecordedL(const RMmfIpcMessage& aMessage);
86 TBool DoSamplesPlayedL(const RMmfIpcMessage& aMessage);
87 TBool DoSetToneRepeatsL(const RMmfIpcMessage& aMessage);
88 TBool DoSetPrioritySettingsL(const RMmfIpcMessage& aMessage);
89 TBool DoFixedSequenceNameL(const RMmfIpcMessage& aMessage);
90 TBool DoFixedSequenceCountL(const RMmfIpcMessage& aMessage);
91 TBool DoGetSupportedOutputDataTypesL(const RMmfIpcMessage& aMessage);
93 TBool DoBufferToBeFilledDataL(const RMmfIpcMessage& aMessage);
94 TBool DoBufferToBeEmptiedDataL(const RMmfIpcMessage& aMessage);
95 TBool DoRegisterAsClientL(const RMmfIpcMessage& aMessage);
96 TBool DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage);
97 TBool DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage);
98 TBool DoWillResumePlayL(const RMmfIpcMessage& aMessage);
99 TBool DoEmptyBuffersL(const RMmfIpcMessage& aMessage);
100 TBool DoSetClientThreadInfoL(const RMmfIpcMessage& aMessage);
101 TBool DoGetTimePlayedL(const RMmfIpcMessage& aMessage);
103 TBool DoSyncCustomCommandL(const RMmfIpcMessage& aMessage);
104 TBool DoSyncCustomCommandResultL(const RMmfIpcMessage& aMessage);
105 TBool DoAsyncCustomCommandL(const RMmfIpcMessage& aMessage);
106 TBool DoAsyncCustomCommandResultL(const RMmfIpcMessage& aMessage);
108 // from MMMFDevSoundCustomInterfaceDeMuxInterface
109 virtual TInt DoOpenSlaveL(TUid aInterface, const TDesC8& aPackageBuf);
110 virtual void DoCloseSlaveL(TInt aHandle);
111 virtual TInt DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage);
112 virtual TInt DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage);
113 virtual void DoSendSlaveAsyncCommandL(const RMmfIpcMessage& aMessage);
114 virtual void DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& aMessage);
117 void InitializeL(MDevSoundObserver& aDevSoundObserver, TMMFState aMode);
118 void InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode);
119 void InitializeL(MDevSoundObserver& aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode);
121 TMMFCapabilities Capabilities();
122 TMMFCapabilities Config() const;
123 void SetConfigL(const TMMFCapabilities& aCaps);
126 void SetVolume(TInt aVolume);
129 void SetGain(TInt aGain);
130 void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
131 void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
132 void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
133 void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
140 TInt SamplesRecorded();
141 TInt SamplesPlayed();
142 void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
143 void PlayDualToneL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
144 void PlayDTMFStringL(const TDesC& aDTMFString);
145 void PlayToneSequenceL(const TDesC8& aData);
146 void PlayFixedSequenceL(TInt aSequenceNumber);
147 void SetToneRepeats(TInt aRepeatCount,
148 const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
149 void SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
150 TTimeIntervalMicroSeconds32& aToneOffLength,
151 TTimeIntervalMicroSeconds32& aPauseLength);
153 void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
154 void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
156 TAny* CustomInterface(TUid aInterfaceId);
157 TInt FixedSequenceCount();
158 const TDesC& FixedSequenceName(TInt aSequenceNumber);
159 void GetSupportedInputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const;
160 void GetSupportedOutputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const;
162 void InitializeComplete(TInt aError);
163 void ToneFinished(TInt aError);
164 void BufferToBeFilled(CMMFBuffer* aBuffer);
165 void PlayError(TInt aError);
166 void BufferToBeEmptied(CMMFBuffer* aBuffer);
167 void RecordError(TInt aError);
168 void ConvertError(TInt aError);
169 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
170 void SendEventToClient(const TMMFEvent& aEvent);
172 TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
173 TInt CancelRegisterAsClient(TUid aEventType);
174 TInt GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData);
175 TInt WillResumePlay();
179 CMMFDevSoundSession();
180 void ConstructL(RServer2& aPolicyServerHandle);
181 CMMFDevSoundSvrImp* iBody;
184 TInt iDevSoundSessionId;
185 CMMFDataBuffer* iBufferPlay;
186 CMMFDataBuffer* iBufferRecord;
187 RArray<TFourCC> iArray;
190 TBool iClientHasCaps;
192 RMsgQueue<TMMFDevSoundQueueItem> iMsgQueue; // replaces the messages / AO handlers
193 TMMFDevSoundProxyHwBufPckg iHwBufPckgFill; // data store for 2-stage asynch message passing
194 TMMFDevSoundProxyHwBufPckg iHwBufPckgEmpty; // data store for 2-stage asynch message passing
196 // array of custom interface pairs
197 RArray<TMMFDevSoundCustomInterfaceDeMuxData> iCustomInterfaceArray;
198 CMMFDevSoundCIDeMuxUtility* iDeMuxUtility;