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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define COM_NO_WINDOWS_H
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
29 /***********************************************************************
30 * MoCreateMediaType (MSDMO.@)
32 HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
36 TRACE("(%p,%lu)\n", ppmedia, cbFormat);
41 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
45 hr = MoInitMediaType(*ppmedia, cbFormat);
47 CoTaskMemFree(*ppmedia);
54 /***********************************************************************
55 * MoInitMediaType (MSDMO.@)
57 HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
59 TRACE("(%p,%lu)\n", pmedia,cbFormat);
64 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
67 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
68 if (pmedia->pbFormat == NULL)
71 pmedia->cbFormat = cbFormat;
77 /***********************************************************************
78 * MoDeleteMediaType (MSDMO.@)
80 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
82 TRACE("(%p)\n", pmedia);
87 MoFreeMediaType(pmedia);
88 CoTaskMemFree(pmedia);
93 /***********************************************************************
94 * MoFreeMediaType (MSDMO.@)
96 HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
98 TRACE("(%p)\n", pmedia);
103 if (pmedia->pUnk != NULL) {
104 IUnknown_Release(pmedia->pUnk);
108 if (pmedia->pbFormat != NULL) {
109 CoTaskMemFree(pmedia->pbFormat);
110 pmedia->pbFormat = NULL;
116 /***********************************************************************
117 * MoDuplicateMediaType (MSDMO.@)
119 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
120 const DMO_MEDIA_TYPE* psrc)
124 TRACE("(%p,%p)\n", ppdst, psrc);
126 if (ppdst == NULL || psrc == NULL)
129 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
131 return E_OUTOFMEMORY;
133 hr = MoCopyMediaType(*ppdst, psrc);
135 MoFreeMediaType(*ppdst);
142 /***********************************************************************
143 * MoCopyMediaType (MSDMO.@)
145 HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
146 const DMO_MEDIA_TYPE* psrc)
148 TRACE("(%p,%p)\n", pdst, psrc);
150 if (pdst == NULL || psrc == NULL)
153 memcpy(&pdst->majortype, &psrc->majortype, sizeof(psrc->majortype));
154 memcpy(&pdst->subtype, &psrc->subtype, sizeof(psrc->subtype));
155 memcpy(&pdst->formattype, &psrc->formattype, sizeof(psrc->formattype));
157 pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
158 pdst->bTemporalCompression = psrc->bTemporalCompression;
159 pdst->lSampleSize = psrc->lSampleSize;
160 pdst->cbFormat = psrc->cbFormat;
162 if (psrc->pbFormat != NULL && psrc->cbFormat > 0) {
163 pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
164 if (pdst->pbFormat == NULL)
165 return E_OUTOFMEMORY;
167 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
169 pdst->pbFormat = NULL;
171 if (psrc->pUnk != NULL) {
172 pdst->pUnk = psrc->pUnk;
173 IUnknown_AddRef(pdst->pUnk);