2003-07-21 22:03:50 +02:00
|
|
|
/*
|
2008-10-18 19:20:10 +02:00
|
|
|
* Copyright (C) 2003 Michael Günnewig
|
2003-07-21 22:03:50 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-07-21 22:03:50 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "mediaobj.h"
|
|
|
|
#include "dmort.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoCreateMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Allocate a new media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
|
|
|
|
{
|
2005-02-24 13:48:00 +01:00
|
|
|
HRESULT r;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2022-02-15 07:29:23 +01:00
|
|
|
TRACE("%p %lu\n", ppmedia, cbFormat);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (!ppmedia)
|
|
|
|
return E_POINTER;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
*ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
|
|
|
|
if (!*ppmedia)
|
|
|
|
return E_OUTOFMEMORY;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
r = MoInitMediaType(*ppmedia, cbFormat);
|
|
|
|
if (FAILED(r))
|
|
|
|
{
|
|
|
|
CoTaskMemFree(*ppmedia);
|
|
|
|
*ppmedia = NULL;
|
|
|
|
}
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
return r;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoInitMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Initialize media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
|
|
|
|
{
|
2022-02-15 07:29:23 +01:00
|
|
|
TRACE("%p %lu\n", pmedia, cbFormat);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (!pmedia)
|
|
|
|
return E_POINTER;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (cbFormat > 0)
|
|
|
|
{
|
|
|
|
pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
|
|
|
|
if (!pmedia->pbFormat)
|
|
|
|
return E_OUTOFMEMORY;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
pmedia->cbFormat = cbFormat;
|
|
|
|
}
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
return S_OK;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoDeleteMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Delete a media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
|
|
|
|
{
|
2005-02-24 13:48:00 +01:00
|
|
|
TRACE("%p\n", pmedia);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (!pmedia)
|
|
|
|
return E_POINTER;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
MoFreeMediaType(pmedia);
|
|
|
|
CoTaskMemFree(pmedia);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
return S_OK;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoFreeMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Free allocated members of a media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
|
|
|
|
{
|
2005-02-24 13:48:00 +01:00
|
|
|
TRACE("%p\n", pmedia);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (!pmedia)
|
|
|
|
return E_POINTER;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (pmedia->pUnk)
|
|
|
|
{
|
|
|
|
IUnknown_Release(pmedia->pUnk);
|
|
|
|
pmedia->pUnk = NULL;
|
|
|
|
}
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2006-10-07 03:05:08 +02:00
|
|
|
CoTaskMemFree(pmedia->pbFormat);
|
|
|
|
pmedia->pbFormat = NULL;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
return S_OK;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoDuplicateMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Duplicates a media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
|
2005-02-24 13:48:00 +01:00
|
|
|
const DMO_MEDIA_TYPE* psrc)
|
2003-07-21 22:03:50 +02:00
|
|
|
{
|
2005-02-24 13:48:00 +01:00
|
|
|
HRESULT r;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
TRACE("%p %p\n", ppdst, psrc);
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
if (!ppdst || !psrc)
|
|
|
|
return E_POINTER;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
*ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
|
|
|
|
if (!*ppdst)
|
|
|
|
return E_OUTOFMEMORY;
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
r = MoCopyMediaType(*ppdst, psrc);
|
|
|
|
if (FAILED(r))
|
|
|
|
{
|
|
|
|
MoFreeMediaType(*ppdst);
|
|
|
|
*ppdst = NULL;
|
|
|
|
}
|
2003-07-21 22:03:50 +02:00
|
|
|
|
2005-02-24 13:48:00 +01:00
|
|
|
return r;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-24 13:48:00 +01:00
|
|
|
* MoCopyMediaType (MSDMO.@)
|
|
|
|
*
|
|
|
|
* Copy a new media type structure
|
2003-07-21 22:03:50 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
|
2005-02-24 13:48:00 +01:00
|
|
|
const DMO_MEDIA_TYPE* psrc)
|
2003-07-21 22:03:50 +02:00
|
|
|
{
|
2005-02-24 13:48:00 +01:00
|
|
|
TRACE("%p %p\n", pdst, psrc);
|
|
|
|
|
|
|
|
if (!pdst || !psrc)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2008-03-05 22:35:04 +01:00
|
|
|
pdst->majortype = psrc->majortype;
|
|
|
|
pdst->subtype = psrc->subtype;
|
|
|
|
pdst->formattype = psrc->formattype;
|
2005-02-24 13:48:00 +01:00
|
|
|
|
|
|
|
pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
|
|
|
|
pdst->bTemporalCompression = psrc->bTemporalCompression;
|
|
|
|
pdst->lSampleSize = psrc->lSampleSize;
|
|
|
|
pdst->cbFormat = psrc->cbFormat;
|
|
|
|
|
|
|
|
if (psrc->pbFormat && psrc->cbFormat > 0)
|
|
|
|
{
|
|
|
|
pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
|
|
|
|
if (!pdst->pbFormat)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pdst->pbFormat = NULL;
|
|
|
|
|
|
|
|
if (psrc->pUnk)
|
|
|
|
{
|
|
|
|
pdst->pUnk = psrc->pUnk;
|
|
|
|
IUnknown_AddRef(pdst->pUnk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pdst->pUnk = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-21 22:03:50 +02:00
|
|
|
}
|