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
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
32 /***********************************************************************
33 * MoCreateMediaType (MSDMO.@)
35 HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
39 TRACE("(%p,%lu)\n", ppmedia, cbFormat);
44 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
48 hr = MoInitMediaType(*ppmedia, cbFormat);
50 CoTaskMemFree(*ppmedia);
57 /***********************************************************************
58 * MoInitMediaType (MSDMO.@)
60 HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
62 TRACE("(%p,%lu)\n", pmedia,cbFormat);
67 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
70 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
71 if (pmedia->pbFormat == NULL)
74 pmedia->cbFormat = cbFormat;
80 /***********************************************************************
81 * MoDeleteMediaType (MSDMO.@)
83 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
85 TRACE("(%p)\n", pmedia);
90 MoFreeMediaType(pmedia);
91 CoTaskMemFree(pmedia);
96 /***********************************************************************
97 * MoFreeMediaType (MSDMO.@)
99 HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
101 TRACE("(%p)\n", pmedia);
106 if (pmedia->pUnk != NULL) {
107 IUnknown_Release(pmedia->pUnk);
111 if (pmedia->pbFormat != NULL) {
112 CoTaskMemFree(pmedia->pbFormat);
113 pmedia->pbFormat = NULL;
119 /***********************************************************************
120 * MoDuplicateMediaType (MSDMO.@)
122 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
123 const DMO_MEDIA_TYPE* psrc)
127 TRACE("(%p,%p)\n", ppdst, psrc);
129 if (ppdst == NULL || psrc == NULL)
132 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
134 return E_OUTOFMEMORY;
136 hr = MoCopyMediaType(*ppdst, psrc);
138 MoFreeMediaType(*ppdst);
145 /***********************************************************************
146 * MoCopyMediaType (MSDMO.@)
148 HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
149 const DMO_MEDIA_TYPE* psrc)
151 TRACE("(%p,%p)\n", pdst, psrc);
153 if (pdst == NULL || psrc == NULL)
156 memcpy(&pdst->majortype, &psrc->majortype, sizeof(psrc->majortype));
157 memcpy(&pdst->subtype, &psrc->subtype, sizeof(psrc->subtype));
158 memcpy(&pdst->formattype, &psrc->formattype, sizeof(psrc->formattype));
160 pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
161 pdst->bTemporalCompression = psrc->bTemporalCompression;
162 pdst->lSampleSize = psrc->lSampleSize;
163 pdst->cbFormat = psrc->cbFormat;
165 if (psrc->pbFormat != NULL && psrc->cbFormat > 0) {
166 pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
167 if (pdst->pbFormat == NULL)
168 return E_OUTOFMEMORY;
170 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
172 pdst->pbFormat = NULL;
174 if (psrc->pUnk != NULL) {
175 pdst->pUnk = psrc->pUnk;
176 IUnknown_AddRef(pdst->pUnk);