multimediacommscontroller/mmccshared/inc/formatstatemachine.h
changeset 0 1bce908db942
child 49 64c62431ac08
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2005 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 statemachine definitions for MCC Payload formatters
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef FORMATSTATEMACHINE_H
       
    22 #define FORMATSTATEMACHINE_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <e32std.h>
       
    27 #include <mmf/server/mmfformat.h>
       
    28 
       
    29 // DATA TYPES
       
    30 // Payload format encoding states.
       
    31 enum TFormatEncodeState
       
    32     {
       
    33     EEncodeIdle             = 0,
       
    34     EEmptySourceBuffer      = 1,
       
    35     ESourceBufferEmptied    = 2
       
    36     };
       
    37 
       
    38 // Payload format decoding states
       
    39 enum TFormatDecodeState
       
    40     {
       
    41     EDecodeIdle         = 0,
       
    42     ESourceDataReady    = 1,
       
    43     EEmptyDataToSink    = 2
       
    44     };
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 class TRtpRecvHeader;
       
    49 class CMccRtpMediaClock;
       
    50 
       
    51 /**
       
    52 *  Format decode statemachine observer
       
    53 *  
       
    54 *  @lib     Mccamrplformat.dll
       
    55 *  @since   Series 60 3.0
       
    56 */
       
    57 class MPayloadFormatRead
       
    58     {
       
    59     public:
       
    60         
       
    61         /**
       
    62         * Fill sinkbuffer state change
       
    63         * @since    Series 60 3.0
       
    64         */
       
    65         virtual void FillSinkBufferL() = 0;
       
    66         
       
    67         /**
       
    68         * Send data to sink state change
       
    69         * @since    Series 60 3.0
       
    70         */
       
    71         virtual void SendDataToSinkL() = 0;
       
    72 
       
    73     };
       
    74 
       
    75 /**
       
    76 *  Format decode statemachine observer
       
    77 *  
       
    78 *  @lib     Mccamrplformat.dll
       
    79 *  @since   Series 60 3.0
       
    80 */
       
    81 class CPayloadFormatRead: public CMMFFormatDecode
       
    82     {
       
    83     public:
       
    84         
       
    85         /**
       
    86         * Called after the data buffer is filled. Update the number of bytes read
       
    87         * and the current read position for the next read operation. 
       
    88         *
       
    89         * @param    aBuffer         data buffer filled
       
    90         * @param    aHeaderInfo     RTP packet header information
       
    91         * @return None
       
    92         */
       
    93         virtual void DataBufferFilledL( CMMFBuffer* aBuffer, 
       
    94                                     const TRtpRecvHeader& aHeaderInfo ) = 0;
       
    95     
       
    96         /**
       
    97         * Configures payload format with format spesific parameters.
       
    98         * Leaves with KErrArgument if parameters are invalid.
       
    99         * @param    aConfigParams       Configuration parameters
       
   100         * @return   void
       
   101         */
       
   102         virtual void ConfigurePayloadFormatL( const TDesC8& aConfigParams ) = 0;
       
   103         
       
   104         /**
       
   105         * Sets maxpayloadsize
       
   106         * @param    aTimeOut      Timeout value to set.
       
   107         * @return	None
       
   108         */
       
   109 		virtual void SetPayloadSize( TInt /*aMaxPayloadSize*/ )
       
   110 		    {
       
   111 		    }
       
   112     };
       
   113 
       
   114 /**
       
   115 *  Format encode statemachine observer
       
   116 *  
       
   117 *  @lib     Mccamrplformat.dll
       
   118 *  @since   Series 60 3.0
       
   119 */
       
   120 class MPayloadFormatWrite
       
   121     {
       
   122     public:
       
   123     
       
   124         /**
       
   125         * Empty sourcebuffer state change
       
   126         * @since    Series 60 3.0
       
   127         */
       
   128         virtual void EmptySourceBufferL() = 0;
       
   129         
       
   130         /**
       
   131         * Sourcebuffer emptied state change
       
   132         * @since    Series 60 3.0
       
   133         */
       
   134         virtual void SourceBufferEmptiedL() = 0;
       
   135     };
       
   136 
       
   137 /**
       
   138 *  Format encode statemachine observer
       
   139 *  
       
   140 *  @lib     Mccamrplformat.dll
       
   141 *  @since   Series 60 3.0
       
   142 */
       
   143 class CPayloadFormatWrite: public CMMFFormatEncode 
       
   144     {
       
   145     public:
       
   146     
       
   147         /**
       
   148         * Configures payload format with format spesific parameters.
       
   149         * Leaves with KErrArgument if parameters are invalid.
       
   150         * @param    aConfigParams       Configuration parameters
       
   151         * @return   void
       
   152         */
       
   153         virtual void ConfigurePayloadFormatL( const TDesC8& aConfigParams, 
       
   154                                               CMccRtpMediaClock& aClock ) = 0;
       
   155     };
       
   156     
       
   157 /**
       
   158 *  Format encoding state machine
       
   159 *
       
   160 *  @lib     Mccamrplformat.dll
       
   161 *  @since   Series 60 3.0
       
   162 */
       
   163 class CFormatEncodeStateMachine : public CActive
       
   164     {
       
   165     public: // Constructors and destructor
       
   166 
       
   167         /**
       
   168         * Two-phased constructor.
       
   169         */
       
   170         static CFormatEncodeStateMachine* NewL( MPayloadFormatWrite* aClient );
       
   171 
       
   172         /**
       
   173         * Destructor.
       
   174         */
       
   175         virtual ~CFormatEncodeStateMachine() ;
       
   176 
       
   177     public: // New functions
       
   178 
       
   179         /**
       
   180         * Change state to the new state.
       
   181         * @since    Series 60 3.0
       
   182         * @param    aNewState State where to proceed to
       
   183         */
       
   184         void ChangeState( enum TFormatEncodeState aNewState );
       
   185 
       
   186         /**
       
   187         * Returns current state.
       
   188         * @since    Series 60 3.0
       
   189         * @return   TFormatEncodeState - Current encoding state
       
   190         */
       
   191         TFormatEncodeState CurrentState() const;
       
   192 
       
   193     private: // Functions from base classes
       
   194     
       
   195         /**
       
   196         * From CActive Handles an active object’s request completion event.
       
   197         * @since    Series 60 3.0
       
   198         */
       
   199         void RunL();
       
   200 
       
   201         /**
       
   202         * From CActive Implements cancellation of an outstanding request.
       
   203         * @since    Series 60 3.0
       
   204         */
       
   205         void DoCancel();
       
   206         
       
   207         /**
       
   208         * From CActive Implements RunL leave error handling
       
   209         * @since    Series 60 3.0
       
   210         * @param    aError The leave error code from RunL()
       
   211         * @return   TInt System wide error code
       
   212         */
       
   213         TInt RunError( TInt aError );
       
   214 
       
   215     private:
       
   216    
       
   217         /**
       
   218         * C++ default constructor.
       
   219         */
       
   220         CFormatEncodeStateMachine( MPayloadFormatWrite* aClient );
       
   221 
       
   222         /**
       
   223         * By default Symbian 2nd phase constructor is private.
       
   224         */
       
   225         void ConstructL();
       
   226 
       
   227     private: // Data
       
   228         
       
   229         // Client who uses this state machine
       
   230         MPayloadFormatWrite* iClient;
       
   231         
       
   232         // Current format encoding state
       
   233         TFormatEncodeState iState;
       
   234     };
       
   235 
       
   236 /**
       
   237 *  Format decoding state machine
       
   238 *
       
   239 *  @lib     Mccamrplformat.dll
       
   240 *  @since   Series 60 3.0
       
   241 */
       
   242 class CFormatDecodeStateMachine : public CActive
       
   243     {
       
   244     public: // Constructors and destructor
       
   245 
       
   246         /**
       
   247         * Two-phased constructor.
       
   248         */
       
   249         static CFormatDecodeStateMachine* NewL( MPayloadFormatRead* aClient );
       
   250 
       
   251         /**
       
   252         * Destructor.
       
   253         */
       
   254         virtual ~CFormatDecodeStateMachine() ;
       
   255 
       
   256     public: // New functions
       
   257   
       
   258         /**
       
   259         * Change state to the new state.
       
   260         * @since    Series 60 3.0
       
   261         * @param    aNewState State where to proceed to
       
   262         */
       
   263         void ChangeState( enum TFormatDecodeState aNewState );
       
   264 
       
   265         /**
       
   266         * Returns current state.
       
   267         * @since    Series 60 3.0
       
   268         * @return   TFormatDecodeState - Current decoding state
       
   269         */
       
   270         TFormatDecodeState CurrentState() const;
       
   271 
       
   272     private: // Functions from base classes
       
   273 
       
   274         /**
       
   275         * From CActive Handles an active object’s request completion event.
       
   276         * @since    Series 60 3.0
       
   277         */
       
   278         void RunL();
       
   279 
       
   280         /**
       
   281         * From CActive Implements cancellation of an outstanding request.
       
   282         * @since    Series 60 3.0
       
   283         */
       
   284         void DoCancel();
       
   285         
       
   286         /**
       
   287         * From CActive Implements RunL leave error handling
       
   288         * @since    Series 60 3.0
       
   289         * @param    aError The leave error code from RunL()
       
   290         * @return   TInt System wide error code
       
   291         */
       
   292         TInt RunError( TInt aError );
       
   293 
       
   294     private:
       
   295 
       
   296         /**
       
   297         * C++ default constructor.
       
   298         */
       
   299         CFormatDecodeStateMachine( MPayloadFormatRead* aClient );
       
   300 
       
   301         /**
       
   302         * By default Symbian 2nd phase constructor is private.
       
   303         */
       
   304         void ConstructL();
       
   305 
       
   306     private: // Data
       
   307         
       
   308         // Client who uses this state machine
       
   309         MPayloadFormatRead* iClient;
       
   310         
       
   311         // Current format decoding state
       
   312         TFormatDecodeState iState;
       
   313     };
       
   314 
       
   315 #endif /* FORMATSTATEMACHINE_H */
       
   316 
       
   317