|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __MMF_AUDIOCONTROLLER_H__ |
|
17 #define __MMF_AUDIOCONTROLLER_H__ |
|
18 |
|
19 // Standard EPOC32 includes required by this header file |
|
20 #include <e32base.h> |
|
21 #include <e32std.h> |
|
22 #include <ecom/implementationproxy.h> |
|
23 |
|
24 // Public Media Server includes |
|
25 #include <mmf/common/mmfcontroller.h> |
|
26 #include <mmf/server/mmfdatasink.h> |
|
27 #include <mmf/server/mmfdatasource.h> |
|
28 |
|
29 #include <mmf/server/mmfdatapathproxy.h> |
|
30 #include <mmf/common/mmfaudio.h> |
|
31 #include <mmf/server/mmfaudiooutput.h> |
|
32 #include <mmf/server/mmfaudioinput.h> |
|
33 #include <mmf/common/mmfstandardcustomcommands.h> |
|
34 #include <mmf/common/mmfdrmcustomcommands.h> |
|
35 |
|
36 const TInt KOneSecondInMicroSeconds(1000000); |
|
37 |
|
38 //forward declaration |
|
39 class CMMFDataPath2; |
|
40 |
|
41 class CMMFMessageHolder : public CBase |
|
42 { |
|
43 public: |
|
44 static CMMFMessageHolder* NewL(TMMFMessage& aMessage) |
|
45 {return new(ELeave) CMMFMessageHolder(aMessage);} |
|
46 void Complete(TInt a) {iMessage.Complete(a);} |
|
47 private: |
|
48 CMMFMessageHolder(TMMFMessage& aMessage): CBase(), iMessage(aMessage) {} |
|
49 TMMFMessage iMessage; |
|
50 }; |
|
51 |
|
52 |
|
53 /** |
|
54 * |
|
55 * The public API for clients of the MMFAudioController |
|
56 * |
|
57 */ |
|
58 |
|
59 class CMMFAudioController : public CMMFController, |
|
60 public MAsyncEventHandler, |
|
61 public MMMFAudioPlayDeviceCustomCommandImplementor, |
|
62 public MMMFAudioRecordDeviceCustomCommandImplementor, |
|
63 public MMMFAudioPlayControllerCustomCommandImplementor, |
|
64 public MMMFAudioRecordControllerCustomCommandImplementor, |
|
65 public MMMFAudioControllerCustomCommandImplementor, |
|
66 public MMMFDRMCustomCommandImplementor, |
|
67 public MMMFResourceNotificationCustomCommandImplementor, |
|
68 public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor |
|
69 { |
|
70 public: |
|
71 static CMMFController* NewL(); |
|
72 virtual ~CMMFAudioController(); |
|
73 |
|
74 //implement CMMFController ecom plugin interface |
|
75 virtual void AddDataSourceL(MDataSource& aDataSource); |
|
76 virtual void AddDataSinkL(MDataSink& aDataSink); |
|
77 virtual void RemoveDataSourceL(MDataSource& aDataSource); |
|
78 virtual void RemoveDataSinkL(MDataSink& aDataSink); |
|
79 |
|
80 virtual void ResetL(); |
|
81 virtual void PrimeL(); |
|
82 virtual void PlayL(); |
|
83 virtual void PauseL(); |
|
84 virtual void StopL() {} //not required |
|
85 virtual void StopL(TMMFMessage& aMessage); |
|
86 |
|
87 virtual TTimeIntervalMicroSeconds PositionL() const; |
|
88 virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition); |
|
89 virtual TTimeIntervalMicroSeconds DurationL() const; |
|
90 virtual void CustomCommand(TMMFMessage& aMessage); |
|
91 virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings); |
|
92 virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries); |
|
93 virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex); |
|
94 |
|
95 //from MAsyncEventHandler |
|
96 virtual TInt SendEventToClient(const TMMFEvent& aEvent); |
|
97 |
|
98 //from MMMFAudioPlayDeviceCustomCommandImplementor |
|
99 virtual void MapdSetVolumeL(TInt aVolume); |
|
100 virtual void MapdGetMaxVolumeL(TInt& aMaxVolume); |
|
101 virtual void MapdGetVolumeL(TInt& aVolume); |
|
102 virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration); |
|
103 virtual void MapdSetBalanceL(TInt aBalance); |
|
104 virtual void MapdGetBalanceL(TInt& aBalance); |
|
105 |
|
106 //from MMMFAudioRecordDeviceCustomCommandImplementor |
|
107 virtual void MardSetGainL(TInt aGain); |
|
108 virtual void MardGetMaxGainL(TInt& aMaxGain); |
|
109 virtual void MardGetGainL(TInt& aGain); |
|
110 virtual void MardSetBalanceL(TInt aBalance); |
|
111 virtual void MardGetBalanceL(TInt& aBalance); |
|
112 |
|
113 //from MMMFAudioPlayControllerCustomCommandImplementor |
|
114 virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd); |
|
115 virtual void MapcDeletePlaybackWindowL(); |
|
116 virtual void MapcGetLoadingProgressL(TInt& aPercentageComplete); |
|
117 |
|
118 //from MMMFAudioRecordControllerCustomCommandImplementor |
|
119 virtual void MarcGetRecordTimeAvailableL(TTimeIntervalMicroSeconds& aTime); |
|
120 virtual void MarcSetMaxDurationL(const TTimeIntervalMicroSeconds& aMaxDuration); |
|
121 virtual void MarcSetMaxFileSizeL(TInt aFileSize); |
|
122 virtual void MarcCropL(TBool aToEnd); |
|
123 virtual void MarcAddMetaDataEntryL(const CMMFMetaDataEntry& aNewEntry); |
|
124 virtual void MarcRemoveMetaDataEntryL(TInt aIndex); |
|
125 virtual void MarcReplaceMetaDataEntryL(TInt aIndex, const CMMFMetaDataEntry& aNewEntry); |
|
126 |
|
127 //from MMMFAudioControllerCustomCommandImplementor |
|
128 virtual void MacSetSourceSampleRateL(TUint aSampleRate); |
|
129 virtual void MacSetSourceNumChannelsL(TUint aNumChannels); |
|
130 virtual void MacSetSourceFormatL(TUid aFormatUid); |
|
131 virtual void MacSetSinkSampleRateL(TUint aSampleRate); |
|
132 virtual void MacSetSinkNumChannelsL(TUint aNumChannels); |
|
133 virtual void MacSetSinkFormatL(TUid aFormatUid); |
|
134 virtual void MacSetCodecL(TFourCC aSourceDataType, TFourCC aSinkDataType); |
|
135 virtual void MacSetSourceBitRateL(TUint aBitRate); |
|
136 virtual void MacSetSourceDataTypeL(TFourCC aDataType); |
|
137 virtual void MacSetSinkBitRateL(TUint aRate); |
|
138 virtual void MacSetSinkDataTypeL(TFourCC aDataType); |
|
139 virtual void MacGetSourceSampleRateL(TUint& aRate); |
|
140 virtual void MacGetSourceBitRateL(TUint& aRate); |
|
141 virtual void MacGetSourceNumChannelsL(TUint& aNumChannels); |
|
142 virtual void MacGetSourceFormatL(TUid& aFormat); |
|
143 virtual void MacGetSourceDataTypeL(TFourCC& aDataType); |
|
144 virtual void MacGetSinkSampleRateL(TUint& aRate); |
|
145 virtual void MacGetSinkBitRateL(TUint& aRate); |
|
146 virtual void MacGetSinkNumChannelsL(TUint& aNumChannels); |
|
147 virtual void MacGetSinkFormatL(TUid& aFormat); |
|
148 virtual void MacGetSinkDataTypeL(TFourCC& aDataType); |
|
149 virtual void MacGetSupportedSourceSampleRatesL(RArray<TUint>& aSupportedRates); |
|
150 virtual void MacGetSupportedSourceBitRatesL(RArray<TUint>& aSupportedRates); |
|
151 virtual void MacGetSupportedSourceNumChannelsL(RArray<TUint>& aSupportedChannels); |
|
152 virtual void MacGetSupportedSourceDataTypesL(RArray<TFourCC>& aSupportedDataTypes); |
|
153 virtual void MacGetSupportedSinkSampleRatesL(RArray<TUint>& aSupportedRates); |
|
154 virtual void MacGetSupportedSinkBitRatesL(RArray<TUint>& aSupportedRates); |
|
155 virtual void MacGetSupportedSinkNumChannelsL(RArray<TUint>& aSupportedChannels); |
|
156 virtual void MacGetSupportedSinkDataTypesL(RArray<TFourCC>& aSupportedDataTypes); |
|
157 |
|
158 // resource notification |
|
159 virtual void MarnRegisterAsClientL(TUid aEventType,const TDesC8& aNotificationRegistrationData); |
|
160 virtual void MarnCancelRegisterAsClientL(TUid aEventType); |
|
161 virtual void MarnGetResourceNotificationDataL(TUid aEventType,TDes8& aNotificationData); |
|
162 virtual void MarnWillResumePlayL(); |
|
163 |
|
164 // from MMMFDRMCustomCommandImplementor |
|
165 virtual TInt MdcExecuteIntent(ContentAccess::TIntent aIntent); |
|
166 virtual TInt MdcEvaluateIntent(ContentAccess::TIntent aIntent); |
|
167 virtual TInt MdcDisableAutomaticIntent(TBool aDisableAutoIntent); |
|
168 virtual TInt MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue); |
|
169 |
|
170 //from MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor |
|
171 virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); |
|
172 public: |
|
173 |
|
174 /** |
|
175 TControllerState is an enumeration within the namespace CMMFAudioController |
|
176 The enumeration provides a set of control states: |
|
177 EStopped is the initial state the controller resides in after it has been loaded |
|
178 EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data |
|
179 EPlaying is the state the controller is in when it is streaming data |
|
180 */ |
|
181 enum TControllerState |
|
182 { |
|
183 EStopped, |
|
184 EPrimed, |
|
185 EPlaying |
|
186 }; |
|
187 |
|
188 protected: |
|
189 CMMFAudioController(); |
|
190 |
|
191 protected: |
|
192 void ConstructL(); |
|
193 void NegotiateL(); |
|
194 |
|
195 void ConvertFromDevSoundCapsToSampleRatesL(const TMMFCapabilities& aDevSoundCaps, |
|
196 RArray<TUint>& aSampleRates); |
|
197 void ConvertFromDevSoundCapsToNumChannelsL(const TMMFCapabilities& aDevSoundCaps, |
|
198 RArray<TUint>& aNumChannels); |
|
199 void ConvertFromDevSoundCapsToDataTypesL(const TMMFCapabilities& aDevSoundCaps, |
|
200 RArray<TFourCC>& aDataTypes); |
|
201 void ConvertFromSampleRateToDevSoundCapsL(TUint aSampleRate, TMMFCapabilities& aDevSoundCaps); |
|
202 void ConvertFromNumChannelsToDevSoundCapsL(TUint aNumChannels, TMMFCapabilities& aDevSoundCaps); |
|
203 void ConvertFromDataTypeToDevSoundCapsL(TFourCC aDataType, TMMFCapabilities& aDevSoundCaps); |
|
204 |
|
205 // state accessor functions |
|
206 TBool SetState( TControllerState aState ); |
|
207 TControllerState State() const ; |
|
208 TBool IsValidStateTransition( TControllerState aState ) const; |
|
209 TBool Invariant() const; |
|
210 TBool IsValidState( TControllerState aState ) const ; |
|
211 TBool ResetPostCondition() const; |
|
212 TBool SinkFormatRequired( MDataSink& aDataSink) const; |
|
213 TBool SourceFormatRequired(MDataSource& aDataSource) const; |
|
214 void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const; |
|
215 void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const; |
|
216 |
|
217 //This method is used to assist testing of the audio controller |
|
218 virtual TBool IsUnderTest(){return EFalse;} |
|
219 |
|
220 private: |
|
221 MDataSource* iDataSource; |
|
222 MDataSink* iDataSink; |
|
223 CMMFDataPath2* iDataPath; |
|
224 CMMFFormatDecode* iSourceFormat; |
|
225 CMMFFormatEncode* iSinkFormat; |
|
226 TMediaId iMediaId; |
|
227 TBool iDisableAutoIntent; |
|
228 TControllerState iState; |
|
229 TMMFPrioritySettings iPrioritySettings; |
|
230 TBool iSourceAndSinkAdded; |
|
231 TBool iStoppingRecording; |
|
232 CMMFMessageHolder* iStoppingMessage; |
|
233 TBool iIsPaused; // used to determine DRM command to send on PlayL() |
|
234 TBool iSourceFormatSupportsCustomInterfaces; |
|
235 TBool iRegisterARN;//CR |
|
236 TBool iIsPreemptionPause;//CR |
|
237 }; |
|
238 |
|
239 |
|
240 #endif |