How to Control Capture Buffer Settings using the DVR Sink Object (C++)
The following method for C++ shows how to get the DVR Sink object from the ltmmPlayControl object, using it to set DVR settings.
void CDVRExample::StartDVRCapture(LPTSTR szBufferFile, long fileCount, double bufferSize) { USES_CONVERSION; HRESULT hr = S_OK; m_captureCtrl->EnterEdit(); BSTR bstrBufferFile = ::SysAllocString(T2OLE(szBufferFile)); // Tell the capture control where to store the captured data m_captureCtrl->put_TargetFile(bstrBufferFile); ::SysFreeString(bstrBufferFile); // Get the graph ready to capture video and audio, but don't start capturing yet hr = m_captureCtrl->ReadyCapture(ltmmCapture_Mode_VideoAndAudio | ltmmCapture_Mode_InhibitRun); if(SUCCEEDED(hr)) { IUnknown *punk = NULL; // Get the sink object unknown interface hr = m_captureCtrl->GetSubObject(ltmmCapture_Object_Sink, &punk); if(SUCCEEDED(hr) && NULL != punk) { ILMDVRSink *pDvrSink = NULL; // Get the sink interface from the unknown object HRESULT hr = punk->QueryInterface(IID_ILMDVRSink, (LPVOID*)&pDvrSink); if (SUCCEEDED(hr)) { // Tell the sink that settings are going to change pDvrSink->StartChangingAttributes(); // Set the folder count (one buffer folder) and number of buffer files and their maximum size pDvrSink->put_FolderCount(1); pDvrSink->SetBufferSize(0, fileCount, bufferSize); // Apply the DVR settings pDvrSink->StopChangingAttributes(FALSE); // Release the sink interface pDvrSink->Release(); } // Release the unknown interface punk->Release(); } // Start the graph capturing data hr = m_captureCtrl->RunCapture(); } m_captureCtrl->LeaveEdit(); }