IltmmCapture::get_TargetStream Example for C

This function will write the contents of the target data for the passed capture object to a disk file.

void IltmmCapture_get_TargetStream_Example (const char *lpszFileName, IltmmCapture* pCapture)  
{    
   HANDLE hFile = NULL;  
   long fl = 0;  
   unsigned long lBytesWritten;  
   IltmmMemory *pTarget = NULL;  
   VARIANT varData;  
   unsigned char *pBuffer = NULL;  
   SAFEARRAY sa;  
 
   // write the data to a file 
 
   hFile = CreateFile(lpszFileName, // open file name  
      GENERIC_WRITE,              // open for writing  
      FILE_SHARE_READ,            // share for reading  
      NULL,                       // no security  
      CREATE_ALWAYS,              // re-create the file 
      FILE_ATTRIBUTE_NORMAL,      // normal file  
      NULL);                      // no attr. template  
 
   if (hFile == INVALID_HANDLE_VALUE)  
   {  
      return;  
   } 
 
   IltmmCapture_get_TargetStream(pCapture, (IUnknown**)&pTarget);  
 
   if(!pTarget)  
      return;  
 
   IltmmMemory_get_BufferSize(pTarget, &fl);  
 
   VariantInit(&varData);  
 
   // pass data 
   memset(&sa, 0, sizeof(sa));  
   sa.cbElements = sizeof(unsigned char);  
   sa.cDims = 1;  
   sa.fFeatures = (FADF_AUTO | FADF_FIXEDSIZE);  
   sa.pvData = (UCHAR*) malloc(sizeof(UCHAR)*fl);  
   sa.rgsabound[0].cElements = fl;  
   V_VT(&varData) = (VT_ARRAY | VT_UI1);  
   V_ARRAY(&varData) = &sa;  
 
   IltmmMemory_CopyData(pTarget, 0, fl, &varData);  
 
   SafeArrayAccessData(V_ARRAY(&varData), (void**)&pBuffer);  
 
   WriteFile(hFile, pBuffer, fl, &lBytesWritten, NULL);  
 
   SafeArrayUnaccessData(V_ARRAY(&varData));  
   VariantClear(&varData);  
 
   CloseHandle(hFile);  
 
   IltmmMemory_Release(pTarget);  
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.