mf/session: Forward more events to the application.
[wine/zf.git] / dlls / msdmo / dmort.c
blobb586cac6116b6ab0cd743cb1b8f436937a04d09f
1 /*
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "objbase.h"
26 #include "mediaobj.h"
27 #include "dmort.h"
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)
40 HRESULT r;
42 TRACE("%p %u\n", ppmedia, cbFormat);
44 if (!ppmedia)
45 return E_POINTER;
47 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
48 if (!*ppmedia)
49 return E_OUTOFMEMORY;
51 r = MoInitMediaType(*ppmedia, cbFormat);
52 if (FAILED(r))
54 CoTaskMemFree(*ppmedia);
55 *ppmedia = NULL;
58 return r;
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);
70 if (!pmedia)
71 return E_POINTER;
73 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
75 if (cbFormat > 0)
77 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
78 if (!pmedia->pbFormat)
79 return E_OUTOFMEMORY;
81 pmedia->cbFormat = cbFormat;
84 return S_OK;
87 /***********************************************************************
88 * MoDeleteMediaType (MSDMO.@)
90 * Delete a media type structure
92 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
94 TRACE("%p\n", pmedia);
96 if (!pmedia)
97 return E_POINTER;
99 MoFreeMediaType(pmedia);
100 CoTaskMemFree(pmedia);
102 return S_OK;
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);
114 if (!pmedia)
115 return E_POINTER;
117 if (pmedia->pUnk)
119 IUnknown_Release(pmedia->pUnk);
120 pmedia->pUnk = NULL;
123 CoTaskMemFree(pmedia->pbFormat);
124 pmedia->pbFormat = NULL;
126 return S_OK;
129 /***********************************************************************
130 * MoDuplicateMediaType (MSDMO.@)
132 * Duplicates a media type structure
134 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
135 const DMO_MEDIA_TYPE* psrc)
137 HRESULT r;
139 TRACE("%p %p\n", ppdst, psrc);
141 if (!ppdst || !psrc)
142 return E_POINTER;
144 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
145 if (!*ppdst)
146 return E_OUTOFMEMORY;
148 r = MoCopyMediaType(*ppdst, psrc);
149 if (FAILED(r))
151 MoFreeMediaType(*ppdst);
152 *ppdst = NULL;
155 return r;
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);
168 if (!pdst || !psrc)
169 return E_POINTER;
171 pdst->majortype = psrc->majortype;
172 pdst->subtype = psrc->subtype;
173 pdst->formattype = 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);
183 if (!pdst->pbFormat)
184 return E_OUTOFMEMORY;
186 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
188 else
189 pdst->pbFormat = NULL;
191 if (psrc->pUnk)
193 pdst->pUnk = psrc->pUnk;
194 IUnknown_AddRef(pdst->pUnk);
196 else
197 pdst->pUnk = NULL;
199 return S_OK;