multimediacommscontroller/mmccredpayloadformat/inc/mccredpayloadread.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 Decode interface for redundancy payload plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef MCCREDPAYLOADREAD_H
       
    23 #define MCCREDPAYLOADREAD_H
       
    24 
       
    25 //  INCLUDES
       
    26 #include <mmf/server/mmfformat.h>
       
    27 #include "mccredencdecbase.h"
       
    28 #include "formatstatemachine.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CMccRedDecoder;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 /**
       
    35 *  Defines configuration parameters to be used with configuration method.
       
    36 *
       
    37 *  @lib mmccredplformat.dll
       
    38 *  @since Series 60 3.0
       
    39 */
       
    40 class TMccRedPayloadReadConfig
       
    41     {
       
    42     public:
       
    43         TMccRedPayloadReadConfig() :
       
    44             iRedPayloadType(0), iRedBlockCount( 0 ), iMaxPayloadSize( 0 ),
       
    45             iNumOfEncodings( 0 ), iEncPayloadTypes()
       
    46                 { }
       
    47 
       
    48         TMccRedPayloadReadConfig( TUint8 aRedPayloadType, TUint8 aRedBlockCount,
       
    49             TUint8 aMaxPayloadSize, TUint8 aNumOfEncodings ) :
       
    50             iRedPayloadType( aRedPayloadType ), iRedBlockCount( aRedBlockCount ),
       
    51             iMaxPayloadSize( aMaxPayloadSize ), iNumOfEncodings( aNumOfEncodings ),
       
    52             iEncPayloadTypes()
       
    53                 { }                    
       
    54 
       
    55         void InitPayloadTypes()
       
    56             {
       
    57             TInt ind( iEncPayloadTypes.Count() );
       
    58             while ( --ind )
       
    59                 {
       
    60                 iEncPayloadTypes[ind] = KPayloadNotDefined;
       
    61                 }
       
    62             }
       
    63             
       
    64         // RTP header payload type indicating redundancy format
       
    65         TUint8 iRedPayloadType;
       
    66         
       
    67         // Number of redundant blocks included in one RTP packet
       
    68         TUint8 iRedBlockCount;
       
    69         
       
    70         // Size of maximum packetization interval of codec data
       
    71         TUint iMaxPayloadSize;
       
    72         
       
    73         // Number of encodings combined in RTP packet
       
    74         TUint8 iNumOfEncodings;
       
    75         
       
    76         // Payload types for encodings to use
       
    77         TFixedArray<TUint8, KPayloadNotDefined> iEncPayloadTypes;
       
    78     };
       
    79     
       
    80 typedef TPckgBuf<TMccRedPayloadReadConfig> TMccRedPayloadReadPckg;
       
    81 
       
    82 /**
       
    83 *  Depacketizes RTP payload in redundancy format.
       
    84 *
       
    85 *  @lib mmccredplformat.dll
       
    86 *  @since Series 60 3.0
       
    87 */
       
    88 class CMccRedPayloadRead : public CPayloadFormatRead
       
    89     {
       
    90     public:  // Constructors and destructor
       
    91         
       
    92         /**
       
    93         * Two-phased constructor.
       
    94         */
       
    95         static CMccRedPayloadRead* NewL( MDataSource* aSource );
       
    96         
       
    97         /**
       
    98         * Destructor.
       
    99         */
       
   100         virtual ~CMccRedPayloadRead();
       
   101 
       
   102     public: // From CPayloadFormatRead
       
   103         
       
   104         /**
       
   105         * Configures payload format with format spesific parameters.
       
   106         * Leaves with KErrArgument if parameters are invalid.
       
   107         *
       
   108         * @since    Series 60 3.0 
       
   109         * @param    aConfigParams       Configuration parameters
       
   110         * @return   void
       
   111         */
       
   112         void ConfigurePayloadFormatL( const TDesC8& aConfigParams );
       
   113 
       
   114         /**
       
   115         * Called after the data buffer is filled. Update the number of bytes
       
   116         * read and the current read position for the next read operation. 
       
   117         *
       
   118         * @since    Series 60 3.0
       
   119         * @param    aBuffer         data buffer filled
       
   120         * @param    aRecvHeader     RTP header
       
   121         * @return   void
       
   122         */
       
   123         void DataBufferFilledL( CMMFBuffer* aBuffer, const TRtpRecvHeader& aRecvHeader );
       
   124     
       
   125     public: // From CMMFFormatDecode
       
   126 
       
   127         /**
       
   128         * From CMMFFormatDecode. Return number of audio streams for the given
       
   129         * media. Raw audio  files can only have 1 audio stream.
       
   130         *
       
   131         * @since    Series 60 3.0
       
   132         * @param    aMediaType  KUidMediaTypeAudio or KUidMediaTypeVideo
       
   133         * @return   Number of audio streams
       
   134         */
       
   135         TUint Streams( TUid aMediaType ) const;
       
   136         
       
   137         /**
       
   138         * From CMMFFormatDecode. Return the frame time interval for the given
       
   139         * media.
       
   140         *
       
   141         * @since    Series 60 3.0
       
   142         * @param    aMediaType  KUidMediaTypeAudio or KUidMediaTypeVideo
       
   143         * @return   Time interval in micro seconds
       
   144         */
       
   145         TTimeIntervalMicroSeconds FrameTimeInterval( TMediaId aMediaType) const;
       
   146         
       
   147         /**
       
   148         * From CMMFFormatDeoce. NOT SUPPORTED. Return the clip duration for 
       
   149         * the given media.
       
   150         *
       
   151         * @since    Series 60 3.0
       
   152         * @param    aMediaType  KUidMediaTypeAudio or KUidMediaTypeVideo
       
   153         * @return   Clip duration in micro seconds
       
   154         */
       
   155         TTimeIntervalMicroSeconds Duration( TMediaId aMediaType ) const;
       
   156         
       
   157     public: // From MDataSource
       
   158 
       
   159         /**
       
   160         * From MDataSource. Return the four CC code for the given media.
       
   161         *
       
   162         * @since    Series 60 3.0
       
   163         * @param    aMediaId    KUidMediaTypeAudio or KUidMediaTypeVideo
       
   164         * @return   FourCC code
       
   165         */
       
   166         TFourCC SourceDataTypeCode( TMediaId aMediaId );
       
   167         
       
   168         /**
       
   169         * From MDataSource. Set the source data type to the given four CC code
       
   170         * for the given media.
       
   171         *
       
   172         * @since    Series 60 3.0
       
   173         * @param    aSourceFourCC    fourCC code
       
   174         * @param    aMediaId         contains the media type KUidMediaTypeAudio
       
   175         *                            or KUidMediaTypeVideo
       
   176         *
       
   177         * @return   KErrNotSupported if invalid media ID, else return KErrvoid
       
   178         */
       
   179         TInt SetSourceDataTypeCode( TFourCC aSourceFourCC,
       
   180                                     TMediaId aMediaId );
       
   181 
       
   182         /**
       
   183         * From MDataSource. Tests whether a source buffer can be created.
       
   184         *
       
   185         * @since    Series 60 3.0
       
   186         * @return   ETrue if a source buffer can be created.
       
   187         */
       
   188         TBool CanCreateSourceBuffer();
       
   189         
       
   190         /**
       
   191         * From MDataSource. Create a source buffer for the given media
       
   192         *
       
   193         * @since    Series 60 3.0
       
   194         * @param    aMediaId   contains the media type KUidMediaTypeAudio or 
       
   195         *                      KUidMediaTypeVideo
       
   196         * @param    aReference value of False is returned to caller if source 
       
   197         *                      buffer is created
       
   198         *
       
   199         * @return   Pointer to source buffer created
       
   200         */
       
   201         CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, 
       
   202                                          TBool &aReference );
       
   203 
       
   204         /**
       
   205         * From MDataSource. Read the next block of data from file into the
       
   206         * given buffer.
       
   207         *
       
   208         * @since    Series 60 3.0        
       
   209         * @param    aBuffer    source data buffer for the AMR-NB data read
       
   210         * @param    aConsumer  data sink pointer
       
   211         * @param    aMediaId   contains the media type KUidMediaTypeAudio or 
       
   212         *                      KUidMediaTypeVideo
       
   213         *
       
   214         * @return   void
       
   215         */
       
   216         void FillBufferL( CMMFBuffer* aBuffer, 
       
   217                           MDataSink* aConsumer, 
       
   218                           TMediaId aMediaId );
       
   219                                  
       
   220         /**
       
   221         * From MDataSource. Log in to the source thread - this funtion merely
       
   222         * passes the command to its source clip data source object. The source
       
   223         * clip object will handle the thread log on procedures.
       
   224         *
       
   225         * @since    Series 60 3.0        
       
   226         * @param    aEventHandler    address of event handler
       
   227         *
       
   228         * @return   error code returned by source clip
       
   229         */
       
   230         TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler );
       
   231 
       
   232         /**
       
   233         * From MDataSource. Log out of the source thread - this funtion merely
       
   234         * passes the command to its source clip data source object. The source
       
   235         * clip object will handle the thread log off procedures.
       
   236         *
       
   237         * @since    Series 60 3.0
       
   238         * @return   void
       
   239         */
       
   240         void SourceThreadLogoff();  
       
   241         
       
   242         /**
       
   243         * From MDataSource. Primes the source.
       
   244         *
       
   245         * @since    Series 60 3.0
       
   246         * @return   void
       
   247         */    
       
   248         void SourcePrimeL();
       
   249 
       
   250         /**
       
   251         * From MDataSource. Plays the source.
       
   252         *
       
   253         * @since    Series 60 3.0
       
   254         * @return   void
       
   255         */    
       
   256         void SourcePlayL();
       
   257 
       
   258         /**
       
   259         * From MDataSource. Pauses the source.
       
   260         *
       
   261         * @since    Series 60 3.0
       
   262          * @return   void
       
   263         */
       
   264         void SourcePauseL();
       
   265 
       
   266         /**
       
   267         * From MDataSource. Stops the source.
       
   268         *
       
   269         * @since    Series 60 3.0
       
   270         * @return   void
       
   271         */    
       
   272         void SourceStopL();
       
   273         
       
   274         /**
       
   275         * From MDataSource. Negotiates source.
       
   276         *
       
   277         * @since    Series 60 3.0
       
   278         * @param    aDataSink       Data sink interested to receive data
       
   279         * @return   void
       
   280         */    
       
   281         void NegotiateSourceL( MDataSink& aDataSink );
       
   282         
       
   283         /**
       
   284         * From MDataSource. Used by the sink to suggest a source buffer size.
       
   285         *
       
   286         * @since    Series 60 3.0
       
   287         * @param    aSuggestedBufferSize A recommended buffer size
       
   288         * @return   void
       
   289         */
       
   290         void SuggestSourceBufferSize( TUint aSuggestedBufferSize );
       
   291     
       
   292     public: // From MDataSink
       
   293 
       
   294         /**
       
   295         * From MDataSink. Gets the data type code for the sink specified by the
       
   296         * media ID. Format decode may act in role of MDataSink.
       
   297         *
       
   298         * @since    Series 60 3.0
       
   299         * @param    aMediaId       Media ID
       
   300         * @return   The data sink type code
       
   301         */
       
   302         TFourCC SinkDataTypeCode( TMediaId aMediaId );
       
   303 
       
   304     private:
       
   305 
       
   306         /**
       
   307         * C++ default constructor.
       
   308         */
       
   309         CMccRedPayloadRead();
       
   310 
       
   311         /**
       
   312         * By default Symbian 2nd phase constructor is private.
       
   313         */
       
   314         void ConstructL( MDataSource* aSource );
       
   315         
       
   316         /**
       
   317         * Set payload types to accept as encodings.
       
   318         *
       
   319         * @since    Series 60 3.0
       
   320         * @param    aPayloadTypes       Payload types
       
   321         * @return   System wide error code
       
   322         */
       
   323         TInt SetPayloadTypes( RArray<TUint>& aPayloadTypes );
       
   324 
       
   325         /**
       
   326          * Creates a buffer used in data transfer between format read and
       
   327          * its datasource.
       
   328          *
       
   329          * @since    Series 60 3.2 
       
   330          * @param    aSize              Suggested buffer size
       
   331          * @param    aIsOwnBuffer       Indicates ownership of the buffer
       
   332          * @return   Created buffer
       
   333          */
       
   334         CMMFDataBuffer* CreateClipBufferL( TUint aSize, TBool& aIsOwnBuffer );
       
   335         
       
   336     private:    // Data
       
   337         
       
   338         // Decoder for redundancy payload
       
   339         CMccRedDecoder* iRedDecoder;
       
   340         
       
   341         // Data sink for redundancy plugin
       
   342         MDataSink* iDataSink;
       
   343         
       
   344         // The fourCC indicating data type used as redundant data
       
   345         TFourCC iFourCC;        
       
   346 
       
   347         // Buffer holding redundancy data got from far end
       
   348         CMMFDataBuffer* iSourceBuffer;
       
   349         
       
   350         // Indicates whether plugin owns it's source buffer
       
   351         TBool iSourceBufOwnership;
       
   352         
       
   353         // Pointer to the buffer passed with FillBufferL
       
   354         CMMFDataBuffer* iSinkBuffer;        // Uses
       
   355         
       
   356         // Encapsulates payload decoding parameters
       
   357         TMccRedPayloadReadConfig iPLConfig;
       
   358         
       
   359         // Suggeste source buffer size
       
   360         TUint iSuggestedBufSize;
       
   361         
       
   362     private:    // Friend classes
       
   363 
       
   364         // Friend class for testing
       
   365         #ifdef TEST_EUNIT
       
   366             friend class UT_CMccRedPayloadRead;
       
   367         #endif
       
   368 
       
   369     };
       
   370 
       
   371 #endif      // MCCREDPAYLOADREAD_H   
       
   372             
       
   373 // End of File