Port Manager Code Example

The following code example demonstrates the creation of the IRTCSessionPortManagement interface and how to set the IRTCPortManager interface.

Note  This example does not contain error checking or releases appropriate for real code.

C++ Code Example

HRESULT hr = S_OK;
IRTCPortManager *pPortManager = NULL;
 
// CoCreate the PortManager.
// Note: Your PortManager implementation might have a different CLSID.
hr = CoCreateInstance(CLSID_MyPortManager,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IRTCPortManager,
                      reinterpret_cast<void **> (&pPortManager));
 
// If (hr != S_OK), process the error here. 
 
IRTCSession *pIRTCSession = NULL;
IRTCSessionPortManagement *pSessionPortManagement = NULL;
 
// Query IRTCSession for IRTCSessionPortManagement.
// Note: It is assumed the session has already been created.
hr = pIRTCSession->QueryInterface(IID_IRTCSessionPortManagement,
                                  reinterpret_cast<void **> 
                                  (&pSessionPortManagement));
 
// If (hr != S_OK), process the error here. 

// Set the PortManager.
hr = pSessionPortManagement->SetPortManager(pPortManager);
 
// If (hr != S_OK), process the error here.