mmfenh/advancedaudiocontroller/audiocontrollerpluginsvariant/AdvancedAudioController/Inc/AdvancedAudioPlayController.h
changeset 0 71ca22bcf22a
child 12 2eb3b066cc7d
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     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 contains the base class from which specific audio
       
    15 *                play controllers are derived. This class encapsulates common
       
    16 *                behavior for all audio play controllers.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef CADVANCEDAUDIOPLAYCONTROLLER_H
       
    22 #define CADVANCEDAUDIOPLAYCONTROLLER_H
       
    23 
       
    24 // INCLUDES
       
    25 #include "AdvancedAudioController.h"
       
    26 #include "AdvancedAudioOutput.h"
       
    27 #include "AdvancedAudioUtility.h"   // for CAdvancedAudioUtility, MAdvancedAudioUtilityObserver
       
    28 #include <mmf/common/mmfdrmcustomcommands.h>
       
    29 #include <mmffile.h>
       
    30 #include <MultimediaDataSource.h>
       
    31 #include <StreamControlCustomCommandsParser.h>
       
    32 #include <StreamControlEvents.h>
       
    33 #include "DataSourceAdapter.h"
       
    34 //#include <s32file.h>
       
    35 
       
    36 // CONSTANTS
       
    37 const TUint KAAPSampleRate8000Hz        = 8000;
       
    38 const TUint KAAPSampleRate11025Hz       = 11025;
       
    39 const TUint KAAPSampleRate12000Hz       = 12000;
       
    40 const TUint KAAPSampleRate16000Hz       = 16000;
       
    41 const TUint KAAPSampleRate22050Hz       = 22050;
       
    42 const TUint KAAPSampleRate24000Hz       = 24000;
       
    43 const TUint KAAPSampleRate32000Hz       = 32000;
       
    44 const TUint KAAPSampleRate44100Hz       = 44100;
       
    45 const TUint KAAPSampleRate48000Hz       = 48000;
       
    46 const TUint KAAPSampleRate64000Hz       = 64000;
       
    47 const TUint KAAPSampleRate88200Hz       = 88200;
       
    48 const TUint KAAPSampleRate96000Hz       = 96000;
       
    49 
       
    50 
       
    51 enum TStopCondition
       
    52 	{
       
    53 	ECommanded,
       
    54 	EPlayComplete,
       
    55 	EErr
       
    56 	};
       
    57 			
       
    58 class MTrailingSilenceObserver
       
    59     {
       
    60 public:
       
    61     /**
       
    62     * From MTrailingSilenceObserver
       
    63     * * Call back function indicating that that trailing silence timer has expired during loop play
       
    64     *
       
    65     * @since 5.x
       
    66     * @param none
       
    67     * @return  void
       
    68     */
       
    69     virtual void TrailingSilenceTimerComplete() = 0;
       
    70     };
       
    71 
       
    72 // FORWARD DECLARATIONS
       
    73 class CAdvancedAudioResource;
       
    74 class CMultimediaDataSource;
       
    75 class CDataSourceAdapter;
       
    76 class CTrailingSilenceTimer;
       
    77 
       
    78 // CLASS DECLARATION
       
    79 /**
       
    80 *  This is the base class CAdvancedAudioPlayController.
       
    81 *  All specific audio play controllers derive from this class.
       
    82 *
       
    83 *  @lib AdvancedAudioController.lib
       
    84 *  @since 3.0
       
    85 */
       
    86 class CAdvancedAudioPlayController : public CAdvancedAudioController,
       
    87 									 public MAdvancedAudioOutputObserver,
       
    88 									 public MMMFAudioPlayControllerCustomCommandImplementor,
       
    89 									 public MAdvancedAudioUtilityObserver,
       
    90  									 public MMultimediaDataSourceObserver,
       
    91  									 public MStreamControlCustomCommandImplementor,
       
    92  									 public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor,
       
    93 #ifndef SYMBIAN_CAF_V2
       
    94 
       
    95                                      public MMMFAudioPlayDeviceCustomCommandImplementor
       
    96 #else
       
    97                                      public MMMFAudioPlayDeviceCustomCommandImplementor,
       
    98 							         public MMMFDRMCustomCommandImplementor,
       
    99 							         public MTrailingSilenceObserver
       
   100 #endif
       
   101     {
       
   102     protected:	// Constructors and destructor
       
   103 
       
   104 		/**
       
   105 		* Destructor
       
   106 		*/
       
   107 		IMPORT_C virtual ~CAdvancedAudioPlayController();
       
   108 
       
   109         /**
       
   110         * C++ default constructor.
       
   111         */
       
   112         IMPORT_C CAdvancedAudioPlayController();
       
   113 
       
   114         IMPORT_C virtual void ConstructL();
       
   115 
       
   116 	protected: // New functions
       
   117 
       
   118         /**
       
   119         * Format specific initialization for Data Source
       
   120         * @since 3.0
       
   121         * @return void
       
   122         */
       
   123         virtual void DoAddDataSourceL() = 0;
       
   124 
       
   125         /**
       
   126         * Format specific initialization for Data Sink
       
   127         * @since 3.0
       
   128         * @return void
       
   129         */
       
   130         virtual void DoAddDataSinkL() = 0;
       
   131         
       
   132         /**
       
   133         * Instantiates codec
       
   134         * @since 5.0
       
   135         * @return CAdvancedAudioDecoder*
       
   136         */
       
   137         virtual CAdvancedAudioDecoder* BuildDecoderL() = 0;
       
   138 
       
   139         /**
       
   140         * Format specific initialization for Data Sink
       
   141         * @since 5.0
       
   142         * @return void
       
   143         */
       
   144         IMPORT_C virtual void DoInitializeSinkL();
       
   145 
       
   146 		/**
       
   147         * Stops playback.
       
   148         * @since 3.0
       
   149         * @return void
       
   150         */
       
   151         IMPORT_C virtual void DoStopL(TInt aError);
       
   152         
       
   153         /**
       
   154         * Format specific header scanning
       
   155         * @since 3.0
       
   156         * @return void
       
   157         */
       
   158         IMPORT_C virtual void DoReadHeaderL(CMMFDataBuffer* aBuffer);
       
   159         
       
   160         /**
       
   161         * support functionality for SetPositionL
       
   162         * @since 3.2
       
   163         * @param aTimePos Position given by its time interval in micro secs
       
   164         * @return void
       
   165         */
       
   166         IMPORT_C virtual void DoSetPositionL(const TTimeIntervalMicroSeconds& aTimePos);
       
   167         
       
   168         /**
       
   169         * Fills source buffer from clip
       
   170         * @since 3.0
       
   171         * @return void
       
   172         */
       
   173         IMPORT_C virtual void InitSharedBuffersL();
       
   174         
       
   175         /**
       
   176         * Stops the source and sink
       
   177         * @since 3.0
       
   178         * @return void
       
   179         */
       
   180         IMPORT_C virtual void SourceSinkStopL();
       
   181         
       
   182         /**
       
   183         * Fills shared buffer from source
       
   184         * @since 3.0
       
   185         * @return void
       
   186         */
       
   187         IMPORT_C virtual void FillSharedBufferL(CMMFBuffer* aBuffer);
       
   188         
       
   189         /**
       
   190         * Find the index of buffer which contain a given position
       
   191         * @since 3.2
       
   192         * @param aPos the position to find
       
   193         * @return TInt the buffer index which recorded the position
       
   194         */
       
   195         IMPORT_C virtual TInt FindBufferFromPos(TUint aPos);
       
   196         
       
   197         /**
       
   198         * Prepare shared buffers and its current index
       
   199         * @since 3.2
       
   200         * @param aStreaming whether SharedBuffers contain streaming source
       
   201         * @return void
       
   202         */
       
   203         IMPORT_C virtual TInt SetPositionInSharedBuffers(TUint aTimeMs, TInt& aFoundPosition, TInt& aFoundTimeMs);
       
   204         
       
   205         /**
       
   206         * Update duration, should be called everytime source size changes
       
   207         * @since 3.2
       
   208         * @param aLimitInMilliSecond, the limit of difference of the new duration in millisec for a callback
       
   209         *        to occur, -1 would mean no callback
       
   210         * @return void
       
   211         */
       
   212         IMPORT_C virtual TInt UpdateDuration(TInt aLimitInMilliSecond = -1);
       
   213         IMPORT_C virtual TInt UpdateBitRate();
       
   214         
       
   215         /**
       
   216         * Handle AutoPaused event during SendEvent callback
       
   217         * @since 3.2
       
   218         * @return void
       
   219         */
       
   220         IMPORT_C virtual void HandleAutoPauseEvent();
       
   221         
       
   222         /**
       
   223         * Handle Preemption event during SendEvent callback
       
   224         * @since 3.2
       
   225         * @return void
       
   226         */
       
   227         IMPORT_C virtual void HandlePreemptionEvent(TInt aError);
       
   228         
       
   229         /**
       
   230         * Handle General event during SendEvent callback
       
   231         * @since 3.2
       
   232         * @return void
       
   233         */
       
   234         IMPORT_C virtual void HandleGeneralEvent(const TMMFEvent& aEvent);
       
   235         
       
   236         /**
       
   237 		* Set the playback window boundaries
       
   238 		* @since 3.2
       
   239 		* @param aStart start of the window, in microseconds
       
   240 		* @param aEnd end of the window, in microseconds
       
   241 		* @return void
       
   242 		*/
       
   243 		IMPORT_C virtual void SetPlaybackWindowBoundariesL(const TTimeIntervalMicroSeconds& aStart,
       
   244 			const TTimeIntervalMicroSeconds& aEnd);
       
   245 
       
   246         IMPORT_C virtual TInt GetCodecConfigData(RArray<TInt>& aCodecConfigData);
       
   247         
       
   248 		IMPORT_C void RefillPreceedingBuffersL();
       
   249 		
       
   250 
       
   251 
       
   252     protected:	// Functions from base classes (CMMFController)
       
   253 
       
   254         /**
       
   255         * From CMMFController
       
   256         * Handles creation of the data source
       
   257         *
       
   258         * @since 3.0
       
   259         * @param aSource data source
       
   260         * @return void
       
   261         */
       
   262         IMPORT_C virtual void AddDataSourceL(MDataSource& aSource);
       
   263 
       
   264         /**
       
   265         * From CMMFController
       
   266         * Handles creation of the data output
       
   267         *
       
   268         * @since 3.0
       
   269         * @param aSing data output
       
   270         * @return void
       
   271         */
       
   272         IMPORT_C virtual void AddDataSinkL(MDataSink& aSink);
       
   273 
       
   274         /**
       
   275         * From CMMFController
       
   276         * Deletes the data source
       
   277         *
       
   278         * @since 3.0
       
   279         * @param aDataSource the address of this source must be same as
       
   280         *                    the existing datasource
       
   281         * @return void
       
   282         */
       
   283         IMPORT_C virtual void RemoveDataSourceL(MDataSource& aDataSource);
       
   284 
       
   285         /**
       
   286         * From CMMFController
       
   287         * Deletes the data output
       
   288         *
       
   289         * @since 3.0
       
   290         * @param aDataSource the address of this output must be same as
       
   291         *                    the existing output
       
   292         * @return void
       
   293         */
       
   294         IMPORT_C virtual void RemoveDataSinkL(MDataSink& aDataSink);
       
   295 
       
   296         /**
       
   297         * From CMMFController
       
   298         * Resets the controller object, removes datasource/sink, resets the datapath.
       
   299         *
       
   300         * @since 3.0
       
   301         * @param none
       
   302         * @return void
       
   303         */
       
   304         IMPORT_C virtual void ResetL();
       
   305 
       
   306         /**
       
   307         * From CMMFController
       
   308         * Prepares the resources for play. Source and sink must have been added before
       
   309         * calling PrimeL().
       
   310         *
       
   311         * @since 3.0
       
   312         * @param none
       
   313         * @return void
       
   314         */
       
   315         IMPORT_C virtual void PrimeL();
       
   316 
       
   317         /**
       
   318         * From CMMFController
       
   319         * Will leave with if PrimeL() has not been called.
       
   320         *
       
   321         * @since 3.0
       
   322         * @param none
       
   323         * @return void
       
   324         */
       
   325         IMPORT_C virtual void PlayL();
       
   326 
       
   327         /**
       
   328         * From CMMFController
       
   329         * Will leave with if Play() has not been called.
       
   330         *
       
   331         * @since 3.0
       
   332         * @param none
       
   333         * @return void
       
   334         */
       
   335         IMPORT_C virtual void PauseL();
       
   336 
       
   337         /**
       
   338         * From CMMFController
       
   339         * Will leave if controller state is already stopped.
       
   340         *
       
   341         * @since 3.0
       
   342         * @param none
       
   343         * @return void
       
   344         */
       
   345         IMPORT_C virtual void StopL();
       
   346 
       
   347         /**
       
   348         * From CMMFController
       
   349         * Calculates the current position in microseconds.
       
   350         *
       
   351         * @since 3.0
       
   352         * @param none
       
   353         * @return TTimeIntervalMicroSeconds The current position in microseconds.
       
   354         */
       
   355         IMPORT_C virtual TTimeIntervalMicroSeconds PositionL() const;
       
   356         
       
   357         /**
       
   358         * From CMMFController
       
   359         * Sets the play position.
       
   360         *
       
   361         * @since 3.0
       
   362         * @param aTimePos Position given by its time interval in micro secs
       
   363         * @return void
       
   364         */
       
   365         IMPORT_C virtual void SetPositionL(const TTimeIntervalMicroSeconds& aTimePos);
       
   366         
       
   367         /**
       
   368         * From CMMFController
       
   369         * Method to set the source priority settings if
       
   370         * a priority mechanism is required to arbitrate between multiple clients
       
   371         * trying to access the same resource. Sets the priority for the source
       
   372         * and the sink (provided they are defined).
       
   373         *
       
   374         * @since 3.0
       
   375         * @param aPrioritySettings
       
   376         * @return void
       
   377         */
       
   378         IMPORT_C virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
       
   379 
       
   380 		/**
       
   381 		* From CMMFController
       
   382 		* Gets the number of meta data entries in the clip.
       
   383         *
       
   384         * @since 3.0
       
   385         * @param aNumberOfEntries the number of meta data entries
       
   386 		* @return void
       
   387 		*/
       
   388 		IMPORT_C virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries);
       
   389 
       
   390 		/**
       
   391 		* From CMMFController
       
   392 		* Gets the specified meta data entry.
       
   393         *
       
   394         * @since 3.0
       
   395         * @param aIndex zero based meta data entry index to retrieve.
       
   396 		* @return pointer to the meta data entry.
       
   397 		*/
       
   398 		IMPORT_C virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex);
       
   399 
       
   400 		/**
       
   401         * From CMMFController
       
   402 		* Returns the duration of source (or the sink if the source is not defined)
       
   403 		* If neither source nor sink are defined, it returns 0.
       
   404 		* @param none
       
   405 		* @return duration in microseconds
       
   406 		*/
       
   407 		IMPORT_C virtual TTimeIntervalMicroSeconds DurationL() const;
       
   408 
       
   409     protected:  // functions from base classes (CAdvancedAudioController)
       
   410 
       
   411         /**
       
   412         * Send StateChanged vent to client
       
   413         * @since 3.2
       
   414         * @return error code. KErrNone if successful
       
   415         */
       
   416         IMPORT_C virtual TInt SendEventToClient(const TMMFEvent& aEvent);
       
   417 
       
   418     protected:	// Functions from base classes (MMMFAudioControllerCustomCommandImplementor)
       
   419 
       
   420 		/**
       
   421 		* From MMMFAudioControllerCustomCommandImplementor
       
   422 		* Sets the sample rate of the data sink in samples/second.
       
   423 		* @param aSampleRate The sample rate, in samples/second.
       
   424 		* @return void
       
   425 		*/
       
   426 		IMPORT_C virtual void MacSetSinkSampleRateL(TUint aSampleRate);
       
   427 
       
   428 		/**
       
   429 		* From MMMFAudioControllerCustomCommandImplementor
       
   430 		* Sets the bit rate of the data sink in bits/second.
       
   431 		* @param aRate bit rate, in bits/second.
       
   432 		* @return void
       
   433 		*/
       
   434 		IMPORT_C virtual void MacSetSinkBitRateL(TUint aRate);
       
   435 
       
   436 		/**
       
   437 		* From MMMFAudioControllerCustomCommandImplementor
       
   438 		* Sets the number of channels in the data sink.
       
   439 		* For example, one channel for mono, two channels for stereo, etc.
       
   440 		* @param aNumChannels number of channels
       
   441 		* @return void
       
   442 		*/
       
   443 		IMPORT_C virtual void MacSetSinkNumChannelsL(TUint aNumChannels);
       
   444 
       
   445 		/**
       
   446 		* From MMMFAudioControllerCustomCommandImplementor
       
   447 		* Sets the format of the data sink.
       
   448 		* The UID corresponds to the UID of the CMMFFormat-derived ECOM plugin to be used.
       
   449 		* @param aFormatUid format plugin to be used
       
   450 		* @return void
       
   451 		*/
       
   452         IMPORT_C virtual void MacSetSinkFormatL(TUid aFormatUid);
       
   453 
       
   454 		/**
       
   455 		* From MMMFAudioControllerCustomCommandImplementor
       
   456 		* Sets the fourCC multimedia data type code of the sink.
       
   457 		* @param aDataType fourCC code
       
   458 		* @return void
       
   459 		*/
       
   460 		IMPORT_C virtual void MacSetSinkDataTypeL(TFourCC aDataType);
       
   461 
       
   462 		/**
       
   463 		* From MMMFAudioControllerCustomCommandImplementor
       
   464 		* Gets the sample rate of the data source in samples/second.
       
   465 		* @param aRate source sample rate, in samples/second
       
   466 		* @return void
       
   467 		*/
       
   468 		IMPORT_C virtual void MacGetSourceSampleRateL(TUint& aRate);
       
   469 
       
   470 		/**
       
   471 		* From MMMFAudioControllerCustomCommandImplementor
       
   472 		* Gets the bit rate of the data source in bits/second.
       
   473 		* @param aRate source bit rate, in samples/second
       
   474 		* @return void
       
   475 		*/
       
   476 		IMPORT_C virtual void MacGetSourceBitRateL(TUint& aRate);
       
   477 
       
   478 		/**
       
   479 		* From MMMFAudioControllerCustomCommandImplementor
       
   480 		* Gets the number of channels in the data source.
       
   481 		* @param aNumChannels number of channels
       
   482 		* @return void
       
   483 		*/
       
   484 		IMPORT_C virtual void MacGetSourceNumChannelsL(TUint& aNumChannels);
       
   485 
       
   486 		/**
       
   487 		* From MMMFAudioControllerCustomCommandImplementor
       
   488 		* Gets the format of the data source.
       
   489 		* The UID corresponds to the UID of the CMMFFormat-derived ECOM plugin being used.
       
   490 		* @param aFormat format plugin being used
       
   491 		* @return void
       
   492 		*/
       
   493 		IMPORT_C virtual void MacGetSourceFormatL(TUid& aFormat);
       
   494 
       
   495 		/**
       
   496 		* From MMMFAudioControllerCustomCommandImplementor
       
   497 		* Gets the fourCC code of the source.
       
   498 		* @param aDataType fourCC code
       
   499 		* @return void
       
   500 		*/
       
   501 		IMPORT_C virtual void MacGetSourceDataTypeL(TFourCC& aDataType);
       
   502 
       
   503 		/**
       
   504 		* From MMMFAudioControllerCustomCommandImplementor
       
   505 		* Gets the sample rate of the data sink in samples/second.
       
   506 		* @param aRate sample rate, in samples/second
       
   507 		* @return void
       
   508 		*/
       
   509 		IMPORT_C virtual void MacGetSinkSampleRateL(TUint& aRate);
       
   510 
       
   511 		/**
       
   512 		* From MMMFAudioControllerCustomCommandImplementor
       
   513 		* Gets the bit rate of the data sink in bits/second.
       
   514 		* @param aRate bit rate, in bits/second.
       
   515 		* @return void
       
   516 		*/
       
   517 		IMPORT_C virtual void MacGetSinkBitRateL(TUint& aRate);
       
   518 
       
   519 		/**
       
   520 		* From MMMFAudioControllerCustomCommandImplementor
       
   521 		* Gets the number of channels in the data sink.
       
   522 		* @param aNumChannels number of channels.
       
   523 		* @return void
       
   524 		*/
       
   525 		IMPORT_C virtual void MacGetSinkNumChannelsL(TUint& aNumChannels);
       
   526 
       
   527         /**
       
   528 		* From MMMFAudioControllerCustomCommandImplementor
       
   529 		* Gets the format of the data sink.
       
   530 		* The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used.
       
   531 		*
       
   532 		* @param aFormat format plugin being used.
       
   533 		* @return void
       
   534 		*/
       
   535 		IMPORT_C virtual void MacGetSinkFormatL(TUid& aFormat);
       
   536 
       
   537 		/**
       
   538 		* From MMMFAudioControllerCustomCommandImplementor
       
   539 		* Gets the fourCC code of the sink.
       
   540 		* @param aDataType fourCC code.
       
   541 		* @return void
       
   542 		*/
       
   543 		IMPORT_C virtual void MacGetSinkDataTypeL(TFourCC& aDataType);
       
   544 
       
   545 		/**
       
   546 		* From MMMFAudioControllerCustomCommandImplementor
       
   547 		* Gets the list of sample rates supported by the data source.
       
   548 		* @param aSupportedRates supported rates.
       
   549 		*        Warning: Existing objects in this array will be removed by this method.
       
   550 		* @return void
       
   551 		*/
       
   552 		IMPORT_C virtual void MacGetSupportedSourceSampleRatesL(RArray<TUint>& aSupportedRates);
       
   553 
       
   554 		/**
       
   555 		* From MMMFAudioControllerCustomCommandImplementor
       
   556 		* Gets the list of bit rates supported by the data source.
       
   557 		* @param aSupportedRates supported rates.
       
   558 		*        Warning: Existing objects in this array will be removed by this method.
       
   559 		* @return void
       
   560 		*/
       
   561 		IMPORT_C virtual void MacGetSupportedSourceBitRatesL(RArray<TUint>& aSupportedRates);
       
   562 
       
   563 		/**
       
   564 		* From MMMFAudioControllerCustomCommandImplementor
       
   565 		* Gets the list of channels supported by the data source L(ie mono, stereo etc).
       
   566 		* @param aSupportedChannels supported channels.
       
   567 		*        Warning: Existing objects in this array will be removed by this method.
       
   568 		* @return void
       
   569 		*/
       
   570 		IMPORT_C virtual void MacGetSupportedSourceNumChannelsL(RArray<TUint>& aSupportedChannels);
       
   571 
       
   572 		/**
       
   573 		* From MMMFAudioControllerCustomCommandImplementor
       
   574 		* Gets the list of fourCC codes supported by the data source.
       
   575 		* @param aSupportedDataTypes supported data types.
       
   576 		*        Warning: Existing objects in this array will be removed by this method.
       
   577 		* @return void
       
   578 		*/
       
   579 		IMPORT_C virtual void MacGetSupportedSourceDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
       
   580 
       
   581 		/**
       
   582 		* From MMMFAudioControllerCustomCommandImplementor
       
   583 		* Gets the list of sample rates supported by the data sink.
       
   584 		* @param aSupportedRates supported rates.
       
   585 		*        Warning: Existing objects in this array will be removed by this method.
       
   586 		* @return void
       
   587 		*/
       
   588 		IMPORT_C virtual void MacGetSupportedSinkSampleRatesL(RArray<TUint>& aSupportedRates);
       
   589 
       
   590 		/**
       
   591 		* From MMMFAudioControllerCustomCommandImplementor
       
   592 		* Gets the list of bit rates supported by the data sink.
       
   593 		* @param aSupportedRates supported rates.
       
   594 		*        Warning: Existing objects in this array will be removed by this method.
       
   595 		* @return void
       
   596 		*/
       
   597 		IMPORT_C virtual void MacGetSupportedSinkBitRatesL(RArray<TUint>& aSupportedRates);
       
   598 
       
   599 		/**
       
   600 		* From MMMFAudioControllerCustomCommandImplementor
       
   601 		* Gets the list of channels supported by the data sink L(ie mono, stereo etc).
       
   602 		* @param aSupportedChannels supported channels.
       
   603 		*        Warning: Existing objects in this array will be removed by this method.
       
   604 		* @return void
       
   605 		*/
       
   606 		IMPORT_C virtual void MacGetSupportedSinkNumChannelsL(RArray<TUint>& aSupportedChannels);
       
   607 
       
   608 		/**
       
   609 		* From MMMFAudioControllerCustomCommandImplementor
       
   610 		* Gets the list of fourCC codes supported by the data sink.
       
   611 		* @param aSupportedDataTypes supported data types.
       
   612 		*        Warning: Existing objects in this array will be removed by this method.
       
   613 		* @return void
       
   614 		*/
       
   615 		IMPORT_C virtual void MacGetSupportedSinkDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
       
   616 
       
   617     protected:	// Functions from base classes (MMMFAudioPlayControllerCustomCommandImplementor)
       
   618 
       
   619 		/**
       
   620 		* From MMMFAudioPlayControllerCustomCommandImplementor
       
   621 		* Sets a playback window. The controller will start playing from the start of the window,
       
   622 		* and finish playing at the end of the window.
       
   623 		* @param aStart start of the window, in microseconds
       
   624 		* @param aEnd end of the window, in microseconds
       
   625 		* @return void
       
   626 		*/
       
   627 		IMPORT_C virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& aStart,
       
   628 			const TTimeIntervalMicroSeconds& aEnd);
       
   629 
       
   630 		/**
       
   631 		* From MMMFAudioPlayControllerCustomCommandImplementor
       
   632 		* Removes a previously defined playback window.
       
   633 		* @param none
       
   634 		* @return void
       
   635 		*/
       
   636 		IMPORT_C virtual void MapcDeletePlaybackWindowL();
       
   637 
       
   638 		/**
       
   639 		* From MMMFAudioPlayControllerCustomCommandImplementor
       
   640 		* Gets the completion status of loading/rebuffering the current audio clip
       
   641 		* @param aPercentageComplete status of loading as a percentage completed
       
   642 		* @return void
       
   643 		*/
       
   644 		IMPORT_C virtual void MapcGetLoadingProgressL(TInt& aPercentageComplete);
       
   645 
       
   646     protected:	// Functions from base classes (MMMFAudioPlayDeviceCustomCommandImplementor)
       
   647 
       
   648 		/**
       
   649 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   650 		* Sets the volume of the sound device.
       
   651 		* @param aVolume new volume
       
   652 		* @return void
       
   653 		*/
       
   654 		IMPORT_C virtual void MapdSetVolumeL(TInt aVolume);
       
   655 
       
   656 		/**
       
   657 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   658 		* Gets the max volume of the sound device
       
   659 		* @param aMaxVolume contains the max volume on return
       
   660 		* @return void
       
   661 		*/
       
   662 		IMPORT_C virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
       
   663 
       
   664 		/**
       
   665 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   666 		* Gets the current playback volume
       
   667 		* @param aVolume contains the current volume on return
       
   668 		* @return void
       
   669 		*/
       
   670 		IMPORT_C virtual void MapdGetVolumeL(TInt& aVolume);
       
   671 
       
   672 		/**
       
   673 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   674 		* Sets a volume ramp.
       
   675 		* This will cause the sound device to start playing with zero volume,
       
   676 		* increasing the volume over aRampDuration microseconds.
       
   677 		* The volume ramp can be removed by setting the ramp duration to zero.
       
   678 		* @param aRampDuration duration over which the volume is to be increased,
       
   679 		*					in microseconds
       
   680 		* @return void
       
   681 		*/
       
   682 		IMPORT_C virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
       
   683 
       
   684 		/**
       
   685 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   686 		* Sets the balance between the left and right stereo audio channels.
       
   687 		* @param aBalance Use a value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.
       
   688 		*                 Center balance can be restored by using KMMFBalanceCenter.
       
   689 		* @return void
       
   690 		*/
       
   691 		IMPORT_C virtual void MapdSetBalanceL(TInt aBalance);
       
   692 
       
   693 		/**
       
   694 		* From MMMFAudioPlayDeviceCustomCommandImplementor
       
   695 		* Retrieves the balance between the left and right stereo audio channels.
       
   696 		*
       
   697 		* @param aBalande The current balance, filled in by the controller.
       
   698 		* @return void
       
   699 		*/
       
   700 		IMPORT_C virtual void MapdGetBalanceL(TInt& aBalance);
       
   701 
       
   702     protected:  // Functions from base classes (MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor)
       
   703         
       
   704         /**
       
   705         * From MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
       
   706         * Sets the number of times the playback of the audio file is to be repeated and the trailing silence value in ms.
       
   707         *
       
   708         * @param aRepeatNumberOfTimes Number of times playback is to be repeated .
       
   709         * @param aTrailingSilence Period of silence to follow each playback of the audio file
       
   710         * @return KErrNone if success, KErrNotSupported and System-wide errors otherwise.
       
   711         */
       
   712         IMPORT_C virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
       
   713 
       
   714     protected: // Functions from base classes (MDataSink)
       
   715 
       
   716         /**
       
   717         * From MDataSink
       
   718         * Callback for ReadBufferL()
       
   719         *
       
   720         * @since 3.0
       
   721         * @param    aBuffer The filled buffer
       
   722         * @return    void
       
   723         */
       
   724         IMPORT_C virtual void BufferFilledL(CMMFBuffer* aBuffer);
       
   725 
       
   726     protected: // Functions from base classes (MAdvancedAudioOutputObserver)
       
   727 
       
   728         /**
       
   729         * From MAdvancedAudioOutputObserver
       
   730         * Request to refill the buffer
       
   731         *
       
   732         * @since 3.0
       
   733         * @param    The buffer to be filled
       
   734         * @return   TInt
       
   735         */
       
   736         IMPORT_C virtual TInt RefillBuffer(CMMFBuffer* refillBuffer);
       
   737 
       
   738         /**
       
   739         * From MAdvancedAudioOutputObserver
       
   740         * Handles playback complete
       
   741         *
       
   742         * @since 3.0
       
   743         * @param
       
   744         * @return   void
       
   745         */
       
   746         IMPORT_C virtual void PlaybackComplete();
       
   747 
       
   748         /**
       
   749         * From MAdvancedAudioOutputObserver
       
   750         * Sends event to client;
       
   751         *
       
   752         * @since 3.0
       
   753         * @param aEvent event to propagate to client
       
   754         * @return   void
       
   755         */
       
   756         IMPORT_C virtual void SendEvent(const TMMFEvent& aEvent);
       
   757 
       
   758         /**
       
   759         * From MAdvancedAudioOutputObserver
       
   760         * Callback when lastbuffer is sent to DevSound during loop play by setting the Last Buffer flag to EFalse
       
   761         *
       
   762         * @since 5.x
       
   763         * @param  none
       
   764         * @return   void
       
   765         */
       
   766         IMPORT_C virtual void LastBufferSent();
       
   767 
       
   768     protected:  // from MAdvancedAudioUtilityObserver
       
   769         
       
   770         /**
       
   771         * Noticifaction of BitRate Changes, occurs when bitrate changes and EnableBitRateChangedEventL is enabled
       
   772         * @since 3.2
       
   773         * @return void
       
   774         */
       
   775         IMPORT_C virtual void BitRateChanged();
       
   776         IMPORT_C virtual void SeekPositionReached(TUint aTimeMs);
       
   777 		IMPORT_C virtual void PlayWindowEndPositionReached();
       
   778 		
       
   779     protected:  // functions from MMultimediaDataSourceObserver
       
   780 
       
   781         IMPORT_C virtual void BufferFilled(CMMFBuffer* aBuffer);
       
   782         IMPORT_C virtual void Event(TUid aEvent);
       
   783         IMPORT_C virtual TInt GetBitRate(TUint& aBitRate);
       
   784         
       
   785     protected:  // functions from MStreamControlCustomCommandImplementor
       
   786 
       
   787         IMPORT_C virtual TInt MscEnableEvents(TBool aEnable);
       
   788         IMPORT_C virtual TInt MscGetSeekingSupported(TBool& aSupported);
       
   789         IMPORT_C virtual TInt MscGetRandomSeekingSupported(TBool& aSupported);
       
   790         
       
   791     private:
       
   792 
       
   793         /**
       
   794         * Calculates the percentage of balance in left and right channels.
       
   795         * @since 3.0
       
   796         * @param aLeft on return, left balance value
       
   797         * @param aRight on return, right balance value
       
   798         * @param aBalance current balance value
       
   799         * @return void
       
   800         */
       
   801 		void CalculateLeftRightBalanceL(TInt& aLeft, TInt& aRight, TInt aBalance);
       
   802 
       
   803         /**
       
   804         * Calculates the balance based on the left and right balance values.
       
   805         * @since 3.0
       
   806         * @param aBalance on return, the balance value
       
   807         * @param aLeft left balance value
       
   808         * @param aRight right balance value
       
   809         * @return void
       
   810         */
       
   811         void CalculateBalanceL(TInt& aBalance, TInt aLeft, TInt aRight);
       
   812 
       
   813         void GoToInitPositionL();
       
   814 		
       
   815 		void ResetPositionVariables();
       
   816 		void DoPlayL();
       
   817 		void DoInitializeL();
       
   818 		void DoPauseL(TBool aPreemption = EFalse);
       
   819 		void DoBufferFilledL(CMMFBuffer* aBuffer);
       
   820 		void DoResume(TInt aResumePosition = -1);
       
   821 		TBool AllBuffersFilled();
       
   822 		TBool AllBuffersEmpty();
       
   823         void RefillSharedBuffersL();
       
   824         void ClearSharedBuffersL();
       
   825         void SeekToTimeMsL(TUint aTimeMs);
       
   826         void PlayForDurationL();
       
   827         void PlayForInitPositionL();
       
   828         void PlayForPauseSeekL();
       
   829 		void PauseForSetPosL();
       
   830 		TInt CleanupForStop();
       
   831 		void ClearRepeatFlag();
       
   832 		// sets the repeat count and trailing silence timer value supplied by the client
       
   833         TInt DoSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
       
   834         // handles the loop play of seekable and non-seekable sources
       
   835         void DoRepeat();
       
   836         TBool IsLoopPlayEnabled() const;
       
   837         
       
   838     public: // Functions from base classes (MTrailingSilenceObserver)
       
   839         /**
       
   840         * From MTrailingSilenceObserver
       
   841         * Call back function indicating that that trailing silence timer has expired during loop play
       
   842         *
       
   843         * @since 5.x
       
   844         * @param none
       
   845         * @return  void
       
   846         */
       
   847         IMPORT_C virtual void TrailingSilenceTimerComplete();
       
   848 
       
   849     protected:	// Functions from base classes (MMMFDRMCustomCommandImplementor)
       
   850 
       
   851 #ifdef SYMBIAN_CAF_V2
       
   852 		/**
       
   853 		* From MMMFDRMCustomCommandImplementor
       
   854 		* Returns the result of MdcEvaluateIntent() when DataSourceType is KUidMmfFileSource.
       
   855 		*
       
   856 		* @param aIntent The generic DRM intent specified by client.
       
   857 		* @return TInt
       
   858 		*/
       
   859 		IMPORT_C virtual TInt MdcEvaluateIntent(ContentAccess::TIntent aIntent);
       
   860 
       
   861 		/**
       
   862 		* From MMMFDRMCustomCommandImplementor
       
   863 		* Returns the result of ExecuteIntent() when DataSourceType is KUidMmfFileSource.
       
   864 		*
       
   865 		* @param aIntent The generic DRM intent specified by client.
       
   866 		* @return TInt
       
   867 		*/
       
   868 		IMPORT_C virtual TInt MdcExecuteIntent(ContentAccess::TIntent aIntent);
       
   869 
       
   870 		/**
       
   871 		* From MMMFDRMCustomCommandImplementor
       
   872 		* Setting the iDisableAutoIntent based on the client request to disable
       
   873 		* or enable the automatic intent.
       
   874 		*
       
   875 		* @param aIntent The generic DRM intent specified by client.
       
   876 		* @return TInt
       
   877 		*/
       
   878 		IMPORT_C virtual TInt MdcDisableAutomaticIntent(TBool aDisableAutoIntent);
       
   879 
       
   880 		/**
       
   881 		* From MMMFDRMCustomCommandImplementor
       
   882 		* Returns the result of SetAgentProperty() when DataSourceType is KUidMmfFileSource.
       
   883 		*
       
   884 		* @param aIntent The generic DRM intent specified by client.
       
   885 		* @return TInt
       
   886 		*/
       
   887 		IMPORT_C virtual TInt MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue);
       
   888 		
       
   889 #endif
       
   890 
       
   891 	protected: // Data
       
   892 
       
   893         enum TPlayControllerState
       
   894         {
       
   895             EStopped,
       
   896             EInitializing,
       
   897             EInitialized,
       
   898             EPlaying,
       
   899             EPaused,
       
   900             EAutoPaused
       
   901         };
       
   902 
       
   903         // Holds the controller state
       
   904         TPlayControllerState iState;
       
   905         // Holds the requested state
       
   906         TPlayControllerState iRequestState;
       
   907         TPlayControllerState iReturnState;
       
   908         // Indicates if the clip is DRM protected
       
   909         TBool iIsDRMProtected;
       
   910 
       
   911 		// Pointer to audio output
       
   912 		CAdvancedAudioOutput* iAudioOutput;
       
   913 		// Pointer to audio resource
       
   914 		CAdvancedAudioResource* iAudioResource;
       
   915 		// Pointer to audio utility
       
   916 		CAdvancedAudioUtility* iAudioUtility;
       
   917 
       
   918         // Data source type - used by metadata functions
       
   919         TUid iSourceType;
       
   920 		
       
   921         // Holds the current byte position in the clip
       
   922         TUint iSourceReadPosition;
       
   923         // 1st or 2nd header offset
       
   924         TInt iHeaderOffset;
       
   925         // 1st header offset
       
   926         TInt iSyncOffset;
       
   927         // Write position for file sink
       
   928         TInt iSinkWritePosition;
       
   929         // Holds the source format
       
   930         TUid iSourceFormat;
       
   931         // Sink number of channels
       
   932         TInt iSinkNumChannels;
       
   933         // Sink sample rate
       
   934         TInt iSinkSampleRate;
       
   935 
       
   936 		// Play window - start position in microseconds
       
   937 		TTimeIntervalMicroSeconds iPlayWindowStartPosition;
       
   938 		// Play window - end position in microseconds
       
   939 		TTimeIntervalMicroSeconds iPlayWindowEndPosition;
       
   940 		// Indication whether metadata is supported or not
       
   941 		TBool iMetaDataSupport;
       
   942 		// Metadata entries, if supported
       
   943 		RPointerArray<CMMFMetaDataEntry> iMetaDataEntries;
       
   944     	// Flag indicating whether metadata has been ready already
       
   945     	TBool iMetaDataRead;
       
   946 	    // Drive number
       
   947         TDriveNumber iDriveNumber;
       
   948         
       
   949 #ifdef SYMBIAN_CAF_V2
       
   950  		TBool iDisableAutoIntent;
       
   951 #endif
       
   952 
       
   953  		TBool iSourceUnreadable;
       
   954  		TBool iSinkInitDataReady;
       
   955 		TBool iReadHeader;                  // indicate whether the header is waited to be read
       
   956 		TUint iCurrentPosition;             // to keep track with current position related to source on streaming situation
       
   957 
       
   958 		TInt64 iPDTimePositionInMicroSecs;
       
   959 		
       
   960     	TBool iEventsEnabled;               // indicate whether StreamControlEvent is enabled
       
   961         TBool iDecoderExists;
       
   962     	
       
   963     	TBool iSourceIsPosSeekable;
       
   964     	TBool iSourceIsTimeSeekable;
       
   965     	TBool iBitRateFrozen;
       
   966     	TBool iDurationFrozen;
       
   967     	TBool iPlayingForDuration;
       
   968     	TBool iPlayingForInitPos;
       
   969         TBool iPausingForSetPos;
       
   970     	TBool iPlayingForPauseSeek;
       
   971     	TBool iPlaySeeking;
       
   972     	TTimeIntervalMicroSeconds iInitPosition;
       
   973     	TTimeIntervalMicroSeconds iPreSeekTime;
       
   974     	
       
   975         CDataSourceAdapter* iDataSourceAdapter;
       
   976         
       
   977         mutable CActiveSchedulerWait* iWait;
       
   978         mutable CActiveSchedulerWait* iBlockSetPos;
       
   979 
       
   980         TUint32 iPlayStartTime;
       
   981         TUint32 iZeroTime;
       
   982         TUint32 iAfterTime;
       
   983         
       
   984 		mutable TBool iBlockDuration;
       
   985 		TBool iEnablePrimedStateChangedEvent;
       
   986 		
       
   987 		// Decoder type
       
   988 		TInt iDecoderType;
       
   989 		
       
   990 		TInt iSharedBufferCnt;
       
   991 
       
   992 		TInt iResumePosition;
       
   993 
       
   994 		TInt iRepeatCount;    // Repeat count set by the client
       
   995 		TInt iCurrentRepeatCount;  // index to track the current repeat count during loop play
       
   996 		TBool iLoopPlayEnabled;   // flag indicating if loop play is enabled or not
       
   997 		TBool iRepeatForever;     // flag indicating that loop play forever is enabled
       
   998 		TTimeIntervalMicroSeconds32 iTrailingSilenceMs;   // Trailing silence value set by the client
       
   999 		CTrailingSilenceTimer* iTrailingSilenceTimer;     // Trailing silence timer class
       
  1000 		TBool iIntentStopped;     // flag indicating that rights are consumed during the end of each repeat in loop play
       
  1001 		TUint iSavedTimePositionInMicroSecs;      // saved position to adjust the position during loop play
       
  1002 		TTimeIntervalMicroSeconds iSavedSetPosition;
       
  1003     };
       
  1004 
       
  1005 class CTrailingSilenceTimer: public CTimer
       
  1006     {
       
  1007     public:
       
  1008 
       
  1009          /**
       
  1010           * First phase constructor in the Two Phase Construction.
       
  1011           */  
       
  1012          // static CTrailingSilenceTimer* NewL(CAdvancedAudioPlayController &aAdvancedAudioPlayController);
       
  1013         static CTrailingSilenceTimer* NewL(MTrailingSilenceObserver &aobserver);
       
  1014 
       
  1015          /**
       
  1016           * Default Destructor.
       
  1017           */
       
  1018          virtual ~CTrailingSilenceTimer();
       
  1019         
       
  1020     private:
       
  1021         
       
  1022          /**
       
  1023           * Default Constructor.
       
  1024           */
       
  1025         // CTrailingSilenceTimer(CAdvancedAudioPlayController &aAdvancedAudioPlayController);
       
  1026         CTrailingSilenceTimer(MTrailingSilenceObserver &aobserver);
       
  1027 
       
  1028          /**
       
  1029           * Second phase constructor in the Two Phase Construction.
       
  1030           */
       
  1031          void ConstructL();
       
  1032 
       
  1033          /**
       
  1034           * Default RunL() from CActive 
       
  1035           */
       
  1036          void RunL();
       
  1037 
       
  1038          /**
       
  1039           * Implements cancellation of an outstanding request. 
       
  1040           */
       
  1041           void DoCancel();
       
  1042 
       
  1043           /**
       
  1044            * Handles a leave occurring in the request completion event handler RunL()
       
  1045            */
       
  1046           void RunError();
       
  1047           
       
  1048     private:
       
  1049           // CAdvancedAudioPlayController* iAdvancedAudioPlayController;
       
  1050         MTrailingSilenceObserver* iObserver;
       
  1051     };
       
  1052 	
       
  1053 #endif 		// CADVANCEDAUDIOPLAYCONTROLLER_H
       
  1054 
       
  1055 // End of File