ILMDVRSource::GetTimedFragmentAlignment Example for C++

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; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Multimedia C API Help