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 interface
HRESULT CopyMediaTypeAttributes(IltmmMediaTypeDisp* pDest, IltmmMediaTypeDisp* pSource)
{
HRESULT hr;
VARIANT_BOOL f;
long l;
BSTR bstr;
long cbData;
VARIANT var;
// return error if NULL
if(!pSource || !pDest)
return E_POINTER;
// get the format data size
hr = pSource->get_FormatSize(&cbData);
if(FAILED(hr))
return hr;
// any format data
if(cbData)
{
// yes, then copy away
hr = 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 zero
hr = pDest->put_FormatSize(0);
if(FAILED(hr))
return hr;
}
// copy type
bstr = NULL;
pSource->get_Type(&bstr);
pDest->put_Type(bstr);
::SysFreeString(bstr);
// copy subtype
bstr = NULL;
pSource->get_Subtype(&bstr);
pDest->put_Subtype(bstr);
::SysFreeString(bstr);
// copy formattype
bstr = NULL;
pSource->get_FormatType(&bstr);
pDest->put_FormatType(bstr);
::SysFreeString(bstr);
// copy fixedsizesamples
f = VARIANT_FALSE;
pSource->get_FixedSizeSamples(&f);
pDest->put_FixedSizeSamples(f);
// copy temporalcompression
f = VARIANT_FALSE;
pSource->get_TemporalCompression(&f);
pDest->put_TemporalCompression(f);
// copy samplesize
l = 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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.