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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.