79 lines
2.1 KiB
C
79 lines
2.1 KiB
C
|
/*
|
||
|
* Implementation of MedaType utility functions
|
||
|
*
|
||
|
* Copyright 2003 Robert Shearman
|
||
|
* Copyright 2010 Aric Stewart, CodeWeavers
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2.1 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with this library; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||
|
*/
|
||
|
#include <stdarg.h>
|
||
|
|
||
|
#define COBJMACROS
|
||
|
#include "dshow.h"
|
||
|
|
||
|
#include "wine/strmbase.h"
|
||
|
#include "wine/debug.h"
|
||
|
|
||
|
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
|
||
|
|
||
|
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc)
|
||
|
{
|
||
|
*pDest = *pSrc;
|
||
|
if (!pSrc->pbFormat) return S_OK;
|
||
|
if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
|
||
|
return E_OUTOFMEMORY;
|
||
|
memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
|
||
|
if (pDest->pUnk)
|
||
|
IUnknown_AddRef(pDest->pUnk);
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType)
|
||
|
{
|
||
|
if (pMediaType->pbFormat)
|
||
|
{
|
||
|
CoTaskMemFree(pMediaType->pbFormat);
|
||
|
pMediaType->pbFormat = NULL;
|
||
|
}
|
||
|
if (pMediaType->pUnk)
|
||
|
{
|
||
|
IUnknown_Release(pMediaType->pUnk);
|
||
|
pMediaType->pUnk = NULL;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc)
|
||
|
{
|
||
|
AM_MEDIA_TYPE * pDest;
|
||
|
|
||
|
pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
|
||
|
if (!pDest)
|
||
|
return NULL;
|
||
|
|
||
|
if (FAILED(CopyMediaType(pDest, pSrc)))
|
||
|
{
|
||
|
CoTaskMemFree(pDest);
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
return pDest;
|
||
|
}
|
||
|
|
||
|
void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
|
||
|
{
|
||
|
FreeMediaType(pMediaType);
|
||
|
CoTaskMemFree(pMediaType);
|
||
|
}
|