multimediacommscontroller/mmccsubcontroller/inc/mccdatapathbase.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:    Provides a base class for datapaths in Mcc
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MCCDATAPATHBASE_H
       
    22 #define MCCDATAPATHBASE_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32std.h>
       
    26 #include <mmf/server/mmfdatasink.h>
       
    27 #include <mmf/server/mmfdatasource.h>
       
    28 #include "mccdatapathdef.h"
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CCompleteCallback;
       
    33 class MMccResources;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  Mcc Datapath base class definition
       
    39 *
       
    40 *  @lib Mccsubthreads.dll
       
    41 *  @since Series 60 3.0
       
    42 */
       
    43 NONSHARABLE_CLASS( CMccDataPathBase ) : public CActive, public MDataSink,
       
    44         public MDataSource
       
    45     {
       
    46     public:  // Constructors and destructor
       
    47         
       
    48         /*
       
    49         * Destructor
       
    50         */
       
    51         virtual ~CMccDataPathBase();           
       
    52 
       
    53     public: // New functions
       
    54 
       
    55         /**
       
    56         * Add datasink to datapath
       
    57         * @since Series 60 3.0
       
    58         * @param [input] aSink Sink to be added
       
    59         * @return void
       
    60         */
       
    61         void AddDataSinkL( MDataSink* aSink );
       
    62 
       
    63         /**
       
    64         * Add a datasource to datapath
       
    65         * @since Series 60 3.0
       
    66         * @param [input] aSource Source to be added
       
    67         * @return void
       
    68         */
       
    69         void AddDataSourceL( MDataSource* aSource );
       
    70         
       
    71         /**
       
    72         * Set the associated data sink
       
    73         * @since Series 60 3.0
       
    74         * @param [input] aAssociatedSink
       
    75         * @return void
       
    76         */
       
    77         void SetAssociatedSink( MDataSink* aAssociatedSink );
       
    78         
       
    79         /**
       
    80         * Set the associated data source
       
    81         * @since Series 60 3.0
       
    82         * @param [input] aAssociatedSource
       
    83         * @return void
       
    84         */
       
    85         void SetAssociatedSource( MDataSource* aAssociatedSource );
       
    86         
       
    87         /**
       
    88         * Handles the end of data
       
    89         * @since Series 60 3.0
       
    90         * @param None
       
    91         * @return void
       
    92         */
       
    93         void EndOfData();
       
    94         
       
    95         /**
       
    96         * Primes the datapath
       
    97         * @since Series 60 3.0
       
    98         * @param None
       
    99         * @return void
       
   100         */
       
   101         virtual void PrimeL( TUint32 aEndpointId ) = 0;
       
   102         
       
   103         /**
       
   104         * Starts the audio play/record
       
   105         * @since Series 60 3.0
       
   106         * @param None
       
   107         * @return void
       
   108         */
       
   109         virtual void PlayL( TUint32 aEndpointId ) = 0;
       
   110         
       
   111         /**
       
   112         * Pauses the audio play/record
       
   113         * @since Series 60 3.0
       
   114         * @param None
       
   115         * @return void
       
   116         */
       
   117         virtual void PauseL( TUint32 aEndpointId ) = 0;
       
   118         
       
   119         /**
       
   120         * Stops the audio play/record
       
   121         * @since Series 60 3.0
       
   122         * @param None
       
   123         * @return void
       
   124         */
       
   125         virtual void StopL( TUint32 aEndpointId ) = 0;
       
   126         
       
   127         /**
       
   128         * Resumes the audio play/record from paused state
       
   129         * @since Series 60 3.0
       
   130         * @param None
       
   131         * @return void
       
   132         */
       
   133         virtual void ResumeL( TUint32 aEndpointId ) = 0;
       
   134 
       
   135     public: // Functions from base classes
       
   136 
       
   137         /**
       
   138         * From MDataSink
       
   139         */
       
   140         virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool& aReference);
       
   141 
       
   142         /**
       
   143         * From MDataSource
       
   144         */
       
   145         virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, TBool& aReference);
       
   146 
       
   147         /**
       
   148         * From MDataSink
       
   149         */
       
   150         virtual TBool CanCreateSinkBuffer();
       
   151 
       
   152         /**
       
   153         * From MDataSource
       
   154         */
       
   155         virtual TBool CanCreateSourceBuffer();
       
   156 
       
   157         /**
       
   158         * From MDataSink
       
   159         */
       
   160         virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);
       
   161 
       
   162         /**
       
   163         * From MDataSource
       
   164         */
       
   165         virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId);
       
   166 
       
   167         /**
       
   168         * From MDataSink
       
   169         */
       
   170         TFourCC SinkDataTypeCode(TMediaId aMediaId);
       
   171 
       
   172         /**
       
   173         * From MDataSource
       
   174         */
       
   175         TFourCC SourceDataTypeCode(TMediaId aMediaId);
       
   176 
       
   177         /**
       
   178         * From MDataSink
       
   179         */
       
   180         virtual TInt SetSinkDataTypeCode(TFourCC aSourceFourCC, TMediaId aMediaId);
       
   181 
       
   182         /**
       
   183         * From MDataSource
       
   184         */
       
   185         virtual TInt SetSourceDataTypeCode(TFourCC aSourceFourCC, TMediaId aMediaId);
       
   186 
       
   187     protected:  // New functions
       
   188         
       
   189         /**
       
   190         * Changes the current datapath transferstate.
       
   191         * @since Series 60 3.0
       
   192         * @param [input] aTransferState New transfer state
       
   193         * @param aFailureFallback, ETrue if state change is done because of some failure
       
   194         *        from which can be recovered
       
   195         * @return void
       
   196         */
       
   197         TBool ChangeDataPathTransferState( TTransferState aTransferState, 
       
   198                                            TBool aFailureFallback = EFalse );
       
   199 
       
   200         /**
       
   201         * Returns the current transferstate
       
   202         * @since Series 60 3.0
       
   203         * @param None
       
   204         * @return TTransferState
       
   205         */
       
   206         TTransferState TransferState() const;
       
   207 
       
   208         /**
       
   209         * Sets the new datapath state
       
   210         * @since Series 60 3.0
       
   211         * @param [input] aState New datapath state
       
   212         * @return void
       
   213         */
       
   214         void SetStateL( const TDataPathState& aState );
       
   215 
       
   216         /**
       
   217         * Checks if the given buffer is supported.
       
   218         * Leaves with KErrNotSupported
       
   219         * @since Series 60 3.0
       
   220         * @param aBuffer Buffer to be checked
       
   221         * @return void
       
   222         */
       
   223         void IsBufferSupportedL( CMMFBuffer* aBuffer );
       
   224         
       
   225         /**
       
   226         * copy CMMFBuffer data and setting from one buffer
       
   227         * to another
       
   228         * @since Series 60 3.0
       
   229         * @param aDesBuffer, destination buffer
       
   230         * @param aOrigBuffer, original buffer
       
   231         * @return void
       
   232         */
       
   233         void CopyBuffer( CMMFBuffer* aDesBuffer,
       
   234                          CMMFBuffer* aOrigBuffer);
       
   235         
       
   236         /**
       
   237         * a CCompleteCallback object is created
       
   238         * @since Series 60 3.0
       
   239         * @return void
       
   240         */
       
   241         void CreateCompleteCallBackL();
       
   242         
       
   243         /**
       
   244         * a signal the datapath complete with a error code
       
   245         * @since Series 60 3.0
       
   246         * @param aErrorCode, a datapath complete error code.
       
   247         * @return void
       
   248         */
       
   249         void SignalDataPathCompleteL( TInt aErrorCode );
       
   250         
       
   251         /**
       
   252         * Worker function for dataending
       
   253         * @since Series 60 3.0
       
   254         * @param None
       
   255         * @return void
       
   256         */
       
   257         virtual void DoEndOfDataL() = 0;
       
   258         
       
   259         /**
       
   260         * Returns datapath's current state
       
   261         * @since Series 60 3.0
       
   262         * @param None
       
   263         * @return TDataPathState
       
   264         */
       
   265         TDataPathState State() const;
       
   266         
       
   267         virtual TBool ControlSource( TUint32 aEndpointId ) const;
       
   268         
       
   269         virtual TBool ControlSink( TUint32 aEndpointId ) const;
       
   270         
       
   271         TBool IsMmfEndpoint( MDataSink* aSink ) const;
       
   272         
       
   273         TBool IsMmfEndpoint( MDataSource* aSource ) const;
       
   274         
       
   275         /**
       
   276         * Fills the source buffer
       
   277         * @since Series 60 3.0
       
   278         * @param None
       
   279         * @return void
       
   280         */
       
   281         virtual void FillSourceBufferL() = 0;
       
   282         
       
   283         /**
       
   284         * Empty the sink buffer
       
   285         * @since Series 60 3.0
       
   286         * @param None
       
   287         * @return void
       
   288         */
       
   289         virtual void EmptySinkBufferL() = 0;
       
   290         
       
   291     protected:  // Functions from base classes
       
   292         
       
   293         /**
       
   294         * From MDataSink
       
   295         */
       
   296         virtual void ConstructSinkL( const TDesC8& aInitData );
       
   297 
       
   298         /**
       
   299         * From MDataSource
       
   300         */
       
   301         virtual void ConstructSourceL( const TDesC8& aInitData );
       
   302 
       
   303         /**
       
   304         * From CActive
       
   305         */
       
   306         virtual void DoCancel();
       
   307 
       
   308         /**
       
   309         * From CActive
       
   310         */
       
   311         void RunL();
       
   312         
       
   313         /**
       
   314         * From CActive
       
   315         */
       
   316         TInt RunError( TInt aError );
       
   317 
       
   318     protected: // Constructors
       
   319 
       
   320         /*
       
   321         * Constructor
       
   322         */
       
   323         inline CMccDataPathBase( MAsyncEventHandler* aEventHandler, 
       
   324                                  MMccResources* aMccResources,
       
   325                                  TMediaId aMediaId ) : 
       
   326                 CActive( EPriorityStandard ), MDataSink( KUidMmfDataPath ),
       
   327                 MDataSource( KUidMmfDataPath ), iDataSink( NULL ), 
       
   328                 iDataSource( NULL ), iSinkBuffer( NULL ), iSourceBuffer( NULL ),
       
   329                 iMediaId( aMediaId ), iEventHandler( aEventHandler ),
       
   330                 iMccResources( aMccResources ),
       
   331                 iCompleteCallback( NULL ), iState( EStopped ) 
       
   332                 { CActiveScheduler::Add(this); };
       
   333 
       
   334     private: // New functions
       
   335         
       
   336         /**
       
   337         * Creates the datapath
       
   338         * @since Series 60 3.0
       
   339         * @param [input] aSource Datapaths datasource
       
   340         * @param [input] aSink Datapaths datasink
       
   341         * @return void
       
   342         */
       
   343         void CreateDataPathL( MDataSource* aSource, MDataSink* aSink );
       
   344 
       
   345     protected:  // Data
       
   346         
       
   347         // Datasink
       
   348         MDataSink* iDataSink;
       
   349 
       
   350         // Datasource
       
   351         MDataSource* iDataSource;
       
   352 
       
   353         // Pointers to used buffers
       
   354         CMMFBuffer* iSinkBuffer;
       
   355         CMMFBuffer* iSourceBuffer;
       
   356         
       
   357         // Datapath's media id. Should be audio
       
   358         TMediaId iMediaId;
       
   359         
       
   360         // Datapaths completion error code
       
   361         TInt iDataPathCompletedErrorCode;
       
   362 
       
   363         // Sink & Source added, CreateDataPath() called
       
   364         TBool iDataPathCreated;
       
   365         
       
   366         // Eventhandler
       
   367         MAsyncEventHandler* iEventHandler;
       
   368         
       
   369         MMccResources* iMccResources;
       
   370         
       
   371         CCompleteCallback* iCompleteCallback;
       
   372         
       
   373         MDataSink* iAssociatedSink;
       
   374         
       
   375         MDataSource* iAssociatedSource;
       
   376 
       
   377     private:    // Data
       
   378 
       
   379         // Current data transfer state
       
   380         TTransferState iTransferState;
       
   381 
       
   382         // Datasink FourCC code
       
   383         TFourCC iSinkFourCC;
       
   384 
       
   385         // Datasource FourCC code
       
   386         TFourCC iSourceFourCC;
       
   387 
       
   388         // Current datapath state
       
   389         TDataPathState iState;
       
   390 
       
   391     private: //friend class
       
   392         #ifdef TEST_EUNIT
       
   393         friend class UT_CMccDlDataPath;
       
   394         friend class UT_CMccUlDataPath;
       
   395         friend class UT_CMccDataPathBase;
       
   396 
       
   397         #endif
       
   398     };
       
   399 
       
   400 #endif      // MCCDATAPATHBASE_H
       
   401             
       
   402 // End of File