Revision: 201021 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 10:06:41 +0300
branchRCL_3
changeset 13 fb1bbf85a302
parent 12 91f50911ea81
child 15 f40c1a748eb9
Revision: 201021 Kit: 2010123
ipappsrv_plat/media_control_api/inc/mmccinterfacedef.h
multimediacommscontroller/mmcccontroller/src/mcccamerahandler.cpp
multimediacommscontroller/mmcccontroller/tsrc/ut_controller/src/UT_CMccCameraHandler.cpp
multimediacommsengine/mmceshared/src/mcecomamrwbcodec.cpp
multimediacommsengine/mmceshared/src/mcecomdisplaysink.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h
multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuremediasession.h
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesdpsession.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcestateupdating.cpp
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp
natfw/natfwconnectionmultiplexer/src/cncmconnectionobserverhandler.cpp
--- a/ipappsrv_plat/media_control_api/inc/mmccinterfacedef.h	Tue May 25 13:07:26 2010 +0300
+++ b/ipappsrv_plat/media_control_api/inc/mmccinterfacedef.h	Wed Jun 09 10:06:41 2010 +0300
@@ -104,6 +104,12 @@
 class TMccVideoSinkSetting
 {
 public:
+    TMccVideoSinkSetting() : iLocation(0,0), iSize(0,0), iVideoPayloadType(0), 
+        iAudioPayloadType(0), iIAPId(0), iDeviceIndex(0), iWindowOrdinalPosition(0),
+        iWindowOrdinalPriority(0), iRotation(EMccNone), iVideoFrameRate(0.0), iEnabled(ETrue)
+        {
+        }
+        
     TPoint iLocation;
     TSize iSize;
     TUint iVideoPayloadType;
@@ -115,6 +121,7 @@
 	TInt iWindowOrdinalPriority;
 	TMccVideoRotation iRotation;	
 	TReal iVideoFrameRate;
+	TBool iEnabled;
 };
 
 typedef TPckgBuf<TMccVideoSinkSetting> TMccVideoSinkSettingBuf;    
--- a/multimediacommscontroller/mmcccontroller/src/mcccamerahandler.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommscontroller/mmcccontroller/src/mcccamerahandler.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -150,6 +150,10 @@
     
     iViewFinderSettings = aSetting;
     
+    if ( !iViewFinderSettings.iEnabled ){
+        __CONTROLLER( "CMccCameraHandler::EnableViewFinderL, param update, exit" )
+        return;
+    }
     __CONTROLLER( "CMccCameraHandler::EnableViewFinderL, starting vf" )
 
     CCamera* cam = IsCameraReady() ? iCamera : NULL;
@@ -217,8 +221,9 @@
 	                       iViewFinderSettings.iSize.iWidth)
     __CONTROLLER_INT2( "CMccCameraHandler::GetViewFinderSettingsL, location",  
 	                       iViewFinderSettings.iLocation.iX, 
-	                       iViewFinderSettings.iLocation.iY)
-    aSetting = iViewFinderSettings;    
+	                       iViewFinderSettings.iLocation.iY)               
+    aSetting = iViewFinderSettings;  
+    aSetting.iEnabled = iViewFinderEnabled;
     __CONTROLLER( "CMccCameraHandler::GetViewFinderSettingsL,exit" )
     }
 
--- a/multimediacommscontroller/mmcccontroller/tsrc/ut_controller/src/UT_CMccCameraHandler.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommscontroller/mmcccontroller/tsrc/ut_controller/src/UT_CMccCameraHandler.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -286,6 +286,22 @@
     iCameraHandler->GetViewFinderSettingsL( settings2 );
     EUNIT_ASSERT_EQUALS( settings2.iSize.iWidth, 0 );
     EUNIT_ASSERT( iCameraHandler->iCamera->iVfStarted == EFalse )
+    
+    // Check that iEnabled in settings is handled correctly
+    iCameraHandler->iViewFinderEnabled = EFalse;
+    settings.iEnabled = EFalse;
+    iCameraHandler->EnableViewFinderL( settings );
+    EUNIT_ASSERT( iCameraHandler->iViewFinderEnabled == EFalse )
+    EUNIT_ASSERT( iCameraHandler->iCamera->iVfStarted == EFalse )
+    iCameraHandler->GetViewFinderSettingsL( settings2 );
+    EUNIT_ASSERT( settings2.iEnabled == EFalse )
+    
+    settings.iEnabled = ETrue;
+    iCameraHandler->EnableViewFinderL( settings );
+    EUNIT_ASSERT( iCameraHandler->iViewFinderEnabled == ETrue )
+    EUNIT_ASSERT( iCameraHandler->iCamera->iVfStarted == EFalse )
+    iCameraHandler->GetViewFinderSettingsL( settings2 );
+    EUNIT_ASSERT( settings2.iEnabled == ETrue )
     }
 
 void UT_CMccCameraHandler::UT_CMccCameraHandler_DisableViewFinderL()
--- a/multimediacommsengine/mmceshared/src/mcecomamrwbcodec.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmceshared/src/mcecomamrwbcodec.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -300,22 +300,8 @@
 //
 CMceComCodec* CMceComAMRWbCodec::DoMccValidateL( CMccCodecInformation& aMccCodec,
                                                CMceSrvStream& /*aStream*/,
-                                               TMceNegotiationRole aRole )
+                                               TMceNegotiationRole /*aRole */)
     {
-    //if answerer mcc codec represents the received offer and codec the answer
-    //if offerer codec represents the sent offer and mcc codec the answer
-    
-    // Bitrates field contains also additional information, mask it away
-    TUint mccBitrates = ( aMccCodec.AllowedBitrates() & KMceAllowedAmrWbBitrateAll );
-    TUint mceBitrates = ( iAllowedBitrates & KMceAllowedAmrWbBitrateAll );
-    
-    TBool notValid = aRole == EMceRoleAnswerer ?
-                  ( mceBitrates && mccBitrates == 0 ||
-	                mceBitrates > mccBitrates ) :
-                  ( mceBitrates && mccBitrates == 0 ||
-	                mceBitrates < mccBitrates );
-	
-	User::LeaveIfError( notValid ? KErrNotSupported : KErrNone );
 	if ( aMccCodec.CodecMode() != (TCodecMode)iCodecMode )
 		{
 		// codec-mode was different, fail.
--- a/multimediacommsengine/mmceshared/src/mcecomdisplaysink.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmceshared/src/mcecomdisplaysink.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -347,6 +347,7 @@
     displaySetting.iWindowOrdinalPosition = 1;
     displaySetting.iWindowOrdinalPriority = iPriority;
     displaySetting.iRotation = EMccNone;
+    displaySetting.iEnabled = ETrue;
     
     if ( aCodec.Stream() && aCodec.Stream()->iType == KMceVideo )
         {
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h	Wed Jun 09 10:06:41 2010 +0300
@@ -213,13 +213,12 @@
        	void ForceUpdateStreamL();
     
    private:     
-    	/**
-        * Set Crypto Context to MCC after Encode/Decode SDP are done
-        * @return void
-        */
- 		void SetCryptoContextL( );
- 		
-        
+       	/**
+       	* * Set Crypto Context to MCC after Encode/Decode SDP are done
+       	* @return void
+       	*/
+       	void SetCryptoContextL( TBool aAnswer = ETrue );
+    
 		/**
         * Base64 encoding
         * @since    Series 60 3.0 
@@ -422,6 +421,9 @@
     	CSdpMediaField* iMediaField;
 
     	TBool iIsSAVP;
+    	
+    	TBool iRemoteChangeKey;
+    	
 
     	TUint32 iCryptoContextOutId;
 
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuremediasession.h	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuremediasession.h	Wed Jun 09 10:06:41 2010 +0300
@@ -207,6 +207,7 @@
         TBool iKeyNeedUpdated;
         TBool iCryptoContextUpdate;
         TBool iLSReadyToBind;
+        TBool iNatBind;
 
     private:
         
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -307,8 +307,8 @@
     aSession.NegotiationState().UpdateL();
     status = !aSession.NegotiationState().CallbackAllowed() ? 
              KMceReady : KMceAsync;
-    if( status==KMceReady && aSession.SecureSession() 
-            && negotationStateId!=KMceMediaIdle )
+    if ( aSession.SecureSession() && negotationStateId ==
+    	 KMceOfferingMedia && aSession.SecureSession()->iLSReadyToBind )
     	{
         aSession.SecureSession()->BindStreamCrypto();
     	}
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -916,7 +916,7 @@
                 const TUint8 KAddrOffsetFromNetType = 4;
                 TInt addr_offset = 
                     value.Match( KMatchIp ) + KAddrOffsetFromNetType;
-                TPtrC8 remoteRtcpAddr = value.Mid( addr_offset );
+                TPtrC8 remoteRtcpAddrTxt = value.Mid( addr_offset );
                 
                 const TUint8 KPortOffsetFromIP = 1;
                 TInt port_offset = 
@@ -927,11 +927,20 @@
                 User::LeaveIfError( lexPT.Val( rtcpPort, EDecimal ) );
                 // copy the address into correct format
                 TBuf16 <KMaxAddressLength> input;
-                input.Copy( remoteRtcpAddr );      
+                input.Copy( remoteRtcpAddrTxt );      
                 
                 MCEMM_DEBUG_SVALUE( "Found RTCP address", input )
                 
-                aStream.SetRemoteRtcpMediaAddrL( input );
+                TInetAddr remoteRtcpAddr;
+                User::LeaveIfError( remoteRtcpAddr.Input( input ) ); 
+                TInetAddr localIpAddr( aStream.Session()->iLocalIpAddress );
+                TBool validRemoteRtcpAddr( 
+                    remoteRtcpAddr.IsLoopback() || !localIpAddr.Match( remoteRtcpAddr ) );
+                MCEMM_DEBUG_DVALUE( "Remote RTCP addr valid:", validRemoteRtcpAddr )
+                if ( validRemoteRtcpAddr )
+                    {
+                    aStream.SetRemoteRtcpMediaAddrL( input );
+                    }
                 }
             else
                 {
@@ -1040,8 +1049,10 @@
     else if ( secureSession && aRole == EMceRoleAnswerer && aUpdate )
         {
         // for long session
-        secureSession->iKeyNeedUpdated = ETrue;
-        secureSession->DecodeSecureDesSdpUpdateL( aStream, aMediaLine ) ;
+          if( secureSession->SdpCryptoAttributeCount( aMediaLine ) )
+        	{
+            secureSession->DecodeSecureDesSdpUpdateL( aStream, aMediaLine ) ;
+        	}
         }
     else if ( secureSession && aRole == EMceRoleOfferer )
         {
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesdpsession.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesdpsession.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -183,6 +183,13 @@
         }
     else
         {
+		if( aSession.SecureSession() )
+			{
+			if( aSession.SecureSession()->iKeyNeedUpdated )
+				{
+			    aSession.SecureSession()->iKeyNeedUpdated = EFalse;
+				}
+			}
         sdpDocument = iSdpDocument;
         CleanSessionParams( *iSdpDocument );
         }
@@ -647,6 +654,11 @@
     
     TOfferType type = !Backup() ? EFirst : EUpdate;
     
+    if( type == EUpdate && aSession.SecureSession() )
+    	{
+		aSession.SecureSession()->iLSReadyToBind = ETrue;
+    	}
+    
     CleanSessionParams( *iSdpDocument );
 
     EncodeSessionParamsL( aSession, *iSdpDocument, type );
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -88,6 +88,7 @@
 	iSecInf(aSecureInterface),
 	iMediaStream(aMediaStream),
 	iIsSAVP(ETrue),
+	iRemoteChangeKey(EFalse),
 	iCryptoContextOutId(0),
 	iCryptoContextInId(0),
 	iOldLocalMediaPort(0)
@@ -336,6 +337,11 @@
     	MCEMM_DEBUG(" Set Multiple Client Cryptoto")
     	User::LeaveIfError ( CountCryptoInOffer( aMediaField ) );
     	Session().iIsSecureSession =  !iGnoreSdpMsg ? ETrue : EFalse;
+    	if( iSecureSession.iNatBind )
+    		{
+			SetCryptoContextL( ETrue );
+			iSecureSession.iNatBind = EFalse;
+    		}
     	}
     MCEMM_DEBUG("CMceSecureDesStream::DecodeSecureSdpL(), Exit")      
     MSG_IGNORE_RETURN()
@@ -376,7 +382,8 @@
 				}
 			if ( iSecureSession.iLSReadyToBind )
 				{
-				SetCryptoContextL();
+				SetCryptoContextL( EFalse );
+				iRemoteChangeKey = EFalse;
 				}
 			MSG_IGNORE_RETURN()
 			if ( !iCryptoIn.iCryptoSuite.Length() )
@@ -437,9 +444,10 @@
 // Sets crypto context to MCC
 // -----------------------------------------------------------------------------
 //
-void CMceSecureDesStream::SetCryptoContextL( )
+void CMceSecureDesStream::SetCryptoContextL( TBool aAnswer )
     {
-    MCEMM_DEBUG("SetCryptoContext(), Entry")   
+    MCEMM_DEBUG("SetCryptoContext(), Entry") 
+    TBool bindContext = ETrue;
     TBool storedIgnoreSdpMsg = EFalse;
     //Check state first if the crypto has been set
     if ( !iCryptoIn.iIfCryptoContextIdSet && 
@@ -454,6 +462,12 @@
     	CreateCryptoContextL( iCryptoOut ); 
     	MCEMM_DEBUG_DVALUE( "iCryptoContextOutId", iCryptoIn.iCryptoContextId )
 		MCEMM_DEBUG_DVALUE( "iCryptoContextInId", iCryptoOut.iCryptoContextId )
+    	
+    	if( !aAnswer )
+    		{
+			bindContext = EFalse;
+    	    MCEMM_DEBUG("delay to bind!");
+    		}
 
     	iCryptoOuts->Reset();
     	
@@ -472,7 +486,7 @@
 			}
 		MCEMM_DEBUG_DVALUE( "Updated iCryptoContextOutId", iCryptoIn.iCryptoContextId )
 		MCEMM_DEBUG_DVALUE( "Updated iCryptoContextInId", iCryptoOut.iCryptoContextId )
-    	if ( iSecureSession.iKeyNeedUpdated )
+    	if ( iSecureSession.iKeyNeedUpdated  || iRemoteChangeKey )
     		{
     		UpdateCryptoContextL( iCryptoIn ); 
     		storedIgnoreSdpMsg = iGnoreSdpMsg;
@@ -488,6 +502,10 @@
     iGnoreSdpMsg = (iCryptoIn.iIfCryptoContextIdSet && 
     				iCryptoOut.iIfCryptoContextIdSet ) &&
     				!iGnoreSdpMsg ? EFalse : ETrue;		
+    if ( iWaitingBinding && bindContext )
+    	{
+    	iSecureSession.BindStreamCrypto();
+    	}
     	
     MCEMM_DEBUG("SetCryptoContext(), Exit")
     }
@@ -839,6 +857,13 @@
         	}
         else
         	{
+			if( iRemoteChangeKey )
+				{
+				MCEMM_DEBUG("Update CryptoIn" )
+				TBool tmpSet = iCryptoIn.iIfCryptoContextIdSet;
+				iCryptoIn.Copy( iCryptoIns->At( 0 ) );
+				iCryptoIn.iIfCryptoContextIdSet = tmpSet;
+				}
         	if(iOldLocalMediaPort != iMediaStream.iLocalMediaPort)
         		{
         	    GenerateRandomKeys( iCryptoOut );
@@ -852,11 +877,8 @@
         MSG_IGNORE_RETURN()
       	if ( iSecureSession.iLSReadyToBind )
       		{
-      		SetCryptoContextL();
-            if ( iWaitingBinding )
-               {
-               iSecureSession.BindStreamCrypto();
-               }
+      		SetCryptoContextL( ETrue );
+      		iRemoteChangeKey = EFalse;
       		}
         MSG_IGNORE_RETURN()
         }
@@ -1206,13 +1228,14 @@
 	        	}
     
 	    TPtrC8 keyInfo = aSecDec.Mid(keyInfoPos, keyInfoLen);
-	    if ( iSecureSession.iKeyNeedUpdated )
-	    	{
+	    	
 	    	
-		    TBool valid = ValidateSecurityDescriptions( keyInfo );
-	   		if ( valid )
+		TBool valid = ValidateSecurityDescriptions( keyInfo );
+		if ( valid )
+	   		{
+		    iRemoteChangeKey = iCryptoIn.iEncodedKey.Compare( keyInfo ) != 0;
+	   		if( iSecureSession.iKeyNeedUpdated || iRemoteChangeKey ) 
 	   			{
-	   			
 		    	// check keyInfo 
 			    if (iCryptoOut.iEncodedKey.Compare( keyInfo ) == 0)
 			    	{
@@ -1226,11 +1249,11 @@
 				iCryptoIn.iEncodedKey = keyInfo;
 				StoreKeys(iCryptoIn.iEncodedKey);
 	   			}
-	   		else
-	   			{
-	   			User::Leave( KErrArgument );
-	   			}
-	    	}
+	   		}
+		else
+	   		{
+		    User::Leave( KErrArgument );
+	   		}
 	   	}
  	else
  		{
@@ -1285,7 +1308,12 @@
         
         if ( valid )
         	{
-        	
+        	if( !iSecureSession.iKeyNeedUpdated && 
+        			iCryptoIn.iEncodedKey.Compare( keyInfo ) != 0 )
+        		{
+        	    MCEMM_DEBUG("Remote change the key");
+        	    iRemoteChangeKey = ETrue;
+        		}
             //check keyinfo mki 
 		     DecodeMKIValueL( aSecDec, EFalse, crypto );   
 		     MSG_IGNORE_RETURN()
@@ -1489,10 +1517,8 @@
 			 cryptoOut.iAuthAlgms == aCrypto.iAuthAlgms &&
 			 cryptoOut.iCryptoSuite.Compare(aCrypto.iCryptoSuite) == 0)
 			{
-            if(!iCryptoOut.iIfCryptoContextIdSet)
-                {  //SEtCrypto
-                iCryptoOut.Copy( cryptoOut );
-                }
+			//SEtCrypto
+			iCryptoOut.Copy( cryptoOut );
 			iCryptoIn.iTag = cryptoOut.iTag;
 			iCryptoIn.iEncAlgms = cryptoOut.iEncAlgms;
 			iCryptoIn.iAuthAlgms = cryptoOut.iAuthAlgms;
@@ -1684,8 +1710,7 @@
 		{
 		iCryptoOuts->AppendL( aCopyFrom.iCryptoOuts->At( i ) );
 		}
-    iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
-    iWaitingBinding = aCopyFrom.iWaitingBinding;
+		iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
  	MCEMM_DEBUG( "CMceSecureDesStream::CopyStreamCryptoL Exit" )
 	}
 
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -49,8 +49,8 @@
             iSession( aSession ),
             iSecureInterface(aSecureInterface),
             iKeyNeedUpdated( ETrue ),
-            iCryptoContextUpdate (EFalse),
-            iLSReadyToBind ( ETrue ),
+            iCryptoContextUpdate (EFalse ),
+            iLSReadyToBind ( EFalse ),
             iStringTable( NULL )
     {
     
@@ -433,7 +433,7 @@
 	{
 	MCEMM_DEBUG("CMceSecureDesStream::BindStreamCrypto(), Entry");
 	TInt err(KErrNone);
-	if (iLSReadyToBind && iSession.iClientCryptoSuites.Count())
+	if (iSession.iClientCryptoSuites.Count())
 		{
 		for (TInt i=0; i<iSession.MccStreams().Count(); i++)
 			{
@@ -441,22 +441,22 @@
 			MCEMM_DEBUG_DVALUE("	CMceSrvStream id =", stream->Data().Id().iId );	
 			MCEMM_DEBUG_DVALUE("	App id", stream->Data().Id().iAppId );		
 			TInt secStreamCount = iMceSecureDesStreams.Count();
-            for (TInt j=0; j<secStreamCount; j++)
-                {
-                CMceSecureDesStream* secureStream=iMceSecureDesStreams[j];
-                MCEMM_DEBUG_DVALUE("	SrvStream id in SecureStream ", secureStream->MediaStream().Id().iId);	
-                MCEMM_DEBUG_DVALUE("	App id in SecureStream ", secureStream->MediaStream().Id().iAppId);	
-                if(secureStream->iWaitingBinding)
-                    {
-                    if (stream->Data().Id()== secureStream->MediaStream().Id() || 
-                         ( stream->Data().BoundStream() && 
-                           stream->Data().iLinkedStream->Id() == secureStream->MediaStream().Id() ) ) 
-                        {
-                        //bind
-                        err = secureStream->BindCrypto(*stream);					
-                        }
-                    }
-                }
+    		for (TInt j=0; j<secStreamCount; j++)
+				{
+				CMceSecureDesStream* secureStream=iMceSecureDesStreams[j]; 
+				MCEMM_DEBUG_DVALUE("	SrvStream id in SecureStream ", secureStream->MediaStream().Id().iId);	
+				MCEMM_DEBUG_DVALUE("	App id in SecureStream ", secureStream->MediaStream().Id().iAppId);	
+				if (stream->Data().Id()== secureStream->MediaStream().Id() || 
+					 ( stream->Data().BoundStream() && 
+					   stream->Data().iLinkedStream->Id() == secureStream->MediaStream().Id() ) ) 
+					{
+					//bind
+				    if( secureStream->iWaitingBinding )
+				    	{
+						secureStream->BindCrypto(*stream);
+				    	}
+					}
+				}
 			}
 		}
 	MCEMM_DEBUG("CMceSecureDesStream::BindStreamCrypto(), Exit");
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h	Wed Jun 09 10:06:41 2010 +0300
@@ -77,7 +77,6 @@
     void UT_CMceMediaSdpCodec_EncodeFmtpAttributeLL();
     void UT_CMceMediaSdpCodec_DecodeFmtpLinesLL();
     void UT_CMceMediaSdpCodec_ValidateSdpL();
-    void UT_CMceMediaSdpCodec_DecodeSecureSessionLL(); 
     void UT_CMceMediaSdpCodec_DecodeDirectionLL(); 
     void UT_CMceMediaSdpCodec_DecodeRtpmapLinesLL();
 
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -658,7 +658,7 @@
     CleanupStack::PushL( mediaAnswer2 );
     //iCryptoOut crypto is not set
     iSecureStream->DecodeSecureSdpAnswerL(*mediaAnswer2);
-    //EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
+    EUNIT_ASSERT( iSecureStream->Session().iIsSecureSession );
     EUNIT_ASSERT( iSecureStream->iCryptoIn.iMKLifeTime == 32 );
     EUNIT_ASSERT( iSecureStream->iCryptoOut.iMKLifeTime == KDefalutMaterKeysLifeTime );
     CleanupStack::PopAndDestroy(mediaAnswer2);
@@ -670,7 +670,7 @@
     CleanupStack::PushL( mediaOffer );	
     iSecureSession->iCryptoContextUpdate = ETrue;
     iSecureStream->EncodeSecureSdpL(*mediaOffer, EFalse );
-    //EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
+    EUNIT_ASSERT( iSecureStream->Session().iIsSecureSession );
 	
     CSdpMediaField* mediaAnswer3 = CSdpMediaField::DecodeL( KMceTestMeidaCryptoMultiple );
     CleanupStack::PushL( mediaAnswer3 );
@@ -1015,11 +1015,9 @@
                                                 *iSecureInterface,
                                                 *iStream1);
 	CleanupStack::PushL( copy);
-    iSecureStream->iWaitingBinding = ETrue;
 	copy->CopyStreamCryptoL(*iSecureStream);
 	CleanupStack::Pop( copy );
 	EUNIT_ASSERT( copy->iCryptoOuts->Count()==KTotalCryptoAnswerCount );
-    EUNIT_ASSERT( copy->iWaitingBinding == ETrue );
 	
 	delete copy;
 	}
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -908,6 +908,25 @@
     EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() )
     audioLine->AttributeFields().ResetAndDestroy();
     
+    // Rtcp attribute has incorrectly our local address, it should not be used
+    mediaStream->Session()->iLocalIpAddress.Input( _L("10.20.30.40") );
+    rtcp = CSdpAttributeField::DecodeLC( _L8( "a=rtcp:5020 IN IP4 10.20.30.40\r\n" ) );
+    audioLine->AttributeFields().AppendL( rtcp );
+    CleanupStack::Pop( rtcp );
+    iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream );
+    EUNIT_ASSERT_EQUALS( 5020, mediaStream->iRemoteRtcpPort )
+    EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() )  // Not changed
+    audioLine->AttributeFields().ResetAndDestroy();
+
+    // Rtcp attrubute is local loopback address, ok to use
+    rtcp = CSdpAttributeField::DecodeLC( _L8( "a=rtcp:5020 IN IP4 127.0.0.1\r\n" ) );
+    audioLine->AttributeFields().AppendL( rtcp );
+    CleanupStack::Pop( rtcp );
+    iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream );
+    EUNIT_ASSERT_EQUALS( 5020, mediaStream->iRemoteRtcpPort )
+    EUNIT_ASSERT_EQUALS( INET_ADDR( 127,0,0,1 ), mediaStream->iRemoteRtcpAddress.Address() )
+    audioLine->AttributeFields().ResetAndDestroy();
+    
     CleanupStack::PopAndDestroy( sdp );
     }
     
@@ -1350,14 +1369,6 @@
 
     }
     
-void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeSecureSessionLL()
-	{
-	CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR );
-	CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ];
-    iSession->SecureSessionL();
-    
-    CMceComMediaStream* mediaStream = iSession->Streams()[ 0 ];
-    CMceSecureMediaSession* secureSession = iSession->SecureSession();
 
     CleanupStack::PushL( sdp );
     secureSession->iKeyNeedUpdated = EFalse;
@@ -1673,17 +1684,11 @@
     "FUNCTIONALITY",
     SetupL, UT_CMceMediaSdpCodec_EncodelocalRtcpAttrLL, Teardown)
     
-EUNIT_TEST (
-    "DecodeSecureSessionL test",
-    "CMceMediaSdpCodec",
-    "DecodeSecureSessionL",
-    "FUNCTIONALITY",
-    SetupL, UT_CMceMediaSdpCodec_DecodeSecureSessionLL, Teardown)
-    
+
 EUNIT_TEST (
     "DecodeDirection test",
     "CMceMediaSdpCodec",
-    "DecodeDirectionL",
+    "DecodeDirectionAttribute",
     "FUNCTIONALITY",
     SetupL, UT_CMceMediaSdpCodec_DecodeDirectionLL, Teardown)        
     
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -242,11 +242,9 @@
             NAT_WAIT_NO_EXEC( session, (status = session.Actions().CreateSDP( response )));
             if ( !MCE_IS_ERROR( status ) && MCE_NEED_TO_SEND( session, NULL ) )
                 {
-                CMceSecureMediaSession* secSession = session.ActiveBody().SecureSession();
-                if ( secSession )
+                if ( session.ActiveBody().SecureSession() )
                 	{
-                    secSession->iLSReadyToBind = ETrue;
-                    secSession->iKeyNeedUpdated = ETrue;
+                	session.ActiveBody().SecureSession()->iLSReadyToBind = ETrue;
                 	}
                 session.SetFirstOffer();
                 status = session.Actions().DecodeL();
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -465,12 +465,10 @@
                     //update FC
                     session.FCActions().PeekFCDocumentL( *session.Offer() );
                 	
-                    CMceSecureMediaSession* secSession = session.ActiveBody().SecureSession();
             	    //decode answer, ignore warning code 
-                    if ( secSession )
+                    if ( session.ActiveBody().SecureSession())
                     	{
-                        secSession->iLSReadyToBind = ETrue;
-                        secSession->iKeyNeedUpdated = ETrue;
+                    	session.ActiveBody().SecureSession()->iLSReadyToBind = ETrue;
                     	}
                     status = session.Actions().Decode();
 
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcestateupdating.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcestateupdating.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -135,6 +135,17 @@
 	                        session.Actions().StateChanged( 
 	                            KMceStateAcknowledgementRequired );
 	                        }
+	    	            else
+	    	            	{
+							if ( session.ActiveBody().SecureSession() )
+								{
+							    if( session.IsNatSession() )
+							    	{
+							        session.ActiveBody().SecureSession()->iNatBind = ETrue;
+							    	}
+							    session.ActiveBody().SecureSession()->iLSReadyToBind = ETrue;
+								}
+	    	            	}
 	    	            }
 	                else
 	                    {
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -374,7 +374,6 @@
     EUNIT_ASSERT ( !iSipSession->WaitingMediaCallback() );
 	EUNIT_ASSERT ( body.iSipContactAddrSecure == CMceSession::EControlPathUnsecure );
 	EUNIT_ASSERT ( body.SecureSession()->iLSReadyToBind == ETrue );
-    EUNIT_ASSERT ( body.SecureSession()->iKeyNeedUpdated == ETrue );
 
     iSipSession->iSubState = CMceSipSession::EOffering;
     MCE_RESET_STUBS();
--- a/natfw/natfwconnectionmultiplexer/src/cncmconnectionobserverhandler.cpp	Tue May 25 13:07:26 2010 +0300
+++ b/natfw/natfwconnectionmultiplexer/src/cncmconnectionobserverhandler.cpp	Wed Jun 09 10:06:41 2010 +0300
@@ -260,20 +260,25 @@
         const TInt KRtpRtcpDiffByteOffset( 1 );
         const TInt KLowestAssignedRtcpMsgType = 200;
         const TInt KHighestAssignedRtcpMsgType = 209;
+        TInt rtcpType = aMessage[KRtpRtcpDiffByteOffset];
         TBool isRtcp = 
-           ( KLowestAssignedRtcpMsgType <= aMessage[KRtpRtcpDiffByteOffset] &&
-            aMessage[KRtpRtcpDiffByteOffset] <= KHighestAssignedRtcpMsgType );
+           ( KLowestAssignedRtcpMsgType <= rtcpType &&
+        		   rtcpType <= KHighestAssignedRtcpMsgType );
         
-        // This offset refers either to SR RTP timestamp or RR highest 
-        // sequence number received. These are unique for a distinct 
-        // RTCP packet.
-        const TInt KRtcpDiffByteOffset( 19 );
+        // This offset refers to RR highest sequence number received.
+        const TInt KRRtcpDiffByteOffset( 19 );
+        
+        // This offset refers either to SR RTP packet count received.
+        const TInt KSRtcpDiffByteOffset( 23 );
         
         // This offset refers to lower byte of unique RTP sequence number.
         const TInt KRtpDiffByteOffset( 3 );
         TInt diffByteOffset 
-            = isRtcp ? KRtcpDiffByteOffset : KRtpDiffByteOffset;
+            = isRtcp ? KRRtcpDiffByteOffset : KRtpDiffByteOffset;
 
+        diffByteOffset = (rtcpType == KLowestAssignedRtcpMsgType)?
+        		KSRtcpDiffByteOffset : diffByteOffset;
+        
         if ( diffByteOffset < aMessage.Size() )
             {
             hash = aMessage[diffByteOffset];
@@ -294,14 +299,12 @@
             }
         else
             {
-            isDuplicate = EFalse;
-            }
-        
-        iLatestHashes.Append( hash );
-        const TInt KMaxHashCount( 5 );
-        if ( KMaxHashCount <= iLatestHashes.Count() )
-            {
-            iLatestHashes.Remove( 0 );
+            iLatestHashes.Append( hash );
+            const TInt KMaxHashCount( 5 );
+            if ( KMaxHashCount <= iLatestHashes.Count() )
+                {
+                iLatestHashes.Remove( 0 );
+                }
             }
         }
     else