HRESULT CreateRTSPStream(IltmsServer* server, LPCTSTR path, LPCTSTR url)
{
HRESULT hr;
long streamcount;
long streamindex;
CComPtr<IltmsLiveStreams> streams;
CComPtr<IltmsLiveStream> stream;
hr = server->GetLiveStreams(&streams);
if (FAILED(hr))
goto error;
// search for existing stream with same path
hr = streams->get_Count(&streamcount);
if (FAILED(hr))
goto error;
for (streamindex = 0; streamindex < streamcount; streamindex++)
{
CComBSTR v;
hr = streams->GetLiveStream(streamindex, &stream);
if (FAILED(hr))
goto error;
hr = stream->get_Path(&v);
if (FAILED(hr))
goto error;
if (CStringW(path).CompareNoCase(v) == 0)
break;
stream = NULL;
}
if (!stream)
{
// create a new stream
streamindex = -1;
hr = streams->CreateLiveStream(&stream);
if (FAILED(hr))
goto error;
}
// set the stream path
hr = stream->put_Path(CComBSTR(path));
if (FAILED(hr))
goto error;
// create the RTSP device
{
CComPtr<IltmsDevices> devices;
long index = -1;
stream->get_VideoDevices(&devices);
hr = devices->Find(CComBSTR(_T("@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\\{E2B7DE48-38C5-11D5-91F6-00104BDB8FF9}")), &index);
if (FAILED(hr))
goto error;
hr = devices->put_Selection(index);
if (FAILED(hr))
goto error;
}
// set the device RTSP URL
hr = stream->put_VideoDeviceURL(CComBSTR(url));
if (FAILED(hr))
goto error;
// add or replace stream
if (streamindex < 0)
hr = streams->AddLiveStream(stream);
else
hr = streams->SetLiveStream(streamindex, stream);
if (FAILED(hr))
goto error;
hr = server->SetLiveStreams(streams);
if (FAILED(hr))
goto error;
error:
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.