multimediacommscontroller/mmcch263payloadformat/inc/mcch263payloadformatwrite.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MCCH263PAYLOADFORMATWRITE_H
       
    22 #define MCCH263PAYLOADFORMATWRITE_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <mmf/server/mmfformat.h>
       
    27 #include <mmf/common/mmfcontrollerframework.h>
       
    28 #include "rtpheader.h"
       
    29 #include "mccdef.h"
       
    30 #include "mccinternalcodecs.h"
       
    31 #include "formatstatemachine.h"
       
    32 #include "mcch263payloadencoder.h"
       
    33 #include "mcch263newpayloadencoder.h"
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // MACROS
       
    38 
       
    39 // DATA TYPES
       
    40 
       
    41 // FUNCTION PROTOTYPES
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class MMccEventHandler;
       
    45     
       
    46 // CLASS DECLARATION
       
    47 /**
       
    48 *  Handles DTMF encoding and passing to the RTP data sink.
       
    49 *  Supported DTMF payload format is telephone-event payload.
       
    50 *
       
    51 *  @lib MMMccDtmfPlFormat.dll
       
    52 *  @since Series 60 3.0
       
    53 */
       
    54 class CMccH263PayloadFormatWrite : public CPayloadFormatWrite, public MPayloadFormatWrite
       
    55     {
       
    56     public:  // Constructors and destructor
       
    57         
       
    58         /**
       
    59         * Two-phased constructor.
       
    60         */
       
    61         static CMccH263PayloadFormatWrite* NewL( MDataSink* aSink );
       
    62         
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~CMccH263PayloadFormatWrite();
       
    67 
       
    68     public: // New functions  
       
    69     
       
    70     public: // Functions from MPayloadFormatWrite
       
    71         /**
       
    72         * Empty sourcebuffer state change
       
    73         * @since    Series 60 3.0
       
    74         */
       
    75         void EmptySourceBufferL();
       
    76         
       
    77         /**
       
    78         * Sourcebuffer emptied state change
       
    79         * @since    Series 60 3.0
       
    80         */
       
    81         void SourceBufferEmptiedL();
       
    82 
       
    83     public: // Functions from CMMFFormatEncode
       
    84 
       
    85         /**
       
    86         * From CMMFFormatEncode. Gets the time interval for one frame.
       
    87         *
       
    88         * @since    Series 60 3.0
       
    89         * @param    aMediaType      The media type ID
       
    90         * @return   The time interval for one frame, in microseconds.
       
    91         */
       
    92         TTimeIntervalMicroSeconds FrameTimeInterval( TMediaId aMediaType ) const;
       
    93         
       
    94         /**
       
    95         * From CMMFFormatEncode. Gets the duration of the sink clip for the specified media ID.
       
    96         *
       
    97         * @since    Series 60 3.0
       
    98         * @param    aMediaType      The media type ID
       
    99         * @return   Duration of the sink clip
       
   100         */
       
   101         TTimeIntervalMicroSeconds Duration( TMediaId aMediaType ) const;
       
   102         
       
   103         /**
       
   104         * From CMMFFormatEncode. Empty the given source buffer.
       
   105         *
       
   106         * @since    Series 60 3.0
       
   107         * @param    aBuffer    data buffer containing DTMF payload
       
   108         * @param    aSupplier  data source pointer
       
   109         * @param    aMediaId   contains the media type KUidMediaTypeAudio or 
       
   110         *                      KUidMediaTypeVideo
       
   111         * @return   None
       
   112         */
       
   113         void EmptyBufferL( CMMFBuffer* aBuffer, 
       
   114                            MDataSource* aSupplier, 
       
   115                            TMediaId aMediaId );
       
   116 
       
   117         /**
       
   118         * From CMMFFormatEncode. Called by the clip to indicate data has been processed.
       
   119         *
       
   120         * @since    Series 60 3.0
       
   121         * @param    aBuffer    The emptied buffer.
       
   122         * @return   None
       
   123         */
       
   124         void BufferEmptiedL( CMMFBuffer* aBuffer );
       
   125         
       
   126         /**
       
   127         * From CMMFFormatEncode. DTMF payload format write doesn't support
       
   128         * sink buffer creation.
       
   129         *
       
   130         * @since    Series 60 3.0
       
   131         * @param    None
       
   132         * @return   EFalse
       
   133         */        
       
   134         TBool CanCreateSinkBuffer();
       
   135         
       
   136         /**
       
   137         * From CMMFFormatEncode. DTMF payload format write doesn't support
       
   138         * sink buffer creation.
       
   139         *
       
   140         * @param aMediaId   contains the media type KUidMediaTypeAudio or 
       
   141         *                   KUidMediaTypeVideo 
       
   142         * @param aReference value of False is returned to caller if sink 
       
   143         *                   buffer is created
       
   144         * @return           NULL
       
   145         */
       
   146         CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId, 
       
   147                                        TBool &aReference );        
       
   148         
       
   149     public:     // Functions from MDataSink
       
   150         
       
   151         /**
       
   152         * From MDataSink. Passes prime transition to the RTP data sink.
       
   153         *
       
   154         * @since    Series 60 3.0
       
   155         * @param    None
       
   156         * @return   None
       
   157         */
       
   158         void SinkPrimeL();
       
   159         
       
   160         /**
       
   161         * From MDataSink. Passes play transition to the RTP data sink.
       
   162         *
       
   163         * @since    Series 60 3.0
       
   164         * @param    None
       
   165         * @return   None
       
   166         */
       
   167         void SinkPlayL();
       
   168         
       
   169         /**
       
   170         * From MDataSink. Passes pause transition to the RTP data sink.
       
   171         *
       
   172         * @since    Series 60 3.0
       
   173         * @param    None
       
   174         * @return   None
       
   175         */
       
   176         void SinkPauseL();
       
   177         
       
   178         /**
       
   179         * From MDataSink. Passes stop transition to the RTP data sink.
       
   180         *
       
   181         * @since    Series 60 3.0
       
   182         * @param    None
       
   183         * @return   None
       
   184         */
       
   185         void SinkStopL();
       
   186                                      
       
   187         /**
       
   188         * Log in to the sink thread - this funtion merely passes the command to 
       
   189         * its sink clip data source object. The sink clip object will handle 
       
   190         * the thread log on procedures.
       
   191         *
       
   192         * @since    Series 60 3.0
       
   193         * @param    aEventHandler    address of event handler
       
   194         * @return   error code returned by source clip
       
   195         */
       
   196         TInt SinkThreadLogon( MAsyncEventHandler& aEventHandler );
       
   197 
       
   198         /**
       
   199         * Log out of the sink thread - this funtion merely passes the command to 
       
   200         * its sink clip data source object. The sink clip object will handle 
       
   201         * the thread log off procedures.
       
   202         *
       
   203         * @since    Series 60 3.0        
       
   204         * @param    None
       
   205         * @return   None
       
   206         */
       
   207         void SinkThreadLogoff();
       
   208         
       
   209         /**
       
   210         * Return the sink four CC code for the given media
       
   211         *
       
   212         * @since    Series 60 3.0
       
   213         * @param aMediaId    contains the media type KUidMediaTypeAudio or
       
   214         *                    KUidMediaTypeVideo
       
   215         * @return            FourCC code for the mediaId
       
   216         */
       
   217         TFourCC SinkDataTypeCode( TMediaId aMediaId );
       
   218 
       
   219         /**
       
   220         * Set the sink data type to the given four CC code for the given media
       
   221         *
       
   222         * @since    Series 60 3.0
       
   223         * @param aSinkFourCC      fourCC code
       
   224         * @param aMediaId         contains the media type KUidMediaTypeAudio or
       
   225         *                         KUidMediaTypeVideo
       
   226         * @return                 error code KErrNotSupported if invalid media 
       
   227         *                         ID, else return KErrNone
       
   228         */
       
   229         TInt SetSinkDataTypeCode( TFourCC aSinkFourCC, 
       
   230                                   TMediaId aMediaId );
       
   231     public:    
       
   232 
       
   233         /**
       
   234         * Configures payload format with format spesific parameters.
       
   235         * Leaves with KErrArgument if parameters are invalid.
       
   236         *
       
   237         * @since    Series 60 3.0 
       
   238         * @param    aConfigParams       Configuration parameters
       
   239         * @return   void
       
   240         */
       
   241         virtual void ConfigurePayloadFormatL( const TDesC8& aConfigParams,
       
   242                                               CMccRtpMediaClock& aClock );
       
   243 
       
   244         
       
   245     protected:  // New functions
       
   246 
       
   247 
       
   248     protected:  // Functions from base classes
       
   249 
       
   250 
       
   251     private:
       
   252 
       
   253         /**
       
   254         * C++ default constructor.
       
   255         */
       
   256         CMccH263PayloadFormatWrite();
       
   257 
       
   258         /**
       
   259         * By default Symbian 2nd phase constructor is private.
       
   260         */
       
   261         void ConstructL( MDataSink* aSink );
       
   262        
       
   263     public:
       
   264     
       
   265         static void PayloadEncodeCleanup( TAny* aAny );
       
   266         
       
   267     protected:  // Data
       
   268 
       
   269     private:    // Data
       
   270             
       
   271         // The FourCC code for DTMF PayloadFormatWrite
       
   272         TFourCC iFourCC;
       
   273         
       
   274         // Format encoding state machine
       
   275         CFormatEncodeStateMachine* iStateMachine;
       
   276         
       
   277 		RPointerArray<CBufferContainer> iBuffers;
       
   278 
       
   279 		MDataSource* iDataSource;
       
   280 		
       
   281         // Current Media id ( audio, video )
       
   282         TMediaId  iMediaId;
       
   283                 
       
   284         CMMFDataBuffer* iSourceBuffer;
       
   285         
       
   286         // Formatter class for encoding of RTP payload
       
   287         CMccH263PayloadEncoder* iPayloadEncoder;
       
   288         
       
   289         // Parameters relating to RTP data encoding
       
   290         TMccCodecInfo iCInfo;
       
   291         
       
   292         TBool iIsRtpSink;
       
   293         
       
   294     public:     // Friend classes
       
   295 
       
   296     protected:  // Friend classes
       
   297 
       
   298     private:    // Friend classes
       
   299 
       
   300 		#ifdef EUNIT_TEST
       
   301 			friend class UT_CMccH263PayloadFormatWrite;	
       
   302    		#endif
       
   303     };
       
   304 
       
   305 #endif      // MCCH263PAYLOADFORMATWRITE_H
       
   306             
       
   307 // End of File