multimediacommscontroller/mmccvideosourcesink/src/mccvideosource.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20         
       
    21 // INCLUDE FILES
       
    22 #include "mccvideosource.h"
       
    23 #include "mccvideosourceimpl.h"
       
    24 #include "mmcccodecinformation.h"
       
    25 #include "mmccinterfacedef.h"
       
    26 #include "mccvideosourcesinklogs.h"
       
    27 #include "mccinternaldef.h"
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CMcpRtpDataSource::NewSourceL
       
    33 // Static constructor.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 MDataSource* CMccVideoSource::NewSourceL( TUid /*aImplementationUid*/, 
       
    37                                             const TDesC8& /*aInitData*/ )
       
    38     {
       
    39     CMccVideoSource* self = new ( ELeave ) CMccVideoSource();
       
    40     return static_cast<MDataSource*>( self );
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CMccVideoSource::ConstructSourceL
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CMccVideoSource::ConstructSourceL( const TDesC8& aInitData )
       
    48     {
       
    49     __V_SOURCESINK_CONTROLL( "CMccVideoSource::ConstructSourceL" )
       
    50 
       
    51 	if ( aInitData.Length() > 0 )
       
    52 	    {
       
    53 	    __V_SOURCESINK_CONTROLL( "CMccVideoSource::ConstructSourceL, with init data" )
       
    54 	    
       
    55 	    TMccVideoSourceSettingBuf settingsBuf;
       
    56         settingsBuf.Copy( aInitData );
       
    57         TMccVideoSourceSetting& settings = settingsBuf();
       
    58             
       
    59         iCameraIndex = settings.iDeviceIndex;
       
    60         
       
    61         __V_SOURCESINK_CONTROLL_INT1( 
       
    62             "CMccVideoSource::ConstructSourceL, camera index:", iCameraIndex )
       
    63 	    }
       
    64     
       
    65     delete iSourceImpl;
       
    66     iSourceImpl = NULL;
       
    67     iSourceImpl = CMccVideoSourceImpl::NewL( 
       
    68             MCC_ENDPOINT_ID( static_cast<MDataSource*>( this ) ), iMccResources );
       
    69     
       
    70     __V_SOURCESINK_CONTROLL( "CMccVideoSource::ConstructSourceL, exit" )
       
    71     }
       
    72     
       
    73 // -----------------------------------------------------------------------------
       
    74 // CMccVideoSource::CMccVideoSource
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CMccVideoSource::CMccVideoSource() :
       
    78     CMccDataSource( KMccVideoSourceUid )
       
    79     {
       
    80     }
       
    81         
       
    82 // -----------------------------------------------------------------------------
       
    83 // CMccVideoSource::~CMccVideoSource
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CMccVideoSource::~CMccVideoSource()
       
    87     {
       
    88 	delete iSourceImpl;	
       
    89 	iUsers.ResetAndDestroy();
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CMccVideoSource::SetCameraHandler
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CMccVideoSource::SetCameraHandler( MMccCameraHandler& aCameraHandler )
       
    97 	{
       
    98     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SetCameraHandler" )
       
    99    
       
   100     if ( iSourceImpl )
       
   101 	    {
       
   102 	   	iSourceImpl->SetCameraHandler( aCameraHandler );
       
   103 	    }
       
   104 	}
       
   105 	
       
   106 // -----------------------------------------------------------------------------
       
   107 // CMccVideoSource::CameraIndex
       
   108 // -----------------------------------------------------------------------------
       
   109 //	
       
   110 TInt CMccVideoSource::CameraIndex() const
       
   111     {
       
   112     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSource::CameraIndex, index:", iCameraIndex )   
       
   113     return iCameraIndex;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CMccVideoSource::SourcePrimeL
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CMccVideoSource::SourcePrimeL()
       
   121 	{
       
   122     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourcePrimeL" )
       
   123     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   124    
       
   125 	iSourceImpl->SourcePrimeL( MultipleCodecs() );
       
   126 	}
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMccVideoSource::SourcePlayL()
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CMccVideoSource::SourcePlayL()
       
   133     {
       
   134     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourcePlayL" )
       
   135     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   136 
       
   137     UpdateCurrentUserL();
       
   138     
       
   139 	iSourceImpl->SourcePlayL();
       
   140     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourcePlayL, done" )
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CMccVideoSource::SourcePauseL()
       
   145 // 
       
   146 // Pauses streaming by cancelling timers
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CMccVideoSource::SourcePauseL()
       
   150     {
       
   151     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourcePauseL" )
       
   152     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   153     
       
   154 	iSourceImpl->SourcePauseL();
       
   155 	}
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CMccVideoSource::SourceStopL()
       
   159 // 
       
   160 // Stops streaming
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CMccVideoSource::SourceStopL()
       
   164     {
       
   165     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourceStopL" )
       
   166     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   167 	iSourceImpl->SourceStopL();
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMccVideoSource::SourceDataTypeCode()
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 TFourCC CMccVideoSource::SourceDataTypeCode( TMediaId aMediaId )
       
   175 	{
       
   176 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::SourceDataTypeCode" )
       
   177 
       
   178     if ( iSourceImpl )
       
   179 	    {
       
   180 	  	return iSourceImpl->SourceDataTypeCode( aMediaId );
       
   181 	    }
       
   182     else
       
   183 	    {
       
   184 	    return TFourCC( KMMFFourCCCodeNULL );
       
   185 	    }
       
   186 	}
       
   187 	
       
   188 // -----------------------------------------------------------------------------
       
   189 // CMccVideoSource::SetSourceDataTypeCode()
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 TInt CMccVideoSource::SetSourceDataTypeCode( 
       
   193     TFourCC aCodec, 
       
   194     TMediaId aMediaId )
       
   195 	{
       
   196 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::SetSourceDataTypeCode" )
       
   197     
       
   198     if ( iSourceImpl )
       
   199 	    {
       
   200 	   	return iSourceImpl->SetSourceDataTypeCode( aCodec, aMediaId );	
       
   201 	    }
       
   202     else
       
   203 	    {
       
   204 	    __V_SOURCESINK_CONTROLL("CMccVideoSource::SetSourceDataTypeCode, \
       
   205 iSourceImpl=NULL")
       
   206 	    return KErrArgument;	
       
   207 	    }
       
   208 	}	
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CMccVideoSource::BufferEmptiedL()
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 void CMccVideoSource::BufferEmptiedL( CMMFBuffer* /*aBuffer*/ )
       
   215 	{
       
   216     __V_SOURCESINK_MEDIA( "CMccVideoSource::BufferEmptiedL" )
       
   217     __ASSERT_ALWAYS( EFalse, User::Leave( KErrNotSupported ) );	
       
   218 	}
       
   219 	
       
   220 // -----------------------------------------------------------------------------
       
   221 // CMccVideoSource::CanCreateSourceBuffer()
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TBool CMccVideoSource::CanCreateSourceBuffer()
       
   225 	{
       
   226     __V_SOURCESINK_CONTROLL( "CMccVideoSource::CanCreateSourceBuffer, ETrue" )	
       
   227 	return EFalse;
       
   228 	}	
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CMccVideoSource::CreateSourceBufferL()
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 CMMFBuffer* CMccVideoSource::CreateSourceBufferL( 
       
   235 	TMediaId aMediaId, 
       
   236     TBool& aReference )
       
   237 	{
       
   238 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::CreateSourceBufferL" )	
       
   239 
       
   240 	return iSourceImpl->CreateSourceBufferL( aMediaId, aReference );
       
   241 	}
       
   242 	
       
   243 // -----------------------------------------------------------------------------
       
   244 // CMccVideoSource::SourceThreadLogon()
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 TInt CMccVideoSource::SourceThreadLogon( MAsyncEventHandler& aEventHandler )
       
   248 	{
       
   249     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourceThreadLogon" )	
       
   250     
       
   251     TInt err( KErrNotReady );
       
   252     if ( iSourceImpl )
       
   253         {
       
   254         err = iSourceImpl->SourceThreadLogon( aEventHandler );
       
   255         }
       
   256     
       
   257     if ( !err )
       
   258         {
       
   259         iSourceImpl->SetResources( iMccResources );
       
   260         }
       
   261     
       
   262     return err; 
       
   263 	}
       
   264 	
       
   265 // -----------------------------------------------------------------------------
       
   266 // CMccVideoSource::SourceThreadLogoff()
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CMccVideoSource::SourceThreadLogoff()
       
   270     {
       
   271     __V_SOURCESINK_CONTROLL( "CMccVideoSource::SourceThreadLogoff" )
       
   272     
       
   273     if ( iSourceImpl )
       
   274         {
       
   275         iSourceImpl->SourceThreadLogoff();
       
   276         TRAP_IGNORE( iSourceImpl->SourceStopL() );
       
   277         delete iSourceImpl;
       
   278         iSourceImpl = NULL;
       
   279         }
       
   280     }
       
   281 	
       
   282 // -----------------------------------------------------------------------------
       
   283 // CMccVideoSource::FillBufferL()
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CMccVideoSource::FillBufferL( CMMFBuffer* aBuffer,
       
   287                   MDataSink* aConsumer,
       
   288                   TMediaId aMediaId )
       
   289 	{
       
   290 	__V_SOURCESINK_MEDIA( "CMccVideoSource::FillBufferL" )		
       
   291     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   292 
       
   293 	iSourceImpl->FillBufferL( aBuffer, aConsumer, aMediaId );
       
   294 	}	
       
   295                   
       
   296 // -----------------------------------------------------------------------------
       
   297 // CMccVideoSource::NegotiateSourceL()
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 void CMccVideoSource::NegotiateSourceL( MDataSink& /*aDataSink*/ )
       
   301 	{
       
   302     __V_SOURCESINK_CONTROLL( "CMccVideoSource::NegotiateSourceL" ) 				
       
   303 	}
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CMccVideoSource::RateAdaptationRequest
       
   307 // -----------------------------------------------------------------------------
       
   308 //     
       
   309 TInt CMccVideoSource::RateAdaptationRequest( const TMccEvent& aInputData, 
       
   310     										TMccEvent& aOutputData )
       
   311     {
       
   312     __V_SOURCESINK_CONTROLL( "CMccVideoSource::RateAdaptationRequest" )
       
   313     if ( iSourceImpl )
       
   314     	{                   
       
   315     	return iSourceImpl->RateAdaptationRequest( aInputData, aOutputData );
       
   316     	}
       
   317     return KErrNotSupported;
       
   318     }
       
   319 
       
   320 
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CMccVideoSource::SetVideoCodecL()
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CMccVideoSource::SetVideoCodecL( const TMccCodecInfo& aVideoCodec )
       
   327 	{
       
   328 	__V_SOURCESINK_CONTROLL_STR8( 
       
   329 	    "CMccVideoSource::SetVideoCodecL, sdpname:", aVideoCodec.iSdpName ) 				
       
   330     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   331     
       
   332     TMccVideoSourceUser* user = 
       
   333         MccUserArray<TMccVideoSourceUser>::FindUserEntryForCurrent( iUsers, iCurrentUser );
       
   334     if ( user )
       
   335         {
       
   336         user->iCodecInfo = aVideoCodec;
       
   337         }
       
   338         
       
   339     iSourceImpl->SetVideoCodecL( aVideoCodec );
       
   340 	}
       
   341 	
       
   342 // -----------------------------------------------------------------------------
       
   343 // CMccVideoSource::GetVideoCodecL()
       
   344 // -----------------------------------------------------------------------------
       
   345 //
       
   346 void CMccVideoSource::GetVideoCodecL( TMccCodecInfo& aVideoCodec )
       
   347 	{
       
   348 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::GetVideoCodecL" ) 				
       
   349     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   350 
       
   351 	iSourceImpl->GetVideoCodecL( aVideoCodec );	
       
   352 	}
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CMccVideoSource::GetSupportedVideoCodecsL()
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 void CMccVideoSource::GetSupportedVideoCodecsL( RArray<TFourCC>& aVideoTypes )
       
   359 	{
       
   360 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::GetSupportedVideoCodecsL" ) 				
       
   361     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   362 
       
   363 	iSourceImpl->GetSupportedVideoCodecsL( aVideoTypes );		
       
   364 	}
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CMccVideoSource::SetAudioCodecL()
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 void CMccVideoSource::SetAudioCodecL( const TMccCodecInfo& aAudioCodec )
       
   371 	{
       
   372 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::SetAudioCodecL" ) 				
       
   373     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   374 	iSourceImpl->SetAudioCodecL( aAudioCodec );			
       
   375 	}
       
   376 
       
   377 // -----------------------------------------------------------------------------
       
   378 // CMccVideoSource::GetAudioCodecL()
       
   379 // -----------------------------------------------------------------------------
       
   380 //
       
   381 void CMccVideoSource::GetAudioCodecL( TMccCodecInfo& aAudioCodec )
       
   382 	{
       
   383 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::GetAudioCodecL" ) 				
       
   384     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   385 	iSourceImpl->GetAudioCodecL( aAudioCodec );
       
   386 	}
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CMccVideoSource::GetSupportedAudioCodecsL()
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 void CMccVideoSource::GetSupportedAudioCodecsL( RArray<TFourCC>& aAudioTypes )
       
   393 	{
       
   394 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::GetSupportedAudioCodecsL" ) 				
       
   395     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   396 	iSourceImpl->GetSupportedAudioCodecsL( aAudioTypes );
       
   397 	}
       
   398 
       
   399 // -----------------------------------------------------------------------------
       
   400 // CMccVideoSource::SetAudioEnabledL()
       
   401 // -----------------------------------------------------------------------------
       
   402 //
       
   403 void CMccVideoSource::SetAudioEnabledL( TBool aEnabled )
       
   404 	{
       
   405 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::SetAudioEnabledL" ) 				
       
   406     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   407 	iSourceImpl->SetAudioEnabledL( aEnabled );
       
   408 	}
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 // CMccVideoSource::AudioEnabledL()
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 TBool CMccVideoSource::AudioEnabledL() const
       
   415 	{
       
   416 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::AudioEnabledL" ) 				
       
   417     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   418 	return iSourceImpl->AudioEnabledL();
       
   419 	}
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CMccVideoSource::SetGainL()
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 void CMccVideoSource::SetGainL( TInt aGain )
       
   426 	{
       
   427 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::SetGainL" ) 				
       
   428     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   429 	iSourceImpl->SetGainL( aGain );
       
   430 	}
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // CMccVideoSource::GainL()
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 TInt CMccVideoSource::GainL() const
       
   437 	{
       
   438 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::GainL" ) 				
       
   439     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   440 
       
   441 	return iSourceImpl->GainL();
       
   442 	}
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CMccVideoSource::MaxGainL()
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 TInt CMccVideoSource::MaxGainL() const
       
   449 	{
       
   450 	__V_SOURCESINK_CONTROLL( "CMccVideoSource::MaxGainL" ) 				
       
   451     __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrArgument ) );
       
   452 
       
   453 	return iSourceImpl->MaxGainL();
       
   454 	}
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // CMccVideoSource::AddUser()
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 TInt CMccVideoSource::AddUser( MAsyncEventHandler* aUser )
       
   461     {
       
   462     __V_SOURCESINK_CONTROLL_INT1( 
       
   463         "CMccVideoSource::AddUser, user:", reinterpret_cast<TInt>( aUser ) )
       
   464     TInt retVal( KErrNone );
       
   465     TMccVideoSourceUser* userEntry = 
       
   466         MccUserArray<TMccVideoSourceUser>::FindUserEntryForCurrent( iUsers, aUser );
       
   467     if ( !userEntry )
       
   468         {
       
   469         TRAP( retVal, AddUserL( aUser ) );
       
   470         }
       
   471     return retVal;
       
   472     }
       
   473 
       
   474 // -----------------------------------------------------------------------------
       
   475 // CMccVideoSource::RemoveUser()
       
   476 // -----------------------------------------------------------------------------
       
   477 //        
       
   478 void CMccVideoSource::RemoveUser( MAsyncEventHandler* aUser )
       
   479     {
       
   480     __V_SOURCESINK_CONTROLL_INT1( 
       
   481         "CMccVideoSource::RemoveUser, user:", reinterpret_cast<TInt>( aUser ) )
       
   482 
       
   483     MccUserArray<TMccVideoSourceUser>::RemoveCurrentUser( iUsers, aUser );
       
   484         
       
   485     if ( aUser == iCurrentUser )
       
   486         {
       
   487         if ( iUsers.Count() > 0 )
       
   488             {
       
   489             iCurrentUser = iUsers[ 0 ]->iEventHandler;
       
   490             TRAP_IGNORE( UpdateCurrentUserL() )
       
   491             }
       
   492         iCurrentUser = NULL;
       
   493         }
       
   494     }
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CMccVideoSource::SetCurrentUser()
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 void CMccVideoSource::SetCurrentUser( MAsyncEventHandler* aUser )
       
   501     {
       
   502     iCurrentUser = aUser;
       
   503     }
       
   504     	
       
   505 // -----------------------------------------------------------------------------
       
   506 // CMccVideoSource::UpdateL()
       
   507 // -----------------------------------------------------------------------------
       
   508 //	
       
   509 void CMccVideoSource::UpdateL( const TDesC8& aVal )
       
   510     {
       
   511     __V_SOURCESINK_CONTROLL( "CMccVideoSource::UpdateL" ) 				
       
   512 
       
   513     // Only device index is used atm
       
   514     
       
   515     TMccVideoSourceSettingBuf settingsBuf;
       
   516     settingsBuf.Copy( aVal );
       
   517     TMccVideoSourceSetting& settings = settingsBuf();
       
   518     
       
   519     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSource::UpdateL, current camera index:", 
       
   520                                   iCameraIndex ) 	
       
   521     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSource::UpdateL, new camera index:", 
       
   522                                   settings.iDeviceIndex )
       
   523     	
       
   524     // If recorder is using the camera, camera index cannot be changed       
       
   525     if ( iSourceImpl && !iSourceImpl->IsStopped() )
       
   526         {
       
   527         __ASSERT_ALWAYS( iCameraIndex == settings.iDeviceIndex, 
       
   528                          User::Leave( KErrInUse ) );
       
   529         }
       
   530     iCameraIndex = settings.iDeviceIndex;
       
   531     
       
   532     __V_SOURCESINK_CONTROLL( "CMccVideoSource::UpdateL, exit" ) 
       
   533     }
       
   534 
       
   535 // -----------------------------------------------------------------------------
       
   536 // CMccVideoSource::GetParameterL()
       
   537 // -----------------------------------------------------------------------------
       
   538 //
       
   539 void CMccVideoSource::GetParameterL( TUint32 aParam, TDes8& aVal )
       
   540     {
       
   541     switch ( aParam )
       
   542         {
       
   543         case KMccConfigKey:
       
   544             {
       
   545             __ASSERT_ALWAYS( iSourceImpl, User::Leave( KErrNotReady ) );
       
   546             TInt found( EFalse );
       
   547             for ( TInt i = 0; i < iUsers.Count() && !found; i++ )
       
   548             	{
       
   549             	if ( MCC_IS_AVC_USER_ENTRY( iUsers[ i ] ) )
       
   550             		{
       
   551             		iSourceImpl->GetConfigKeyL( iUsers[ i ]->iCodecInfo, aVal );
       
   552             		found = ETrue;
       
   553             		}
       
   554             	}
       
   555             __ASSERT_ALWAYS( found, User::Leave( KErrNotFound ) );
       
   556             break;
       
   557             }
       
   558         default:
       
   559             {
       
   560             User::Leave( KErrArgument );
       
   561             break;
       
   562             }
       
   563         }  
       
   564     }
       
   565 
       
   566 // -----------------------------------------------------------------------------
       
   567 // CMccVideoSource::SetParameterL()
       
   568 // -----------------------------------------------------------------------------
       
   569 //        
       
   570 void CMccVideoSource::SetParameterL( TUint32 aParam, const TDesC8& /*aVal*/ )
       
   571     {
       
   572     switch ( aParam )
       
   573         {
       
   574         case KMccConfigKey:
       
   575             {
       
   576             // NOP
       
   577             break;
       
   578             }
       
   579         default:
       
   580             {
       
   581             User::Leave( KErrArgument );
       
   582             break;
       
   583             }
       
   584         }    
       
   585     }
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CMccVideoSource::AddUserL()
       
   589 // -----------------------------------------------------------------------------
       
   590 // 
       
   591 void CMccVideoSource::AddUserL( MAsyncEventHandler* aUser )
       
   592     {
       
   593     TMccVideoSourceUser* user = new ( ELeave ) TMccVideoSourceUser( aUser );
       
   594     CleanupStack::PushL( user );
       
   595     iUsers.AppendL( user );
       
   596     CleanupStack::Pop( user );
       
   597     }
       
   598 
       
   599 // -----------------------------------------------------------------------------
       
   600 // CMccVideoSource::MultipleCodecs()
       
   601 // -----------------------------------------------------------------------------
       
   602 //
       
   603 TBool CMccVideoSource::MultipleCodecs() const
       
   604     {
       
   605     TBool multipleCodecs( EFalse );
       
   606     TMccCodecInfo* codecInfo = iUsers.Count() > 1 ? &iUsers[ 0 ]->iCodecInfo : NULL;
       
   607     for ( TInt i = 1; i < iUsers.Count() && codecInfo; i++ )
       
   608         {
       
   609         if ( codecInfo->iSdpName.CompareF( iUsers[ i ]->iCodecInfo.iSdpName ) != 0 )
       
   610             {
       
   611             multipleCodecs = ETrue;
       
   612             codecInfo = NULL;
       
   613             }
       
   614         }
       
   615     return multipleCodecs;
       
   616     }
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 // CMccVideoSource::UpdateCurrentUserL()
       
   620 // -----------------------------------------------------------------------------
       
   621 //
       
   622 void CMccVideoSource::UpdateCurrentUserL()
       
   623     {
       
   624     __V_SOURCESINK_CONTROLL( "CMccVideoSource::UpdateCurrentUserL" ) 
       
   625     
       
   626     TMccVideoSourceUser* userEntry = 
       
   627         MccUserArray<TMccVideoSourceUser>::FindUserEntryForCurrent( iUsers, iCurrentUser );
       
   628 
       
   629     // If multiple different codecs may be using the video source, update source
       
   630     // according to current user
       
   631 
       
   632     TMccCodecInfo currCodecInfo;
       
   633     iSourceImpl->GetVideoCodecL( currCodecInfo );
       
   634     if ( userEntry && currCodecInfo.iSdpName.CompareF( userEntry->iCodecInfo.iSdpName ) != 0 )
       
   635         {
       
   636         iSourceImpl->SetVideoCodecL( userEntry->iCodecInfo );
       
   637         }
       
   638    
       
   639     __V_SOURCESINK_CONTROLL( "CMccVideoSource::UpdateCurrentUserL, exit" )
       
   640     }
       
   641         
       
   642 // End of file
       
   643