Share via


Set the Security Level for the Client Object

The following code examples demonstrate how to set the security levels for different media types on the Client object. The operations in the Initialize RTC and Create a Session and Make a Call code examples must be performed before using this example.

Note  These examples does not contain error checking or releases appropriate for real code.

C++ Code Example

HRESULT hr = S_OK;
IRTCClient2 *pClient2 = NULL;		
IRTCSession2 *pSession2 = NULL;			
RTC_SECURITY_LEVEL  enAVLevel;
RTC_SECURITY_LEVEL  enT120Level;
VARIANT_BOOL fSecurityEnabled;

// Cocreate and initialize the client object here. 
// See the "Initialize RTC" code example to 
// CoCreate the client object. 

// Create the session object here. See the
// "Create a Session and Make a Call" code example.

// Set the security level for the Audio/Video media  
// to RTCSECL_REQUIRED. 
enAVLevel = RTCSECL_REQUIRED;
 
hr = pClient2->put_PreferredSecurityLevel(RTCSECT_AUDIO_VIDEO_MEDIA_ENCRYPTION, 
                                          enAVLevel);

// If (hr != S_OK), process the error here.


// Set the security level for the T120 media type 
// to RTCSECL_SUPPORTED.
// Note: If the T120 security level is set from 
// NetMeeting, the NetMeeting setting will take
// effect instead of what is set here. 
enT120Level = RTCSECL_SUPPORTED;

hr = pClient2->put_PreferredSecurityLevel(RTCSECT_T120_MEDIA_ENCRYPTION, 
                                          enT120Level);

// If (hr != S_OK), process the error here.


// Check whether encryption is enabled for the T120 media.
// Note: IsSecurityEnabled() will succeed if the
// session type is RTCST_PC_TO_PC, and the session state 
// is RTCSS_CONNECTED.
hr = pSession2->IsSecurityEnabled(RTCSECT_T120_MEDIA_ENCRYPTION,
                                  &fSecurityEnabled); 
 
// If (hr != S_OK), process the error here.

Visual Basic Code Example

' Set the error handling routine here. 
' On Error GoTo MyErrorRoutine 

'Usually declared globally 
Private g_objClient2 As IRTCClient2
Private g_objSession2 As IRTCSession2

Dim securityLevelAV As RTC_SECURITY_LEVEL
Dim securityLevelT120 As RTC_SECURITY_LEVEL
Dim IsSecurityEnabled As Boolean

' Create and initialize the client object here. 
' See the "Initialize RTC" code example.

' Create the session object here. See the
' "Create a Session and Make a Call" code example.

' Set the security level for the Audio/Video 
' media to RTCSECL_REQUIRED.
securityLevelAV = RTCSECL_REQUIRED 
g_objClient2.PreferredSecurityLevel(RTCSECT_AUDIO_VIDEO_MEDIA_ENCRYPTION) = securityLevelAV

'Set the security level for T120 to RTCSECL_SUPPORTED.
securityLevelT120 =  RTCSECL_SUPPORTED 
g_objClient2.PreferredSecurityLevel(RTCSECT_T120_MEDIA_ENCRYPTION) = securityLevelT120

' Check whether encryption is enabled for the T120 media.
' IsSecurityEnabled can be called only after the session 
' is connected and will return TRUE if encryption is enabled. 
IsSecurityEnabled = g_objSession2.IsSecurityEnabled(RTCSECT_T120_MEDIA_ENCRYPTION)