multimediacommscontroller/tsrc/stubs/src/mccredpayloadread_STUB.cpp
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:    Implements format decode interface for redundancy plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "rtpheader.h"
       
    24 #include "mccredpayloadread.h"
       
    25 #include "mccreddecoder.h"
       
    26 #include "mccredpayloadformatdefs.h"
       
    27 #include "formatstatemachine.h"
       
    28 
       
    29 // ============================= LOCAL FUNCTIONS ===============================
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CMccRedPayloadRead::CMccRedPayloadRead
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CMccRedPayloadRead::CMccRedPayloadRead()
       
    40     {
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CMccRedPayloadRead::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CMccRedPayloadRead::ConstructL( MDataSource* aSource )
       
    49     {
       
    50     DP_RED_DECODE( "CMccRedPayloadRead_STUB::ConstructL" )
       
    51     //__ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) );
       
    52     
       
    53     iClip = aSource;
       
    54     /*iRedDecoder = CMccRedDecoder::NewL();*/
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CMccRedPayloadRead::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CMccRedPayloadRead* CMccRedPayloadRead::NewL( MDataSource* aSource )
       
    63     {
       
    64     DP_RED_DECODE( "CMccRedPayloadRead_STUB::NewL" )/*
       
    65     __ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) );*/
       
    66     
       
    67     CMccRedPayloadRead* self = new( ELeave ) CMccRedPayloadRead;
       
    68     
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( aSource );
       
    71     CleanupStack::Pop( self );
       
    72 
       
    73     return self;
       
    74     }
       
    75 
       
    76     
       
    77 // Destructor
       
    78 CMccRedPayloadRead::~CMccRedPayloadRead()
       
    79     {
       
    80     DP_RED_DECODE( "CMccRedPayloadRead_STUB::~CMccRedPayloadRead" )
       
    81 
       
    82     /*delete iRedDecoder;
       
    83     if ( iSourceBufOwnership )
       
    84         {
       
    85         delete iSourceBuffer;
       
    86         }
       
    87     else
       
    88         {
       
    89         iSourceBuffer = NULL;
       
    90         }*/
       
    91     
       
    92     iDataSink = NULL;
       
    93     iClip = NULL;
       
    94     iSinkBuffer = NULL;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMccRedPayloadRead::ConfigurePayloadFormatL
       
    99 // Configure payload decoding parameters.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CMccRedPayloadRead::ConfigurePayloadFormatL( const TDesC8& /*aConfigParams*/ )
       
   103     {
       
   104     DP_RED_DECODE( "CMccRedPayloadRead_STUB::ConfigurePayloadFormatL" )/*
       
   105     __ASSERT_ALWAYS( aConfigParams.Size() == sizeof( TMccRedPayloadReadConfig ),
       
   106         User::Leave( KErrArgument ) );
       
   107     
       
   108     TMccRedPayloadReadPckg cPckg;
       
   109     cPckg.Copy( aConfigParams );
       
   110     iPLConfig = cPckg();
       
   111 
       
   112     __ASSERT_ALWAYS( iPLConfig.iRedBlockCount <= KMaxRedCount, 
       
   113         User::Leave( KErrArgument ) );
       
   114     
       
   115     if ( iSourceBuffer && iSourceBufOwnership )
       
   116         {
       
   117         delete iSourceBuffer;
       
   118         iSourceBuffer = NULL;
       
   119         }
       
   120     
       
   121     // Extra variables for clarity
       
   122     TInt redPayloadSize
       
   123         = iPLConfig.iMaxPayloadSize * ( 1 + iPLConfig.iRedBlockCount );
       
   124     TInt redHeadersSize 
       
   125         = iPLConfig.iRedBlockCount * KRedHeaderSize + KFinalHeaderSize;
       
   126     
       
   127     iSourceBuffer = CreateClipBufferL( redPayloadSize + redHeadersSize, 
       
   128         iSourceBufOwnership );
       
   129     iRedDecoder->InitializeL( iPLConfig.iRedBlockCount,
       
   130                               iPLConfig.iMaxPayloadSize, 
       
   131                               iPLConfig.iNumOfEncodings );
       
   132                               
       
   133     RArray<TUint> encPTs;
       
   134     CleanupClosePushL( encPTs );
       
   135 
       
   136     TInt maxNumOfEncodings = iPLConfig.iEncPayloadTypes.Count();
       
   137     for ( TInt i = 0; i < maxNumOfEncodings; i++ )
       
   138         {
       
   139         if ( KPayloadNotDefined != iPLConfig.iEncPayloadTypes[i] )
       
   140             {
       
   141             encPTs.AppendL( iPLConfig.iEncPayloadTypes[i] );
       
   142             }
       
   143         }
       
   144 
       
   145     User::LeaveIfError( iRedDecoder->SetPayloadTypes( encPTs ) );
       
   146     CleanupStack::PopAndDestroy( &encPTs );  */                            
       
   147     }
       
   148     
       
   149 // -----------------------------------------------------------------------------
       
   150 // CMccRedPayloadRead::DataBufferFilledL
       
   151 // Redundancy format is decoded from parameter buffer and result is passed
       
   152 // to the data sink of redundancy payload plugin.
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CMccRedPayloadRead::DataBufferFilledL( CMMFBuffer* /*aBuffer*/, 
       
   156                                         const TRtpRecvHeader& /*aRecvHeader*/ )
       
   157     {
       
   158     DP_RED_DECODE( "CMccRedPayloadRead_STUB::BufferFilledL" )
       
   159     
       
   160     /*__ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) );
       
   161     __ASSERT_ALWAYS( KUidMmfDataBuffer == aBuffer->Type(),
       
   162         User::Leave( KErrNotSupported ) );
       
   163     __ASSERT_ALWAYS( iDataSink, User::Leave( KErrNotReady ) );
       
   164     
       
   165     if ( aRecvHeader.iPayloadType == iPLConfig.iRedPayloadType )
       
   166         {
       
   167         iRedDecoder->SetEncodingBlockL( EMccRTPPayload, 
       
   168             static_cast<CMMFDataBuffer*>( aBuffer )->Data() );
       
   169         
       
   170         TInt numOfBlocks = User::LeaveIfError( 
       
   171             iRedDecoder->DecodePayload( aRecvHeader.iTimestamp ) );
       
   172         
       
   173         if ( numOfBlocks )
       
   174             {
       
   175             iRedDecoder->GetEncodingBlockL( 
       
   176                 EMccPrimaryEncoding, iSinkBuffer->Data() );
       
   177             }
       
   178         }
       
   179     else
       
   180         {
       
   181         iSinkBuffer->Data().Copy( static_cast<CMMFDataBuffer*>( aBuffer )->Data() );
       
   182         }        
       
   183     
       
   184     DP_RED_DECODE( "CMccRedPayloadRead::BufferFilledL - Buffer decoded" )
       
   185         
       
   186     // Payload format read is data sink for redundancy plugin
       
   187     static_cast<CPayloadFormatRead*>( iDataSink )
       
   188         ->BufferFilledL( iSinkBuffer, aRecvHeader );*/
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CMccRedPayloadRead::Streams
       
   193 // NOT USED. Pure virtual method implementation from CMMFormatDecode needed.
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 TUint CMccRedPayloadRead::Streams( TUid /*aMediaType*/ ) const
       
   197     {
       
   198     DP_RED_DECODE( "CMccRedPayloadRead_STUB::Streams" )
       
   199         
       
   200     /*if ( KUidMediaTypeAudio == aMediaType )
       
   201         {
       
   202         return 1;
       
   203         }
       
   204     else
       
   205         {
       
   206         return 0;
       
   207         }*/
       
   208     return KErrNone;    
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CMccRedPayloadRead::FrameTimeInterval
       
   213 // NOT USED. Pure virtual method implementation from CMMFormatDecode needed.
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 TTimeIntervalMicroSeconds CMccRedPayloadRead::FrameTimeInterval( 
       
   217         TMediaId /*aMediaType*/ ) const
       
   218     {
       
   219     DP_RED_DECODE( "CMccRedPayloadRead_STUB::FrameTimeInterval" )
       
   220         
       
   221     //return TTimeIntervalMicroSeconds( TInt64( 0 ) );
       
   222     return KErrNone;
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CMccRedPayloadRead::Duration
       
   227 // NOT USED. Pure virtual method implementation from CMMFormatDecode needed.
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 TTimeIntervalMicroSeconds   CMccRedPayloadRead::Duration( 
       
   231         TMediaId /*aMediaType*/ ) const
       
   232     {
       
   233     DP_RED_DECODE( "CMccRedPayloadRead_STUB::Duration" )
       
   234 
       
   235     //return TTimeIntervalMicroSeconds( TInt64( 0 ) );
       
   236     return KErrNone;
       
   237     }
       
   238         
       
   239 // -----------------------------------------------------------------------------
       
   240 // CMccRedPayloadRead::SourceDataTypeCode
       
   241 // Returns the current datatype FourCC code.
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 TFourCC CMccRedPayloadRead::SourceDataTypeCode( TMediaId /*aMediaId*/ )
       
   245     {
       
   246     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourceDataTypeCode" )
       
   247         
       
   248     /*if ( KUidMediaTypeAudio == aMediaId.iMediaType )
       
   249         {
       
   250         return iFourCC;
       
   251         }
       
   252     else
       
   253         {
       
   254         return TFourCC(); //defaults to 'NULL' fourCC
       
   255         }*/
       
   256     return TFourCC();   
       
   257     }
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // CMccRedPayloadRead::SetSourceDataTypeCode
       
   261 // Sets source datatype fourCC code.
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 TInt CMccRedPayloadRead::SetSourceDataTypeCode( TFourCC /*aSourceFourCC*/,
       
   265                                                 TMediaId /*aMediaId*/ )
       
   266     {
       
   267     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SetSourceDataTypeCode" )
       
   268     
       
   269     /*if ( KUidMediaTypeAudio != aMediaId.iMediaType )
       
   270         {
       
   271         return KErrNotSupported;
       
   272         }
       
   273     
       
   274     iFourCC = aSourceFourCC;*/
       
   275     return KErrNone;
       
   276     }
       
   277     
       
   278 // -----------------------------------------------------------------------------
       
   279 // CMccRedPayloadRead::CanCreateSourceBuffer
       
   280 // 
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 TBool CMccRedPayloadRead::CanCreateSourceBuffer()
       
   284     {
       
   285     DP_RED_DECODE( "CMccRedPayloadRead_STUB::CanCreateSourceBuffer" )
       
   286 
       
   287     return EFalse;
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CMccRedPayloadRead::CreateSourceBufferL
       
   292 // 
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 CMMFBuffer* CMccRedPayloadRead::CreateSourceBufferL( TMediaId /*aMediaId*/, 
       
   296                                                      TBool& /*aReference*/ )
       
   297     {
       
   298     DP_RED_DECODE( "CMccRedPayloadRead_STUB::CreateSourceBufferL" )
       
   299     /*__ASSERT_ALWAYS( KUidMediaTypeAudio == aMediaId.iMediaType,
       
   300         User::Leave( KErrNotSupported ) );
       
   301     __ASSERT_ALWAYS( iSuggestedBufSize, User::Leave( KErrNotReady ) );
       
   302     
       
   303     aReference = EFalse;
       
   304     
       
   305     CMMFDataBuffer* buf = CMMFDataBuffer::NewL( iSuggestedBufSize );
       
   306     iSuggestedBufSize = 0;
       
   307     return buf;*/
       
   308     return NULL;
       
   309     }
       
   310 
       
   311 // -----------------------------------------------------------------------------
       
   312 // CMccRedPayloadRead::FillBufferL
       
   313 // 
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 void CMccRedPayloadRead::FillBufferL( CMMFBuffer* /*aBuffer*/, 
       
   317                                       MDataSink* /*aConsumer*/, 
       
   318                                       TMediaId /*aMediaId*/ )
       
   319     {
       
   320     DP_RED_DECODE( "CMccRedPayloadRead_STUB::FillBufferL" )
       
   321 
       
   322     /*__ASSERT_ALWAYS( NULL != aBuffer, User::Leave( KErrArgument ) );
       
   323     __ASSERT_ALWAYS( NULL != aConsumer, User::Leave( KErrArgument ) );
       
   324     __ASSERT_ALWAYS( KUidMediaTypeAudio == aMediaId.iMediaType,
       
   325         User::Leave( KErrNotSupported ) );
       
   326     __ASSERT_ALWAYS( KUidMmfDataBuffer == aBuffer->Type(),
       
   327         User::Leave( KErrNotSupported ) );
       
   328     
       
   329     iDataSink = aConsumer;
       
   330     iSinkBuffer = static_cast<CMMFDataBuffer*>( aBuffer );
       
   331     
       
   332     iClip->FillBufferL( iSourceBuffer, this, aMediaId );*/
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // CMccRedPayloadRead::SourceThreadLogon
       
   337 // Passes state transition to the data source of redundancy payload plugin.
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 TInt CMccRedPayloadRead::SourceThreadLogon( MAsyncEventHandler& /*aEventHandler*/ )
       
   341     {
       
   342     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourceThreadLogon" )
       
   343         
       
   344     //return iClip->SourceThreadLogon( aEventHandler );
       
   345     return KErrNone;
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CMccRedPayloadRead::SourceThreadLogoff
       
   350 // Passes state transition to the data source of redundancy payload plugin.
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 void CMccRedPayloadRead::SourceThreadLogoff()
       
   354     {
       
   355     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourceThreadLogoff" )
       
   356         
       
   357     //iClip->SourceThreadLogoff();
       
   358     }
       
   359 
       
   360 // -----------------------------------------------------------------------------
       
   361 // CMccRedPayloadRead::SourcePrimeL
       
   362 // Passes state transition to the data source of redundancy payload plugin.
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 void CMccRedPayloadRead::SourcePrimeL()
       
   366     {
       
   367     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourcePrimeL" )
       
   368         
       
   369     //iClip->SourcePrimeL();
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CMccRedPayloadRead::SourcePlayL
       
   374 // Passes state transition to the data source of redundancy payload plugin.
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 void CMccRedPayloadRead::SourcePlayL()
       
   378     {
       
   379     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourcePlayL" )
       
   380         
       
   381     //iClip->SourcePlayL();
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CMccRedPayloadRead::SourcePauseL
       
   386 // Passes state transition to the data source of redundancy payload plugin.
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 void CMccRedPayloadRead::SourcePauseL()
       
   390     {
       
   391     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourcePauseL" )
       
   392         
       
   393     //iClip->SourcePauseL();
       
   394     }
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // CMccRedPayloadRead::SourceStopL
       
   398 // Passes state transition to the data source of redundancy payload plugin.
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 void CMccRedPayloadRead::SourceStopL()
       
   402     {
       
   403     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SourceStopL" )
       
   404         
       
   405     //iClip->SourceStopL();
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CMccRedPayloadRead::NegotiateSourceL
       
   410 // Negotiate Source.
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 void CMccRedPayloadRead::NegotiateSourceL( MDataSink& /*aDataSink*/ )
       
   414     {
       
   415     DP_RED_DECODE( "CMccRedPayloadRead_STUB::NegotiateSourceL" )
       
   416         
       
   417     //iDataSink = &aDataSink;
       
   418     ///iClip->NegotiateSourceL( *this );
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CMccRedPayloadRead::SuggestSourceBufferSize
       
   423 // 
       
   424 // -----------------------------------------------------------------------------
       
   425 //
       
   426 void CMccRedPayloadRead::SuggestSourceBufferSize( TUint /*aSuggestedBufferSize*/ )
       
   427     {
       
   428     //iSuggestedBufSize = aSuggestedBufferSize;
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CMccRedPayloadRead::SinkDataTypeCode
       
   433 // Returns the current datatype FourCC code.
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 TFourCC CMccRedPayloadRead::SinkDataTypeCode( TMediaId /*aMediaId*/ )
       
   437     {
       
   438     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SinkDataTypeCode" )
       
   439         
       
   440     /*if ( KUidMediaTypeAudio == aMediaId.iMediaType )
       
   441         {
       
   442         if ( iDataSink )
       
   443             {
       
   444             return iDataSink->SinkDataTypeCode( aMediaId );
       
   445             }
       
   446         else
       
   447             {
       
   448             return TFourCC();
       
   449             }
       
   450         }
       
   451     else
       
   452         {
       
   453         return TFourCC(); //defaults to 'NULL' fourCC
       
   454         }*/
       
   455     return TFourCC();
       
   456     }
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CMccRedPayloadRead::SetPayloadTypes
       
   460 // Set payload types to accept as encodings.
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 TInt CMccRedPayloadRead::SetPayloadTypes( RArray<TUint>& /*aPayloadTypes*/ )
       
   464     {
       
   465     DP_RED_DECODE( "CMccRedPayloadRead_STUB::SetPayloadTypes" )
       
   466     
       
   467     /*if ( aPayloadTypes.Count() )
       
   468         {
       
   469         iPLConfig.iRedPayloadType = static_cast<TUint8>( aPayloadTypes[0] );
       
   470         aPayloadTypes.Remove( 0 );
       
   471         
       
   472         return iRedDecoder->SetPayloadTypes( aPayloadTypes );
       
   473         }
       
   474     else
       
   475         {
       
   476         return KErrArgument;
       
   477         }*/
       
   478     return KErrNone;    
       
   479     }
       
   480     
       
   481 // -----------------------------------------------------------------------------
       
   482 // CMccRedPayloadRead::CreateClipBufferL
       
   483 // Creates buffer needed in data transfer with format readers clip.
       
   484 // -----------------------------------------------------------------------------
       
   485 //
       
   486 CMMFDataBuffer* CMccRedPayloadRead::CreateClipBufferL( 
       
   487         TUint /*aSize*/, TBool& /*aIsOwnBuffer*/ )
       
   488     {
       
   489     DP_RED_DECODE( "CMccRedPayloadRead_STUB::CreateClipBufferL" )
       
   490     CMMFDataBuffer* buffer( NULL );
       
   491     
       
   492     /*if ( iClip->CanCreateSourceBuffer() )
       
   493         {
       
   494         static_cast<CMMFFormatDecode*>( iClip )->SuggestSourceBufferSize( aSize );
       
   495         
       
   496         TBool reference( EFalse );
       
   497         CMMFBuffer* sourceBuf 
       
   498             = iClip->CreateSourceBufferL( KUidMediaTypeAudio, reference );
       
   499         TBool isSupportedBuf 
       
   500             = CMMFBuffer::IsSupportedDataBuffer( sourceBuf->Type() );
       
   501         TBool isOwnBuffer = reference ? EFalse : ETrue;
       
   502         
       
   503         if ( !isSupportedBuf )
       
   504             {
       
   505             if ( isOwnBuffer )
       
   506                 {
       
   507                 delete sourceBuf;
       
   508                 }
       
   509             
       
   510             User::Leave( KErrNotSupported );
       
   511             }
       
   512         
       
   513         aIsOwnBuffer = isOwnBuffer;
       
   514         buffer = static_cast<CMMFDataBuffer*>( sourceBuf );
       
   515         }
       
   516     else
       
   517         {
       
   518         aIsOwnBuffer = ETrue;
       
   519         buffer = CMMFDataBuffer::NewL( aSize );
       
   520         }*/
       
   521     
       
   522     return buffer;
       
   523     }
       
   524 
       
   525 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   526 
       
   527 
       
   528 //  End of File