ReactOS  0.4.14-dev-833-g5f692ed
CKsDataTypeHandler Class Reference
Inheritance diagram for CKsDataTypeHandler:
Collaboration diagram for CKsDataTypeHandler:

Public Member Functions

STDMETHODIMP QueryInterface (REFIID InterfaceId, PVOID *Interface)
 
 STDMETHODIMP_ (ULONG) AddRef()
 
 STDMETHODIMP_ (ULONG) Release()
 
HRESULT STDMETHODCALLTYPE KsCompleteIoOperation (IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation, IN BOOL Cancelled)
 
HRESULT STDMETHODCALLTYPE KsIsMediaTypeInRanges (IN PVOID DataRanges)
 
HRESULT STDMETHODCALLTYPE KsPrepareIoOperation (IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation)
 
HRESULT STDMETHODCALLTYPE KsQueryExtendedSize (OUT ULONG *ExtendedSize)
 
HRESULT STDMETHODCALLTYPE KsSetMediaType (IN const AM_MEDIA_TYPE *AmMediaType)
 
 CKsDataTypeHandler ()
 
virtual ~CKsDataTypeHandler ()
 

Protected Attributes

LONG m_Ref
 
AM_MEDIA_TYPEm_Type
 

Detailed Description

Definition at line 15 of file datatype.cpp.

Constructor & Destructor Documentation

◆ CKsDataTypeHandler()

CKsDataTypeHandler::CKsDataTypeHandler ( )
inline

Definition at line 43 of file datatype.cpp.

43 : m_Ref(0), m_Type(0){};
AM_MEDIA_TYPE * m_Type
Definition: datatype.cpp:61

◆ ~CKsDataTypeHandler()

virtual CKsDataTypeHandler::~CKsDataTypeHandler ( )
inlinevirtual

Definition at line 44 of file datatype.cpp.

45  {
46  if (m_Type)
47  {
48  if (m_Type->pbFormat)
49  CoTaskMemFree(m_Type->pbFormat);
50 
51  if (m_Type->pUnk)
52  m_Type->pUnk->Release();
53 
55  }
56 
57  };
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
AM_MEDIA_TYPE * m_Type
Definition: datatype.cpp:61

Member Function Documentation

◆ KsCompleteIoOperation()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::KsCompleteIoOperation ( IN OUT IMediaSample Sample,
IN OUT PVOID  StreamHeader,
IN KSIOOPERATION  IoOperation,
IN BOOL  Cancelled 
)

Definition at line 84 of file datatype.cpp.

89 {
90  return NOERROR;
91 }
#define NOERROR
Definition: winerror.h:2354

◆ KsIsMediaTypeInRanges()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::KsIsMediaTypeInRanges ( IN PVOID  DataRanges)

Definition at line 96 of file datatype.cpp.

98 {
100  PKSDATARANGE DataRange;
101  ULONG Index;
102  //HRESULT hr = S_FALSE;
103 
104 #ifdef KSPROXY_TRACE
105  OutputDebugStringW(L"CKsDataTypeHandler::KsIsMediaTypeInRanges\n");
106 #endif
107 
108  DataList = (PKSMULTIPLE_ITEM)DataRanges;
109  DataRange = (PKSDATARANGE)(DataList + 1);
110 
111  for(Index = 0; Index < DataList->Count; Index++)
112  {
113  BOOL bMatch = FALSE;
114 
115  if (DataRange->FormatSize >= sizeof(KSDATARANGE))
116  {
117  bMatch = IsEqualGUID(DataRange->MajorFormat, GUID_NULL);
118  }
119 
120  if (!bMatch && DataRange->FormatSize >= sizeof(KSDATARANGE_AUDIO))
121  {
122  bMatch = IsEqualGUID(DataRange->MajorFormat, MEDIATYPE_Audio);
123  }
124 
125  if (bMatch)
126  {
127  if (IsEqualGUID(DataRange->SubFormat, m_Type->subtype) ||
128  IsEqualGUID(DataRange->SubFormat, GUID_NULL))
129  {
130  if (IsEqualGUID(DataRange->Specifier, m_Type->formattype) ||
131  IsEqualGUID(DataRange->Specifier, GUID_NULL))
132  {
133  if (!IsEqualGUID(m_Type->formattype, FORMAT_WaveFormatEx) && !IsEqualGUID(DataRange->Specifier, FORMAT_WaveFormatEx))
134  {
135  //found match
136  //hr = S_OK;
137  break;
138  }
139 
140  if (DataRange->FormatSize >= sizeof(KSDATARANGE_AUDIO) && m_Type->cbFormat >= sizeof(WAVEFORMATEX))
141  {
143  PKSDATARANGE_AUDIO AudioRange = (PKSDATARANGE_AUDIO)DataRange;
144 
145  if (Format->nSamplesPerSec >= AudioRange->MinimumSampleFrequency &&
146  Format->nSamplesPerSec <= AudioRange->MaximumSampleFrequency &&
147  Format->wBitsPerSample >= AudioRange->MinimumSampleFrequency &&
148  Format->wBitsPerSample <= AudioRange->MaximumBitsPerSample &&
149  Format->nChannels <= AudioRange->MaximumChannels)
150  {
151  // found match
152  //hr = S_OK;
153  break;
154  }
155  }
156  }
157  }
158  }
159 
160  DataRange = (PKSDATARANGE)(((ULONG_PTR)DataRange + DataRange->FormatSize + 7) & ~7);
161  }
162  return S_OK;
163 }
int nChannels
Definition: imaadp32.c:63
AM_MEDIA_TYPE * m_Type
Definition: datatype.cpp:61
uint32_t ULONG_PTR
Definition: typedefs.h:63
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WAVEFORMATEX * LPWAVEFORMATEX
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA DataList
Definition: hidpi.h:333
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
#define GUID_NULL
Definition: ks.h:106
struct KSMULTIPLE_ITEM * PKSMULTIPLE_ITEM
union KSDATAFORMAT * PKSDATARANGE
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1

◆ KsPrepareIoOperation()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::KsPrepareIoOperation ( IN OUT IMediaSample Sample,
IN OUT PVOID  StreamHeader,
IN KSIOOPERATION  IoOperation 
)

Definition at line 167 of file datatype.cpp.

171 {
172  return NOERROR;
173 }
#define NOERROR
Definition: winerror.h:2354

◆ KsQueryExtendedSize()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::KsQueryExtendedSize ( OUT ULONG ExtendedSize)

Definition at line 177 of file datatype.cpp.

179 {
180  /* no header extension required */
181  *ExtendedSize = 0;
182  return NOERROR;
183 }
#define NOERROR
Definition: winerror.h:2354

◆ KsSetMediaType()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::KsSetMediaType ( IN const AM_MEDIA_TYPE AmMediaType)

Definition at line 187 of file datatype.cpp.

189 {
190 #ifdef KSPROXY_TRACE
191  OutputDebugString("CKsDataTypeHandler::KsSetMediaType\n");
192 #endif
193 
194  if (m_Type)
195  {
196  /* media type can only be set once */
197  return E_FAIL;
198  }
199 
201  if (!m_Type)
202  return E_OUTOFMEMORY;
203 
204  CopyMemory(m_Type, AmMediaType, sizeof(AM_MEDIA_TYPE));
205 
206  if (m_Type->cbFormat)
207  {
208  m_Type->pbFormat = (BYTE*)CoTaskMemAlloc(m_Type->cbFormat);
209 
210  if (!m_Type->pbFormat)
211  {
213  return E_OUTOFMEMORY;
214  }
215 
216  CopyMemory(m_Type->pbFormat, AmMediaType->pbFormat, m_Type->cbFormat);
217  }
218 
219  if (m_Type->pUnk)
220  m_Type->pUnk->AddRef();
221 
222 
223  return S_OK;
224 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
AM_MEDIA_TYPE * m_Type
Definition: datatype.cpp:61
#define OutputDebugString
Definition: winbase.h:3724
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CopyMemory
Definition: winbase.h:1640
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE CKsDataTypeHandler::QueryInterface ( REFIID  InterfaceId,
PVOID Interface 
)

Definition at line 67 of file datatype.cpp.

70 {
71  if (IsEqualGUID(refiid, IID_IUnknown) ||
72  IsEqualGUID(refiid, IID_IKsDataTypeHandler))
73  {
74  *Output = PVOID(this);
75  reinterpret_cast<IUnknown*>(*Output)->AddRef();
76  return NOERROR;
77  }
78  return E_NOINTERFACE;
79 }
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
void * PVOID
Definition: retypes.h:9
Definition: arc.h:85
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
const GUID IID_IUnknown
Definition: datatype.cpp:12

◆ STDMETHODIMP_() [1/2]

CKsDataTypeHandler::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 20 of file datatype.cpp.

21  {
23  return m_Ref;
24  }
#define InterlockedIncrement
Definition: armddk.h:53

◆ STDMETHODIMP_() [2/2]

CKsDataTypeHandler::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 25 of file datatype.cpp.

26  {
28 
29  if (!m_Ref)
30  {
31  delete this;
32  return 0;
33  }
34  return m_Ref;
35  }
#define InterlockedDecrement
Definition: armddk.h:52

Member Data Documentation

◆ m_Ref

LONG CKsDataTypeHandler::m_Ref
protected

Definition at line 57 of file datatype.cpp.

Referenced by STDMETHODIMP_().

◆ m_Type

AM_MEDIA_TYPE* CKsDataTypeHandler::m_Type
protected

Definition at line 61 of file datatype.cpp.

Referenced by KsIsMediaTypeInRanges(), KsSetMediaType(), and ~CKsDataTypeHandler().


The documentation for this class was generated from the following file: