ReactOS 0.4.15-dev-8344-g0574987
enum_mediatypes.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Network Provider for MPEG2 based networks
4 * FILE: dll/directx/msdvbnp/enum_mediatypes.cpp
5 * PURPOSE: IEnumMediaTypes interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9#include "precomp.h"
10
12{
13public:
15
17 {
19 return m_Ref;
20 }
22 {
24 if (!m_Ref)
25 {
26 delete this;
27 return 0;
28 }
29 return m_Ref;
30 }
31
32 HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched);
36
37
38 CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE * MediaTypes) : m_Ref(0), m_MediaTypeCount(MediaTypeCount), m_MediaTypes(MediaTypes), m_Index(0){};
39 virtual ~CEnumMediaTypes(){};
40
41protected:
42 LONG m_Ref;
46};
47
51 IN REFIID refiid,
53{
54 if (IsEqualGUID(refiid, IID_IUnknown))
55 {
56 *Output = PVOID(this);
57 reinterpret_cast<IUnknown*>(*Output)->AddRef();
58 return NOERROR;
59 }
60 if (IsEqualGUID(refiid, IID_IEnumMediaTypes))
61 {
62 *Output = (IEnumMediaTypes*)(this);
63 reinterpret_cast<IEnumMediaTypes*>(*Output)->AddRef();
64 return NOERROR;
65 }
66
69 StringFromCLSID(refiid, &lpstr);
70 swprintf(Buffer, L"CEnumMediaTypes::QueryInterface: NoInterface for %s\n", lpstr);
73
74 return E_NOINTERFACE;
75}
76
77//-------------------------------------------------------------------
78// IEnumMediaTypes
79//
80
84 ULONG cMediaTypes,
85 AM_MEDIA_TYPE **ppMediaTypes,
86 ULONG *pcFetched)
87{
88 ULONG i = 0;
89 AM_MEDIA_TYPE * MediaType;
90
91 if (!ppMediaTypes)
92 return E_POINTER;
93
94 if (cMediaTypes > 1 && !pcFetched)
95 return E_INVALIDARG;
96
97 while(i < cMediaTypes)
98 {
99 if (m_Index + i >= m_MediaTypeCount)
100 break;
101
102 MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
103 if (!MediaType)
104 break;
105
106 CopyMemory(MediaType, &m_MediaTypes[m_Index + i], sizeof(AM_MEDIA_TYPE));
107 ppMediaTypes[i] = MediaType;
108 i++;
109 }
110
111 if (pcFetched)
112 {
113 *pcFetched = i;
114 }
115
116 m_Index += i;
117
118 if (i < cMediaTypes)
119 return S_FALSE;
120 else
121 return S_OK;
122}
123
127 ULONG cMediaTypes)
128{
129 if (cMediaTypes + m_Index >= m_MediaTypeCount)
130 {
131 return S_FALSE;
132 }
133
134 m_Index += cMediaTypes;
135 return S_OK;
136}
137
141{
142 m_Index = 0;
143 return S_OK;
144}
145
149 IEnumMediaTypes **ppEnum)
150{
151 OutputDebugStringW(L"CEnumMediaTypes::Clone : NotImplemented\n");
152 return E_NOTIMPL;
153}
154
156WINAPI
159 ULONG MediaTypeCount,
160 AM_MEDIA_TYPE * MediaTypes,
161 REFIID riid,
162 LPVOID * ppv)
163{
164 CEnumMediaTypes * handler = new CEnumMediaTypes(MediaTypeCount, MediaTypes);
165
166#ifdef MSDVBNP_TRACE
170 swprintf(Buffer, L"CEnumMediaTypes_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
172#endif
173
174 if (!handler)
175 {
176 CoTaskMemFree(MediaTypes);
177 return E_OUTOFMEMORY;
178 }
179
180 if (FAILED(handler->QueryInterface(riid, ppv)))
181 {
182 /* not supported */
183 delete handler;
184 return E_NOINTERFACE;
185 }
186
187 return NOERROR;
188}
189
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: bufpool.h:45
HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes)
HRESULT STDMETHODCALLTYPE Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched)
HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum)
STDMETHODIMP_(ULONG) Release()
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
HRESULT STDMETHODCALLTYPE Reset()
AM_MEDIA_TYPE * m_MediaTypes
virtual ~CEnumMediaTypes()
CEnumMediaTypes(ULONG MediaTypeCount, AM_MEDIA_TYPE *MediaTypes)
STDMETHODIMP_(ULONG) AddRef()
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define MAX_PATH
Definition: compat.h:34
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define swprintf
Definition: precomp.h:40
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
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
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
ULONG AddRef()
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI CEnumMediaTypes_fnConstructor(ULONG MediaTypeCount, AM_MEDIA_TYPE *MediaTypes, REFIID riid, LPVOID *ppv)
static LPCSTR lpstr
Definition: font.c:51
static LPOLESTR
Definition: stg_prop.c:27
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
@ Output
Definition: arc.h:85
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define CopyMemory
Definition: winbase.h:1710
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180