Set the Security Level for the Session Object

The following code example demonstrates how to set the security level for different media types on the Session 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  This example 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;

// Cocreate 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.

// Once we have a pointer to the IRTCSession2 interface, 
// it is possible to set the security level for a
// particular media type (Audio/Video or T120) on 
// this particular session as long as the stream
// for that media type is not active.

// Set the security level for the T120 media type to
// RTCSECL_SUPPORTED for the current session.
hr = pSession2->put_PreferredSecurityLevel(RTCSECT_T120_MEDIA_ENCRYPTION, 
                                           RTCSECL_SUPPORTED);

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

// Release the object pointers if they 
// are no longer needed.
if (pClient2)
   pClient2->Release();

if (pSession2)
   pSession2->Release();
	

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 

' 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 T120 media to
' RTCSECL_SUPPORTED for the session. 
' The security level for the session can be changed 
' for a particular media type only if that media  
' type is not active.
g_objSession2.PreferredSecurityLevel(RTCSECT_T120_MEDIA_ENCRYPTION) = RTCSECL_SUPPORTED