|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file defines the file audio output class responsible for |
|
15 * sending output to the file system. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef FILEAUDIOOUTPUT_H |
|
21 #define FILEAUDIOOUTPUT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "AdvancedAudioOutput.h" |
|
25 #include "FileOutputAO.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMMFClip; |
|
29 |
|
30 // CLASS DECLARATIONS |
|
31 |
|
32 /** |
|
33 * Class containing audio output function implementation specific to file output |
|
34 * used for conversion. |
|
35 * |
|
36 * @lib FileAudioOutput.lib |
|
37 * @since 3.0 |
|
38 */ |
|
39 class CFileAudioOutput : public CAdvancedAudioOutput, |
|
40 public MFAOEventGeneratorObserver |
|
41 { |
|
42 public: // New functions |
|
43 |
|
44 /** |
|
45 * Class instantiation function. |
|
46 * @param aDataSink a data sink where converted data is sent |
|
47 * @param aPrioritySettings priority settings for devSound and policy |
|
48 * @param aObserver observer class that will handle all DevSoundAudioOutput |
|
49 * callbacks |
|
50 * @return pointer to the instance created |
|
51 */ |
|
52 IMPORT_C static CFileAudioOutput* NewL(MDataSink& aDataSink, |
|
53 const TMMFPrioritySettings& aPrioritySettings, |
|
54 MAdvancedAudioOutputObserver& aObserver); |
|
55 |
|
56 /** |
|
57 * Destructor function |
|
58 * @param none |
|
59 * @return none |
|
60 */ |
|
61 IMPORT_C virtual ~CFileAudioOutput(); |
|
62 |
|
63 /** |
|
64 * |
|
65 * Prepares DevSound Audio Input for playback (sets state to ready) |
|
66 * @since 2.1 |
|
67 * @param none |
|
68 * @return none |
|
69 */ |
|
70 IMPORT_C virtual void PrimeL(); |
|
71 |
|
72 /** |
|
73 * Handles request to pause playback. Sends pause command to DevSound. |
|
74 * @since 2.1 |
|
75 * @param none |
|
76 * @return none |
|
77 */ |
|
78 IMPORT_C virtual void PauseL(); |
|
79 |
|
80 /** |
|
81 * Handles request to start playback. Configures and initializes DevSound and |
|
82 * sends first buffer of audio data to DevSound, |
|
83 * @since 2.1 |
|
84 * @param aBuffer buffer to be played |
|
85 * aIndex index of the buffer to be played. |
|
86 * @return none |
|
87 */ |
|
88 IMPORT_C virtual void PlayL(TAny* aBuffer, TInt aIndex); |
|
89 |
|
90 /** |
|
91 * Handles request to stop playback. Sends stop command to DevSound. |
|
92 * @since 2.1 |
|
93 * @param none |
|
94 * @return none |
|
95 */ |
|
96 IMPORT_C virtual void StopL(TBool aStopDevsound=ETrue); |
|
97 |
|
98 /** |
|
99 * Handles request to get the maximum volume. The max volume is obtained from DevSound. |
|
100 * @since 2.1 |
|
101 * @param none |
|
102 * @return the maximum gain value |
|
103 */ |
|
104 IMPORT_C virtual TInt MaxVolumeL(); |
|
105 |
|
106 /** |
|
107 * Handles request to set the maximum volume. The new value is sent to DevSound. |
|
108 * @since 2.1 |
|
109 * @param aVolume new volume value |
|
110 * @return void |
|
111 */ |
|
112 IMPORT_C virtual void SetVolumeL(TInt aVolume); |
|
113 |
|
114 /** |
|
115 * Handles request to get the current volume. The current volume is obtained from DevSound. |
|
116 * @since 2.1 |
|
117 * @param void |
|
118 * @return the current volume value |
|
119 */ |
|
120 IMPORT_C virtual TInt VolumeL(); |
|
121 |
|
122 /** |
|
123 * Handles request to set priority. The given priority settings are sent to DevSound. |
|
124 * @since 2.1 |
|
125 * @param aPrioritySettings new priority settings |
|
126 * @return none |
|
127 */ |
|
128 IMPORT_C virtual void SetPrioritySettingsL(const TMMFPrioritySettings& aPrioritySettings); |
|
129 |
|
130 /** |
|
131 * Handles request to calculate current playback position in terms to micro seconds |
|
132 * @since 2.1 |
|
133 * @param none |
|
134 * @return Current position in microseconds |
|
135 */ |
|
136 IMPORT_C virtual TInt64 CalculateAudioOutputPositionL() const; |
|
137 |
|
138 /** |
|
139 * Handles request to get all configured sampling rates from DevSound. |
|
140 * This is a request for all sampling rates that DevSound is currently |
|
141 * configured with. |
|
142 * @since 2.1 |
|
143 * @param aRates array to hold the retrieved sampling rates |
|
144 * @return void |
|
145 */ |
|
146 IMPORT_C virtual void ConfigRatesL(RArray<TUint>& aRates); |
|
147 |
|
148 /** |
|
149 * Handles request to get all configured channels from DevSound. |
|
150 * This is a request for all channels that DevSound is currently |
|
151 * configured with. |
|
152 * @since 2.1 |
|
153 * @param aChannels array to hold the retrieved channels |
|
154 * @return void |
|
155 */ |
|
156 IMPORT_C virtual void ConfigChannelsL(RArray<TUint>& aChannels); |
|
157 |
|
158 /** |
|
159 * Handles request to get all configured data types (FourCC) from DevSound. |
|
160 * This is a request for all data types that DevSound is currently |
|
161 * configured with. |
|
162 * @since 2.1 |
|
163 * @param aDataTypes array to hold the retrieved data types |
|
164 * @return void |
|
165 */ |
|
166 IMPORT_C virtual void ConfigDataTypesL(RArray<TFourCC>& aDataTypes); |
|
167 |
|
168 /** |
|
169 * Handles request to get all capablities sampling rates from DevSound. |
|
170 * This contains all sampling rates DevSound is capable of supporting |
|
171 * @since 2.1 |
|
172 * @param aRates array to hold the retrieved sampling rates |
|
173 * @return void |
|
174 */ |
|
175 IMPORT_C virtual void CapabilitiesRatesL(RArray<TUint>& aRates); |
|
176 |
|
177 /** |
|
178 * Handles request to get all capabilities channels from DevSound. |
|
179 * This is a request for all channels that DevSound is capable of |
|
180 * supporting. |
|
181 * @since 2.1 |
|
182 * @param aChannels array to hold the retrieved channels |
|
183 * @return void |
|
184 */ |
|
185 IMPORT_C virtual void CapabilitiesChannelsL(RArray<TUint>& aChannels); |
|
186 |
|
187 /** |
|
188 * Handles request to get all capabilities data types (FourCC) from DevSound. |
|
189 * This is a request for all data types that DevSound is capable of |
|
190 * supporting. |
|
191 * @since 2.1 |
|
192 * @param aDataTypes array to hold the retrieved channels |
|
193 * @return void |
|
194 */ |
|
195 IMPORT_C virtual void CapabilitiesDataTypesL(RArray<TFourCC>& aDataTypes); |
|
196 |
|
197 /** |
|
198 * Handles request to set volume ramp to given duration. |
|
199 * @since 2.1 |
|
200 * @param aRampDuration ramp duration in microseconds |
|
201 * @return void |
|
202 */ |
|
203 IMPORT_C virtual void SetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration); |
|
204 |
|
205 /** |
|
206 * Handles request to set play balance in DevSound. |
|
207 * @since 2.1 |
|
208 * @param aLeftPercentage percentage for left channel |
|
209 * @param aRightPercentage percentage for right channel |
|
210 * @return void |
|
211 */ |
|
212 IMPORT_C virtual void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage); |
|
213 |
|
214 /** |
|
215 * Handles request to get play balance from DevSound. |
|
216 * @since 2.1 |
|
217 * @param aLeftPercentage percentage retrieved for left channel |
|
218 * @param aRightPercentage percentage retrieved for right channel |
|
219 * @return void |
|
220 */ |
|
221 IMPORT_C virtual void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage); |
|
222 |
|
223 /** |
|
224 * Handles request to configure DevSound with the given parameters. |
|
225 * @since 2.1 |
|
226 * @param aSampleRate recording sampling rate |
|
227 * @param aNumChannel required number of channels (mono/stereo indication) |
|
228 * @param aFourCC FourCC of required recording format |
|
229 * @param aConfigType UID for use in the codec ConfigureL function (this UID |
|
230 * is used to identify the command to the ConfigureL function |
|
231 * @param aCodecConfigData specific codec configuration data |
|
232 * |
|
233 * @return void |
|
234 * |
|
235 */ |
|
236 IMPORT_C virtual void ConfigureL(TUint aSampleRate, TUint aNumChannel, TFourCC aFourCC, |
|
237 const RArray<TInt>& aCodecConfigData); |
|
238 |
|
239 /** |
|
240 * Sets the Decoder instance to be used by the audio output. |
|
241 * @since 3.0 |
|
242 * @param aDecoder Decoder instance |
|
243 * @return void |
|
244 */ |
|
245 IMPORT_C virtual void SetDecoder(CAdvancedAudioDecoder* aDecoder); |
|
246 |
|
247 IMPORT_C virtual void Resume(TInt aBufferIndex = -1); |
|
248 |
|
249 IMPORT_C virtual void IsLoopPlayEnabled(const TBool aLoopPlayEnabled); |
|
250 |
|
251 IMPORT_C virtual void UnSetLastBuffer(const TBool aUnSetLastBuffer); |
|
252 |
|
253 IMPORT_C TBool IsDSStopped(); |
|
254 |
|
255 IMPORT_C virtual void SetDataSourceAdapter(CDataSourceAdapter* aDataSourceAdapter); |
|
256 |
|
257 /** |
|
258 * From MAdvancedAudioConverterObserver |
|
259 * Called by a CAdvancedAudioDecoder object when the specifed buffer is filled. |
|
260 * @since 3.0 |
|
261 * @param @param aFilledBuffer data buffer filled with converted data |
|
262 * @return void |
|
263 */ |
|
264 virtual void BufferFilled(CMMFBuffer* aFilledBuffer); |
|
265 |
|
266 /** |
|
267 * From MAdvancedAudioConverterObserver |
|
268 * Callback function from CAdvancedAudioDecoder when the specified buffer |
|
269 * needs to be refilled. |
|
270 * @since 3.0 |
|
271 * @param aEmptyBuffer an empty buffer to be refilled |
|
272 * @return - |
|
273 */ |
|
274 virtual void RefillBuffer(CMMFBuffer* aEmptyBuffer); |
|
275 |
|
276 /** |
|
277 * From MAdvancedAudioDecoderObserver |
|
278 * Callback function from CAdvancedAudioDecoder when the specified buffer |
|
279 * needs to be refilled. This indicates a shared buffer is to be refilled. |
|
280 * @since 3.2 |
|
281 * @param aEmptyBuffer an empty buffer to be refilled |
|
282 * @param aDoSynchronousRead if the operation should be perform Synchronuously |
|
283 * @return - |
|
284 */ |
|
285 //virtual void RefillBuffer(CMMFBuffer* aEmptyBuffer, TBool aDoSynchronousRead); |
|
286 |
|
287 /** |
|
288 * From MAdvancedAudioDecoderObserver |
|
289 * Callback function from CAdvancedAudioDecoder to handle specified event |
|
290 * @since 3.0 |
|
291 * @param aEvent The event to be handled |
|
292 * @return - |
|
293 */ |
|
294 virtual void SendEvent(const TMMFEvent& aEvent); |
|
295 |
|
296 /** |
|
297 * From MFAOEventGeneratorObserver |
|
298 * Callback function from CFAOEventGenerator when an IO error occurs. |
|
299 * @since 3.0 |
|
300 * @param aError a system-wide error code. |
|
301 * @return - |
|
302 */ |
|
303 virtual void IOError(TInt aError); |
|
304 |
|
305 private: |
|
306 |
|
307 /** |
|
308 * C++ default constructor. |
|
309 */ |
|
310 CFileAudioOutput(); |
|
311 |
|
312 /** |
|
313 * |
|
314 * Phase 2 of two-phase constructor |
|
315 * |
|
316 * @param aDataSink a data sink where converted data is sent |
|
317 * @param aPrioritySettings priority settings for devSound and policy |
|
318 * @param aObserver observer class that will handle all DevSoundAudioInput |
|
319 * callbacks |
|
320 * |
|
321 * @return void |
|
322 * |
|
323 */ |
|
324 void ConstructL(MDataSink& aDataSink, |
|
325 const TMMFPrioritySettings& aPrioritySettings, |
|
326 MAdvancedAudioOutputObserver& aObserver); |
|
327 |
|
328 /** |
|
329 * Builds configuration data for DevSound and codec |
|
330 * @since 3.0 |
|
331 * @return void |
|
332 */ |
|
333 void BuildConfigurationParameters(); |
|
334 |
|
335 |
|
336 /** |
|
337 * Issues a user panic with the given panic code |
|
338 * @param aPanicCode panic code |
|
339 * @return void |
|
340 */ |
|
341 void Panic(TInt aPanicCode) const; |
|
342 |
|
343 private: |
|
344 |
|
345 // FileAudioOutput states |
|
346 enum TState |
|
347 { |
|
348 EIdle=0, |
|
349 EPlaying, |
|
350 EPaused, |
|
351 EPreIdle |
|
352 }; |
|
353 |
|
354 private: |
|
355 |
|
356 // FileAudioOutput internal state |
|
357 TState iState; |
|
358 |
|
359 MDataSink* iDataSink; |
|
360 |
|
361 CMMFClip* iClip; |
|
362 |
|
363 // Buffer used when writting to sink |
|
364 CMMFDataBuffer* iSinkBuffer; |
|
365 |
|
366 // sampling rate from the source audio data |
|
367 TUint iSourceSampleRate; |
|
368 |
|
369 // number of channel from the source audio data |
|
370 TUint iSourceChannels; |
|
371 |
|
372 // FourCC from the source audio data |
|
373 TFourCC iSourceFourCC; |
|
374 |
|
375 // codec configuration data |
|
376 RArray<TInt> iCodecConfigData; |
|
377 |
|
378 // Write position for file sink |
|
379 TInt iSinkWritePosition; |
|
380 |
|
381 CFAOEventGenerator* iFAOEventGenerator; |
|
382 |
|
383 }; |
|
384 |
|
385 #endif |