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
22 #define COM_NO_WINDOWS_H
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
34 /***********************************************************************
35 * MoCreateMediaType (MSDMO.@)
37 HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
41 TRACE("(%p,%lu)\n", ppmedia, cbFormat);
46 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
50 hr = MoInitMediaType(*ppmedia, cbFormat);
52 CoTaskMemFree(*ppmedia);
59 /***********************************************************************
60 * MoInitMediaType (MSDMO.@)
62 HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
64 TRACE("(%p,%lu)\n", pmedia,cbFormat);
69 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
72 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
73 if (pmedia->pbFormat == NULL)
76 pmedia->cbFormat = cbFormat;
82 /***********************************************************************
83 * MoDeleteMediaType (MSDMO.@)
85 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
87 TRACE("(%p)\n", pmedia);
92 MoFreeMediaType(pmedia);
93 CoTaskMemFree(pmedia);
98 /***********************************************************************
99 * MoFreeMediaType (MSDMO.@)
101 HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
103 TRACE("(%p)\n", pmedia);
108 if (pmedia->pUnk != NULL) {
109 IUnknown_Release(pmedia->pUnk);
113 if (pmedia->pbFormat != NULL) {
114 CoTaskMemFree(pmedia->pbFormat);
115 pmedia->pbFormat = NULL;
121 /***********************************************************************
122 * MoDuplicateMediaType (MSDMO.@)
124 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
125 const DMO_MEDIA_TYPE* psrc)
129 TRACE("(%p,%p)\n", ppdst, psrc);
131 if (ppdst == NULL || psrc == NULL)
134 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
136 return E_OUTOFMEMORY;
138 hr = MoCopyMediaType(*ppdst, psrc);
140 MoFreeMediaType(*ppdst);
147 /***********************************************************************
148 * MoCopyMediaType (MSDMO.@)
150 HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
151 const DMO_MEDIA_TYPE* psrc)
153 TRACE("(%p,%p)\n", pdst, psrc);
155 if (pdst == NULL || psrc == NULL)
158 memcpy(&pdst->majortype, &psrc->majortype, sizeof(psrc->majortype));
159 memcpy(&pdst->subtype, &psrc->subtype, sizeof(psrc->subtype));
160 memcpy(&pdst->formattype, &psrc->formattype, sizeof(psrc->formattype));
162 pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
163 pdst->bTemporalCompression = psrc->bTemporalCompression;
164 pdst->lSampleSize = psrc->lSampleSize;
165 pdst->cbFormat = psrc->cbFormat;
167 if (psrc->pbFormat != NULL && psrc->cbFormat > 0) {
168 pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
169 if (pdst->pbFormat == NULL)
170 return E_OUTOFMEMORY;
172 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
174 pdst->pbFormat = NULL;
176 if (psrc->pUnk != NULL) {
177 pdst->pUnk = psrc->pUnk;
178 IUnknown_AddRef(pdst->pUnk);