ILMDVRSink::GetTimedFragmentAlignment Example for C++

HRESULT SaveTimedDVRFragments(ILMDVRSink* 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; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help