multimediacommsengine/mmceshared/src/mcecomrtpsource.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 #include "mcertpsource.h"
       
    22 #include "mcecomrtpsource.h"
       
    23 #include "mceserial.h"
       
    24 #include "mceevents.h"
       
    25 
       
    26 #ifdef MCE_COMMON_SERVER_SIDE
       
    27 
       
    28 #include <mmccinterface.h>
       
    29 #include "mcemediaobserver.h"
       
    30 #include "mcesdpsession.h"
       
    31 #include "mcemediamanager.h"
       
    32 
       
    33 #endif//MCE_COMMON_SERVER_SIDE
       
    34 
       
    35 
       
    36 const TUint KTimeConversion = 1000;
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CMceComRtpSource::NewL
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CMceComRtpSource* CMceComRtpSource::NewL()
       
    46     {
       
    47     CMceComRtpSource* self = NewLC();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CMceComRtpSource::NewLC
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CMceComRtpSource* CMceComRtpSource::NewLC()
       
    57     {
       
    58     CMceComRtpSource* self = new (ELeave) CMceComRtpSource();
       
    59     CleanupStack::PushL( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CMceComRtpSource::ConstructL
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CMceComRtpSource::ConstructL( CMceComRtpSource& aSource )
       
    68     {
       
    69     Mem::Copy( this, &aSource, sizeof(CMceComMediaSource) );
       
    70     Zero();
       
    71     iSettings = NULL;
       
    72     
       
    73     iInactivityTimer = aSource.iInactivityTimer;
       
    74     iBufferLength = aSource.iBufferLength;
       
    75     iBufferTreshold = aSource.iBufferTreshold;
       
    76     iTalkBurstIndicator = aSource.iTalkBurstIndicator ? 
       
    77                             aSource.iTalkBurstIndicator->AllocL() : NULL;
       
    78                             
       
    79     iIdentity = aSource.iIdentity ? aSource.iIdentity->AllocL() : NULL;
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CMceComRtpSource::CloneL
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CMceComMediaSource* CMceComRtpSource::CloneL()
       
    88     {
       
    89     CMceComRtpSource* copy = new (ELeave) CMceComRtpSource();
       
    90     CleanupStack::PushL( copy );
       
    91     copy->ConstructL( *this );
       
    92     CleanupStack::Pop( copy );    
       
    93     return copy;
       
    94         
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMceComRtpSource::~CMceComRtpSource
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CMceComRtpSource::~CMceComRtpSource()
       
   102     {
       
   103     delete iTalkBurstIndicator;
       
   104     delete iIdentity;
       
   105     delete iSettings;
       
   106     
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CMceComRtpSource::CMceComRtpSource
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 CMceComRtpSource::CMceComRtpSource()
       
   115   : CMceComMediaSource( KMceRTPSource ),
       
   116     iInactivityTimer( 0 ),
       
   117 	iBufferLength( KMceJitterBufferLength ),
       
   118 	iBufferTreshold( KMceJitterBufferTreshold ),
       
   119 	iTalkBurstIndicator( NULL ),
       
   120 	iIdentity( NULL )
       
   121     {
       
   122     }
       
   123 
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CMceComRtpSource::InternalizeFlatL
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CMceComRtpSource::InternalizeFlatL( RReadStream& aReadStream )
       
   130     {
       
   131     CMceComMediaSource::InternalizeFlatL( aReadStream );
       
   132     
       
   133     iInactivityTimer = aReadStream.ReadUint32L();
       
   134 	iBufferLength = aReadStream.ReadUint32L();
       
   135 	iBufferTreshold = aReadStream.ReadUint32L();
       
   136     MceSerial::DecodeL( iTalkBurstIndicator, aReadStream ); 
       
   137     MceSerial::DecodeL( iIdentity, aReadStream ); 
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CMceComRtpSource::ExternalizeFlatL
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CMceComRtpSource::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   145     {
       
   146     CMceComMediaSource::ExternalizeFlatL( aWriteStream );
       
   147     
       
   148 	aWriteStream.WriteUint32L( iInactivityTimer );
       
   149 	aWriteStream.WriteUint32L( iBufferLength );
       
   150 	aWriteStream.WriteUint32L( iBufferTreshold );
       
   151     MceSerial::EncodeL( iTalkBurstIndicator, aWriteStream ); 
       
   152     MceSerial::EncodeL( iIdentity, aWriteStream ); 
       
   153     }
       
   154 
       
   155   
       
   156 // -----------------------------------------------------------------------------
       
   157 // CMceComRtpSource::UpdateL
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CMceComRtpSource::UpdateL( CMceComMediaSource& aUpdate )
       
   161     {
       
   162     CMceComMediaSource::UpdateL( aUpdate );
       
   163     CMceComRtpSource& update = static_cast<CMceComRtpSource&>( aUpdate );
       
   164     
       
   165     iInactivityTimer = update.iInactivityTimer;
       
   166     iBufferLength = update.iBufferLength;
       
   167     iBufferTreshold = update.iBufferTreshold;
       
   168 
       
   169 	delete iTalkBurstIndicator;
       
   170 	iTalkBurstIndicator = NULL;
       
   171 	iTalkBurstIndicator = 
       
   172 	    update.iTalkBurstIndicator ? update.iTalkBurstIndicator->AllocL() : NULL;
       
   173     
       
   174     delete iIdentity;
       
   175     iIdentity = NULL;
       
   176     iIdentity = update.iIdentity ? update.iIdentity->AllocL() : NULL;
       
   177     }
       
   178 
       
   179     
       
   180     
       
   181 // -----------------------------------------------------------------------------
       
   182 // CMceComRtpSource::EventReceivedL
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CMceComRtpSource::EventReceivedL( TMceComEvent& aEvent )
       
   186     {
       
   187     TInt status = CMceComMediaSource::EventReceivedL( aEvent );
       
   188     if ( status != KMceEventNotConsumed )
       
   189         {
       
   190         return status;
       
   191         }
       
   192                 
       
   193     if ( aEvent.Id().IsSourceId() )
       
   194         {
       
   195         status = aEvent.Handler().HandleL( *this, aEvent );
       
   196         }
       
   197     else
       
   198         {
       
   199         status = KMceEventNotConsumed;
       
   200         }
       
   201     
       
   202     return status;
       
   203     
       
   204     }
       
   205     
       
   206     
       
   207 // -----------------------------------------------------------------------------
       
   208 // CMceComRtpSource::InactivityTimer
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TUint CMceComRtpSource::InactivityTimer() const
       
   212     {
       
   213     return iInactivityTimer * KTimeConversion;
       
   214     }
       
   215 
       
   216     
       
   217 #ifdef MCE_COMMON_SERVER_SIDE
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // CMceComRtpSource::MccType
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 const TUid CMceComRtpSource::MccType()
       
   224     {
       
   225     return KUidMccRtpSource;
       
   226     }
       
   227 
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // CMceComRtpSource::InitParamL
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 const TDesC8& CMceComRtpSource::InitParamL( const CMceComCodec& /*aCodec*/ )
       
   234     {
       
   235     delete iSettings;
       
   236     iSettings = NULL;
       
   237     TMccRtpSourceSetting setting;
       
   238     setting.iStandByTimerValue = iInactivityTimer;
       
   239     TMccRtpSourceSettingBuf settingBuf( setting );
       
   240     
       
   241     iSettings = settingBuf.AllocL();
       
   242 
       
   243     return *iSettings;
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CMceComRtpSource::PrepareL
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 void CMceComRtpSource::PrepareL()
       
   251     {
       
   252     if ( MediaStream() && MediaStream()->Session() && 
       
   253          iIdentity &&
       
   254          iIdentity->Length() > 0 )
       
   255         {
       
   256         MediaStream()->Session()->SdpSession().Manager().SetCNameL( *this, *iIdentity );
       
   257         }
       
   258     }
       
   259     
       
   260 #endif//MCE_COMMON_SERVER_SIDE
       
   261