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"
25 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
27 typedef struct AsyncReader
30 IFileSourceFilter IFileSourceFilter_iface
;
31 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
38 static inline AsyncReader
*impl_from_BaseFilter(BaseFilter
*iface
)
40 return CONTAINING_RECORD(iface
, AsyncReader
, filter
);
43 static inline AsyncReader
*impl_from_IBaseFilter(IBaseFilter
*iface
)
45 return CONTAINING_RECORD(iface
, AsyncReader
, filter
.IBaseFilter_iface
);
48 static inline AsyncReader
*impl_from_IFileSourceFilter(IFileSourceFilter
*iface
)
50 return CONTAINING_RECORD(iface
, AsyncReader
, IFileSourceFilter_iface
);
53 static inline AsyncReader
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
55 return CONTAINING_RECORD(iface
, AsyncReader
, IAMFilterMiscFlags_iface
);
58 static const IBaseFilterVtbl AsyncReader_Vtbl
;
59 static const IFileSourceFilterVtbl FileSource_Vtbl
;
60 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
;
61 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
63 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
65 static const WCHAR mediatype_name
[] = {
66 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 };
67 static const WCHAR subtype_name
[] = {
68 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 };
69 static const WCHAR source_filter_name
[] = {
70 'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
72 static HRESULT
process_extensions(HKEY hkeyExtensions
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
83 /* Get the part of the name that matters */
84 extension
= PathFindExtensionW(pszFileName
);
85 if (*extension
!= '.')
88 l
= RegOpenKeyExW(hkeyExtensions
, extension
, 0, KEY_READ
, &hsub
);
94 size
= sizeof(keying
);
95 l
= RegQueryValueExW(hsub
, mediatype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
97 CLSIDFromString(keying
, majorType
);
102 size
= sizeof(keying
);
104 l
= RegQueryValueExW(hsub
, subtype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
106 CLSIDFromString(keying
, minorType
);
111 size
= sizeof(keying
);
113 l
= RegQueryValueExW(hsub
, source_filter_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
115 CLSIDFromString(keying
, sourceFilter
);
125 static unsigned char byte_from_hex_char(WCHAR wHex
)
127 switch (tolowerW(wHex
))
139 return (wHex
- '0') & 0xf;
146 return (wHex
- 'a' + 10) & 0xf;
152 static HRESULT
process_pattern_string(LPCWSTR wszPatternString
, IAsyncReader
* pReader
)
162 TRACE("\t\tPattern string: %s\n", debugstr_w(wszPatternString
));
164 /* format: "offset, bytestocompare, mask, value" */
166 ulOffset
= strtolW(wszPatternString
, NULL
, 10);
168 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
171 wszPatternString
++; /* skip ',' */
173 ulBytes
= strtolW(wszPatternString
, NULL
, 10);
175 pbMask
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
176 pbValue
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ulBytes
);
177 pbFile
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
179 /* default mask is match everything */
180 memset(pbMask
, 0xFF, ulBytes
);
182 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
187 wszPatternString
++; /* skip ',' */
188 while (!isxdigitW(*wszPatternString
) && (*wszPatternString
!= ',')) wszPatternString
++;
190 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
192 if ((strpos
% 2) == 1) /* odd numbered position */
193 pbMask
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
195 pbMask
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
198 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
201 wszPatternString
++; /* skip ',' */
206 for ( ; !isxdigitW(*wszPatternString
) && (*wszPatternString
!= ','); wszPatternString
++)
209 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
211 if ((strpos
% 2) == 1) /* odd numbered position */
212 pbValue
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
214 pbValue
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
219 hr
= IAsyncReader_SyncRead(pReader
, ulOffset
, ulBytes
, pbFile
);
224 for (i
= 0; i
< ulBytes
; i
++)
225 if ((pbFile
[i
] & pbMask
[i
]) != pbValue
[i
])
232 HeapFree(GetProcessHeap(), 0, pbMask
);
233 HeapFree(GetProcessHeap(), 0, pbValue
);
234 HeapFree(GetProcessHeap(), 0, pbFile
);
236 /* if we encountered no errors with this string, and there is a following tuple, then we
237 * have to match that as well to succeed */
238 if ((hr
== S_OK
) && (wszPatternString
= strchrW(wszPatternString
, ',')))
239 return process_pattern_string(wszPatternString
+ 1, pReader
);
244 HRESULT
GetClassMediaFile(IAsyncReader
* pReader
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
246 HKEY hkeyMediaType
= NULL
;
250 static const WCHAR wszMediaType
[] = {'M','e','d','i','a',' ','T','y','p','e',0};
252 TRACE("(%p, %s, %p, %p)\n", pReader
, debugstr_w(pszFileName
), majorType
, minorType
);
255 *majorType
= GUID_NULL
;
257 *minorType
= GUID_NULL
;
259 *sourceFilter
= GUID_NULL
;
261 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszMediaType
, 0, KEY_READ
, &hkeyMediaType
);
262 hr
= HRESULT_FROM_WIN32(lRet
);
268 for (indexMajor
= 0; !bFound
; indexMajor
++)
271 WCHAR wszMajorKeyName
[CHARS_IN_GUID
];
272 DWORD dwKeyNameLength
= sizeof(wszMajorKeyName
) / sizeof(wszMajorKeyName
[0]);
273 static const WCHAR wszExtensions
[] = {'E','x','t','e','n','s','i','o','n','s',0};
275 if (RegEnumKeyExW(hkeyMediaType
, indexMajor
, wszMajorKeyName
, &dwKeyNameLength
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
277 if (RegOpenKeyExW(hkeyMediaType
, wszMajorKeyName
, 0, KEY_READ
, &hkeyMajor
) != ERROR_SUCCESS
)
279 TRACE("%s\n", debugstr_w(wszMajorKeyName
));
280 if (!strcmpW(wszExtensions
, wszMajorKeyName
))
282 if (process_extensions(hkeyMajor
, pszFileName
, majorType
, minorType
, sourceFilter
) == S_OK
)
285 /* We need a reader interface to check bytes */
290 for (indexMinor
= 0; !bFound
; indexMinor
++)
293 WCHAR wszMinorKeyName
[CHARS_IN_GUID
];
294 DWORD dwMinorKeyNameLen
= sizeof(wszMinorKeyName
) / sizeof(wszMinorKeyName
[0]);
295 WCHAR wszSourceFilterKeyName
[CHARS_IN_GUID
];
296 DWORD dwSourceFilterKeyNameLen
= sizeof(wszSourceFilterKeyName
);
300 if (RegEnumKeyExW(hkeyMajor
, indexMinor
, wszMinorKeyName
, &dwMinorKeyNameLen
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
303 if (RegOpenKeyExW(hkeyMajor
, wszMinorKeyName
, 0, KEY_READ
, &hkeyMinor
) != ERROR_SUCCESS
)
306 TRACE("\t%s\n", debugstr_w(wszMinorKeyName
));
308 if (RegQueryInfoKeyW(hkeyMinor
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &maxValueLen
, NULL
, NULL
) != ERROR_SUCCESS
)
311 for (indexValue
= 0; !bFound
; indexValue
++)
314 WCHAR wszValueName
[14]; /* longest name we should encounter will be "Source Filter" */
315 LPWSTR wszPatternString
= HeapAlloc(GetProcessHeap(), 0, maxValueLen
);
316 DWORD dwValueNameLen
= sizeof(wszValueName
) / sizeof(wszValueName
[0]); /* remember this is in chars */
317 DWORD dwDataLen
= maxValueLen
; /* remember this is in bytes */
319 if (RegEnumValueW(hkeyMinor
, indexValue
, wszValueName
, &dwValueNameLen
, NULL
, &dwType
, (LPBYTE
)wszPatternString
, &dwDataLen
) != ERROR_SUCCESS
)
321 HeapFree(GetProcessHeap(), 0, wszPatternString
);
325 if (strcmpW(wszValueName
, source_filter_name
)==0) {
326 HeapFree(GetProcessHeap(), 0, wszPatternString
);
330 /* if it is not the source filter value */
331 if (process_pattern_string(wszPatternString
, pReader
) == S_OK
)
333 HeapFree(GetProcessHeap(), 0, wszPatternString
);
334 if (majorType
&& FAILED(CLSIDFromString(wszMajorKeyName
, majorType
)))
336 if (minorType
&& FAILED(CLSIDFromString(wszMinorKeyName
, minorType
)))
340 /* Look up the source filter key */
341 if (RegQueryValueExW(hkeyMinor
, source_filter_name
, NULL
, NULL
, (LPBYTE
)wszSourceFilterKeyName
, &dwSourceFilterKeyNameLen
))
343 if (FAILED(CLSIDFromString(wszSourceFilterKeyName
, sourceFilter
)))
348 HeapFree(GetProcessHeap(), 0, wszPatternString
);
350 CloseHandle(hkeyMinor
);
353 CloseHandle(hkeyMajor
);
356 CloseHandle(hkeyMediaType
);
358 if (SUCCEEDED(hr
) && !bFound
)
360 ERR("Media class not found\n");
365 TRACE("Found file's class:\n");
367 TRACE("\tmajor = %s\n", qzdebugstr_guid(majorType
));
369 TRACE("\tsubtype = %s\n", qzdebugstr_guid(minorType
));
371 TRACE("\tsource filter = %s\n", qzdebugstr_guid(sourceFilter
));
377 static IPin
* WINAPI
AsyncReader_GetPin(BaseFilter
*iface
, int pos
)
379 AsyncReader
*This
= impl_from_BaseFilter(iface
);
381 if (pos
>= 1 || !This
->pOutputPin
)
384 IPin_AddRef(This
->pOutputPin
);
385 return This
->pOutputPin
;
388 static LONG WINAPI
AsyncReader_GetPinCount(BaseFilter
*iface
)
390 AsyncReader
*This
= impl_from_BaseFilter(iface
);
392 if (!This
->pOutputPin
)
398 static const BaseFilterFuncTable BaseFuncTable
= {
400 AsyncReader_GetPinCount
403 HRESULT
AsyncReader_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
405 AsyncReader
*pAsyncRead
;
408 return CLASS_E_NOAGGREGATION
;
410 pAsyncRead
= CoTaskMemAlloc(sizeof(AsyncReader
));
413 return E_OUTOFMEMORY
;
415 BaseFilter_Init(&pAsyncRead
->filter
, &AsyncReader_Vtbl
, &CLSID_AsyncReader
, (DWORD_PTR
)(__FILE__
": AsyncReader.csFilter"), &BaseFuncTable
);
417 pAsyncRead
->IFileSourceFilter_iface
.lpVtbl
= &FileSource_Vtbl
;
418 pAsyncRead
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
419 pAsyncRead
->pOutputPin
= NULL
;
421 pAsyncRead
->pszFileName
= NULL
;
422 pAsyncRead
->pmt
= NULL
;
426 TRACE("-- created at %p\n", pAsyncRead
);
431 /** IUnknown methods **/
433 static HRESULT WINAPI
AsyncReader_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
435 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
437 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
441 if (IsEqualIID(riid
, &IID_IUnknown
))
443 else if (IsEqualIID(riid
, &IID_IPersist
))
445 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
447 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
449 else if (IsEqualIID(riid
, &IID_IFileSourceFilter
))
450 *ppv
= &This
->IFileSourceFilter_iface
;
451 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
452 *ppv
= &This
->IAMFilterMiscFlags_iface
;
456 IUnknown_AddRef((IUnknown
*)(*ppv
));
460 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
) &&
461 !IsEqualIID(riid
, &IID_IVideoWindow
) && !IsEqualIID(riid
, &IID_IBasicAudio
))
462 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
464 return E_NOINTERFACE
;
467 static ULONG WINAPI
AsyncReader_Release(IBaseFilter
* iface
)
469 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
470 ULONG refCount
= BaseFilterImpl_Release(iface
);
472 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
476 if (This
->pOutputPin
)
479 if(SUCCEEDED(IPin_ConnectedTo(This
->pOutputPin
, &pConnectedTo
)))
481 IPin_Disconnect(pConnectedTo
);
482 IPin_Release(pConnectedTo
);
484 IPin_Disconnect(This
->pOutputPin
);
485 IPin_Release(This
->pOutputPin
);
487 CoTaskMemFree(This
->pszFileName
);
489 FreeMediaType(This
->pmt
);
497 /** IMediaFilter methods **/
499 static HRESULT WINAPI
AsyncReader_Stop(IBaseFilter
* iface
)
501 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
505 This
->filter
.state
= State_Stopped
;
510 static HRESULT WINAPI
AsyncReader_Pause(IBaseFilter
* iface
)
512 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
516 This
->filter
.state
= State_Paused
;
521 static HRESULT WINAPI
AsyncReader_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
523 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
525 TRACE("(%x%08x)\n", (ULONG
)(tStart
>> 32), (ULONG
)tStart
);
527 This
->filter
.state
= State_Running
;
532 /** IBaseFilter methods **/
534 static HRESULT WINAPI
AsyncReader_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
536 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
537 TRACE("(%s, %p)\n", debugstr_w(Id
), ppPin
);
542 if (strcmpW(Id
, wszOutputPinName
))
545 return VFW_E_NOT_FOUND
;
548 *ppPin
= This
->pOutputPin
;
553 static const IBaseFilterVtbl AsyncReader_Vtbl
=
555 AsyncReader_QueryInterface
,
556 BaseFilterImpl_AddRef
,
558 BaseFilterImpl_GetClassID
,
562 BaseFilterImpl_GetState
,
563 BaseFilterImpl_SetSyncSource
,
564 BaseFilterImpl_GetSyncSource
,
565 BaseFilterImpl_EnumPins
,
567 BaseFilterImpl_QueryFilterInfo
,
568 BaseFilterImpl_JoinFilterGraph
,
569 BaseFilterImpl_QueryVendorInfo
572 static HRESULT WINAPI
FileSource_QueryInterface(IFileSourceFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
574 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
576 return IBaseFilter_QueryInterface(&This
->filter
.IBaseFilter_iface
, riid
, ppv
);
579 static ULONG WINAPI
FileSource_AddRef(IFileSourceFilter
* iface
)
581 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
583 return IBaseFilter_AddRef(&This
->filter
.IBaseFilter_iface
);
586 static ULONG WINAPI
FileSource_Release(IFileSourceFilter
* iface
)
588 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
590 return IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);
593 static HRESULT WINAPI
FileSource_Load(IFileSourceFilter
* iface
, LPCOLESTR pszFileName
, const AM_MEDIA_TYPE
* pmt
)
597 IAsyncReader
* pReader
= NULL
;
598 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
600 TRACE("(%s, %p)\n", debugstr_w(pszFileName
), pmt
);
603 /* FIXME: check the sharing values that native uses */
604 hFile
= CreateFileW(pszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_FLAG_OVERLAPPED
, NULL
);
606 if (hFile
== INVALID_HANDLE_VALUE
)
608 return HRESULT_FROM_WIN32(GetLastError());
612 hr
= FileAsyncReader_Construct(hFile
, &This
->filter
.IBaseFilter_iface
, &This
->filter
.csFilter
, &This
->pOutputPin
);
613 BaseFilterImpl_IncrementPinVersion(&This
->filter
);
616 hr
= IPin_QueryInterface(This
->pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
618 /* store file name & media type */
621 CoTaskMemFree(This
->pszFileName
);
623 FreeMediaType(This
->pmt
);
625 This
->pszFileName
= CoTaskMemAlloc((strlenW(pszFileName
) + 1) * sizeof(WCHAR
));
626 strcpyW(This
->pszFileName
, pszFileName
);
628 This
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
631 This
->pmt
->bFixedSizeSamples
= TRUE
;
632 This
->pmt
->bTemporalCompression
= FALSE
;
633 This
->pmt
->cbFormat
= 0;
634 This
->pmt
->pbFormat
= NULL
;
635 This
->pmt
->pUnk
= NULL
;
636 This
->pmt
->lSampleSize
= 0;
637 This
->pmt
->formattype
= FORMAT_None
;
638 hr
= GetClassMediaFile(pReader
, pszFileName
, &This
->pmt
->majortype
, &This
->pmt
->subtype
, NULL
);
641 CoTaskMemFree(This
->pmt
);
646 CopyMediaType(This
->pmt
, pmt
);
650 IAsyncReader_Release(pReader
);
654 if (This
->pOutputPin
)
656 IPin_Release(This
->pOutputPin
);
657 This
->pOutputPin
= NULL
;
660 CoTaskMemFree(This
->pszFileName
);
662 FreeMediaType(This
->pmt
);
663 This
->pszFileName
= NULL
;
669 /* FIXME: check return codes */
673 static HRESULT WINAPI
FileSource_GetCurFile(IFileSourceFilter
* iface
, LPOLESTR
* ppszFileName
, AM_MEDIA_TYPE
* pmt
)
675 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
677 TRACE("(%p, %p)\n", ppszFileName
, pmt
);
682 /* copy file name & media type if available, otherwise clear the outputs */
683 if (This
->pszFileName
)
685 *ppszFileName
= CoTaskMemAlloc((strlenW(This
->pszFileName
) + 1) * sizeof(WCHAR
));
686 strcpyW(*ppszFileName
, This
->pszFileName
);
689 *ppszFileName
= NULL
;
694 CopyMediaType(pmt
, This
->pmt
);
696 ZeroMemory(pmt
, sizeof(*pmt
));
702 static const IFileSourceFilterVtbl FileSource_Vtbl
=
704 FileSource_QueryInterface
,
708 FileSource_GetCurFile
712 /* the dwUserData passed back to user */
713 typedef struct DATAREQUEST
715 IMediaSample
* pSample
; /* sample passed to us by user */
716 DWORD_PTR dwUserData
; /* user data passed to us */
717 OVERLAPPED ovl
; /* our overlapped structure */
720 typedef struct FileAsyncReader
723 IAsyncReader IAsyncReader_iface
;
725 ALLOCATOR_PROPERTIES allocProps
;
728 /* Why would you need more? Every sample has its own handle */
732 CRITICAL_SECTION csList
; /* critical section to prevent concurrency issues */
733 DATAREQUEST
*sample_list
;
735 /* Have a handle for every sample, and then one more as flushing handle */
739 static inline FileAsyncReader
*impl_from_IPin(IPin
*iface
)
741 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
.IPin_iface
);
744 static inline FileAsyncReader
*impl_from_BasePin(BasePin
*iface
)
746 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
);
749 static inline FileAsyncReader
*impl_from_BaseOutputPin(BaseOutputPin
*iface
)
751 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
);
754 static inline BaseOutputPin
*impl_BaseOututPin_from_BasePin(BasePin
*iface
)
756 return CONTAINING_RECORD(iface
, BaseOutputPin
, pin
);
759 static inline FileAsyncReader
*impl_from_IAsyncReader(IAsyncReader
*iface
)
761 return CONTAINING_RECORD(iface
, FileAsyncReader
, IAsyncReader_iface
);
764 static HRESULT WINAPI
FileAsyncReaderPin_QueryAccept(IPin
*iface
, const AM_MEDIA_TYPE
*pmt
)
766 FileAsyncReader
*This
= impl_from_IPin(iface
);
767 AM_MEDIA_TYPE
*pmt_filter
= impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
;
769 FIXME("(%p, %p)\n", iface
, pmt
);
771 if (IsEqualGUID(&pmt
->majortype
, &pmt_filter
->majortype
) &&
772 IsEqualGUID(&pmt
->subtype
, &pmt_filter
->subtype
) &&
773 IsEqualGUID(&pmt
->formattype
, &FORMAT_None
))
779 static HRESULT WINAPI
FileAsyncReaderPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
)
781 FileAsyncReader
*This
= impl_from_BasePin(iface
);
785 return VFW_S_NO_MORE_ITEMS
;
786 CopyMediaType(pmt
, impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
);
790 /* overridden pin functions */
792 static HRESULT WINAPI
FileAsyncReaderPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
794 FileAsyncReader
*This
= impl_from_IPin(iface
);
795 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
799 if (IsEqualIID(riid
, &IID_IUnknown
))
801 else if (IsEqualIID(riid
, &IID_IPin
))
803 else if (IsEqualIID(riid
, &IID_IAsyncReader
))
804 *ppv
= &This
->IAsyncReader_iface
;
808 IUnknown_AddRef((IUnknown
*)(*ppv
));
812 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
))
813 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
815 return E_NOINTERFACE
;
818 static ULONG WINAPI
FileAsyncReaderPin_Release(IPin
* iface
)
820 FileAsyncReader
*This
= impl_from_IPin(iface
);
821 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
824 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
828 CoTaskMemFree(This
->sample_list
);
829 if (This
->handle_list
)
831 for (x
= 0; x
<= This
->samples
; ++x
)
832 CloseHandle(This
->handle_list
[x
]);
833 CoTaskMemFree(This
->handle_list
);
835 CloseHandle(This
->hFile
);
836 This
->csList
.DebugInfo
->Spare
[0] = 0;
837 DeleteCriticalSection(&This
->csList
);
844 static const IPinVtbl FileAsyncReaderPin_Vtbl
=
846 FileAsyncReaderPin_QueryInterface
,
848 FileAsyncReaderPin_Release
,
849 BaseOutputPinImpl_Connect
,
850 BaseOutputPinImpl_ReceiveConnection
,
851 BasePinImpl_Disconnect
,
852 BasePinImpl_ConnectedTo
,
853 BasePinImpl_ConnectionMediaType
,
854 BasePinImpl_QueryPinInfo
,
855 BasePinImpl_QueryDirection
,
857 FileAsyncReaderPin_QueryAccept
,
858 BasePinImpl_EnumMediaTypes
,
859 BasePinImpl_QueryInternalConnections
,
860 BaseOutputPinImpl_EndOfStream
,
861 BaseOutputPinImpl_BeginFlush
,
862 BaseOutputPinImpl_EndFlush
,
863 BasePinImpl_NewSegment
866 /* Function called as a helper to IPin_Connect */
867 /* specific AM_MEDIA_TYPE - it cannot be NULL */
868 /* this differs from standard OutputPin_AttemptConnection only in that it
869 * doesn't need the IMemInputPin interface on the receiving pin */
870 static HRESULT WINAPI
FileAsyncReaderPin_AttemptConnection(BasePin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
872 BaseOutputPin
*This
= impl_BaseOututPin_from_BasePin(iface
);
875 TRACE("(%p, %p)\n", pReceivePin
, pmt
);
876 dump_AM_MEDIA_TYPE(pmt
);
878 /* FIXME: call queryacceptproc */
880 This
->pin
.pConnectedTo
= pReceivePin
;
881 IPin_AddRef(pReceivePin
);
882 CopyMediaType(&This
->pin
.mtCurrent
, pmt
);
884 hr
= IPin_ReceiveConnection(pReceivePin
, &iface
->IPin_iface
, pmt
);
888 IPin_Release(This
->pin
.pConnectedTo
);
889 This
->pin
.pConnectedTo
= NULL
;
890 FreeMediaType(&This
->pin
.mtCurrent
);
893 TRACE(" -- %x\n", hr
);
897 static HRESULT WINAPI
FileAsyncReaderPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
)
899 FileAsyncReader
*This
= impl_from_BaseOutputPin(iface
);
900 ALLOCATOR_PROPERTIES actual
;
902 if (ppropInputRequest
->cbAlign
&& ppropInputRequest
->cbAlign
!= This
->allocProps
.cbAlign
)
903 FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This
->allocProps
.cbAlign
, ppropInputRequest
->cbAlign
);
904 if (ppropInputRequest
->cbPrefix
)
905 FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This
->allocProps
.cbPrefix
, ppropInputRequest
->cbPrefix
);
906 if (ppropInputRequest
->cbBuffer
)
907 FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This
->allocProps
.cbBuffer
, ppropInputRequest
->cbBuffer
);
908 if (ppropInputRequest
->cBuffers
)
909 FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This
->allocProps
.cBuffers
, ppropInputRequest
->cBuffers
);
911 return IMemAllocator_SetProperties(pAlloc
, &This
->allocProps
, &actual
);
914 static const BaseOutputPinFuncTable output_BaseOutputFuncTable
= {
917 FileAsyncReaderPin_AttemptConnection
,
918 BasePinImpl_GetMediaTypeVersion
,
919 FileAsyncReaderPin_GetMediaType
921 FileAsyncReaderPin_DecideBufferSize
,
922 BaseOutputPinImpl_DecideAllocator
,
923 BaseOutputPinImpl_BreakConnect
926 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
932 piOutput
.dir
= PINDIR_OUTPUT
;
933 piOutput
.pFilter
= pBaseFilter
;
934 strcpyW(piOutput
.achName
, wszOutputPinName
);
935 hr
= BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl
, sizeof(FileAsyncReader
), &piOutput
, &output_BaseOutputFuncTable
, pCritSec
, ppPin
);
939 FileAsyncReader
*pPinImpl
= (FileAsyncReader
*)*ppPin
;
940 pPinImpl
->IAsyncReader_iface
.lpVtbl
= &FileAsyncReader_Vtbl
;
941 pPinImpl
->hFile
= hFile
;
942 pPinImpl
->bFlushing
= FALSE
;
943 pPinImpl
->sample_list
= NULL
;
944 pPinImpl
->handle_list
= NULL
;
945 pPinImpl
->queued_number
= 0;
946 InitializeCriticalSection(&pPinImpl
->csList
);
947 pPinImpl
->csList
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": FileAsyncReader.csList");
954 static HRESULT WINAPI
FileAsyncReader_QueryInterface(IAsyncReader
* iface
, REFIID riid
, LPVOID
* ppv
)
956 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
958 return IPin_QueryInterface(&This
->pin
.pin
.IPin_iface
, riid
, ppv
);
961 static ULONG WINAPI
FileAsyncReader_AddRef(IAsyncReader
* iface
)
963 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
965 return IPin_AddRef(&This
->pin
.pin
.IPin_iface
);
968 static ULONG WINAPI
FileAsyncReader_Release(IAsyncReader
* iface
)
970 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
972 return IPin_Release(&This
->pin
.pin
.IPin_iface
);
975 #define DEF_ALIGNMENT 1
977 static HRESULT WINAPI
FileAsyncReader_RequestAllocator(IAsyncReader
* iface
, IMemAllocator
* pPreferred
, ALLOCATOR_PROPERTIES
* pProps
, IMemAllocator
** ppActual
)
979 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
983 TRACE("(%p, %p, %p)\n", pPreferred
, pProps
, ppActual
);
985 if (!pProps
->cbAlign
|| (pProps
->cbAlign
% DEF_ALIGNMENT
) != 0)
986 pProps
->cbAlign
= DEF_ALIGNMENT
;
990 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
991 /* FIXME: check we are still aligned */
994 IMemAllocator_AddRef(pPreferred
);
995 *ppActual
= pPreferred
;
996 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1003 hr
= CoCreateInstance(&CLSID_MemoryAllocator
, NULL
, CLSCTX_INPROC
, &IID_IMemAllocator
, (LPVOID
*)&pPreferred
);
1007 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1008 /* FIXME: check we are still aligned */
1011 *ppActual
= pPreferred
;
1012 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1019 CoTaskMemFree(This
->sample_list
);
1020 if (This
->handle_list
)
1023 for (x
= 0; x
<= This
->samples
; ++x
)
1024 CloseHandle(This
->handle_list
[x
]);
1025 CoTaskMemFree(This
->handle_list
);
1028 This
->samples
= pProps
->cBuffers
;
1029 This
->oldest_sample
= 0;
1030 TRACE("Samples: %u\n", This
->samples
);
1031 This
->sample_list
= CoTaskMemAlloc(sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1032 This
->handle_list
= CoTaskMemAlloc(sizeof(HANDLE
) * pProps
->cBuffers
* 2);
1034 if (This
->sample_list
&& This
->handle_list
)
1037 ZeroMemory(This
->sample_list
, sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1038 for (x
= 0; x
< This
->samples
; ++x
)
1040 This
->sample_list
[x
].ovl
.hEvent
= This
->handle_list
[x
] = CreateEventW(NULL
, 0, 0, NULL
);
1041 if (x
+ 1 < This
->samples
)
1042 This
->handle_list
[This
->samples
+ 1 + x
] = This
->handle_list
[x
];
1044 This
->handle_list
[This
->samples
] = CreateEventW(NULL
, 1, 0, NULL
);
1045 This
->allocProps
= *pProps
;
1050 CoTaskMemFree(This
->sample_list
);
1051 CoTaskMemFree(This
->handle_list
);
1053 This
->sample_list
= NULL
;
1054 This
->handle_list
= NULL
;
1062 IMemAllocator_Release(pPreferred
);
1065 TRACE("-- %x\n", hr
);
1069 /* we could improve the Request/WaitForNext mechanism by allowing out of order samples.
1070 * however, this would be quite complicated to do and may be a bit error prone */
1071 static HRESULT WINAPI
FileAsyncReader_Request(IAsyncReader
* iface
, IMediaSample
* pSample
, DWORD_PTR dwUser
)
1074 REFERENCE_TIME Start
;
1075 REFERENCE_TIME Stop
;
1076 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1077 LPBYTE pBuffer
= NULL
;
1079 TRACE("(%p, %lx)\n", pSample
, dwUser
);
1084 /* get start and stop positions in bytes */
1086 hr
= IMediaSample_GetTime(pSample
, &Start
, &Stop
);
1089 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1091 EnterCriticalSection(&This
->csList
);
1092 if (This
->bFlushing
)
1094 LeaveCriticalSection(&This
->csList
);
1095 return VFW_E_WRONG_STATE
;
1100 DWORD dwLength
= (DWORD
) BYTES_FROM_MEDIATIME(Stop
- Start
);
1101 DATAREQUEST
*pDataRq
;
1104 /* Try to insert above the waiting sample if possible */
1105 for (x
= This
->oldest_sample
; x
< This
->samples
; ++x
)
1107 if (!This
->sample_list
[x
].pSample
)
1111 if (x
>= This
->samples
)
1112 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1114 if (!This
->sample_list
[x
].pSample
)
1118 /* There must be a sample we have found */
1119 assert(x
< This
->samples
);
1120 ++This
->queued_number
;
1122 pDataRq
= This
->sample_list
+ x
;
1124 pDataRq
->ovl
.u
.s
.Offset
= (DWORD
) BYTES_FROM_MEDIATIME(Start
);
1125 pDataRq
->ovl
.u
.s
.OffsetHigh
= (DWORD
)(BYTES_FROM_MEDIATIME(Start
) >> (sizeof(DWORD
) * 8));
1126 pDataRq
->dwUserData
= dwUser
;
1128 /* we violate traditional COM rules here by maintaining
1129 * a reference to the sample, but not calling AddRef, but
1130 * that's what MSDN says to do */
1131 pDataRq
->pSample
= pSample
;
1133 /* this is definitely not how it is implemented on Win9x
1134 * as they do not support async reads on files, but it is
1135 * sooo much easier to use this than messing around with threads!
1137 if (!ReadFile(This
->hFile
, pBuffer
, dwLength
, NULL
, &pDataRq
->ovl
))
1138 hr
= HRESULT_FROM_WIN32(GetLastError());
1140 /* ERROR_IO_PENDING is not actually an error since this is what we want! */
1141 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1145 LeaveCriticalSection(&This
->csList
);
1147 TRACE("-- %x\n", hr
);
1151 static HRESULT WINAPI
FileAsyncReader_WaitForNext(IAsyncReader
* iface
, DWORD dwTimeout
, IMediaSample
** ppSample
, DWORD_PTR
* pdwUser
)
1154 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1157 TRACE("(%u, %p, %p)\n", dwTimeout
, ppSample
, pdwUser
);
1162 EnterCriticalSection(&This
->csList
);
1163 if (!This
->bFlushing
)
1165 LONG oldest
= This
->oldest_sample
;
1167 if (!This
->queued_number
)
1169 /* It could be that nothing is queued right now, but that can be fixed */
1170 WARN("Called without samples in queue and not flushing!!\n");
1172 LeaveCriticalSection(&This
->csList
);
1174 /* wait for an object to read, or time out */
1175 buffer
= WaitForMultipleObjectsEx(This
->samples
+1, This
->handle_list
+ oldest
, FALSE
, dwTimeout
, TRUE
);
1177 EnterCriticalSection(&This
->csList
);
1178 if (buffer
<= This
->samples
)
1180 /* Re-scale the buffer back to normal */
1183 /* Uh oh, we overshot the flusher handle, renormalize it back to 0..Samples-1 */
1184 if (buffer
> This
->samples
)
1185 buffer
-= This
->samples
+ 1;
1186 assert(buffer
<= This
->samples
);
1189 if (buffer
>= This
->samples
)
1191 if (buffer
!= This
->samples
)
1193 FIXME("Returned: %u (%08x)\n", buffer
, GetLastError());
1197 hr
= VFW_E_WRONG_STATE
;
1201 --This
->queued_number
;
1204 if (This
->bFlushing
&& buffer
== ~0)
1206 for (buffer
= 0; buffer
< This
->samples
; ++buffer
)
1208 if (This
->sample_list
[buffer
].pSample
)
1210 ResetEvent(This
->handle_list
[buffer
]);
1214 if (buffer
== This
->samples
)
1216 assert(!This
->queued_number
);
1221 --This
->queued_number
;
1228 REFERENCE_TIME rtStart
, rtStop
;
1229 REFERENCE_TIME rtSampleStart
, rtSampleStop
;
1230 DATAREQUEST
*pDataRq
= This
->sample_list
+ buffer
;
1233 /* get any errors */
1234 if (!This
->bFlushing
&& !GetOverlappedResult(This
->hFile
, &pDataRq
->ovl
, &dwBytes
, FALSE
))
1235 hr
= HRESULT_FROM_WIN32(GetLastError());
1237 /* Return the sample no matter what so it can be destroyed */
1238 *ppSample
= pDataRq
->pSample
;
1239 *pdwUser
= pDataRq
->dwUserData
;
1241 if (This
->bFlushing
)
1242 hr
= VFW_E_WRONG_STATE
;
1247 /* Set the time on the sample */
1248 IMediaSample_SetActualDataLength(pDataRq
->pSample
, dwBytes
);
1250 rtStart
= (DWORD64
)pDataRq
->ovl
.u
.s
.Offset
+ ((DWORD64
)pDataRq
->ovl
.u
.s
.OffsetHigh
<< 32);
1251 rtStart
= MEDIATIME_FROM_BYTES(rtStart
);
1252 rtStop
= rtStart
+ MEDIATIME_FROM_BYTES(dwBytes
);
1254 IMediaSample_GetTime(pDataRq
->pSample
, &rtSampleStart
, &rtSampleStop
);
1255 assert(rtStart
== rtSampleStart
);
1256 assert(rtStop
<= rtSampleStop
);
1258 IMediaSample_SetTime(pDataRq
->pSample
, &rtStart
, &rtStop
);
1259 assert(rtStart
== rtSampleStart
);
1261 assert(rtStop
== rtSampleStop
);
1263 assert(rtStop
== rtStart
);
1265 This
->sample_list
[buffer
].pSample
= NULL
;
1266 assert(This
->oldest_sample
< This
->samples
);
1268 if (buffer
== This
->oldest_sample
)
1271 for (x
= This
->oldest_sample
+ 1; x
< This
->samples
; ++x
)
1272 if (This
->sample_list
[x
].pSample
)
1274 if (x
>= This
->samples
)
1275 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1276 if (This
->sample_list
[x
].pSample
)
1278 if (This
->oldest_sample
== x
)
1279 /* No samples found, reset to 0 */
1281 This
->oldest_sample
= x
;
1284 LeaveCriticalSection(&This
->csList
);
1286 TRACE("-- %x\n", hr
);
1290 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
);
1292 static HRESULT WINAPI
FileAsyncReader_SyncReadAligned(IAsyncReader
* iface
, IMediaSample
* pSample
)
1295 REFERENCE_TIME tStart
;
1296 REFERENCE_TIME tStop
;
1299 TRACE("(%p)\n", pSample
);
1301 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
1304 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1307 hr
= FileAsyncReader_SyncRead(iface
,
1308 BYTES_FROM_MEDIATIME(tStart
),
1309 (LONG
) BYTES_FROM_MEDIATIME(tStop
- tStart
),
1312 TRACE("-- %x\n", hr
);
1316 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
)
1320 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1322 TRACE("(%x%08x, %d, %p)\n", (ULONG
)(llPosition
>> 32), (ULONG
)llPosition
, lLength
, pBuffer
);
1324 ZeroMemory(&ovl
, sizeof(ovl
));
1326 ovl
.hEvent
= CreateEventW(NULL
, 0, 0, NULL
);
1327 /* NOTE: llPosition is the actual byte position to start reading from */
1328 ovl
.u
.s
.Offset
= (DWORD
) llPosition
;
1329 ovl
.u
.s
.OffsetHigh
= (DWORD
) (llPosition
>> (sizeof(DWORD
) * 8));
1331 if (!ReadFile(This
->hFile
, pBuffer
, lLength
, NULL
, &ovl
))
1332 hr
= HRESULT_FROM_WIN32(GetLastError());
1334 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1341 if (!GetOverlappedResult(This
->hFile
, &ovl
, &dwBytesRead
, TRUE
))
1342 hr
= HRESULT_FROM_WIN32(GetLastError());
1345 CloseHandle(ovl
.hEvent
);
1347 TRACE("-- %x\n", hr
);
1351 static HRESULT WINAPI
FileAsyncReader_Length(IAsyncReader
* iface
, LONGLONG
* pTotal
, LONGLONG
* pAvailable
)
1355 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1357 TRACE("(%p, %p)\n", pTotal
, pAvailable
);
1359 if (((dwSizeLow
= GetFileSize(This
->hFile
, &dwSizeHigh
)) == -1) &&
1360 (GetLastError() != NO_ERROR
))
1361 return HRESULT_FROM_WIN32(GetLastError());
1363 *pTotal
= (LONGLONG
)dwSizeLow
| (LONGLONG
)dwSizeHigh
<< (sizeof(DWORD
) * 8);
1365 *pAvailable
= *pTotal
;
1370 static HRESULT WINAPI
FileAsyncReader_BeginFlush(IAsyncReader
* iface
)
1372 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1376 EnterCriticalSection(&This
->csList
);
1377 This
->bFlushing
= TRUE
;
1378 CancelIo(This
->hFile
);
1379 SetEvent(This
->handle_list
[This
->samples
]);
1380 LeaveCriticalSection(&This
->csList
);
1385 static HRESULT WINAPI
FileAsyncReader_EndFlush(IAsyncReader
* iface
)
1387 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1392 EnterCriticalSection(&This
->csList
);
1393 ResetEvent(This
->handle_list
[This
->samples
]);
1394 This
->bFlushing
= FALSE
;
1395 for (x
= 0; x
< This
->samples
; ++x
)
1396 assert(!This
->sample_list
[x
].pSample
);
1398 LeaveCriticalSection(&This
->csList
);
1403 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
=
1405 FileAsyncReader_QueryInterface
,
1406 FileAsyncReader_AddRef
,
1407 FileAsyncReader_Release
,
1408 FileAsyncReader_RequestAllocator
,
1409 FileAsyncReader_Request
,
1410 FileAsyncReader_WaitForNext
,
1411 FileAsyncReader_SyncReadAligned
,
1412 FileAsyncReader_SyncRead
,
1413 FileAsyncReader_Length
,
1414 FileAsyncReader_BeginFlush
,
1415 FileAsyncReader_EndFlush
,
1419 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1420 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1421 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
1424 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1425 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1426 return IUnknown_AddRef((IUnknown
*)This
);
1429 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1430 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1431 return IUnknown_Release((IUnknown
*)This
);
1434 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1435 return AM_FILTER_MISC_FLAGS_IS_SOURCE
;
1438 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1439 AMFilterMiscFlags_QueryInterface
,
1440 AMFilterMiscFlags_AddRef
,
1441 AMFilterMiscFlags_Release
,
1442 AMFilterMiscFlags_GetMiscFlags