The following code demonstrates how to copy a media type's attributes and data to another media type.
// 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 interfaceHRESULT CopyMediaTypeAttributes(IltmmMediaTypeDisp* pDest, IltmmMediaTypeDisp* pSource){HRESULT hr;VARIANT_BOOL f;long l;BSTR bstr;long cbData;VARIANT var;// return error if NULLif(!pSource || !pDest)return E_POINTER;// get the format data sizehr = pSource->get_FormatSize(&cbData);if(FAILED(hr))return hr;// any format dataif(cbData){// yes, then copy awayhr = pSource->GetFormatData(cbData, &var);if(FAILED(hr))return hr;hr = pDest->SetFormatData(cbData, var);VariantClear(&var);if(FAILED(hr))return hr;}else{// no, just set the dest to zerohr = pDest->put_FormatSize(0);if(FAILED(hr))return hr;}// copy typebstr = NULL;pSource->get_Type(&bstr);pDest->put_Type(bstr);::SysFreeString(bstr);// copy subtypebstr = NULL;pSource->get_Subtype(&bstr);pDest->put_Subtype(bstr);::SysFreeString(bstr);// copy formattypebstr = NULL;pSource->get_FormatType(&bstr);pDest->put_FormatType(bstr);::SysFreeString(bstr);// copy fixedsizesamplesf = VARIANT_FALSE;pSource->get_FixedSizeSamples(&f);pDest->put_FixedSizeSamples(f);// copy temporalcompressionf = VARIANT_FALSE;pSource->get_TemporalCompression(&f);pDest->put_TemporalCompression(f);// copy samplesizel = 0;pSource->get_SampleSize(&l);pDest->put_SampleSize(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
