|
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 class is the top base class in the Advanced Audio Controller |
|
15 * inheritance hierarchy. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CADVANCEDAUDIOCONTROLLER_H |
|
22 #define CADVANCEDAUDIOCONTROLLER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 #include <implementationproxy.h> |
|
28 #include <mmfcontroller.h> |
|
29 #include <mmfstandardcustomcommands.h> |
|
30 #include "MCustomInterfaceCustomCommandImplementor.h" |
|
31 |
|
32 class CCustomInterfaceBuilder; |
|
33 class CMMFDevSound; |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * This is the base class CAdvancedAudioController. |
|
38 * |
|
39 * @lib AdvancedAudioController.lib |
|
40 * @since 3.0 |
|
41 */ |
|
42 class CAdvancedAudioController : public CMMFController, |
|
43 public MAsyncEventHandler, |
|
44 public MMMFAudioControllerCustomCommandImplementor, |
|
45 public MDataSource, |
|
46 public MDataSink, |
|
47 public MCustomInterfaceCustomCommandImplementor |
|
48 { |
|
49 protected: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 IMPORT_C virtual ~CAdvancedAudioController(); |
|
55 |
|
56 /** |
|
57 * C++ default constructor. |
|
58 */ |
|
59 IMPORT_C CAdvancedAudioController(); |
|
60 |
|
61 virtual void ConstructL(); |
|
62 |
|
63 protected: // New functions |
|
64 |
|
65 /** |
|
66 * Creates a buffer of specified size. Buffer is pushed onto the cleanupstack. |
|
67 * @since 3.0 |
|
68 * @param aSize size of the buffer |
|
69 * @return pointer to the new buffer |
|
70 */ |
|
71 IMPORT_C CMMFDataBuffer* CreateSourceBufferOfSizeLC( TUint aSize ); |
|
72 |
|
73 /** |
|
74 * Resets all buffers in iSharedBuffers. |
|
75 * @since 3.0 |
|
76 * @param aNumOfBuffer number of buffers to be contained in iSharedBuffers |
|
77 * @param aBufferSize size of the buffers |
|
78 * @return void |
|
79 */ |
|
80 IMPORT_C void ResetSharedBuffersL( TInt aNumOfBuffer, TInt aBufferSize ); |
|
81 |
|
82 /** |
|
83 * Raises a system panic. |
|
84 * @since 3.0 |
|
85 * @param aPanicCode panic code |
|
86 * @return void |
|
87 */ |
|
88 IMPORT_C void Panic( TInt aPanicCode ); |
|
89 |
|
90 protected: // Functions from base classes (CMMFController) |
|
91 |
|
92 /** |
|
93 * From CMMFController |
|
94 * Handles creation of the data source. |
|
95 * @param aSource data source |
|
96 * @return void |
|
97 */ |
|
98 IMPORT_C virtual void AddDataSourceL( MDataSource& aSource ); |
|
99 |
|
100 /** |
|
101 * From CMMFController |
|
102 * Handles creation of the data output. |
|
103 * @param aSink data output |
|
104 * @return void |
|
105 */ |
|
106 IMPORT_C virtual void AddDataSinkL( MDataSink& aSink ); |
|
107 |
|
108 /** |
|
109 * From CMMFController |
|
110 * Deletes the data source. |
|
111 * @param aDataSource the address of this source must be same as |
|
112 * the existing datasource |
|
113 * @return void |
|
114 */ |
|
115 IMPORT_C virtual void RemoveDataSourceL( MDataSource& aDataSource ); |
|
116 |
|
117 /** |
|
118 * From CMMFController |
|
119 * Deletes the data output. |
|
120 * @param aDataSink the address of this output must be same as |
|
121 * the existing output |
|
122 * @return void |
|
123 */ |
|
124 IMPORT_C virtual void RemoveDataSinkL( MDataSink& aDataSink ); |
|
125 |
|
126 /** |
|
127 * From CMMFController |
|
128 * Resets the controller object and removes datasource/sink. |
|
129 * @param none |
|
130 * @return void |
|
131 */ |
|
132 IMPORT_C virtual void ResetL(); |
|
133 |
|
134 /** |
|
135 * From CMMFController |
|
136 * Prepares the resources for play. Source and sink must have been added before |
|
137 * calling PrimeL(). |
|
138 * @param none |
|
139 * @return void |
|
140 */ |
|
141 IMPORT_C virtual void PrimeL(); |
|
142 |
|
143 /** |
|
144 * From CMMFController |
|
145 * Initiates play. Leaves if PrimeL() has not been called. |
|
146 * @param none |
|
147 * @return void |
|
148 */ |
|
149 IMPORT_C virtual void PlayL(); |
|
150 |
|
151 /** |
|
152 * From CMMFController |
|
153 * Pauses the play. Leave with if PlayL() has not been called. |
|
154 * @param none |
|
155 * @return void |
|
156 */ |
|
157 IMPORT_C virtual void PauseL(); |
|
158 |
|
159 /** |
|
160 * From CMMFController |
|
161 * Stops the play. Leaves if controller state is already stopped. |
|
162 * @param none |
|
163 * @return void |
|
164 */ |
|
165 IMPORT_C virtual void StopL(); |
|
166 |
|
167 /** |
|
168 * From CMMFController |
|
169 * Returns the current position in microseconds. |
|
170 * @param none |
|
171 * @return current position in microseconds |
|
172 */ |
|
173 IMPORT_C virtual TTimeIntervalMicroSeconds PositionL() const; |
|
174 |
|
175 /** |
|
176 * From CMMFController |
|
177 * Sets the play position. |
|
178 * @param aPosition position in microseconds |
|
179 * @return void |
|
180 */ |
|
181 IMPORT_C virtual void SetPositionL( const TTimeIntervalMicroSeconds& aPosition ); |
|
182 |
|
183 /** |
|
184 * From CMMFController |
|
185 * Returns the duration of source (or the sink if the source is not defined) |
|
186 * If neither source nor sink are defined, it returns 0. |
|
187 * @param none |
|
188 * @return duration in microseconds |
|
189 */ |
|
190 IMPORT_C virtual TTimeIntervalMicroSeconds DurationL() const; |
|
191 |
|
192 /** |
|
193 * From CMMFController |
|
194 * Sets the source priority settings if a priority mechanism is required |
|
195 * to arbitrate between multiple clients trying to access the same resource. |
|
196 * Sets the priority for the source and the sink (provided they are defined). |
|
197 * @param aPrioritySettings priority settings |
|
198 * @return void |
|
199 */ |
|
200 IMPORT_C virtual void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings ); |
|
201 |
|
202 /** |
|
203 * From CMMFController |
|
204 * Retrieve the number of meta data entries in the clip. |
|
205 * @param aNumberOfEntries on return, the number of meta data entries |
|
206 * @return void |
|
207 */ |
|
208 IMPORT_C virtual void GetNumberOfMetaDataEntriesL( TInt& aNumberOfEntries ); |
|
209 |
|
210 /** |
|
211 * From CMMFController |
|
212 * Gets the specified meta data entry. |
|
213 * @param aIndex the zero based meta data entry index to retrieve |
|
214 * @return pointer to the meta data entry |
|
215 */ |
|
216 IMPORT_C virtual CMMFMetaDataEntry* GetMetaDataEntryL( TInt aIndex ); |
|
217 |
|
218 protected: // Functions from base classes (MMMFAudioControllerCustomCommandImplementor) |
|
219 |
|
220 /** |
|
221 * From MMMFAudioControllerCustomCommandImplementor |
|
222 * Sets the sample rate of the data source in samples/second. |
|
223 * @param aSampleRate sample rate, in samples/second. |
|
224 * @return void |
|
225 */ |
|
226 IMPORT_C virtual void MacSetSourceSampleRateL( TUint aSampleRate ); |
|
227 |
|
228 /** |
|
229 * From MMMFAudioControllerCustomCommandImplementor |
|
230 * Sets the bit rate of the data source in bits/second. |
|
231 * @param aBitRate bit rate, in bits/second. |
|
232 * @return void |
|
233 */ |
|
234 IMPORT_C virtual void MacSetSourceBitRateL( TUint aBitRate ); |
|
235 |
|
236 /** |
|
237 * From MMMFAudioControllerCustomCommandImplementor |
|
238 * Sets the number of channels in the data source. |
|
239 * For example, one channel for mono, two channels for stereo, etc. |
|
240 * @param aNumChannels number of channels |
|
241 * @return void |
|
242 */ |
|
243 IMPORT_C virtual void MacSetSourceNumChannelsL( TUint aNumChannels ); |
|
244 |
|
245 /** |
|
246 * From MMMFAudioControllerCustomCommandImplementor |
|
247 * Sets the format of the data source. |
|
248 * The UID corresponds to the UID of the CMMFFormat-derived ECOM plugin to be used. |
|
249 * @param aFormatUid format plugin to be used. |
|
250 * @return void |
|
251 */ |
|
252 IMPORT_C virtual void MacSetSourceFormatL( TUid aFormatUid ); |
|
253 |
|
254 /** |
|
255 * From MMMFAudioControllerCustomCommandImplementor |
|
256 * Sets the fourCC multimedia data type code of the source. |
|
257 * @param aDataType fourCC code. |
|
258 * @return void |
|
259 */ |
|
260 IMPORT_C virtual void MacSetSourceDataTypeL( TFourCC aDataType ); |
|
261 |
|
262 /** |
|
263 * From MMMFAudioControllerCustomCommandImplementor |
|
264 * Sets the sample rate of the data sink in samples/second. |
|
265 * @param aSampleRate The sample rate, in samples/second. |
|
266 * @return void |
|
267 */ |
|
268 IMPORT_C virtual void MacSetSinkSampleRateL( TUint aSampleRate ); |
|
269 |
|
270 /** |
|
271 * From MMMFAudioControllerCustomCommandImplementor |
|
272 * Sets the bit rate of the data sink in bits/second. |
|
273 * @param aRate bit rate, in bits/second. |
|
274 * @return void |
|
275 */ |
|
276 IMPORT_C virtual void MacSetSinkBitRateL( TUint aRate ); |
|
277 |
|
278 /** |
|
279 * From MMMFAudioControllerCustomCommandImplementor |
|
280 * Sets the number of channels in the data sink. |
|
281 * For example, one channel for mono, two channels for stereo, etc. |
|
282 * @param aNumChannels number of channels |
|
283 * @return void |
|
284 */ |
|
285 IMPORT_C virtual void MacSetSinkNumChannelsL( TUint aNumChannels ); |
|
286 |
|
287 /** |
|
288 * From MMMFAudioControllerCustomCommandImplementor |
|
289 * Sets the format of the data sink. |
|
290 * The UID corresponds to the UID of the CMMFFormat-derived ECOM plugin to be used. |
|
291 * @param aFormatUid format plugin to be used |
|
292 * @return void |
|
293 */ |
|
294 IMPORT_C virtual void MacSetSinkFormatL( TUid aFormatUid ); |
|
295 |
|
296 /** |
|
297 * From MMMFAudioControllerCustomCommandImplementor |
|
298 * Sets the fourCC multimedia data type code of the sink. |
|
299 * @param aDataType fourCC code |
|
300 * @return void |
|
301 */ |
|
302 IMPORT_C virtual void MacSetSinkDataTypeL( TFourCC aDataType ); |
|
303 |
|
304 /** |
|
305 * From MMMFAudioControllerCustomCommandImplementor |
|
306 * Sets the codec to be used. Useful when recording data. |
|
307 * @param aSourceDataType source data type |
|
308 * @param aSinkDataType sink data type |
|
309 * @return void |
|
310 */ |
|
311 IMPORT_C virtual void MacSetCodecL( TFourCC aSourceDataType, TFourCC aSinkDataType ); |
|
312 |
|
313 /** |
|
314 * From MMMFAudioControllerCustomCommandImplementor |
|
315 * Gets the sample rate of the data source in samples/second. |
|
316 * @param aRate sample rate, in samples/second |
|
317 * @return void |
|
318 */ |
|
319 IMPORT_C virtual void MacGetSourceSampleRateL( TUint& aRate ); |
|
320 |
|
321 /** |
|
322 * From MMMFAudioControllerCustomCommandImplementor |
|
323 * Gets the bit rate of the data source in bits/second. |
|
324 * @param aRate sample rate, in samples/second. |
|
325 * @return void |
|
326 */ |
|
327 IMPORT_C virtual void MacGetSourceBitRateL( TUint& aRate ); |
|
328 |
|
329 /** |
|
330 * From MMMFAudioControllerCustomCommandImplementor |
|
331 * Gets the number of channels in the data source. |
|
332 * @param aNumChannels number of channels |
|
333 * @return void |
|
334 */ |
|
335 IMPORT_C virtual void MacGetSourceNumChannelsL( TUint& aNumChannels ); |
|
336 |
|
337 /** |
|
338 * From MMMFAudioControllerCustomCommandImplementor |
|
339 * Gets the format of the data source. |
|
340 * The UID corresponds to the UID of the CMMFFormat-derived ECOM plugin being used. |
|
341 * @param aFormat format plugin being used |
|
342 * @return void |
|
343 */ |
|
344 IMPORT_C virtual void MacGetSourceFormatL( TUid& aFormat ); |
|
345 |
|
346 /** |
|
347 * From MMMFAudioControllerCustomCommandImplementor |
|
348 * Gets the fourCC code of the source. |
|
349 * @param aDataType fourCC code |
|
350 * @return void |
|
351 */ |
|
352 IMPORT_C virtual void MacGetSourceDataTypeL( TFourCC& aDataType ); |
|
353 |
|
354 /** |
|
355 * From MMMFAudioControllerCustomCommandImplementor |
|
356 * Gets the sample rate of the data sink in samples/second. |
|
357 * @param aRate sample rate, in samples/second |
|
358 * @return void |
|
359 */ |
|
360 IMPORT_C virtual void MacGetSinkSampleRateL( TUint& aRate ); |
|
361 |
|
362 /** |
|
363 * From MMMFAudioControllerCustomCommandImplementor |
|
364 * Gets the bit rate of the data sink in bits/second. |
|
365 * @param aRate bit rate, in bits/second. |
|
366 * @return void |
|
367 */ |
|
368 IMPORT_C virtual void MacGetSinkBitRateL( TUint& aRate ); |
|
369 |
|
370 /** |
|
371 * From MMMFAudioControllerCustomCommandImplementor |
|
372 * Gets the number of channels in the data sink. |
|
373 * @param aNumChannels number of channels. |
|
374 * @return void |
|
375 */ |
|
376 IMPORT_C virtual void MacGetSinkNumChannelsL( TUint& aNumChannels ); |
|
377 |
|
378 /** |
|
379 * From MMMFAudioControllerCustomCommandImplementor |
|
380 * Gets the format of the data sink. |
|
381 * The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used. |
|
382 * |
|
383 * @param aFormat format plugin being used. |
|
384 * @return void |
|
385 */ |
|
386 IMPORT_C virtual void MacGetSinkFormatL( TUid& aFormat ); |
|
387 |
|
388 /** |
|
389 * From MMMFAudioControllerCustomCommandImplementor |
|
390 * Gets the fourCC code of the sink. |
|
391 * @param aDataType fourCC code |
|
392 * @return void |
|
393 */ |
|
394 IMPORT_C virtual void MacGetSinkDataTypeL( TFourCC& aDataType ); |
|
395 |
|
396 /** |
|
397 * From MMMFAudioControllerCustomCommandImplementor |
|
398 * Gets the list of sample rates supported by the data source. |
|
399 * @param aSupportedRates supported rates |
|
400 * Warning: Existing objects in this array will be removed by this method. |
|
401 * @return void |
|
402 */ |
|
403 IMPORT_C virtual void MacGetSupportedSourceSampleRatesL( RArray<TUint>& aSupportedRates ); |
|
404 |
|
405 /** |
|
406 * From MMMFAudioControllerCustomCommandImplementor |
|
407 * Gets the list of bit rates supported by the data source. |
|
408 * @param aSupportedRates supported rates |
|
409 * Warning: Existing objects in this array will be removed by this method. |
|
410 * @return void |
|
411 */ |
|
412 IMPORT_C virtual void MacGetSupportedSourceBitRatesL( RArray<TUint>& aSupportedRates ); |
|
413 |
|
414 /** |
|
415 * From MMMFAudioControllerCustomCommandImplementor |
|
416 * Gets the list of channels supported by the data source (ie mono, stereo etc). |
|
417 * @param aSupportedChannels supported channels |
|
418 * Warning: Existing objects in this array will be removed by this method. |
|
419 * @return void |
|
420 */ |
|
421 IMPORT_C virtual void MacGetSupportedSourceNumChannelsL( RArray<TUint>& aSupportedChannels ); |
|
422 |
|
423 /** |
|
424 * From MMMFAudioControllerCustomCommandImplementor |
|
425 * Gets the list of fourCC codes supported by the data source. |
|
426 * @param aSupportedDataTypes supported data types |
|
427 * Warning: Existing objects in this array will be removed by this method. |
|
428 * @return void |
|
429 */ |
|
430 IMPORT_C virtual void MacGetSupportedSourceDataTypesL( RArray<TFourCC>& aSupportedDataTypes ); |
|
431 |
|
432 /** |
|
433 * From MMMFAudioControllerCustomCommandImplementor |
|
434 * Gets the list of sample rates supported by the data sink. |
|
435 * @param aSupportedRates supported rates |
|
436 * Warning: Existing objects in this array will be removed by this method. |
|
437 * @return void |
|
438 */ |
|
439 IMPORT_C virtual void MacGetSupportedSinkSampleRatesL( RArray<TUint>& aSupportedRates ); |
|
440 |
|
441 /** |
|
442 * From MMMFAudioControllerCustomCommandImplementor |
|
443 * Gets the list of bit rates supported by the data sink. |
|
444 * @param aSupportedRates supported rates |
|
445 * Warning: Existing objects in this array will be removed by this method. |
|
446 * @return void |
|
447 */ |
|
448 IMPORT_C virtual void MacGetSupportedSinkBitRatesL( RArray<TUint>& aSupportedRates ); |
|
449 |
|
450 /** |
|
451 * From MMMFAudioControllerCustomCommandImplementor |
|
452 * Gets the list of channels supported by the data sink (ie mono, stereo etc). |
|
453 * @param aSupportedChannels supported channels |
|
454 * Warning: Existing objects in this array will be removed by this method. |
|
455 * @return void |
|
456 */ |
|
457 IMPORT_C virtual void MacGetSupportedSinkNumChannelsL( RArray<TUint>& aSupportedChannels ); |
|
458 |
|
459 /** |
|
460 * From MMMFAudioControllerCustomCommandImplementor |
|
461 * Gets the list of fourCC codes supported by the data sink. |
|
462 * @param aSupportedDataTypes supported data types |
|
463 * Warning: Existing objects in this array will be removed by this method. |
|
464 * @return void |
|
465 */ |
|
466 IMPORT_C virtual void MacGetSupportedSinkDataTypesL( RArray<TFourCC>& aSupportedDataTypes ); |
|
467 |
|
468 protected: // Functions from base classes (MAsyncEventHandler) |
|
469 |
|
470 /** |
|
471 * From MAsyncEventHandler |
|
472 * Sends an event to the client. |
|
473 * @param aEvent event to send |
|
474 * @return error code. KErrNone if successful. |
|
475 */ |
|
476 IMPORT_C virtual TInt SendEventToClient( const TMMFEvent& aEvent ); |
|
477 |
|
478 protected: // Functions from base classes (MDataSource & MDataSink) |
|
479 |
|
480 // From MDataSource |
|
481 // The following functions are declared as pure virtual in MDataSource, therefore |
|
482 // declared here. However, they are not implemented. |
|
483 IMPORT_C virtual TFourCC SourceDataTypeCode( TMediaId aMediaId ); |
|
484 IMPORT_C virtual void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId ); |
|
485 IMPORT_C virtual void BufferEmptiedL( CMMFBuffer* aBuffer ); |
|
486 IMPORT_C virtual TBool CanCreateSourceBuffer(); |
|
487 IMPORT_C virtual CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, TBool& aReference ); |
|
488 IMPORT_C virtual void ConstructSourceL( const TDesC8& aInitData ); |
|
489 |
|
490 // From MDataSink |
|
491 // The following functions are declared as pure virtual in MDataSink, therefore |
|
492 // declared here. However, they are not implemented. |
|
493 IMPORT_C virtual TFourCC SinkDataTypeCode( TMediaId aMediaId ); |
|
494 IMPORT_C virtual void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId ); |
|
495 IMPORT_C virtual void BufferFilledL ( CMMFBuffer* aBuffer ); |
|
496 IMPORT_C virtual TBool CanCreateSinkBuffer(); |
|
497 IMPORT_C virtual CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId, TBool& aReference ); |
|
498 IMPORT_C virtual void ConstructSinkL( const TDesC8& aInitData ); |
|
499 |
|
500 protected: // Data |
|
501 |
|
502 /** |
|
503 * From MCustomInterfaceCustomCommandImplementor |
|
504 * Creates a Custom Interface Builder |
|
505 */ |
|
506 IMPORT_C virtual const TMMFMessageDestination& GetCustomInterfaceBuilderL(); |
|
507 |
|
508 protected: // Data |
|
509 // AdvancedAudioController panic codes |
|
510 enum TAdvancedAudioControllerPanics |
|
511 { |
|
512 EBadArgument, |
|
513 EBadState, |
|
514 EBadInvariant, |
|
515 EBadReset, |
|
516 EPostConditionViolation |
|
517 }; |
|
518 |
|
519 // Pointer to the data source |
|
520 MDataSource* iDataSource; |
|
521 // Pointer to the data sink |
|
522 MDataSink* iDataSink; |
|
523 |
|
524 // Priority settings |
|
525 TMMFPrioritySettings iPrioritySettings; |
|
526 // Sample rate |
|
527 TInt iSampleRate; |
|
528 // Bit rate |
|
529 TInt iBitRate; |
|
530 // Number of channels |
|
531 TInt iChannels; |
|
532 // Duration of the clip |
|
533 TInt64 iDuration; |
|
534 // Data type |
|
535 TFourCC iDataType; |
|
536 // Time position in microseconds |
|
537 TInt64 iTimePositionInMicroSecs; |
|
538 |
|
539 // Max number of shared buffer |
|
540 TInt iSharedBufferMaxNum; |
|
541 // Max buffer size |
|
542 TInt iSharedBufferMaxSize; |
|
543 // Array of shared buffers |
|
544 RPointerArray<CMMFDataBuffer> iSharedBuffers; |
|
545 // Current index within iSharedBuffers |
|
546 TInt iSharedBufferIndex; |
|
547 CMMFDevSound* iMMFDevSound; |
|
548 |
|
549 // Pointer to the custom interface builder |
|
550 CCustomInterfaceBuilder* iCustomInterfaceBuilder; |
|
551 }; |
|
552 |
|
553 #endif // CADVANCEDAUDIOCONTROLLER_H |
|
554 |
|
555 // End of File |