IltmmRTSPServer Example for C++

The following C++ functions show how to create an RTSP Server using the high level functions in IltmmRTSPServer.

/* Ask the LEAD RTSP Sink filter to create a ILMRTSPServer interface and add one user to it */ 
ILMRTSPSecurity *CreateRTSPSecurity() 
   ILMRTSPSecurity *pSecurity; 
   HRESULT hr = CoCreateInstance(CLSID_LMRTSPSecurity, NULL, CLSCTX_INPROC_SERVER, IID_ILMRTSPSecurity, (void **)&pSecurity); 
      return NULL; 
   // use Digest authentication 
   // note that since I created the interface as an inproc server, I can pass wide char as BSTR instead of allocating them with SysAllocString 
   pSecurity->put_RealmName(L"My RTSP Server"); 
   // add one user with a password 
   pSecurity->AddUser(L"user1", L"pass1", NULL); 
   return pSecurity; 
/* Create an RTSP Server with an optional file containing the conversion settings. Pass NULL for defaultConvertSettings if you 
don't have a settings file */ 
HRESULT TestRTSPServer(BSTR defaultConvertSettings, long flags) 
   IltmmRTSPServer *pServer = NULL; 
   HRESULT hr = CoCreateInstance(CLSID_ltmmRTSPServer, NULL, CLSCTX_INPROC_SERVER, IID_IltmmRTSPServer, (void **)&pServer); 
   if(FAILED(hr) || pServer == NULL) 
      return hr; 
   // add one source folder. You can pass wide char string for BSTR since the server is created as an inproc server 
   pServer->put_SourceFolder(0, L"c:\\RTSPSourceFolder"); 
   pServer->put_LiveLatency(-1, 0.2);   // use 0.2 sec live latency 
   // create and assign as security the interface with Digest authentication and one authenticated user 
   ILMRTSPSecurity *pSecurity = CreateRTSPSecurity(); 
      pServer->put_Security(-1, pSecurity); 
      pServer->LoadSettingsFromFile(-1, defaultConvertSettings, flags); 
   // make the server listen on the local loopback address 
   // listen on the default RTSP port (554). Change this value if you already have an RTSP server running on this port 
   hr = pServer->StartServer(ltmmRTSP_DefaultPort); 
      // the server will be running while the message box is running 
      MessageBoxA(NULL, "Press OK to stop the server", "RTSP Server is running!", MB_OK); 
   return hr; 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Multimedia C API Help