IltmmRTSPServer Example for C++

The following C++ functions show how to create a 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); 
   if(FAILED(hr)) 
      return NULL; 
 
   // use Digest authentication 
   pSecurity->put_AuthenticationRequired(LMRTSPAuthenticationType_Digest); 
   // 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 a 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(); 
   if(pSecurity) 
   { 
      pServer->put_Security(-1, pSecurity); 
      pSecurity->Release(); 
   } 
 
   if(defaultConvertSettings) 
      pServer->LoadSettingsFromFile(-1, defaultConvertSettings, flags); 
 
   // make the server listen on the local loopback address 
   pServer->put_TargetAddress(L"127.0.0.1"); 
 
   // listen on the default RTSP port (554). Change this value if you already have a RTSP server running on this port 
   hr = pServer->StartServer(ltmmRTSP_DefaultPort); 
   if(SUCCEEDED(hr)) 
   { 
      // 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); 
 
      pServer->StopServer(ltmmRTSP_DefaultPort); 
 
      pServer->Release(); 
   } 
 
   return hr; 
}  

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.