sl@0
|
1 |
// Copyright (c) 2003-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 |
#ifndef __TESTUSEOLDCODECAUDIOCONTROLLER_H__
|
sl@0
|
17 |
#define __TESTUSEOLDCODECAUDIOCONTROLLER_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
// Standard EPOC32 includes required by this header file
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <e32std.h>
|
sl@0
|
23 |
#include <ecom/implementationproxy.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
// Public Media Server includes
|
sl@0
|
26 |
#include <mmf/common/mmfcontroller.h>
|
sl@0
|
27 |
#include <mmf/server/mmfdatasink.h>
|
sl@0
|
28 |
#include <mmf/server/mmfdatasource.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
#include <mmf/server/mmfdatapathproxy.h>
|
sl@0
|
31 |
#include <mmf/common/mmfaudio.h>
|
sl@0
|
32 |
#include <mmf/server/mmfaudiooutput.h>
|
sl@0
|
33 |
#include <mmf/server/mmfaudioinput.h>
|
sl@0
|
34 |
#include <mmf/common/mmfstandardcustomcommands.h>
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
const TInt KOneSecondInMicroSeconds(1000000);
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
class CMMFMessageHolder : public CBase
|
sl@0
|
41 |
{
|
sl@0
|
42 |
public:
|
sl@0
|
43 |
static CMMFMessageHolder* NewL(TMMFMessage& aMessage)
|
sl@0
|
44 |
{return new(ELeave) CMMFMessageHolder(aMessage);}
|
sl@0
|
45 |
void Complete(TInt a) {iMessage.Complete(a);}
|
sl@0
|
46 |
private:
|
sl@0
|
47 |
CMMFMessageHolder(TMMFMessage& aMessage): CBase(), iMessage(aMessage) {}
|
sl@0
|
48 |
TMMFMessage iMessage;
|
sl@0
|
49 |
};
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
*
|
sl@0
|
53 |
* The public API for clients of the MMFAudioController
|
sl@0
|
54 |
*
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
|
sl@0
|
57 |
class CMMFTestUseOldCodecAudioController : public CMMFController,
|
sl@0
|
58 |
public MAsyncEventHandler,
|
sl@0
|
59 |
public MMMFAudioPlayDeviceCustomCommandImplementor,
|
sl@0
|
60 |
public MMMFAudioRecordDeviceCustomCommandImplementor,
|
sl@0
|
61 |
public MMMFAudioPlayControllerCustomCommandImplementor,
|
sl@0
|
62 |
public MMMFAudioRecordControllerCustomCommandImplementor,
|
sl@0
|
63 |
public MMMFAudioControllerCustomCommandImplementor
|
sl@0
|
64 |
{
|
sl@0
|
65 |
public:
|
sl@0
|
66 |
static CMMFController* NewL();
|
sl@0
|
67 |
virtual ~CMMFTestUseOldCodecAudioController();
|
sl@0
|
68 |
|
sl@0
|
69 |
void DevSoundInitialised(TInt aError);
|
sl@0
|
70 |
|
sl@0
|
71 |
//implement CMMFController ecom plugin interface
|
sl@0
|
72 |
virtual void AddDataSourceL(MDataSource& aDataSource);
|
sl@0
|
73 |
virtual void AddDataSinkL(MDataSink& aDataSink);
|
sl@0
|
74 |
virtual void RemoveDataSourceL(MDataSource& aDataSource);
|
sl@0
|
75 |
virtual void RemoveDataSinkL(MDataSink& aDataSink);
|
sl@0
|
76 |
|
sl@0
|
77 |
virtual void ResetL();
|
sl@0
|
78 |
virtual void PrimeL();
|
sl@0
|
79 |
virtual void PlayL();
|
sl@0
|
80 |
virtual void PauseL();
|
sl@0
|
81 |
virtual void StopL() {} //not required
|
sl@0
|
82 |
virtual void StopL(TMMFMessage& aMessage);
|
sl@0
|
83 |
|
sl@0
|
84 |
virtual TTimeIntervalMicroSeconds PositionL() const;
|
sl@0
|
85 |
virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
|
sl@0
|
86 |
virtual TTimeIntervalMicroSeconds DurationL() const;
|
sl@0
|
87 |
virtual void CustomCommand(TMMFMessage& aMessage);
|
sl@0
|
88 |
virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
|
sl@0
|
89 |
virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries);
|
sl@0
|
90 |
virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex);
|
sl@0
|
91 |
|
sl@0
|
92 |
//from MAsyncEventHandler
|
sl@0
|
93 |
virtual TInt SendEventToClient(const TMMFEvent& aEvent);
|
sl@0
|
94 |
|
sl@0
|
95 |
//from MMMFAudioPlayDeviceCustomCommandImplementor
|
sl@0
|
96 |
virtual void MapdSetVolumeL(TInt aVolume);
|
sl@0
|
97 |
virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
|
sl@0
|
98 |
virtual void MapdGetVolumeL(TInt& aVolume);
|
sl@0
|
99 |
virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
|
sl@0
|
100 |
virtual void MapdSetBalanceL(TInt aBalance);
|
sl@0
|
101 |
virtual void MapdGetBalanceL(TInt& aBalance);
|
sl@0
|
102 |
|
sl@0
|
103 |
//from MMMFAudioRecordDeviceCustomCommandImplementor
|
sl@0
|
104 |
virtual void MardSetGainL(TInt aGain);
|
sl@0
|
105 |
virtual void MardGetMaxGainL(TInt& aMaxGain);
|
sl@0
|
106 |
virtual void MardGetGainL(TInt& aGain);
|
sl@0
|
107 |
virtual void MardSetBalanceL(TInt aBalance);
|
sl@0
|
108 |
virtual void MardGetBalanceL(TInt& aBalance);
|
sl@0
|
109 |
|
sl@0
|
110 |
//from MMMFAudioPlayControllerCustomCommandImplementor
|
sl@0
|
111 |
virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd);
|
sl@0
|
112 |
virtual void MapcDeletePlaybackWindowL();
|
sl@0
|
113 |
virtual void MapcGetLoadingProgressL(TInt& aPercentageComplete);
|
sl@0
|
114 |
|
sl@0
|
115 |
//from MMMFAudioRecordControllerCustomCommandImplementor
|
sl@0
|
116 |
virtual void MarcGetRecordTimeAvailableL(TTimeIntervalMicroSeconds& aTime);
|
sl@0
|
117 |
virtual void MarcSetMaxDurationL(const TTimeIntervalMicroSeconds& aMaxDuration);
|
sl@0
|
118 |
virtual void MarcSetMaxFileSizeL(TInt aFileSize);
|
sl@0
|
119 |
virtual void MarcCropL(TBool aToEnd);
|
sl@0
|
120 |
virtual void MarcAddMetaDataEntryL(const CMMFMetaDataEntry& aNewEntry);
|
sl@0
|
121 |
virtual void MarcRemoveMetaDataEntryL(TInt aIndex);
|
sl@0
|
122 |
virtual void MarcReplaceMetaDataEntryL(TInt aIndex, const CMMFMetaDataEntry& aNewEntry);
|
sl@0
|
123 |
|
sl@0
|
124 |
//from MMMFAudioControllerCustomCommandImplementor
|
sl@0
|
125 |
virtual void MacSetSourceSampleRateL(TUint aSampleRate);
|
sl@0
|
126 |
virtual void MacSetSourceNumChannelsL(TUint aNumChannels);
|
sl@0
|
127 |
virtual void MacSetSourceFormatL(TUid aFormatUid);
|
sl@0
|
128 |
virtual void MacSetSinkSampleRateL(TUint aSampleRate);
|
sl@0
|
129 |
virtual void MacSetSinkNumChannelsL(TUint aNumChannels);
|
sl@0
|
130 |
virtual void MacSetSinkFormatL(TUid aFormatUid);
|
sl@0
|
131 |
virtual void MacSetCodecL(TFourCC aSourceDataType, TFourCC aSinkDataType);
|
sl@0
|
132 |
virtual void MacSetSourceBitRateL(TUint aBitRate);
|
sl@0
|
133 |
virtual void MacSetSourceDataTypeL(TFourCC aDataType);
|
sl@0
|
134 |
virtual void MacSetSinkBitRateL(TUint aRate);
|
sl@0
|
135 |
virtual void MacSetSinkDataTypeL(TFourCC aDataType);
|
sl@0
|
136 |
virtual void MacGetSourceSampleRateL(TUint& aRate);
|
sl@0
|
137 |
virtual void MacGetSourceBitRateL(TUint& aRate);
|
sl@0
|
138 |
virtual void MacGetSourceNumChannelsL(TUint& aNumChannels);
|
sl@0
|
139 |
virtual void MacGetSourceFormatL(TUid& aFormat);
|
sl@0
|
140 |
virtual void MacGetSourceDataTypeL(TFourCC& aDataType);
|
sl@0
|
141 |
virtual void MacGetSinkSampleRateL(TUint& aRate);
|
sl@0
|
142 |
virtual void MacGetSinkBitRateL(TUint& aRate);
|
sl@0
|
143 |
virtual void MacGetSinkNumChannelsL(TUint& aNumChannels);
|
sl@0
|
144 |
virtual void MacGetSinkFormatL(TUid& aFormat);
|
sl@0
|
145 |
virtual void MacGetSinkDataTypeL(TFourCC& aDataType);
|
sl@0
|
146 |
virtual void MacGetSupportedSourceSampleRatesL(RArray<TUint>& aSupportedRates);
|
sl@0
|
147 |
virtual void MacGetSupportedSourceBitRatesL(RArray<TUint>& aSupportedRates);
|
sl@0
|
148 |
virtual void MacGetSupportedSourceNumChannelsL(RArray<TUint>& aSupportedChannels);
|
sl@0
|
149 |
virtual void MacGetSupportedSourceDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
|
sl@0
|
150 |
virtual void MacGetSupportedSinkSampleRatesL(RArray<TUint>& aSupportedRates);
|
sl@0
|
151 |
virtual void MacGetSupportedSinkBitRatesL(RArray<TUint>& aSupportedRates);
|
sl@0
|
152 |
virtual void MacGetSupportedSinkNumChannelsL(RArray<TUint>& aSupportedChannels);
|
sl@0
|
153 |
virtual void MacGetSupportedSinkDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
|
sl@0
|
154 |
|
sl@0
|
155 |
public:
|
sl@0
|
156 |
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
TControllerState is an enumeration within the namespace CMMFAudioController
|
sl@0
|
159 |
The enumeration provides a set of control states:
|
sl@0
|
160 |
EStopped is the initial state the controller resides in after it has been loaded
|
sl@0
|
161 |
EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data
|
sl@0
|
162 |
EPlaying is the state the controller is in when it is streaming data
|
sl@0
|
163 |
*/
|
sl@0
|
164 |
enum TControllerState
|
sl@0
|
165 |
{
|
sl@0
|
166 |
EStopped,
|
sl@0
|
167 |
EPrimed,
|
sl@0
|
168 |
EPlaying
|
sl@0
|
169 |
};
|
sl@0
|
170 |
|
sl@0
|
171 |
protected:
|
sl@0
|
172 |
CMMFTestUseOldCodecAudioController();
|
sl@0
|
173 |
protected:
|
sl@0
|
174 |
void ConstructL();
|
sl@0
|
175 |
void NegotiateL();
|
sl@0
|
176 |
|
sl@0
|
177 |
void ConvertFromDevSoundCapsToSampleRatesL(const TMMFCapabilities& aDevSoundCaps,
|
sl@0
|
178 |
RArray<TUint>& aSampleRates);
|
sl@0
|
179 |
void ConvertFromDevSoundCapsToNumChannelsL(const TMMFCapabilities& aDevSoundCaps,
|
sl@0
|
180 |
RArray<TUint>& aNumChannels);
|
sl@0
|
181 |
void ConvertFromDevSoundCapsToDataTypesL(const TMMFCapabilities& aDevSoundCaps,
|
sl@0
|
182 |
RArray<TFourCC>& aDataTypes);
|
sl@0
|
183 |
void ConvertFromSampleRateToDevSoundCapsL(TUint aSampleRate, TMMFCapabilities& aDevSoundCaps);
|
sl@0
|
184 |
void ConvertFromNumChannelsToDevSoundCapsL(TUint aNumChannels, TMMFCapabilities& aDevSoundCaps);
|
sl@0
|
185 |
void ConvertFromDataTypeToDevSoundCapsL(TFourCC aDataType, TMMFCapabilities& aDevSoundCaps);
|
sl@0
|
186 |
|
sl@0
|
187 |
// state accessor functions
|
sl@0
|
188 |
TBool SetState( TControllerState aState );
|
sl@0
|
189 |
TControllerState State() const ;
|
sl@0
|
190 |
TBool IsValidStateTransition( TControllerState aState ) const;
|
sl@0
|
191 |
TBool Invariant() const;
|
sl@0
|
192 |
TBool IsValidState( TControllerState aState ) const ;
|
sl@0
|
193 |
TBool ResetPostCondition() const;
|
sl@0
|
194 |
TBool SinkFormatRequired( MDataSink& aDataSink) const;
|
sl@0
|
195 |
TBool SourceFormatRequired(MDataSource& aDataSource) const;
|
sl@0
|
196 |
void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const;
|
sl@0
|
197 |
void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const;
|
sl@0
|
198 |
|
sl@0
|
199 |
|
sl@0
|
200 |
//This method is used to assist testing of the audio controller
|
sl@0
|
201 |
virtual TBool IsUnderTest(){return EFalse;}
|
sl@0
|
202 |
|
sl@0
|
203 |
private:
|
sl@0
|
204 |
/**
|
sl@0
|
205 |
*
|
sl@0
|
206 |
* This class is required to ensure that CMMFTestUseOldCodecAudioController::PrimeL() runs synchronously
|
sl@0
|
207 |
* as in some configurations it needs to wait on DevSound initialisation. This class sits between the
|
sl@0
|
208 |
* DevSound interface and the actual real DevSound client, propagating all the function calls to it.
|
sl@0
|
209 |
* The only additional functionality it performs is to inform the CMMFTestUseOldCodecAudioController object
|
sl@0
|
210 |
* when DevSound initialisation is complete.
|
sl@0
|
211 |
*
|
sl@0
|
212 |
*/
|
sl@0
|
213 |
class TDevSoundEventHandler : public MDevSoundObserver
|
sl@0
|
214 |
{
|
sl@0
|
215 |
public:
|
sl@0
|
216 |
TDevSoundEventHandler();
|
sl@0
|
217 |
|
sl@0
|
218 |
void SetInterceptedDevSoundObserver(MDevSoundObserver* aObserver);
|
sl@0
|
219 |
void SetEventObserver(CMMFTestUseOldCodecAudioController* aObserver);
|
sl@0
|
220 |
|
sl@0
|
221 |
//from MDevSoundObserver
|
sl@0
|
222 |
virtual void InitializeComplete(TInt aError);
|
sl@0
|
223 |
virtual void ToneFinished(TInt aError);
|
sl@0
|
224 |
virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
|
sl@0
|
225 |
virtual void PlayError(TInt aError);
|
sl@0
|
226 |
virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
|
sl@0
|
227 |
virtual void RecordError(TInt aError);
|
sl@0
|
228 |
virtual void ConvertError(TInt aError);
|
sl@0
|
229 |
virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
|
sl@0
|
230 |
|
sl@0
|
231 |
private:
|
sl@0
|
232 |
MDevSoundObserver* iInterceptedDevSoundObserver; //Not owned
|
sl@0
|
233 |
CMMFTestUseOldCodecAudioController* iEventObserver; //Not owned
|
sl@0
|
234 |
};
|
sl@0
|
235 |
|
sl@0
|
236 |
private:
|
sl@0
|
237 |
MDataSource* iDataSource;
|
sl@0
|
238 |
MDataSink* iDataSink;
|
sl@0
|
239 |
CMMFDataPath* iDataPath;
|
sl@0
|
240 |
CMMFFormatDecode* iSourceFormat;
|
sl@0
|
241 |
CMMFFormatEncode* iSinkFormat;
|
sl@0
|
242 |
TMediaId iMediaId;
|
sl@0
|
243 |
TControllerState iState;
|
sl@0
|
244 |
TMMFPrioritySettings iPrioritySettings;
|
sl@0
|
245 |
TBool iSourceAndSinkAdded;
|
sl@0
|
246 |
|
sl@0
|
247 |
TBool iStoppingRecording;
|
sl@0
|
248 |
|
sl@0
|
249 |
CMMFMessageHolder* iStoppingMessage;
|
sl@0
|
250 |
TDevSoundEventHandler iDevSoundEventHandler;
|
sl@0
|
251 |
CActiveSchedulerWait* iWaitForAsyncService;
|
sl@0
|
252 |
};
|
sl@0
|
253 |
|
sl@0
|
254 |
|
sl@0
|
255 |
#endif
|