The following code demonstrates how to copy a media type's attributes and data to another media type.
// define helper macros for using interfaces under C#ifndef COBJMACROS#define COBJMACROS#endif// include the LEAD Multimedia TOOLKIT header#include "ltmm.h"/////////////////////////////////////////////////////////////////// CopyMediaTypeAttributes// copies data and attributes from one media type to another// pDest - destination media type interface// pSource - source media type interface//HRESULT CopyMediaTypeAttributesExample (IltmmMediaTypeDisp* pDest, IltmmMediaTypeDisp* pSource){HRESULT hr;VARIANT_BOOL f;long l;BSTR bstr;long cbData;VARIANT var;// return an error if NULLif(!pSource || !pDest)return E_POINTER;// get the format data sizehr = IltmmMediaTypeDisp_get_FormatSize (pSource, &cbData);if(FAILED(hr))return hr;// any format data?if(cbData){// yes, then copy awayhr = IltmmMediaTypeDisp_GetFormatData (pSource, cbData, &var);if(FAILED(hr))return hr;hr = IltmmMediaTypeDisp_SetFormatData (pDest, cbData, var);VariantClear(&var);if(FAILED(hr))return hr;}else{// no, just set the destdestination to zerohr = IltmmMediaTypeDisp_put_FormatSize (pDest, 0);if(FAILED(hr))return hr;}// copy typebstr = NULL;IltmmMediaTypeDisp_get_Type(pSource, &bstr);IltmmMediaTypeDisp_put_Type (pDest, bstr);SysFreeString(bstr);// copy subtypebstr = NULL;IltmmMediaTypeDisp_get_Subtype (pSource, &bstr);IltmmMediaTypeDisp_put_Subtype (pDest, bstr);SysFreeString(bstr);// copy formattypebstr = NULL;IltmmMediaTypeDisp_get_FormatType(pSource, &bstr);IltmmMediaTypeDisp_put_FormatType (pDest, bstr);SysFreeString(bstr);// copy fixedsizesamplesf = VARIANT_FALSE;IltmmMediaTypeDisp_get_FixedSizeSamples (pSource, &f);IltmmMediaTypeDisp_put_FixedSizeSamples(pDest, f);// copy temporalcompressionf = VARIANT_FALSE;IltmmMediaTypeDisp_get_TemporalCompression (pSource, &f);IltmmMediaTypeDisp_put_TemporalCompression (pDest, f);// copy samplesizel = 0;IltmmMediaTypeDisp_get_SampleSize (pSource, &l);IltmmMediaTypeDisp_put_SampleSize (pDest, l);return S_OK;}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
