HRESULT SaveTimedDVRFragments(ILMDVRSource* pDVR, double dTimeThreshold, LPCWSTR pszFilePrefix)
{
HRESULT hr;
double dStartPos;
double dEndPos;
double dTotal;
double dFragmentStartPos;
double dFragmentEndPos = 0;
WCHAR szPath[MAX_PATH];
for (UINT fragment = 0; ; fragment++)
{
// find available range of bytes
hr = pDVR->GetAvailabilityInfo(&dStartPos, &dEndPos, &dTotal);
if (FAILED(hr))
return hr;
// if this is not the first fragment, then start where we left off
if (fragment > 0)
dStartPos = dFragmentEndPos;
// Get aligned boundaries for next timed fragment
hr = pDVR->GetTimedFragmentAlignment(dStartPos, dEndPos, dTimeThreshold, &dFragmentStartPos, &dFragmentEndPos, NULL);
if (FAILED(hr))
return hr;
// if nothing more is available, then exit the loop
if (hr != S_OK)
break;
// generate an output path for this fragment
swprintf_s(szPath, _countof(szPath), L"%s%u.ts", pszFilePrefix, fragment);
// save the fragments to a file
hr = pDVR->CopyBufferToFile(CComBSTR(szPath), dFragmentStartPos, dFragmentEndPos);
if (FAILED(hr))
return hr;
}
return S_OK;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET