4 * Copyright 2003 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "quartz_private.h"
23 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
25 typedef struct AsyncReader
28 IFileSourceFilter IFileSourceFilter_iface
;
29 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
36 static inline AsyncReader
*impl_from_BaseFilter(BaseFilter
*iface
)
38 return CONTAINING_RECORD(iface
, AsyncReader
, filter
);
41 static inline AsyncReader
*impl_from_IBaseFilter(IBaseFilter
*iface
)
43 return CONTAINING_RECORD(iface
, AsyncReader
, filter
.IBaseFilter_iface
);
46 static inline AsyncReader
*impl_from_IFileSourceFilter(IFileSourceFilter
*iface
)
48 return CONTAINING_RECORD(iface
, AsyncReader
, IFileSourceFilter_iface
);
51 static inline AsyncReader
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
53 return CONTAINING_RECORD(iface
, AsyncReader
, IAMFilterMiscFlags_iface
);
56 static const IBaseFilterVtbl AsyncReader_Vtbl
;
57 static const IFileSourceFilterVtbl FileSource_Vtbl
;
58 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
;
59 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
61 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
63 static const WCHAR mediatype_name
[] = {
64 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 };
65 static const WCHAR subtype_name
[] = {
66 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 };
67 static const WCHAR source_filter_name
[] = {
68 'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
70 static HRESULT
process_extensions(HKEY hkeyExtensions
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
81 /* Get the part of the name that matters */
82 extension
= PathFindExtensionW(pszFileName
);
83 if (*extension
!= '.')
86 l
= RegOpenKeyExW(hkeyExtensions
, extension
, 0, KEY_READ
, &hsub
);
92 size
= sizeof(keying
);
93 l
= RegQueryValueExW(hsub
, mediatype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
95 CLSIDFromString(keying
, majorType
);
100 size
= sizeof(keying
);
102 l
= RegQueryValueExW(hsub
, subtype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
104 CLSIDFromString(keying
, minorType
);
109 size
= sizeof(keying
);
111 l
= RegQueryValueExW(hsub
, source_filter_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
113 CLSIDFromString(keying
, sourceFilter
);
123 static unsigned char byte_from_hex_char(WCHAR wHex
)
125 switch (tolowerW(wHex
))
137 return (wHex
- '0') & 0xf;
144 return (wHex
- 'a' + 10) & 0xf;
150 static HRESULT
process_pattern_string(LPCWSTR wszPatternString
, IAsyncReader
* pReader
)
160 TRACE("\t\tPattern string: %s\n", debugstr_w(wszPatternString
));
162 /* format: "offset, bytestocompare, mask, value" */
164 ulOffset
= strtolW(wszPatternString
, NULL
, 10);
166 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
169 wszPatternString
++; /* skip ',' */
171 ulBytes
= strtolW(wszPatternString
, NULL
, 10);
173 pbMask
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
174 pbValue
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ulBytes
);
175 pbFile
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
177 /* default mask is match everything */
178 memset(pbMask
, 0xFF, ulBytes
);
180 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
185 wszPatternString
++; /* skip ',' */
186 while (!isxdigitW(*wszPatternString
) && (*wszPatternString
!= ',')) wszPatternString
++;
188 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
190 if ((strpos
% 2) == 1) /* odd numbered position */
191 pbMask
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
193 pbMask
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
196 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
199 wszPatternString
++; /* skip ',' */
204 for ( ; !isxdigitW(*wszPatternString
) && (*wszPatternString
!= ','); wszPatternString
++)
207 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
209 if ((strpos
% 2) == 1) /* odd numbered position */
210 pbValue
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
212 pbValue
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
217 hr
= IAsyncReader_SyncRead(pReader
, ulOffset
, ulBytes
, pbFile
);
222 for (i
= 0; i
< ulBytes
; i
++)
223 if ((pbFile
[i
] & pbMask
[i
]) != pbValue
[i
])
230 HeapFree(GetProcessHeap(), 0, pbMask
);
231 HeapFree(GetProcessHeap(), 0, pbValue
);
232 HeapFree(GetProcessHeap(), 0, pbFile
);
234 /* if we encountered no errors with this string, and there is a following tuple, then we
235 * have to match that as well to succeed */
236 if ((hr
== S_OK
) && (wszPatternString
= strchrW(wszPatternString
, ',')))
237 return process_pattern_string(wszPatternString
+ 1, pReader
);
242 HRESULT
GetClassMediaFile(IAsyncReader
* pReader
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
244 HKEY hkeyMediaType
= NULL
;
248 static const WCHAR wszMediaType
[] = {'M','e','d','i','a',' ','T','y','p','e',0};
250 TRACE("(%p, %s, %p, %p)\n", pReader
, debugstr_w(pszFileName
), majorType
, minorType
);
253 *majorType
= GUID_NULL
;
255 *minorType
= GUID_NULL
;
257 *sourceFilter
= GUID_NULL
;
259 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszMediaType
, 0, KEY_READ
, &hkeyMediaType
);
260 hr
= HRESULT_FROM_WIN32(lRet
);
266 for (indexMajor
= 0; !bFound
; indexMajor
++)
269 WCHAR wszMajorKeyName
[CHARS_IN_GUID
];
270 DWORD dwKeyNameLength
= sizeof(wszMajorKeyName
) / sizeof(wszMajorKeyName
[0]);
271 static const WCHAR wszExtensions
[] = {'E','x','t','e','n','s','i','o','n','s',0};
273 if (RegEnumKeyExW(hkeyMediaType
, indexMajor
, wszMajorKeyName
, &dwKeyNameLength
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
275 if (RegOpenKeyExW(hkeyMediaType
, wszMajorKeyName
, 0, KEY_READ
, &hkeyMajor
) != ERROR_SUCCESS
)
277 TRACE("%s\n", debugstr_w(wszMajorKeyName
));
278 if (!strcmpW(wszExtensions
, wszMajorKeyName
))
280 if (process_extensions(hkeyMajor
, pszFileName
, majorType
, minorType
, sourceFilter
) == S_OK
)
283 /* We need a reader interface to check bytes */
288 for (indexMinor
= 0; !bFound
; indexMinor
++)
291 WCHAR wszMinorKeyName
[CHARS_IN_GUID
];
292 DWORD dwMinorKeyNameLen
= sizeof(wszMinorKeyName
) / sizeof(wszMinorKeyName
[0]);
293 WCHAR wszSourceFilterKeyName
[CHARS_IN_GUID
];
294 DWORD dwSourceFilterKeyNameLen
= sizeof(wszSourceFilterKeyName
);
298 if (RegEnumKeyExW(hkeyMajor
, indexMinor
, wszMinorKeyName
, &dwMinorKeyNameLen
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
301 if (RegOpenKeyExW(hkeyMajor
, wszMinorKeyName
, 0, KEY_READ
, &hkeyMinor
) != ERROR_SUCCESS
)
304 TRACE("\t%s\n", debugstr_w(wszMinorKeyName
));
306 if (RegQueryInfoKeyW(hkeyMinor
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &maxValueLen
, NULL
, NULL
) != ERROR_SUCCESS
)
309 for (indexValue
= 0; !bFound
; indexValue
++)
312 WCHAR wszValueName
[14]; /* longest name we should encounter will be "Source Filter" */
313 LPWSTR wszPatternString
= HeapAlloc(GetProcessHeap(), 0, maxValueLen
);
314 DWORD dwValueNameLen
= sizeof(wszValueName
) / sizeof(wszValueName
[0]); /* remember this is in chars */
315 DWORD dwDataLen
= maxValueLen
; /* remember this is in bytes */
317 if (RegEnumValueW(hkeyMinor
, indexValue
, wszValueName
, &dwValueNameLen
, NULL
, &dwType
, (LPBYTE
)wszPatternString
, &dwDataLen
) != ERROR_SUCCESS
)
319 HeapFree(GetProcessHeap(), 0, wszPatternString
);
323 if (strcmpW(wszValueName
, source_filter_name
)==0) {
324 HeapFree(GetProcessHeap(), 0, wszPatternString
);
328 /* if it is not the source filter value */
329 if (process_pattern_string(wszPatternString
, pReader
) == S_OK
)
331 HeapFree(GetProcessHeap(), 0, wszPatternString
);
332 if (majorType
&& FAILED(CLSIDFromString(wszMajorKeyName
, majorType
)))
334 if (minorType
&& FAILED(CLSIDFromString(wszMinorKeyName
, minorType
)))
338 /* Look up the source filter key */
339 if (RegQueryValueExW(hkeyMinor
, source_filter_name
, NULL
, NULL
, (LPBYTE
)wszSourceFilterKeyName
, &dwSourceFilterKeyNameLen
))
341 if (FAILED(CLSIDFromString(wszSourceFilterKeyName
, sourceFilter
)))
346 HeapFree(GetProcessHeap(), 0, wszPatternString
);
348 CloseHandle(hkeyMinor
);
351 CloseHandle(hkeyMajor
);
354 CloseHandle(hkeyMediaType
);
356 if (SUCCEEDED(hr
) && !bFound
)
358 ERR("Media class not found\n");
363 TRACE("Found file's class:\n");
365 TRACE("\tmajor = %s\n", qzdebugstr_guid(majorType
));
367 TRACE("\tsubtype = %s\n", qzdebugstr_guid(minorType
));
369 TRACE("\tsource filter = %s\n", qzdebugstr_guid(sourceFilter
));
375 static IPin
* WINAPI
AsyncReader_GetPin(BaseFilter
*iface
, int pos
)
377 AsyncReader
*This
= impl_from_BaseFilter(iface
);
379 if (pos
>= 1 || !This
->pOutputPin
)
382 IPin_AddRef(This
->pOutputPin
);
383 return This
->pOutputPin
;
386 static LONG WINAPI
AsyncReader_GetPinCount(BaseFilter
*iface
)
388 AsyncReader
*This
= impl_from_BaseFilter(iface
);
390 if (!This
->pOutputPin
)
396 static const BaseFilterFuncTable BaseFuncTable
= {
398 AsyncReader_GetPinCount
401 HRESULT
AsyncReader_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
403 AsyncReader
*pAsyncRead
;
406 return CLASS_E_NOAGGREGATION
;
408 pAsyncRead
= CoTaskMemAlloc(sizeof(AsyncReader
));
411 return E_OUTOFMEMORY
;
413 BaseFilter_Init(&pAsyncRead
->filter
, &AsyncReader_Vtbl
, &CLSID_AsyncReader
, (DWORD_PTR
)(__FILE__
": AsyncReader.csFilter"), &BaseFuncTable
);
415 pAsyncRead
->IFileSourceFilter_iface
.lpVtbl
= &FileSource_Vtbl
;
416 pAsyncRead
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
417 pAsyncRead
->pOutputPin
= NULL
;
419 pAsyncRead
->pszFileName
= NULL
;
420 pAsyncRead
->pmt
= NULL
;
424 TRACE("-- created at %p\n", pAsyncRead
);
429 /** IUnknown methods **/
431 static HRESULT WINAPI
AsyncReader_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
433 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
435 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
439 if (IsEqualIID(riid
, &IID_IUnknown
))
441 else if (IsEqualIID(riid
, &IID_IPersist
))
443 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
445 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
447 else if (IsEqualIID(riid
, &IID_IFileSourceFilter
))
448 *ppv
= &This
->IFileSourceFilter_iface
;
449 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
450 *ppv
= &This
->IAMFilterMiscFlags_iface
;
454 IUnknown_AddRef((IUnknown
*)(*ppv
));
458 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
) &&
459 !IsEqualIID(riid
, &IID_IVideoWindow
) && !IsEqualIID(riid
, &IID_IBasicAudio
))
460 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
462 return E_NOINTERFACE
;
465 static ULONG WINAPI
AsyncReader_Release(IBaseFilter
* iface
)
467 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
468 ULONG refCount
= BaseFilterImpl_Release(iface
);
470 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
474 if (This
->pOutputPin
)
477 if(SUCCEEDED(IPin_ConnectedTo(This
->pOutputPin
, &pConnectedTo
)))
479 IPin_Disconnect(pConnectedTo
);
480 IPin_Release(pConnectedTo
);
482 IPin_Disconnect(This
->pOutputPin
);
483 IPin_Release(This
->pOutputPin
);
485 CoTaskMemFree(This
->pszFileName
);
487 FreeMediaType(This
->pmt
);
495 /** IMediaFilter methods **/
497 static HRESULT WINAPI
AsyncReader_Stop(IBaseFilter
* iface
)
499 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
503 This
->filter
.state
= State_Stopped
;
508 static HRESULT WINAPI
AsyncReader_Pause(IBaseFilter
* iface
)
510 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
514 This
->filter
.state
= State_Paused
;
519 static HRESULT WINAPI
AsyncReader_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
521 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
523 TRACE("(%x%08x)\n", (ULONG
)(tStart
>> 32), (ULONG
)tStart
);
525 This
->filter
.state
= State_Running
;
530 /** IBaseFilter methods **/
532 static HRESULT WINAPI
AsyncReader_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
534 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
535 TRACE("(%s, %p)\n", debugstr_w(Id
), ppPin
);
540 if (strcmpW(Id
, wszOutputPinName
))
543 return VFW_E_NOT_FOUND
;
546 *ppPin
= This
->pOutputPin
;
551 static const IBaseFilterVtbl AsyncReader_Vtbl
=
553 AsyncReader_QueryInterface
,
554 BaseFilterImpl_AddRef
,
556 BaseFilterImpl_GetClassID
,
560 BaseFilterImpl_GetState
,
561 BaseFilterImpl_SetSyncSource
,
562 BaseFilterImpl_GetSyncSource
,
563 BaseFilterImpl_EnumPins
,
565 BaseFilterImpl_QueryFilterInfo
,
566 BaseFilterImpl_JoinFilterGraph
,
567 BaseFilterImpl_QueryVendorInfo
570 static HRESULT WINAPI
FileSource_QueryInterface(IFileSourceFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
572 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
574 return IBaseFilter_QueryInterface(&This
->filter
.IBaseFilter_iface
, riid
, ppv
);
577 static ULONG WINAPI
FileSource_AddRef(IFileSourceFilter
* iface
)
579 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
581 return IBaseFilter_AddRef(&This
->filter
.IBaseFilter_iface
);
584 static ULONG WINAPI
FileSource_Release(IFileSourceFilter
* iface
)
586 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
588 return IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);
591 static HRESULT WINAPI
FileSource_Load(IFileSourceFilter
* iface
, LPCOLESTR pszFileName
, const AM_MEDIA_TYPE
* pmt
)
595 IAsyncReader
* pReader
= NULL
;
596 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
598 TRACE("(%s, %p)\n", debugstr_w(pszFileName
), pmt
);
601 /* FIXME: check the sharing values that native uses */
602 hFile
= CreateFileW(pszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_FLAG_OVERLAPPED
, NULL
);
604 if (hFile
== INVALID_HANDLE_VALUE
)
606 return HRESULT_FROM_WIN32(GetLastError());
610 hr
= FileAsyncReader_Construct(hFile
, &This
->filter
.IBaseFilter_iface
, &This
->filter
.csFilter
, &This
->pOutputPin
);
611 BaseFilterImpl_IncrementPinVersion(&This
->filter
);
614 hr
= IPin_QueryInterface(This
->pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
616 /* store file name & media type */
619 CoTaskMemFree(This
->pszFileName
);
621 FreeMediaType(This
->pmt
);
623 This
->pszFileName
= CoTaskMemAlloc((strlenW(pszFileName
) + 1) * sizeof(WCHAR
));
624 strcpyW(This
->pszFileName
, pszFileName
);
626 This
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
629 This
->pmt
->bFixedSizeSamples
= TRUE
;
630 This
->pmt
->bTemporalCompression
= FALSE
;
631 This
->pmt
->cbFormat
= 0;
632 This
->pmt
->pbFormat
= NULL
;
633 This
->pmt
->pUnk
= NULL
;
634 This
->pmt
->lSampleSize
= 0;
635 This
->pmt
->formattype
= FORMAT_None
;
636 hr
= GetClassMediaFile(pReader
, pszFileName
, &This
->pmt
->majortype
, &This
->pmt
->subtype
, NULL
);
639 CoTaskMemFree(This
->pmt
);
644 CopyMediaType(This
->pmt
, pmt
);
648 IAsyncReader_Release(pReader
);
652 if (This
->pOutputPin
)
654 IPin_Release(This
->pOutputPin
);
655 This
->pOutputPin
= NULL
;
658 CoTaskMemFree(This
->pszFileName
);
660 FreeMediaType(This
->pmt
);
661 This
->pszFileName
= NULL
;
667 /* FIXME: check return codes */
671 static HRESULT WINAPI
FileSource_GetCurFile(IFileSourceFilter
* iface
, LPOLESTR
* ppszFileName
, AM_MEDIA_TYPE
* pmt
)
673 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
675 TRACE("(%p, %p)\n", ppszFileName
, pmt
);
680 /* copy file name & media type if available, otherwise clear the outputs */
681 if (This
->pszFileName
)
683 *ppszFileName
= CoTaskMemAlloc((strlenW(This
->pszFileName
) + 1) * sizeof(WCHAR
));
684 strcpyW(*ppszFileName
, This
->pszFileName
);
687 *ppszFileName
= NULL
;
692 CopyMediaType(pmt
, This
->pmt
);
694 ZeroMemory(pmt
, sizeof(*pmt
));
700 static const IFileSourceFilterVtbl FileSource_Vtbl
=
702 FileSource_QueryInterface
,
706 FileSource_GetCurFile
710 /* the dwUserData passed back to user */
711 typedef struct DATAREQUEST
713 IMediaSample
* pSample
; /* sample passed to us by user */
714 DWORD_PTR dwUserData
; /* user data passed to us */
715 OVERLAPPED ovl
; /* our overlapped structure */
718 typedef struct FileAsyncReader
721 IAsyncReader IAsyncReader_iface
;
723 ALLOCATOR_PROPERTIES allocProps
;
726 /* Why would you need more? Every sample has its own handle */
730 CRITICAL_SECTION csList
; /* critical section to prevent concurrency issues */
731 DATAREQUEST
*sample_list
;
733 /* Have a handle for every sample, and then one more as flushing handle */
737 static inline FileAsyncReader
*impl_from_IPin(IPin
*iface
)
739 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
.IPin_iface
);
742 static inline FileAsyncReader
*impl_from_BasePin(BasePin
*iface
)
744 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
);
747 static inline FileAsyncReader
*impl_from_BaseOutputPin(BaseOutputPin
*iface
)
749 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
);
752 static inline BaseOutputPin
*impl_BaseOututPin_from_BasePin(BasePin
*iface
)
754 return CONTAINING_RECORD(iface
, BaseOutputPin
, pin
);
757 static inline FileAsyncReader
*impl_from_IAsyncReader(IAsyncReader
*iface
)
759 return CONTAINING_RECORD(iface
, FileAsyncReader
, IAsyncReader_iface
);
762 static HRESULT WINAPI
FileAsyncReaderPin_QueryAccept(IPin
*iface
, const AM_MEDIA_TYPE
*pmt
)
764 FileAsyncReader
*This
= impl_from_IPin(iface
);
765 AM_MEDIA_TYPE
*pmt_filter
= impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
;
767 FIXME("(%p, %p)\n", iface
, pmt
);
769 if (IsEqualGUID(&pmt
->majortype
, &pmt_filter
->majortype
) &&
770 IsEqualGUID(&pmt
->subtype
, &pmt_filter
->subtype
) &&
771 IsEqualGUID(&pmt
->formattype
, &FORMAT_None
))
777 static HRESULT WINAPI
FileAsyncReaderPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
)
779 FileAsyncReader
*This
= impl_from_BasePin(iface
);
783 return VFW_S_NO_MORE_ITEMS
;
784 CopyMediaType(pmt
, impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
);
788 /* overridden pin functions */
790 static HRESULT WINAPI
FileAsyncReaderPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
792 FileAsyncReader
*This
= impl_from_IPin(iface
);
793 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
797 if (IsEqualIID(riid
, &IID_IUnknown
))
799 else if (IsEqualIID(riid
, &IID_IPin
))
801 else if (IsEqualIID(riid
, &IID_IAsyncReader
))
802 *ppv
= &This
->IAsyncReader_iface
;
806 IUnknown_AddRef((IUnknown
*)(*ppv
));
810 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
))
811 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
813 return E_NOINTERFACE
;
816 static ULONG WINAPI
FileAsyncReaderPin_Release(IPin
* iface
)
818 FileAsyncReader
*This
= impl_from_IPin(iface
);
819 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
822 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
826 CoTaskMemFree(This
->sample_list
);
827 if (This
->handle_list
)
829 for (x
= 0; x
<= This
->samples
; ++x
)
830 CloseHandle(This
->handle_list
[x
]);
831 CoTaskMemFree(This
->handle_list
);
833 CloseHandle(This
->hFile
);
834 This
->csList
.DebugInfo
->Spare
[0] = 0;
835 DeleteCriticalSection(&This
->csList
);
842 static const IPinVtbl FileAsyncReaderPin_Vtbl
=
844 FileAsyncReaderPin_QueryInterface
,
846 FileAsyncReaderPin_Release
,
847 BaseOutputPinImpl_Connect
,
848 BaseOutputPinImpl_ReceiveConnection
,
849 BasePinImpl_Disconnect
,
850 BasePinImpl_ConnectedTo
,
851 BasePinImpl_ConnectionMediaType
,
852 BasePinImpl_QueryPinInfo
,
853 BasePinImpl_QueryDirection
,
855 FileAsyncReaderPin_QueryAccept
,
856 BasePinImpl_EnumMediaTypes
,
857 BasePinImpl_QueryInternalConnections
,
858 BaseOutputPinImpl_EndOfStream
,
859 BaseOutputPinImpl_BeginFlush
,
860 BaseOutputPinImpl_EndFlush
,
861 BasePinImpl_NewSegment
864 /* Function called as a helper to IPin_Connect */
865 /* specific AM_MEDIA_TYPE - it cannot be NULL */
866 /* this differs from standard OutputPin_AttemptConnection only in that it
867 * doesn't need the IMemInputPin interface on the receiving pin */
868 static HRESULT WINAPI
FileAsyncReaderPin_AttemptConnection(BasePin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
870 BaseOutputPin
*This
= impl_BaseOututPin_from_BasePin(iface
);
873 TRACE("(%p, %p)\n", pReceivePin
, pmt
);
874 dump_AM_MEDIA_TYPE(pmt
);
876 /* FIXME: call queryacceptproc */
878 This
->pin
.pConnectedTo
= pReceivePin
;
879 IPin_AddRef(pReceivePin
);
880 CopyMediaType(&This
->pin
.mtCurrent
, pmt
);
882 hr
= IPin_ReceiveConnection(pReceivePin
, &iface
->IPin_iface
, pmt
);
886 IPin_Release(This
->pin
.pConnectedTo
);
887 This
->pin
.pConnectedTo
= NULL
;
888 FreeMediaType(&This
->pin
.mtCurrent
);
891 TRACE(" -- %x\n", hr
);
895 static HRESULT WINAPI
FileAsyncReaderPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
)
897 FileAsyncReader
*This
= impl_from_BaseOutputPin(iface
);
898 ALLOCATOR_PROPERTIES actual
;
900 if (ppropInputRequest
->cbAlign
&& ppropInputRequest
->cbAlign
!= This
->allocProps
.cbAlign
)
901 FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This
->allocProps
.cbAlign
, ppropInputRequest
->cbAlign
);
902 if (ppropInputRequest
->cbPrefix
)
903 FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This
->allocProps
.cbPrefix
, ppropInputRequest
->cbPrefix
);
904 if (ppropInputRequest
->cbBuffer
)
905 FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This
->allocProps
.cbBuffer
, ppropInputRequest
->cbBuffer
);
906 if (ppropInputRequest
->cBuffers
)
907 FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This
->allocProps
.cBuffers
, ppropInputRequest
->cBuffers
);
909 return IMemAllocator_SetProperties(pAlloc
, &This
->allocProps
, &actual
);
912 static const BaseOutputPinFuncTable output_BaseOutputFuncTable
= {
915 FileAsyncReaderPin_AttemptConnection
,
916 BasePinImpl_GetMediaTypeVersion
,
917 FileAsyncReaderPin_GetMediaType
919 FileAsyncReaderPin_DecideBufferSize
,
920 BaseOutputPinImpl_DecideAllocator
,
921 BaseOutputPinImpl_BreakConnect
924 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
930 piOutput
.dir
= PINDIR_OUTPUT
;
931 piOutput
.pFilter
= pBaseFilter
;
932 strcpyW(piOutput
.achName
, wszOutputPinName
);
933 hr
= BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl
, sizeof(FileAsyncReader
), &piOutput
, &output_BaseOutputFuncTable
, pCritSec
, ppPin
);
937 FileAsyncReader
*pPinImpl
= (FileAsyncReader
*)*ppPin
;
938 pPinImpl
->IAsyncReader_iface
.lpVtbl
= &FileAsyncReader_Vtbl
;
939 pPinImpl
->hFile
= hFile
;
940 pPinImpl
->bFlushing
= FALSE
;
941 pPinImpl
->sample_list
= NULL
;
942 pPinImpl
->handle_list
= NULL
;
943 pPinImpl
->queued_number
= 0;
944 InitializeCriticalSection(&pPinImpl
->csList
);
945 pPinImpl
->csList
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": FileAsyncReader.csList");
952 static HRESULT WINAPI
FileAsyncReader_QueryInterface(IAsyncReader
* iface
, REFIID riid
, LPVOID
* ppv
)
954 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
956 return IPin_QueryInterface(&This
->pin
.pin
.IPin_iface
, riid
, ppv
);
959 static ULONG WINAPI
FileAsyncReader_AddRef(IAsyncReader
* iface
)
961 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
963 return IPin_AddRef(&This
->pin
.pin
.IPin_iface
);
966 static ULONG WINAPI
FileAsyncReader_Release(IAsyncReader
* iface
)
968 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
970 return IPin_Release(&This
->pin
.pin
.IPin_iface
);
973 #define DEF_ALIGNMENT 1
975 static HRESULT WINAPI
FileAsyncReader_RequestAllocator(IAsyncReader
* iface
, IMemAllocator
* pPreferred
, ALLOCATOR_PROPERTIES
* pProps
, IMemAllocator
** ppActual
)
977 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
981 TRACE("(%p, %p, %p)\n", pPreferred
, pProps
, ppActual
);
983 if (!pProps
->cbAlign
|| (pProps
->cbAlign
% DEF_ALIGNMENT
) != 0)
984 pProps
->cbAlign
= DEF_ALIGNMENT
;
988 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
989 /* FIXME: check we are still aligned */
992 IMemAllocator_AddRef(pPreferred
);
993 *ppActual
= pPreferred
;
994 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1001 hr
= CoCreateInstance(&CLSID_MemoryAllocator
, NULL
, CLSCTX_INPROC
, &IID_IMemAllocator
, (LPVOID
*)&pPreferred
);
1005 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1006 /* FIXME: check we are still aligned */
1009 *ppActual
= pPreferred
;
1010 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1017 CoTaskMemFree(This
->sample_list
);
1018 if (This
->handle_list
)
1021 for (x
= 0; x
<= This
->samples
; ++x
)
1022 CloseHandle(This
->handle_list
[x
]);
1023 CoTaskMemFree(This
->handle_list
);
1026 This
->samples
= pProps
->cBuffers
;
1027 This
->oldest_sample
= 0;
1028 TRACE("Samples: %u\n", This
->samples
);
1029 This
->sample_list
= CoTaskMemAlloc(sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1030 This
->handle_list
= CoTaskMemAlloc(sizeof(HANDLE
) * pProps
->cBuffers
* 2);
1032 if (This
->sample_list
&& This
->handle_list
)
1035 ZeroMemory(This
->sample_list
, sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1036 for (x
= 0; x
< This
->samples
; ++x
)
1038 This
->sample_list
[x
].ovl
.hEvent
= This
->handle_list
[x
] = CreateEventW(NULL
, 0, 0, NULL
);
1039 if (x
+ 1 < This
->samples
)
1040 This
->handle_list
[This
->samples
+ 1 + x
] = This
->handle_list
[x
];
1042 This
->handle_list
[This
->samples
] = CreateEventW(NULL
, 1, 0, NULL
);
1043 This
->allocProps
= *pProps
;
1048 CoTaskMemFree(This
->sample_list
);
1049 CoTaskMemFree(This
->handle_list
);
1051 This
->sample_list
= NULL
;
1052 This
->handle_list
= NULL
;
1060 IMemAllocator_Release(pPreferred
);
1063 TRACE("-- %x\n", hr
);
1067 /* we could improve the Request/WaitForNext mechanism by allowing out of order samples.
1068 * however, this would be quite complicated to do and may be a bit error prone */
1069 static HRESULT WINAPI
FileAsyncReader_Request(IAsyncReader
* iface
, IMediaSample
* pSample
, DWORD_PTR dwUser
)
1072 REFERENCE_TIME Start
;
1073 REFERENCE_TIME Stop
;
1074 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1075 LPBYTE pBuffer
= NULL
;
1077 TRACE("(%p, %lx)\n", pSample
, dwUser
);
1082 /* get start and stop positions in bytes */
1084 hr
= IMediaSample_GetTime(pSample
, &Start
, &Stop
);
1087 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1089 EnterCriticalSection(&This
->csList
);
1090 if (This
->bFlushing
)
1092 LeaveCriticalSection(&This
->csList
);
1093 return VFW_E_WRONG_STATE
;
1098 DWORD dwLength
= (DWORD
) BYTES_FROM_MEDIATIME(Stop
- Start
);
1099 DATAREQUEST
*pDataRq
;
1102 /* Try to insert above the waiting sample if possible */
1103 for (x
= This
->oldest_sample
; x
< This
->samples
; ++x
)
1105 if (!This
->sample_list
[x
].pSample
)
1109 if (x
>= This
->samples
)
1110 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1112 if (!This
->sample_list
[x
].pSample
)
1116 /* There must be a sample we have found */
1117 assert(x
< This
->samples
);
1118 ++This
->queued_number
;
1120 pDataRq
= This
->sample_list
+ x
;
1122 pDataRq
->ovl
.u
.s
.Offset
= (DWORD
) BYTES_FROM_MEDIATIME(Start
);
1123 pDataRq
->ovl
.u
.s
.OffsetHigh
= (DWORD
)(BYTES_FROM_MEDIATIME(Start
) >> (sizeof(DWORD
) * 8));
1124 pDataRq
->dwUserData
= dwUser
;
1126 /* we violate traditional COM rules here by maintaining
1127 * a reference to the sample, but not calling AddRef, but
1128 * that's what MSDN says to do */
1129 pDataRq
->pSample
= pSample
;
1131 /* this is definitely not how it is implemented on Win9x
1132 * as they do not support async reads on files, but it is
1133 * sooo much easier to use this than messing around with threads!
1135 if (!ReadFile(This
->hFile
, pBuffer
, dwLength
, NULL
, &pDataRq
->ovl
))
1136 hr
= HRESULT_FROM_WIN32(GetLastError());
1138 /* ERROR_IO_PENDING is not actually an error since this is what we want! */
1139 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1143 LeaveCriticalSection(&This
->csList
);
1145 TRACE("-- %x\n", hr
);
1149 static HRESULT WINAPI
FileAsyncReader_WaitForNext(IAsyncReader
* iface
, DWORD dwTimeout
, IMediaSample
** ppSample
, DWORD_PTR
* pdwUser
)
1152 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1155 TRACE("(%u, %p, %p)\n", dwTimeout
, ppSample
, pdwUser
);
1160 EnterCriticalSection(&This
->csList
);
1161 if (!This
->bFlushing
)
1163 LONG oldest
= This
->oldest_sample
;
1165 if (!This
->queued_number
)
1167 /* It could be that nothing is queued right now, but that can be fixed */
1168 WARN("Called without samples in queue and not flushing!!\n");
1170 LeaveCriticalSection(&This
->csList
);
1172 /* wait for an object to read, or time out */
1173 buffer
= WaitForMultipleObjectsEx(This
->samples
+1, This
->handle_list
+ oldest
, FALSE
, dwTimeout
, TRUE
);
1175 EnterCriticalSection(&This
->csList
);
1176 if (buffer
<= This
->samples
)
1178 /* Re-scale the buffer back to normal */
1181 /* Uh oh, we overshot the flusher handle, renormalize it back to 0..Samples-1 */
1182 if (buffer
> This
->samples
)
1183 buffer
-= This
->samples
+ 1;
1184 assert(buffer
<= This
->samples
);
1187 if (buffer
>= This
->samples
)
1189 if (buffer
!= This
->samples
)
1191 FIXME("Returned: %u (%08x)\n", buffer
, GetLastError());
1195 hr
= VFW_E_WRONG_STATE
;
1199 --This
->queued_number
;
1202 if (This
->bFlushing
&& buffer
== ~0)
1204 for (buffer
= 0; buffer
< This
->samples
; ++buffer
)
1206 if (This
->sample_list
[buffer
].pSample
)
1208 ResetEvent(This
->handle_list
[buffer
]);
1212 if (buffer
== This
->samples
)
1214 assert(!This
->queued_number
);
1219 --This
->queued_number
;
1226 REFERENCE_TIME rtStart
, rtStop
;
1227 REFERENCE_TIME rtSampleStart
, rtSampleStop
;
1228 DATAREQUEST
*pDataRq
= This
->sample_list
+ buffer
;
1231 /* get any errors */
1232 if (!This
->bFlushing
&& !GetOverlappedResult(This
->hFile
, &pDataRq
->ovl
, &dwBytes
, FALSE
))
1233 hr
= HRESULT_FROM_WIN32(GetLastError());
1235 /* Return the sample no matter what so it can be destroyed */
1236 *ppSample
= pDataRq
->pSample
;
1237 *pdwUser
= pDataRq
->dwUserData
;
1239 if (This
->bFlushing
)
1240 hr
= VFW_E_WRONG_STATE
;
1245 /* Set the time on the sample */
1246 IMediaSample_SetActualDataLength(pDataRq
->pSample
, dwBytes
);
1248 rtStart
= (DWORD64
)pDataRq
->ovl
.u
.s
.Offset
+ ((DWORD64
)pDataRq
->ovl
.u
.s
.OffsetHigh
<< 32);
1249 rtStart
= MEDIATIME_FROM_BYTES(rtStart
);
1250 rtStop
= rtStart
+ MEDIATIME_FROM_BYTES(dwBytes
);
1252 IMediaSample_GetTime(pDataRq
->pSample
, &rtSampleStart
, &rtSampleStop
);
1253 assert(rtStart
== rtSampleStart
);
1254 assert(rtStop
<= rtSampleStop
);
1256 IMediaSample_SetTime(pDataRq
->pSample
, &rtStart
, &rtStop
);
1257 assert(rtStart
== rtSampleStart
);
1259 assert(rtStop
== rtSampleStop
);
1261 assert(rtStop
== rtStart
);
1263 This
->sample_list
[buffer
].pSample
= NULL
;
1264 assert(This
->oldest_sample
< This
->samples
);
1266 if (buffer
== This
->oldest_sample
)
1269 for (x
= This
->oldest_sample
+ 1; x
< This
->samples
; ++x
)
1270 if (This
->sample_list
[x
].pSample
)
1272 if (x
>= This
->samples
)
1273 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1274 if (This
->sample_list
[x
].pSample
)
1276 if (This
->oldest_sample
== x
)
1277 /* No samples found, reset to 0 */
1279 This
->oldest_sample
= x
;
1282 LeaveCriticalSection(&This
->csList
);
1284 TRACE("-- %x\n", hr
);
1288 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
);
1290 static HRESULT WINAPI
FileAsyncReader_SyncReadAligned(IAsyncReader
* iface
, IMediaSample
* pSample
)
1293 REFERENCE_TIME tStart
;
1294 REFERENCE_TIME tStop
;
1297 TRACE("(%p)\n", pSample
);
1299 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
1302 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1305 hr
= FileAsyncReader_SyncRead(iface
,
1306 BYTES_FROM_MEDIATIME(tStart
),
1307 (LONG
) BYTES_FROM_MEDIATIME(tStop
- tStart
),
1310 TRACE("-- %x\n", hr
);
1314 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
)
1318 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1320 TRACE("(%x%08x, %d, %p)\n", (ULONG
)(llPosition
>> 32), (ULONG
)llPosition
, lLength
, pBuffer
);
1322 ZeroMemory(&ovl
, sizeof(ovl
));
1324 ovl
.hEvent
= CreateEventW(NULL
, 0, 0, NULL
);
1325 /* NOTE: llPosition is the actual byte position to start reading from */
1326 ovl
.u
.s
.Offset
= (DWORD
) llPosition
;
1327 ovl
.u
.s
.OffsetHigh
= (DWORD
) (llPosition
>> (sizeof(DWORD
) * 8));
1329 if (!ReadFile(This
->hFile
, pBuffer
, lLength
, NULL
, &ovl
))
1330 hr
= HRESULT_FROM_WIN32(GetLastError());
1332 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1339 if (!GetOverlappedResult(This
->hFile
, &ovl
, &dwBytesRead
, TRUE
))
1340 hr
= HRESULT_FROM_WIN32(GetLastError());
1343 CloseHandle(ovl
.hEvent
);
1345 TRACE("-- %x\n", hr
);
1349 static HRESULT WINAPI
FileAsyncReader_Length(IAsyncReader
* iface
, LONGLONG
* pTotal
, LONGLONG
* pAvailable
)
1353 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1355 TRACE("(%p, %p)\n", pTotal
, pAvailable
);
1357 if (((dwSizeLow
= GetFileSize(This
->hFile
, &dwSizeHigh
)) == -1) &&
1358 (GetLastError() != NO_ERROR
))
1359 return HRESULT_FROM_WIN32(GetLastError());
1361 *pTotal
= (LONGLONG
)dwSizeLow
| (LONGLONG
)dwSizeHigh
<< (sizeof(DWORD
) * 8);
1363 *pAvailable
= *pTotal
;
1368 static HRESULT WINAPI
FileAsyncReader_BeginFlush(IAsyncReader
* iface
)
1370 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1374 EnterCriticalSection(&This
->csList
);
1375 This
->bFlushing
= TRUE
;
1376 CancelIo(This
->hFile
);
1377 SetEvent(This
->handle_list
[This
->samples
]);
1378 LeaveCriticalSection(&This
->csList
);
1383 static HRESULT WINAPI
FileAsyncReader_EndFlush(IAsyncReader
* iface
)
1385 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1390 EnterCriticalSection(&This
->csList
);
1391 ResetEvent(This
->handle_list
[This
->samples
]);
1392 This
->bFlushing
= FALSE
;
1393 for (x
= 0; x
< This
->samples
; ++x
)
1394 assert(!This
->sample_list
[x
].pSample
);
1396 LeaveCriticalSection(&This
->csList
);
1401 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
=
1403 FileAsyncReader_QueryInterface
,
1404 FileAsyncReader_AddRef
,
1405 FileAsyncReader_Release
,
1406 FileAsyncReader_RequestAllocator
,
1407 FileAsyncReader_Request
,
1408 FileAsyncReader_WaitForNext
,
1409 FileAsyncReader_SyncReadAligned
,
1410 FileAsyncReader_SyncRead
,
1411 FileAsyncReader_Length
,
1412 FileAsyncReader_BeginFlush
,
1413 FileAsyncReader_EndFlush
,
1417 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1418 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1419 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
1422 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1423 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1424 return IUnknown_AddRef((IUnknown
*)This
);
1427 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1428 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1429 return IUnknown_Release((IUnknown
*)This
);
1432 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1433 return AM_FILTER_MISC_FLAGS_IS_SOURCE
;
1436 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1437 AMFilterMiscFlags_QueryInterface
,
1438 AMFilterMiscFlags_AddRef
,
1439 AMFilterMiscFlags_Release
,
1440 AMFilterMiscFlags_GetMiscFlags