multimediacommscontroller/tsrc/stubs/src/mccredpayloadwrite_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 encode interface for redundancy plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    "rtpheader.h"
       
    24 #include    "mccredpayloadwrite.h"
       
    25 #include    "mccredencoder.h"
       
    26 #include    "mccrtpdatasink.h"
       
    27 #include    "mccredpayloadformatdefs.h"
       
    28 #include    "mccdef.h"
       
    29 #include    "mccinternaldef.h"
       
    30 #include    "mccrtpmediaclock.h"
       
    31 
       
    32 // ============================= LOCAL FUNCTIONS ===============================
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CMccRedPayloadWrite::CMccRedPayloadWrite
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CMccRedPayloadWrite::CMccRedPayloadWrite()
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CMccRedPayloadWrite::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CMccRedPayloadWrite::ConstructL( MDataSink* /*aSink*/ )
       
    52     {
       
    53     /*DP_RED_ENCODE( "CMccRedPayloadWrite::ConstructL" )
       
    54     __ASSERT_ALWAYS( aSink, User::Leave( KErrArgument ) );
       
    55     
       
    56     iClip = aSink;*/
       
    57     //iRedEncoder = CMccRedEncoder::NewL();
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CMccRedPayloadWrite::NewL
       
    62 // Two-phased constructor.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CMccRedPayloadWrite* CMccRedPayloadWrite::NewL( MDataSink* aSink )
       
    66     {
       
    67     /*DP_RED_ENCODE( "CMccRedPayloadWrite::NewL" )
       
    68     __ASSERT_ALWAYS( aSink, User::Leave( KErrArgument ) );
       
    69     __ASSERT_ALWAYS( KMccRtpSinkUid == aSink->DataSinkType(),
       
    70         User::Leave( KErrNotSupported ) );*/
       
    71     
       
    72     CMccRedPayloadWrite* self = new( ELeave ) CMccRedPayloadWrite;
       
    73     
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL( aSink );
       
    76     CleanupStack::Pop( self );
       
    77 
       
    78     return self;
       
    79     }
       
    80 
       
    81     
       
    82 // Destructor
       
    83 CMccRedPayloadWrite::~CMccRedPayloadWrite()
       
    84     {
       
    85     /*DP_RED_ENCODE( "CMccRedPayloadWrite::~CMccRedPayloadWrite" )*/
       
    86         
       
    87     //delete iRedEncoder;
       
    88     /*delete iSinkBuffer;
       
    89     iDataSource = NULL;
       
    90     iBufToEmptyPtr = NULL;*/
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CMccRedPayloadRead::ConfigurePayloadFormatL
       
    95 // Configure payload encoding parameters.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void CMccRedPayloadWrite::ConfigurePayloadFormatL( const TDesC8& /*aConfigParams*/,
       
    99         CMccRtpMediaClock& /*aClock*/ )
       
   100     {
       
   101     /*DP_RED_ENCODE( "CMccRedPayloadWrite::ConfigurePayloadFormatL" )
       
   102     __ASSERT_ALWAYS( aConfigParams.Size() == sizeof( TMccRedPayloadWriteConfig ),
       
   103         User::Leave( KErrArgument ) );
       
   104     
       
   105     TMccRedPayloadWritePckg cPckg;
       
   106     cPckg.Copy( aConfigParams );
       
   107     iPLConfig = cPckg();
       
   108 
       
   109     __ASSERT_ALWAYS( iPLConfig.iRedBlockCount <= KMaxRedCount, 
       
   110         User::Leave( KErrArgument ) );
       
   111     
       
   112     if ( iSinkBuffer )
       
   113         {
       
   114         delete iSinkBuffer;
       
   115         iSinkBuffer = NULL;
       
   116         }
       
   117     
       
   118     // Extra variables for clarity
       
   119     TInt redPayloadSize
       
   120         = iPLConfig.iMaxPayloadSize * ( 1 + iPLConfig.iRedBlockCount );
       
   121     TInt redHeadersSize 
       
   122         = iPLConfig.iRedBlockCount * KRedHeaderSize + KFinalHeaderSize;
       
   123     iSinkBuffer = CMMFDataBuffer::NewL( redPayloadSize + redHeadersSize );
       
   124                                     
       
   125     iRedEncoder->InitializeL( iPLConfig.iRedBlockCount,
       
   126                               iPLConfig.iMaxPayloadSize, 
       
   127                               iPLConfig.iNumOfEncodings );
       
   128                               
       
   129     RArray<TUint> encPTs;
       
   130     CleanupClosePushL( encPTs );
       
   131 
       
   132     TInt maxNumOfEncodings = iPLConfig.iEncPayloadTypes.Count();
       
   133     for ( TInt i = 0; i < maxNumOfEncodings; i++ )
       
   134         {
       
   135         if ( KPayloadNotDefined != iPLConfig.iEncPayloadTypes[i] )
       
   136             {
       
   137             encPTs.AppendL( iPLConfig.iEncPayloadTypes[i] );
       
   138             }
       
   139         }
       
   140 
       
   141     User::LeaveIfError( iRedEncoder->SetPayloadTypes( encPTs ) );
       
   142     CleanupStack::PopAndDestroy( &encPTs );*/
       
   143     }
       
   144     
       
   145 // -----------------------------------------------------------------------------
       
   146 // CMccRedPayloadWrite::FrameTimeInterval
       
   147 // NOT USED. Pure virtual method implementation from CMMFormatEncode needed.
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TTimeIntervalMicroSeconds CMccRedPayloadWrite::FrameTimeInterval( 
       
   151         TMediaId /*aMediaType*/ ) const
       
   152     {
       
   153     //DP_RED_ENCODE( "CMccRedPayloadWrite::FrameTimeInterval" )
       
   154 
       
   155     return TTimeIntervalMicroSeconds( TInt64( 0 ) );
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CMccRedPayloadWrite::Duration
       
   160 // NOT USED. Pure virtual method implementation from CMMFormatEncode needed.
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 TTimeIntervalMicroSeconds CMccRedPayloadWrite::Duration( 
       
   164         TMediaId /*aMediaType*/ ) const
       
   165     {
       
   166     //DP_RED_ENCODE( "CMccRedPayloadWrite::Duration" )
       
   167 
       
   168     return TTimeIntervalMicroSeconds( TInt64( 0 ) );
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CMccRedPayloadWrite::CreateSinkBufferL
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 CMMFBuffer* CMccRedPayloadWrite::CreateSinkBufferL( TMediaId /*aMediaId*/,
       
   176                                                     TBool& /*aReference*/ )
       
   177     {
       
   178     /*DP_RED_ENCODE( "CMccRedPayloadWrite::CreateSinkBufferL" )
       
   179     User::Leave( KErrNotSupported );*/
       
   180     return NULL;
       
   181     }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CMccRedPayloadWrite::DataSinkType
       
   185 //
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 TUid CMccRedPayloadWrite::DataSinkType() const
       
   189     {
       
   190     return TUid::Uid( KImplUidRedPayloadFormatEncode );
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CMccRedPayloadWrite::SinkDataTypeCode
       
   195 // NOT USED.
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TFourCC CMccRedPayloadWrite::SinkDataTypeCode( TMediaId /*aMediaId*/ )
       
   199     {
       
   200     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkDataTypeCode" )
       
   201         
       
   202     return TFourCC();
       
   203     }
       
   204 
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CMccRedPayloadWrite::SetSinkDataTypeCode
       
   208 // NOT USED.
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TInt CMccRedPayloadWrite::SetSinkDataTypeCode( TFourCC /*aSinkFourCC*/,
       
   212                                                TMediaId /*aMediaId*/ )
       
   213     {
       
   214     //DP_RED_ENCODE( "CMccRedPayloadWrite::SetSinkDataTypeCode" )
       
   215         
       
   216     return KErrNone;
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // CMccRedPayloadWrite::SinkThreadLogon
       
   221 // Passes state transition to the data sink of redundancy payload plugin.
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TInt CMccRedPayloadWrite::SinkThreadLogon( MAsyncEventHandler& /*aEventHandler*/ )
       
   225     {
       
   226     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkThreadLogon" )
       
   227         
       
   228     //iClip->SinkThreadLogon( aEventHandler );
       
   229     return KErrNone;
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CMccRedPayloadWrite::SinkThreadLogoff
       
   234 // Passes state transition to the data sink of redundancy payload plugin.
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CMccRedPayloadWrite::SinkThreadLogoff()
       
   238     {
       
   239     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkThreadLogoff" )
       
   240         
       
   241     //iClip->SinkThreadLogoff();    
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CMccRedPayloadWrite::SinkPrimeL
       
   246 // Passes state transition to the data sink of redundancy payload plugin.
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 void CMccRedPayloadWrite::SinkPrimeL()
       
   250     {
       
   251     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkPrimeL" )
       
   252         
       
   253     //iClip->SinkPrimeL();
       
   254     }
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // CMccRedPayloadWrite::SinkPlayL
       
   258 // Passes state transition to the data sink of redundancy payload plugin.
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 void CMccRedPayloadWrite::SinkPlayL()
       
   262     {
       
   263     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkPlayL" )
       
   264         
       
   265     //iClip->SinkPlayL();
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CMccRedPayloadWrite::SinkPauseL
       
   270 // Passes state transition to the data sink of redundancy payload plugin.
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CMccRedPayloadWrite::SinkPauseL()
       
   274     {
       
   275     //DP_RED_ENCODE( "CMccRedPayloadWrite::SinkPauseL" )
       
   276         
       
   277     //iClip->SinkPauseL();
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CMccRedPayloadWrite::SinkStopL
       
   282 // Passes state transition to the data sink of redundancy payload plugin.
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CMccRedPayloadWrite::SinkStopL()
       
   286     {
       
   287     DP_RED_ENCODE( "CMccRedPayloadWrite::SinkStopL" )
       
   288         
       
   289     //iClip->SinkStopL();
       
   290     }
       
   291     
       
   292 // -----------------------------------------------------------------------------
       
   293 // CMccRedPayloadWrite::EmptyBufferL
       
   294 // NOT USED.
       
   295 // Overloaded emptybuffer with additional RTP header parameter used instead.
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 void CMccRedPayloadWrite::EmptyBufferL( CMMFBuffer* /*aBuffer*/,
       
   299                                         MDataSource* /*aSupplier*/, 
       
   300                                         TMediaId /*aMediaId*/ )
       
   301     {
       
   302     //DP_RED_ENCODE( "CMccRedPayloadWrite::EmptyBufferL" )
       
   303         
       
   304     //User::Leave( KErrNotSupported );
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CMccRedPayloadWrite::BufferEmptiedL
       
   309 // Called by data sink of redundancy payload plugin, when payload is emptied.
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 void CMccRedPayloadWrite::BufferEmptiedL( CMMFBuffer* /*aBuffer*/ )
       
   313     {
       
   314     //DP_RED_ENCODE( "CMccRedPayloadWrite::BufferEmptiedL" )
       
   315     //__ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) );
       
   316     //__ASSERT_ALWAYS( iBufToEmptyPtr, User::Leave( KErrNotReady ) );
       
   317     
       
   318     //iDataSource->BufferEmptiedL( iBufToEmptyPtr );
       
   319     }
       
   320     
       
   321 // -----------------------------------------------------------------------------
       
   322 // CMccRedPayloadWrite::EmptyBufferL
       
   323 // Encodes contents of source buffer with redundancy encoder and forwards
       
   324 // result buffer to the data sink of redundancy payload plugin.
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 void CMccRedPayloadWrite::EmptyBufferL( CMMFBuffer* /*aSourceBuffer*/,
       
   328                                         MDataSource* /*aSupplier*/, 
       
   329                                         TMediaId /*aMediaId*/,
       
   330                                         TRtpSendHeader& /*aSendHeader*/ )
       
   331     {
       
   332     /*DP_RED_ENCODE( "CMccRedPayloadWrite::EmptyBufferL" )
       
   333     __ASSERT_ALWAYS( aSourceBuffer, User::Leave( KErrArgument ) );
       
   334     __ASSERT_ALWAYS( KUidMmfDataBuffer == aSourceBuffer->Type(),
       
   335         User::Leave( KErrNotSupported ) );
       
   336     __ASSERT_ALWAYS( aSupplier, User::Leave( KErrArgument ) );
       
   337     __ASSERT_ALWAYS( KUidMediaTypeAudio == aMediaId.iMediaType,
       
   338         User::Leave( KErrNotSupported ) );
       
   339     
       
   340     DP_RED_ENCODE( "CMccRedPayloadWrite::EmptyBufferL() - MEDIA TYPE OK" )
       
   341     
       
   342     iDataSource = aSupplier;
       
   343     iBufToEmptyPtr = static_cast<CMMFDataBuffer*>( aSourceBuffer );
       
   344 
       
   345     if ( KComfortNoisePT != aSendHeader.iPayloadType )
       
   346         {
       
   347         // Comfort noise packets are forwarded without encoding
       
   348         iRedEncoder->SetEncodingBlockL( 
       
   349             EMccPrimaryEncoding, iBufToEmptyPtr->Data() );
       
   350         iRedEncoder->EncodePayloadL( aSendHeader.iTimestamp );
       
   351         iRedEncoder->GetEncodingBlockL( EMccRTPPayload, iSinkBuffer->Data() );
       
   352 
       
   353         DP_RED_ENCODE( "CMccRedPayloadWrite::EmptyBufferL() - Buffer encoded" )
       
   354         aSendHeader.iPayloadType = iPLConfig.iRedPayloadType;
       
   355         }
       
   356 
       
   357     // Deliver the packet
       
   358     static_cast<CMccRtpDataSink*>( iClip )
       
   359         ->EmptyBufferL( iSinkBuffer, this, aMediaId, aSendHeader );*/
       
   360     }
       
   361     
       
   362 // -----------------------------------------------------------------------------
       
   363 // CMccRedPayloadWrite::SetPayloadTypes
       
   364 // Set payload types to accept as encodings.
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 TInt CMccRedPayloadWrite::SetPayloadTypes( RArray<TUint>& /*aPayloadTypes*/ )
       
   368     {
       
   369     /*DP_RED_ENCODE( "CMccRedPayloadWrite::SetPayloadTypes" )
       
   370         
       
   371     if ( aPayloadTypes.Count() )
       
   372         {
       
   373         iPLConfig.iRedPayloadType = aPayloadTypes[0];
       
   374         aPayloadTypes.Remove( 0 );
       
   375         
       
   376         return iRedEncoder->SetPayloadTypes( aPayloadTypes );
       
   377         }
       
   378     else
       
   379         {
       
   380         return KErrArgument;
       
   381         } */
       
   382     return KErrNone;           
       
   383     }
       
   384     
       
   385 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   386 
       
   387 //  End of File