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 StartDVRCapture(IltmmCapture *pCapture, LPTSTR szBufferFile, long fileCount, double bufferSize) 
{ 
   USES_CONVERSION; 
   HRESULT hr = S_OK; 
   pCapture->EnterEdit(); 
   BSTR bstrBufferFile = SysAllocString(T2OLE(szBufferFile)); 
   // Tell the capture control where to store the captured data 
   pCapture->put_TargetFile(bstrBufferFile); 
   SysFreeString(bstrBufferFile); 
   // Get the graph ready to capture video and audio, but don't start capturing yet 
   hr = pCapture->ReadyCapture(ltmmCapture_Mode_VideoAndAudio | ltmmCapture_Mode_InhibitRun); 
   if(SUCCEEDED(hr)) 
   { 
      IUnknown *punk = NULL; 
      // Get the sink object unknown interface 
      hr = pCapture->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 = pCapture->RunCapture(); 
   } 
   pCapture->LeaveEdit(); 
} 

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