ReactOS 0.4.16-dev-297-gc569aee
mediatype.c File Reference
#include <stdarg.h>
#include "dshow.h"
#include "wine/strmbase.h"
#include "wine/debug.h"
Include dependency graph for mediatype.c:

Go to the source code of this file.

Classes

struct  tagENUMEDIADETAILS
 
struct  IEnumMediaTypesImpl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct tagENUMEDIADETAILS ENUMMEDIADETAILS
 
typedef struct IEnumMediaTypesImpl IEnumMediaTypesImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (strmbase)
 
HRESULT WINAPI CopyMediaType (AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src)
 
void WINAPI FreeMediaType (AM_MEDIA_TYPE *pMediaType)
 
AM_MEDIA_TYPE *WINAPI CreateMediaType (AM_MEDIA_TYPE const *pSrc)
 
void WINAPI DeleteMediaType (AM_MEDIA_TYPE *pMediaType)
 
static IEnumMediaTypesImplimpl_from_IEnumMediaTypes (IEnumMediaTypes *iface)
 
HRESULT WINAPI EnumMediaTypes_Construct (BasePin *basePin, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes **ppEnum)
 
static HRESULT WINAPI IEnumMediaTypesImpl_QueryInterface (IEnumMediaTypes *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IEnumMediaTypesImpl_AddRef (IEnumMediaTypes *iface)
 
static ULONG WINAPI IEnumMediaTypesImpl_Release (IEnumMediaTypes *iface)
 
static HRESULT WINAPI IEnumMediaTypesImpl_Next (IEnumMediaTypes *iface, ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched)
 
static HRESULT WINAPI IEnumMediaTypesImpl_Skip (IEnumMediaTypes *iface, ULONG cMediaTypes)
 
static HRESULT WINAPI IEnumMediaTypesImpl_Reset (IEnumMediaTypes *iface)
 
static HRESULT WINAPI IEnumMediaTypesImpl_Clone (IEnumMediaTypes *iface, IEnumMediaTypes **ppEnum)
 

Variables

static const struct IEnumMediaTypesVtbl IEnumMediaTypesImpl_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file mediatype.c.

Typedef Documentation

◆ ENUMMEDIADETAILS

◆ IEnumMediaTypesImpl

Function Documentation

◆ CopyMediaType()

HRESULT WINAPI CopyMediaType ( AM_MEDIA_TYPE dest,
const AM_MEDIA_TYPE src 
)

Definition at line 31 of file mediatype.c.

32{
33 *dest = *src;
34 if (src->pbFormat)
35 {
36 dest->pbFormat = CoTaskMemAlloc(src->cbFormat);
37 if (!dest->pbFormat)
38 return E_OUTOFMEMORY;
39 memcpy(dest->pbFormat, src->pbFormat, src->cbFormat);
40 }
41 if (dest->pUnk)
42 IUnknown_AddRef(dest->pUnk);
43 return S_OK;
44}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLenum src
Definition: glext.h:6340
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135

Referenced by CreateMediaType(), and IEnumMediaTypesImpl_Reset().

◆ CreateMediaType()

AM_MEDIA_TYPE *WINAPI CreateMediaType ( AM_MEDIA_TYPE const pSrc)

Definition at line 60 of file mediatype.c.

61{
62 AM_MEDIA_TYPE * pDest;
63
64 pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
65 if (!pDest)
66 return NULL;
67
68 if (FAILED(CopyMediaType(pDest, pSrc)))
69 {
70 CoTaskMemFree(pDest);
71 return NULL;
72 }
73
74 return pDest;
75}
#define NULL
Definition: types.h:112
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src)
Definition: mediatype.c:31

Referenced by IEnumMediaTypesImpl_Next().

◆ DeleteMediaType()

void WINAPI DeleteMediaType ( AM_MEDIA_TYPE pMediaType)

Definition at line 77 of file mediatype.c.

78{
79 FreeMediaType(pMediaType);
80 CoTaskMemFree(pMediaType);
81}
void WINAPI FreeMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:46

Referenced by IEnumMediaTypesImpl_Next().

◆ EnumMediaTypes_Construct()

HRESULT WINAPI EnumMediaTypes_Construct ( BasePin basePin,
BasePin_GetMediaType  enumFunc,
BasePin_GetMediaTypeVersion  versionFunc,
IEnumMediaTypes **  ppEnum 
)

Definition at line 108 of file mediatype.c.

109{
110 ULONG i;
111 IEnumMediaTypesImpl * pEnumMediaTypes = CoTaskMemAlloc(sizeof(IEnumMediaTypesImpl));
112 AM_MEDIA_TYPE amt;
113
114 *ppEnum = NULL;
115
116 if (!pEnumMediaTypes)
117 return E_OUTOFMEMORY;
118
119 pEnumMediaTypes->IEnumMediaTypes_iface.lpVtbl = &IEnumMediaTypesImpl_Vtbl;
120 pEnumMediaTypes->refCount = 1;
121 pEnumMediaTypes->uIndex = 0;
122 pEnumMediaTypes->enumMediaFunction = enumFunc;
123 pEnumMediaTypes->mediaVersionFunction = versionFunc;
124 IPin_AddRef(&basePin->IPin_iface);
125 pEnumMediaTypes->basePin = basePin;
126
127 i = 0;
128 while (enumFunc(basePin, i, &amt) == S_OK)
129 {
130 FreeMediaType(&amt);
131 i++;
132 }
133
134 pEnumMediaTypes->enumMediaDetails.cMediaTypes = i;
135 pEnumMediaTypes->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * i);
136 memset(pEnumMediaTypes->enumMediaDetails.pMediaTypes, 0, sizeof(AM_MEDIA_TYPE) * i);
137 for (i = 0; i < pEnumMediaTypes->enumMediaDetails.cMediaTypes; i++)
138 {
139 HRESULT hr;
140
141 if (FAILED(hr = enumFunc(basePin, i, &pEnumMediaTypes->enumMediaDetails.pMediaTypes[i])))
142 {
143 IEnumMediaTypes_Release(&pEnumMediaTypes->IEnumMediaTypes_iface);
144 return hr;
145 }
146 }
147 *ppEnum = &pEnumMediaTypes->IEnumMediaTypes_iface;
148 pEnumMediaTypes->currentVersion = versionFunc(basePin);
149 return S_OK;
150}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const struct IEnumMediaTypesVtbl IEnumMediaTypesImpl_Vtbl
Definition: mediatype.c:106
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
IPin IPin_iface
Definition: strmbase.h:35
BasePin_GetMediaType enumMediaFunction
Definition: mediatype.c:94
BasePin_GetMediaTypeVersion mediaVersionFunction
Definition: mediatype.c:95
ENUMMEDIADETAILS enumMediaDetails
Definition: mediatype.c:97
BasePin * basePin
Definition: mediatype.c:93
IEnumMediaTypes IEnumMediaTypes_iface
Definition: filtergraph.c:749
AM_MEDIA_TYPE * pMediaTypes
Definition: mediatype.c:86
uint32_t ULONG
Definition: typedefs.h:59

Referenced by BasePinImpl_EnumMediaTypes(), IEnumMediaTypesImpl_Clone(), and Parser_PullPin_EnumMediaTypes().

◆ FreeMediaType()

void WINAPI FreeMediaType ( AM_MEDIA_TYPE pMediaType)

Definition at line 46 of file mediatype.c.

47{
48 if (pMediaType->pbFormat)
49 {
50 CoTaskMemFree(pMediaType->pbFormat);
51 pMediaType->pbFormat = NULL;
52 }
53 if (pMediaType->pUnk)
54 {
55 IUnknown_Release(pMediaType->pUnk);
56 pMediaType->pUnk = NULL;
57 }
58}

Referenced by DeleteMediaType(), EnumMediaTypes_Construct(), IEnumMediaTypesImpl_Release(), and IEnumMediaTypesImpl_Reset().

◆ IEnumMediaTypesImpl_AddRef()

static ULONG WINAPI IEnumMediaTypesImpl_AddRef ( IEnumMediaTypes iface)
static

Definition at line 171 of file mediatype.c.

172{
174 ULONG ref = InterlockedIncrement(&This->refCount);
175
176 TRACE("(%p)->(): new ref = %u\n", iface, ref);
177
178 return ref;
179}
#define InterlockedIncrement
Definition: armddk.h:53
static IEnumMediaTypesImpl * impl_from_IEnumMediaTypes(IEnumMediaTypes *iface)
Definition: mediatype.c:101
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48

◆ IEnumMediaTypesImpl_Clone()

static HRESULT WINAPI IEnumMediaTypesImpl_Clone ( IEnumMediaTypes iface,
IEnumMediaTypes **  ppEnum 
)
static

Definition at line 289 of file mediatype.c.

290{
291 HRESULT hr;
293
294 TRACE("(%p)->(%p)\n", iface, ppEnum);
295
296 hr = EnumMediaTypes_Construct(This->basePin, This->enumMediaFunction, This->mediaVersionFunction, ppEnum);
297 if (FAILED(hr))
298 return hr;
299 return IEnumMediaTypes_Skip(*ppEnum, This->uIndex);
300}
HRESULT WINAPI EnumMediaTypes_Construct(BasePin *basePin, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes **ppEnum)
Definition: mediatype.c:108

◆ IEnumMediaTypesImpl_Next()

static HRESULT WINAPI IEnumMediaTypesImpl_Next ( IEnumMediaTypes iface,
ULONG  cMediaTypes,
AM_MEDIA_TYPE **  ppMediaTypes,
ULONG pcFetched 
)
static

Definition at line 200 of file mediatype.c.

201{
202 ULONG cFetched;
204
205 TRACE("(%p)->(%u, %p, %p)\n", iface, cMediaTypes, ppMediaTypes, pcFetched);
206
207 cFetched = min(This->enumMediaDetails.cMediaTypes, This->uIndex + cMediaTypes) - This->uIndex;
208
209 if (This->currentVersion != This->mediaVersionFunction(This->basePin))
211
212 TRACE("Next uIndex: %u, cFetched: %u\n", This->uIndex, cFetched);
213
214 if (cFetched > 0)
215 {
216 ULONG i;
217 for (i = 0; i < cFetched; i++)
218 if (!(ppMediaTypes[i] = CreateMediaType(&This->enumMediaDetails.pMediaTypes[This->uIndex + i])))
219 {
220 while (i--)
221 DeleteMediaType(ppMediaTypes[i]);
222 *pcFetched = 0;
223 return E_OUTOFMEMORY;
224 }
225 }
226
227 if ((cMediaTypes != 1) || pcFetched)
228 *pcFetched = cFetched;
229
230 This->uIndex += cFetched;
231
232 if (cFetched != cMediaTypes)
233 return S_FALSE;
234 return S_OK;
235}
AM_MEDIA_TYPE *WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)
Definition: mediatype.c:60
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:77
#define min(a, b)
Definition: monoChain.cc:55
#define VFW_E_ENUM_OUT_OF_SYNC
Definition: vfwmsgs.h:42
#define S_FALSE
Definition: winerror.h:2357

◆ IEnumMediaTypesImpl_QueryInterface()

static HRESULT WINAPI IEnumMediaTypesImpl_QueryInterface ( IEnumMediaTypes iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 152 of file mediatype.c.

153{
154 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
155
157 IsEqualIID(riid, &IID_IEnumMediaTypes))
158 {
159 IEnumMediaTypes_AddRef(iface);
160 *ret_iface = iface;
161 return S_OK;
162 }
163
164 *ret_iface = NULL;
165
166 WARN("No interface for %s\n", debugstr_guid(riid));
167
168 return E_NOINTERFACE;
169}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IEnumMediaTypesImpl_Release()

static ULONG WINAPI IEnumMediaTypesImpl_Release ( IEnumMediaTypes iface)
static

Definition at line 181 of file mediatype.c.

182{
184 ULONG ref = InterlockedDecrement(&This->refCount);
185
186 TRACE("(%p)->(): new ref = %u\n", iface, ref);
187
188 if (!ref)
189 {
190 ULONG i;
191 for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
192 FreeMediaType(&This->enumMediaDetails.pMediaTypes[i]);
193 CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
194 IPin_Release(&This->basePin->IPin_iface);
196 }
197 return ref;
198}
#define InterlockedDecrement
Definition: armddk.h:52

◆ IEnumMediaTypesImpl_Reset()

static HRESULT WINAPI IEnumMediaTypesImpl_Reset ( IEnumMediaTypes iface)
static

Definition at line 254 of file mediatype.c.

255{
256 ULONG i;
257 AM_MEDIA_TYPE amt;
259
260 TRACE("(%p)->()\n", iface);
261
262 for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
263 FreeMediaType(&This->enumMediaDetails.pMediaTypes[i]);
264 CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
265
266 i = 0;
267 while (This->enumMediaFunction(This->basePin, i, &amt) == S_OK) i++;
268
269 This->enumMediaDetails.cMediaTypes = i;
270 This->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * i);
271 for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
272 {
273 This->enumMediaFunction(This->basePin, i,&amt);
274 if (FAILED(CopyMediaType(&This->enumMediaDetails.pMediaTypes[i], &amt)))
275 {
276 while (i--)
277 FreeMediaType(&This->enumMediaDetails.pMediaTypes[i]);
278 CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
279 return E_OUTOFMEMORY;
280 }
281 }
282
283 This->currentVersion = This->mediaVersionFunction(This->basePin);
284 This->uIndex = 0;
285
286 return S_OK;
287}

◆ IEnumMediaTypesImpl_Skip()

static HRESULT WINAPI IEnumMediaTypesImpl_Skip ( IEnumMediaTypes iface,
ULONG  cMediaTypes 
)
static

Definition at line 237 of file mediatype.c.

238{
240
241 TRACE("(%p)->(%u)\n", iface, cMediaTypes);
242
243 if (This->currentVersion != This->mediaVersionFunction(This->basePin))
245
246 if (This->uIndex + cMediaTypes < This->enumMediaDetails.cMediaTypes)
247 {
248 This->uIndex += cMediaTypes;
249 return S_OK;
250 }
251 return S_FALSE;
252}

◆ impl_from_IEnumMediaTypes()

static IEnumMediaTypesImpl * impl_from_IEnumMediaTypes ( IEnumMediaTypes iface)
inlinestatic

Definition at line 101 of file mediatype.c.

102{
103 return CONTAINING_RECORD(iface, IEnumMediaTypesImpl, IEnumMediaTypes_iface);
104}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by IEnumMediaTypesImpl_AddRef(), IEnumMediaTypesImpl_Clone(), IEnumMediaTypesImpl_Next(), IEnumMediaTypesImpl_Release(), IEnumMediaTypesImpl_Reset(), and IEnumMediaTypesImpl_Skip().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( strmbase  )

Variable Documentation

◆ IEnumMediaTypesImpl_Vtbl

static const IEnumMediaTypesVtbl IEnumMediaTypesImpl_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI IEnumMediaTypesImpl_Reset(IEnumMediaTypes *iface)
Definition: mediatype.c:254
static HRESULT WINAPI IEnumMediaTypesImpl_Clone(IEnumMediaTypes *iface, IEnumMediaTypes **ppEnum)
Definition: mediatype.c:289
static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes *iface, ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched)
Definition: mediatype.c:200
static HRESULT WINAPI IEnumMediaTypesImpl_Skip(IEnumMediaTypes *iface, ULONG cMediaTypes)
Definition: mediatype.c:237
static ULONG WINAPI IEnumMediaTypesImpl_AddRef(IEnumMediaTypes *iface)
Definition: mediatype.c:171
static ULONG WINAPI IEnumMediaTypesImpl_Release(IEnumMediaTypes *iface)
Definition: mediatype.c:181
static HRESULT WINAPI IEnumMediaTypesImpl_QueryInterface(IEnumMediaTypes *iface, REFIID riid, void **ret_iface)
Definition: mediatype.c:152

Definition at line 106 of file mediatype.c.

Referenced by EnumMediaTypes_Construct().