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 * Allocate a new media type structure
39 HRESULT WINAPI
MoCreateMediaType(DMO_MEDIA_TYPE
** ppmedia
, DWORD cbFormat
)
43 TRACE("%p %lu\n", ppmedia
, cbFormat
);
48 *ppmedia
= CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE
));
52 r
= MoInitMediaType(*ppmedia
, cbFormat
);
55 CoTaskMemFree(*ppmedia
);
62 /***********************************************************************
63 * MoInitMediaType (MSDMO.@)
65 * Initialize media type structure
67 HRESULT WINAPI
MoInitMediaType(DMO_MEDIA_TYPE
* pmedia
, DWORD cbFormat
)
69 TRACE("%p %lu\n", pmedia
, cbFormat
);
74 memset(pmedia
, 0, sizeof(DMO_MEDIA_TYPE
));
78 pmedia
->pbFormat
= CoTaskMemAlloc(cbFormat
);
79 if (!pmedia
->pbFormat
)
82 pmedia
->cbFormat
= cbFormat
;
88 /***********************************************************************
89 * MoDeleteMediaType (MSDMO.@)
91 * Delete a media type structure
93 HRESULT WINAPI
MoDeleteMediaType(DMO_MEDIA_TYPE
* pmedia
)
95 TRACE("%p\n", pmedia
);
100 MoFreeMediaType(pmedia
);
101 CoTaskMemFree(pmedia
);
106 /***********************************************************************
107 * MoFreeMediaType (MSDMO.@)
109 * Free allocated members of a media type structure
111 HRESULT WINAPI
MoFreeMediaType(DMO_MEDIA_TYPE
* pmedia
)
113 TRACE("%p\n", pmedia
);
120 IUnknown_Release(pmedia
->pUnk
);
124 if (pmedia
->pbFormat
)
126 CoTaskMemFree(pmedia
->pbFormat
);
127 pmedia
->pbFormat
= NULL
;
133 /***********************************************************************
134 * MoDuplicateMediaType (MSDMO.@)
136 * Duplicates a media type structure
138 HRESULT WINAPI
MoDuplicateMediaType(DMO_MEDIA_TYPE
** ppdst
,
139 const DMO_MEDIA_TYPE
* psrc
)
143 TRACE("%p %p\n", ppdst
, psrc
);
148 *ppdst
= CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE
));
150 return E_OUTOFMEMORY
;
152 r
= MoCopyMediaType(*ppdst
, psrc
);
155 MoFreeMediaType(*ppdst
);
162 /***********************************************************************
163 * MoCopyMediaType (MSDMO.@)
165 * Copy a new media type structure
167 HRESULT WINAPI
MoCopyMediaType(DMO_MEDIA_TYPE
* pdst
,
168 const DMO_MEDIA_TYPE
* psrc
)
170 TRACE("%p %p\n", pdst
, psrc
);
175 memcpy(&pdst
->majortype
, &psrc
->majortype
, sizeof(psrc
->majortype
));
176 memcpy(&pdst
->subtype
, &psrc
->subtype
, sizeof(psrc
->subtype
));
177 memcpy(&pdst
->formattype
, &psrc
->formattype
, sizeof(psrc
->formattype
));
179 pdst
->bFixedSizeSamples
= psrc
->bFixedSizeSamples
;
180 pdst
->bTemporalCompression
= psrc
->bTemporalCompression
;
181 pdst
->lSampleSize
= psrc
->lSampleSize
;
182 pdst
->cbFormat
= psrc
->cbFormat
;
184 if (psrc
->pbFormat
&& psrc
->cbFormat
> 0)
186 pdst
->pbFormat
= CoTaskMemAlloc(psrc
->cbFormat
);
188 return E_OUTOFMEMORY
;
190 memcpy(pdst
->pbFormat
, psrc
->pbFormat
, psrc
->cbFormat
);
193 pdst
->pbFormat
= NULL
;
197 pdst
->pUnk
= psrc
->pUnk
;
198 IUnknown_AddRef(pdst
->pUnk
);