multimediacommscontroller/mmccredpayloadformat/inc/mccredpayloadwrite.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005-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:    MMF Format Encode interface for redundancy payload plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef MCCREDPAYLOADWRITE_H
       
    23 #define MCCREDPAYLOADWRITE_H
       
    24 
       
    25 //  INCLUDES
       
    26 #include <mmf/server/mmfformat.h>
       
    27 #include "rtpdatasink.h"
       
    28 #include "mccredencdecbase.h"
       
    29 #include "formatstatemachine.h"
       
    30 
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CMccRedEncoder;
       
    34 class TRtpSendHeader;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38 *  Defines configuration parameters to be used with configuration method.
       
    39 *
       
    40 *  @lib mmccredplformat.dll
       
    41 *  @since Series 60 3.0
       
    42 */
       
    43 class TMccRedPayloadWriteConfig
       
    44     {
       
    45     public:
       
    46         TMccRedPayloadWriteConfig() :
       
    47             iRedPayloadType(0), iRedBlockCount( 0 ), iMaxPayloadSize( 0 ),
       
    48             iNumOfEncodings( 0 ), iEncPayloadTypes()
       
    49                 { }
       
    50                 
       
    51         TMccRedPayloadWriteConfig( TUint8 aRedPayloadType, TUint8 aRedBlockCount,
       
    52             TUint8 aMaxPayloadSize, TUint8 aNumOfEncodings ) :
       
    53             iRedPayloadType( aRedPayloadType ), iRedBlockCount( aRedBlockCount ),
       
    54             iMaxPayloadSize( aMaxPayloadSize ), iNumOfEncodings( aNumOfEncodings ),
       
    55             iEncPayloadTypes()
       
    56                 { }
       
    57 
       
    58         void InitPayloadTypes()
       
    59             {
       
    60             TInt ind( iEncPayloadTypes.Count() );
       
    61             while ( --ind )
       
    62                 {
       
    63                 iEncPayloadTypes[ind] = KPayloadNotDefined;
       
    64                 }
       
    65             }
       
    66 
       
    67         // RTP header payload type indicating redundancy format
       
    68         TUint8 iRedPayloadType;
       
    69         
       
    70         // Number of redundant blocks included in one RTP packet
       
    71         TUint8 iRedBlockCount;
       
    72         
       
    73         // Size of maximum packetization interval of codec data
       
    74         TUint iMaxPayloadSize;
       
    75         
       
    76         // Number of encodings combined in RTP packet
       
    77         TUint8 iNumOfEncodings;
       
    78         
       
    79         // Payload types for encodings to use
       
    80         TFixedArray<TUint8, KMaxNumOfEncodings> iEncPayloadTypes;
       
    81     };
       
    82     
       
    83 typedef TPckgBuf<TMccRedPayloadWriteConfig> TMccRedPayloadWritePckg;
       
    84 
       
    85 /**
       
    86 *  CMMFFormatEncode interface for redundancy payload plugin.
       
    87 *
       
    88 *  @lib mmccredplformat.dll
       
    89 *  @since Series 60 3.0
       
    90 */
       
    91 class CMccRedPayloadWrite : public CPayloadFormatWrite,
       
    92                             public MMccRtpDataSink
       
    93     {
       
    94     public:  // Constructors and destructor
       
    95         
       
    96         /**
       
    97         * Two-phased constructor.
       
    98         */
       
    99         static CMccRedPayloadWrite* NewL( MDataSink* aSink );
       
   100         
       
   101         /**
       
   102         * Destructor.
       
   103         */
       
   104         virtual ~CMccRedPayloadWrite();
       
   105 
       
   106     public: // New functions
       
   107         
       
   108         /**
       
   109         * Configures payload format with format spesific parameters.
       
   110         * Leaves with KErrArgument if parameters are invalid.
       
   111         *
       
   112         * @since    Series 60 3.0 
       
   113         * @param    aConfigParams       Configuration parameters
       
   114         * @param    aClock              RTP media clock
       
   115         * @return   void
       
   116         */
       
   117         virtual void ConfigurePayloadFormatL( const TDesC8& aConfigParams,
       
   118             CMccRtpMediaClock& aClock );
       
   119         
       
   120     public: // From CMMFFormatEncode
       
   121 
       
   122         /**
       
   123         * From CMMFFormatEncode. Return the frame time interval for the given
       
   124         * media.
       
   125         *
       
   126         * @since    Series 60 3.0
       
   127         * @param    aMediaType  KUidMediaTypeAudio or KUidMediaTypeVideo
       
   128         * @return   Time interval in micro seconds
       
   129         */
       
   130         TTimeIntervalMicroSeconds FrameTimeInterval( TMediaId aMediaType) const;
       
   131 
       
   132         /**
       
   133         * NOT SUPPORTED. Return the clip duration for the given media.
       
   134         *
       
   135         * @since    Series 60 3.0        
       
   136         * @param    aMediaType KUidMediaTypeAudio or KUidMediaTypeVideo
       
   137         * @return   Clip duration in micro seconds
       
   138         */
       
   139         TTimeIntervalMicroSeconds Duration( TMediaId aMediaType ) const;          
       
   140 
       
   141 
       
   142     public:     // From MDataSink
       
   143 
       
   144         /**
       
   145         * From MDataSink. Create a sink buffer for the given media
       
   146         *
       
   147         * @since    Series 60 3.0
       
   148         * @param    aMediaId    media type KUidMediaTypeAudio or KUidMediaTypeVideo
       
   149         * @param    aReference  False is returned if sink buffer is created
       
   150         * @return   Pointer to sink buffer created
       
   151         */
       
   152         CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId,
       
   153                                        TBool &aReference ); 
       
   154 
       
   155         /**
       
   156         * From MDataSink. Returns the UID identifying the type of data sink.
       
   157         *
       
   158         * @since    Series 60 3.0
       
   159         * @return   The UID identifying the type of data sink
       
   160         */
       
   161         TUid DataSinkType() const;
       
   162         
       
   163         /**
       
   164         * From MDataSink. Return the sink four CC code for the given media
       
   165         *
       
   166         * @since    Series 60 3.0
       
   167         * @param    aMediaId    media type KUidMediaTypeAudio or KUidMediaTypeVideo
       
   168         * @return   FourCC code for the mediaId
       
   169         */
       
   170         TFourCC SinkDataTypeCode( TMediaId aMediaId );
       
   171 
       
   172         /**
       
   173         * From MDataSink. Set the sink data type to the given four CC code for
       
   174         * the given media.
       
   175         *
       
   176         * @since    Series 60 3.0
       
   177         * @param    aSinkFourCC fourCC code
       
   178         * @param    aMediaId    media type KUidMediaTypeAudio or KUidMediaTypeVideo
       
   179         * @return   KErrNotSupported if invalid media ID, else KErrNone
       
   180         */
       
   181         TInt SetSinkDataTypeCode( TFourCC aSinkFourCC,
       
   182                                   TMediaId aMediaId ); 
       
   183 
       
   184         /**
       
   185         * From MDataSink. Log on to the sink thread - this funtion merely
       
   186         * passes the command to its sink clip data source object. The sink
       
   187         * clip object will handle the thread log on procedures.
       
   188         *
       
   189         * @since    Series 60 3.0
       
   190         * @param    aEventHandler   address of event handler
       
   191         * @return   Error code returned by source clip
       
   192         */
       
   193         TInt SinkThreadLogon( MAsyncEventHandler& aEventHandler );
       
   194 
       
   195         /**
       
   196         * From MDataSink. Log out of the sink thread - this funtion merely
       
   197         * passes the command to its sink clip data source object. The sink
       
   198         * clip object will handle the thread log off procedures.
       
   199         *
       
   200         * @since    Series 60 3.0
       
   201         * @return   void
       
   202         */
       
   203         void SinkThreadLogoff();
       
   204         
       
   205         /**
       
   206         * From MDataSink Primes the source.
       
   207         *
       
   208         * @since    Series 60 3.0
       
   209         * @return   void
       
   210         */
       
   211         void SinkPrimeL();
       
   212 
       
   213         /**
       
   214         * From MDataSink Plays the source.
       
   215         *        
       
   216         * @since    Series 60 3.0
       
   217         * @return   void
       
   218         */
       
   219         void SinkPlayL();
       
   220 
       
   221         /**
       
   222         * From MDataSink Pauses the source.
       
   223         *
       
   224         * @since    Series 60 3.0
       
   225         * @return   void
       
   226         */
       
   227         void SinkPauseL();
       
   228 
       
   229         /**
       
   230         * From MDataSink Stops the source.
       
   231         *
       
   232         * @since    Series 60 3.0
       
   233         * @return   void
       
   234         */
       
   235         void SinkStopL();
       
   236 
       
   237         /**
       
   238         * From MDataSink. Empty the given source buffer.
       
   239         *
       
   240         * @param    aBuffer    data buffer to empty
       
   241         * @param    aSupplier  data source pointer
       
   242         * @param    aMediaId   media type KUidMediaTypeAudio or KUidMediaTypeVideo
       
   243         *
       
   244         * @return   void
       
   245         */
       
   246         void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier,
       
   247             TMediaId aMediaId );
       
   248         
       
   249 
       
   250         /**
       
   251         * From MDataSink. Called after the data buffer is written.
       
   252         * Update the number of bytes written and the current write position for
       
   253         * the next write operation. 
       
   254         *
       
   255         * @since    Series 60 3.0
       
   256         * @param    aBuffer       data buffer emptied
       
   257         * @return   void
       
   258         */
       
   259         void BufferEmptiedL( CMMFBuffer* aBuffer );
       
   260         
       
   261     public: // From MMccRtpDataSink
       
   262     
       
   263         /**
       
   264         * Empty source buffer to the sink of redundancy plugin.
       
   265         *
       
   266         * @since    Series 60 3.0
       
   267         * @param    aBuffer     Buffer to empty
       
   268         * @param    aSupplier   Data source to notify after buffer is emptied
       
   269         * @param    aMediaId    Identifies the media type of particular stream
       
   270         * @param    aSendHeader Carries RTP packet header fields
       
   271         * @return   void
       
   272         */
       
   273         void EmptyBufferL( CMMFBuffer* aBuffer,
       
   274                            MDataSource* aSupplier, 
       
   275                            TMediaId aMediaId,
       
   276                            TRtpSendHeader& aSendHeader );
       
   277 
       
   278     private:
       
   279 
       
   280         /**
       
   281         * C++ default constructor.
       
   282         */
       
   283         CMccRedPayloadWrite();
       
   284 
       
   285         /**
       
   286         * By default Symbian 2nd phase constructor is private.
       
   287         */
       
   288         void ConstructL( MDataSink* aSink );
       
   289         
       
   290         /**
       
   291         * Set payload types to accept as encodings.
       
   292         *
       
   293         * @since    Series 60 3.0
       
   294         * @param    aPayloadTypes       Payload types
       
   295         * @return   System wide error code
       
   296         */
       
   297         TInt SetPayloadTypes( RArray<TUint>& aPayloadTypes );
       
   298 
       
   299     private:    // Data
       
   300         
       
   301         // Redundancy encoder used to construct redundancy RTP format packet
       
   302         CMccRedEncoder* iRedEncoder;        // Has
       
   303         
       
   304         // Data source for redundancy plugin
       
   305         MDataSource* iDataSource;           // Uses
       
   306         
       
   307         // Sink buffer holding constructed redundancy RTP payload
       
   308         CMMFDataBuffer* iSinkBuffer;        // Has
       
   309         
       
   310         // Pointer to data buffer containing source data
       
   311         CMMFDataBuffer* iBufToEmptyPtr;     // Uses
       
   312         
       
   313         // Encapsulates payload format encoding parameters
       
   314         TMccRedPayloadWriteConfig iPLConfig;
       
   315 
       
   316     private:    // Friend classes
       
   317          // Friend class for testing
       
   318         #ifdef TEST_EUNIT
       
   319             friend class UT_CMccRedPayloadWrite;
       
   320         #endif
       
   321     };
       
   322 
       
   323 #endif      // MCCREDPAYLOADWRITE_H   
       
   324             
       
   325 // End of File