2 * Copyright (C) 2003 Michael Günnewig
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
33 /***********************************************************************
34 * MoCreateMediaType (MSDMO.@)
36 * Allocate a new media type structure
38 HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
42 TRACE("%p %u\n", ppmedia, cbFormat);
47 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
51 r = MoInitMediaType(*ppmedia, cbFormat);
54 CoTaskMemFree(*ppmedia);
61 /***********************************************************************
62 * MoInitMediaType (MSDMO.@)
64 * Initialize media type structure
66 HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
68 TRACE("%p %u\n", pmedia, cbFormat);
73 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
77 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
78 if (!pmedia->pbFormat)
81 pmedia->cbFormat = cbFormat;
87 /***********************************************************************
88 * MoDeleteMediaType (MSDMO.@)
90 * Delete a media type structure
92 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
94 TRACE("%p\n", pmedia);
99 MoFreeMediaType(pmedia);
100 CoTaskMemFree(pmedia);
105 /***********************************************************************
106 * MoFreeMediaType (MSDMO.@)
108 * Free allocated members of a media type structure
110 HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
112 TRACE("%p\n", pmedia);
119 IUnknown_Release(pmedia->pUnk);
123 CoTaskMemFree(pmedia->pbFormat);
124 pmedia->pbFormat = NULL;
129 /***********************************************************************
130 * MoDuplicateMediaType (MSDMO.@)
132 * Duplicates a media type structure
134 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
135 const DMO_MEDIA_TYPE* psrc)
139 TRACE("%p %p\n", ppdst, psrc);
144 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
146 return E_OUTOFMEMORY;
148 r = MoCopyMediaType(*ppdst, psrc);
151 MoFreeMediaType(*ppdst);
158 /***********************************************************************
159 * MoCopyMediaType (MSDMO.@)
161 * Copy a new media type structure
163 HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
164 const DMO_MEDIA_TYPE* psrc)
166 TRACE("%p %p\n", pdst, psrc);
171 memcpy(&pdst->majortype, &psrc->majortype, sizeof(psrc->majortype));
172 memcpy(&pdst->subtype, &psrc->subtype, sizeof(psrc->subtype));
173 memcpy(&pdst->formattype, &psrc->formattype, sizeof(psrc->formattype));
175 pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
176 pdst->bTemporalCompression = psrc->bTemporalCompression;
177 pdst->lSampleSize = psrc->lSampleSize;
178 pdst->cbFormat = psrc->cbFormat;
180 if (psrc->pbFormat && psrc->cbFormat > 0)
182 pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
184 return E_OUTOFMEMORY;
186 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
189 pdst->pbFormat = NULL;
193 pdst->pUnk = psrc->pUnk;
194 IUnknown_AddRef(pdst->pUnk);