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 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
24 #include "quartz_private.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
38 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
40 typedef struct AsyncReader
43 IFileSourceFilter IFileSourceFilter_iface
;
44 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
51 static inline AsyncReader
*impl_from_BaseFilter(BaseFilter
*iface
)
53 return CONTAINING_RECORD(iface
, AsyncReader
, filter
);
56 static inline AsyncReader
*impl_from_IBaseFilter(IBaseFilter
*iface
)
58 return CONTAINING_RECORD(iface
, AsyncReader
, filter
.IBaseFilter_iface
);
61 static inline AsyncReader
*impl_from_IFileSourceFilter(IFileSourceFilter
*iface
)
63 return CONTAINING_RECORD(iface
, AsyncReader
, IFileSourceFilter_iface
);
66 static inline AsyncReader
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
68 return CONTAINING_RECORD(iface
, AsyncReader
, IAMFilterMiscFlags_iface
);
71 static const IBaseFilterVtbl AsyncReader_Vtbl
;
72 static const IFileSourceFilterVtbl FileSource_Vtbl
;
73 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
;
74 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
76 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
78 static const WCHAR mediatype_name
[] = {
79 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 };
80 static const WCHAR subtype_name
[] = {
81 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 };
82 static const WCHAR source_filter_name
[] = {
83 'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
85 static HRESULT
process_extensions(HKEY hkeyExtensions
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
96 /* Get the part of the name that matters */
97 extension
= PathFindExtensionW(pszFileName
);
98 if (*extension
!= '.')
101 l
= RegOpenKeyExW(hkeyExtensions
, extension
, 0, KEY_READ
, &hsub
);
107 size
= sizeof(keying
);
108 l
= RegQueryValueExW(hsub
, mediatype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
110 CLSIDFromString(keying
, majorType
);
115 size
= sizeof(keying
);
117 l
= RegQueryValueExW(hsub
, subtype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
119 CLSIDFromString(keying
, minorType
);
124 size
= sizeof(keying
);
126 l
= RegQueryValueExW(hsub
, source_filter_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
128 CLSIDFromString(keying
, sourceFilter
);
138 static unsigned char byte_from_hex_char(WCHAR wHex
)
140 switch (tolowerW(wHex
))
152 return (wHex
- '0') & 0xf;
159 return (wHex
- 'a' + 10) & 0xf;
165 static HRESULT
process_pattern_string(LPCWSTR wszPatternString
, IAsyncReader
* pReader
)
175 TRACE("\t\tPattern string: %s\n", debugstr_w(wszPatternString
));
177 /* format: "offset, bytestocompare, mask, value" */
179 ulOffset
= strtolW(wszPatternString
, NULL
, 10);
181 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
184 wszPatternString
++; /* skip ',' */
186 ulBytes
= strtolW(wszPatternString
, NULL
, 10);
188 pbMask
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
189 pbValue
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ulBytes
);
190 pbFile
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
192 /* default mask is match everything */
193 memset(pbMask
, 0xFF, ulBytes
);
195 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
200 wszPatternString
++; /* skip ',' */
201 while (!isxdigitW(*wszPatternString
) && (*wszPatternString
!= ',')) wszPatternString
++;
203 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
205 if ((strpos
% 2) == 1) /* odd numbered position */
206 pbMask
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
208 pbMask
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
211 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
214 wszPatternString
++; /* skip ',' */
219 for ( ; !isxdigitW(*wszPatternString
) && (*wszPatternString
!= ','); wszPatternString
++)
222 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
224 if ((strpos
% 2) == 1) /* odd numbered position */
225 pbValue
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
227 pbValue
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
232 hr
= IAsyncReader_SyncRead(pReader
, ulOffset
, ulBytes
, pbFile
);
237 for (i
= 0; i
< ulBytes
; i
++)
238 if ((pbFile
[i
] & pbMask
[i
]) != pbValue
[i
])
245 HeapFree(GetProcessHeap(), 0, pbMask
);
246 HeapFree(GetProcessHeap(), 0, pbValue
);
247 HeapFree(GetProcessHeap(), 0, pbFile
);
249 /* if we encountered no errors with this string, and there is a following tuple, then we
250 * have to match that as well to succeed */
251 if ((hr
== S_OK
) && (wszPatternString
= strchrW(wszPatternString
, ',')))
252 return process_pattern_string(wszPatternString
+ 1, pReader
);
257 HRESULT
GetClassMediaFile(IAsyncReader
* pReader
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
259 HKEY hkeyMediaType
= NULL
;
263 static const WCHAR wszMediaType
[] = {'M','e','d','i','a',' ','T','y','p','e',0};
265 TRACE("(%p, %s, %p, %p)\n", pReader
, debugstr_w(pszFileName
), majorType
, minorType
);
268 *majorType
= GUID_NULL
;
270 *minorType
= GUID_NULL
;
272 *sourceFilter
= GUID_NULL
;
274 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszMediaType
, 0, KEY_READ
, &hkeyMediaType
);
275 hr
= HRESULT_FROM_WIN32(lRet
);
281 for (indexMajor
= 0; !bFound
; indexMajor
++)
284 WCHAR wszMajorKeyName
[CHARS_IN_GUID
];
285 DWORD dwKeyNameLength
= sizeof(wszMajorKeyName
) / sizeof(wszMajorKeyName
[0]);
286 static const WCHAR wszExtensions
[] = {'E','x','t','e','n','s','i','o','n','s',0};
288 if (RegEnumKeyExW(hkeyMediaType
, indexMajor
, wszMajorKeyName
, &dwKeyNameLength
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
290 if (RegOpenKeyExW(hkeyMediaType
, wszMajorKeyName
, 0, KEY_READ
, &hkeyMajor
) != ERROR_SUCCESS
)
292 TRACE("%s\n", debugstr_w(wszMajorKeyName
));
293 if (!strcmpW(wszExtensions
, wszMajorKeyName
))
295 if (process_extensions(hkeyMajor
, pszFileName
, majorType
, minorType
, sourceFilter
) == S_OK
)
298 /* We need a reader interface to check bytes */
303 for (indexMinor
= 0; !bFound
; indexMinor
++)
306 WCHAR wszMinorKeyName
[CHARS_IN_GUID
];
307 DWORD dwMinorKeyNameLen
= sizeof(wszMinorKeyName
) / sizeof(wszMinorKeyName
[0]);
308 WCHAR wszSourceFilterKeyName
[CHARS_IN_GUID
];
309 DWORD dwSourceFilterKeyNameLen
= sizeof(wszSourceFilterKeyName
);
313 if (RegEnumKeyExW(hkeyMajor
, indexMinor
, wszMinorKeyName
, &dwMinorKeyNameLen
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
316 if (RegOpenKeyExW(hkeyMajor
, wszMinorKeyName
, 0, KEY_READ
, &hkeyMinor
) != ERROR_SUCCESS
)
319 TRACE("\t%s\n", debugstr_w(wszMinorKeyName
));
321 if (RegQueryInfoKeyW(hkeyMinor
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &maxValueLen
, NULL
, NULL
) != ERROR_SUCCESS
)
324 for (indexValue
= 0; !bFound
; indexValue
++)
327 WCHAR wszValueName
[14]; /* longest name we should encounter will be "Source Filter" */
328 LPWSTR wszPatternString
= HeapAlloc(GetProcessHeap(), 0, maxValueLen
);
329 DWORD dwValueNameLen
= sizeof(wszValueName
) / sizeof(wszValueName
[0]); /* remember this is in chars */
330 DWORD dwDataLen
= maxValueLen
; /* remember this is in bytes */
332 if (RegEnumValueW(hkeyMinor
, indexValue
, wszValueName
, &dwValueNameLen
, NULL
, &dwType
, (LPBYTE
)wszPatternString
, &dwDataLen
) != ERROR_SUCCESS
)
334 HeapFree(GetProcessHeap(), 0, wszPatternString
);
338 if (strcmpW(wszValueName
, source_filter_name
)==0) {
339 HeapFree(GetProcessHeap(), 0, wszPatternString
);
343 /* if it is not the source filter value */
344 if (process_pattern_string(wszPatternString
, pReader
) == S_OK
)
346 HeapFree(GetProcessHeap(), 0, wszPatternString
);
347 if (majorType
&& FAILED(CLSIDFromString(wszMajorKeyName
, majorType
)))
349 if (minorType
&& FAILED(CLSIDFromString(wszMinorKeyName
, minorType
)))
353 /* Look up the source filter key */
354 if (RegQueryValueExW(hkeyMinor
, source_filter_name
, NULL
, NULL
, (LPBYTE
)wszSourceFilterKeyName
, &dwSourceFilterKeyNameLen
))
356 if (FAILED(CLSIDFromString(wszSourceFilterKeyName
, sourceFilter
)))
361 HeapFree(GetProcessHeap(), 0, wszPatternString
);
363 CloseHandle(hkeyMinor
);
366 CloseHandle(hkeyMajor
);
369 CloseHandle(hkeyMediaType
);
371 if (SUCCEEDED(hr
) && !bFound
)
373 ERR("Media class not found\n");
378 TRACE("Found file's class:\n");
380 TRACE("\tmajor = %s\n", qzdebugstr_guid(majorType
));
382 TRACE("\tsubtype = %s\n", qzdebugstr_guid(minorType
));
384 TRACE("\tsource filter = %s\n", qzdebugstr_guid(sourceFilter
));
390 static IPin
* WINAPI
AsyncReader_GetPin(BaseFilter
*iface
, int pos
)
392 AsyncReader
*This
= impl_from_BaseFilter(iface
);
394 if (pos
>= 1 || !This
->pOutputPin
)
397 IPin_AddRef(This
->pOutputPin
);
398 return This
->pOutputPin
;
401 static LONG WINAPI
AsyncReader_GetPinCount(BaseFilter
*iface
)
403 AsyncReader
*This
= impl_from_BaseFilter(iface
);
405 if (!This
->pOutputPin
)
411 static const BaseFilterFuncTable BaseFuncTable
= {
413 AsyncReader_GetPinCount
416 HRESULT
AsyncReader_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
418 AsyncReader
*pAsyncRead
;
421 return CLASS_E_NOAGGREGATION
;
423 pAsyncRead
= CoTaskMemAlloc(sizeof(AsyncReader
));
426 return E_OUTOFMEMORY
;
428 BaseFilter_Init(&pAsyncRead
->filter
, &AsyncReader_Vtbl
, &CLSID_AsyncReader
, (DWORD_PTR
)(__FILE__
": AsyncReader.csFilter"), &BaseFuncTable
);
430 pAsyncRead
->IFileSourceFilter_iface
.lpVtbl
= &FileSource_Vtbl
;
431 pAsyncRead
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
432 pAsyncRead
->pOutputPin
= NULL
;
434 pAsyncRead
->pszFileName
= NULL
;
435 pAsyncRead
->pmt
= NULL
;
439 TRACE("-- created at %p\n", pAsyncRead
);
444 /** IUnknown methods **/
446 static HRESULT WINAPI
AsyncReader_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
448 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
450 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
454 if (IsEqualIID(riid
, &IID_IUnknown
))
455 *ppv
= &This
->filter
.IBaseFilter_iface
;
456 else if (IsEqualIID(riid
, &IID_IPersist
))
457 *ppv
= &This
->filter
.IBaseFilter_iface
;
458 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
459 *ppv
= &This
->filter
.IBaseFilter_iface
;
460 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
461 *ppv
= &This
->filter
.IBaseFilter_iface
;
462 else if (IsEqualIID(riid
, &IID_IFileSourceFilter
))
463 *ppv
= &This
->IFileSourceFilter_iface
;
464 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
465 *ppv
= &This
->IAMFilterMiscFlags_iface
;
469 IUnknown_AddRef((IUnknown
*)(*ppv
));
473 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
) &&
474 !IsEqualIID(riid
, &IID_IVideoWindow
) && !IsEqualIID(riid
, &IID_IBasicAudio
))
475 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
477 return E_NOINTERFACE
;
480 static ULONG WINAPI
AsyncReader_Release(IBaseFilter
* iface
)
482 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
483 ULONG refCount
= InterlockedDecrement(&This
->filter
.refCount
);
485 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
489 if (This
->pOutputPin
)
492 if(SUCCEEDED(IPin_ConnectedTo(This
->pOutputPin
, &pConnectedTo
)))
494 IPin_Disconnect(pConnectedTo
);
495 IPin_Release(pConnectedTo
);
497 IPin_Disconnect(This
->pOutputPin
);
498 IPin_Release(This
->pOutputPin
);
500 CoTaskMemFree(This
->pszFileName
);
502 FreeMediaType(This
->pmt
);
503 BaseFilter_Destroy(&This
->filter
);
511 /** IMediaFilter methods **/
513 static HRESULT WINAPI
AsyncReader_Stop(IBaseFilter
* iface
)
515 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
519 This
->filter
.state
= State_Stopped
;
524 static HRESULT WINAPI
AsyncReader_Pause(IBaseFilter
* iface
)
526 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
530 This
->filter
.state
= State_Paused
;
535 static HRESULT WINAPI
AsyncReader_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
537 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
539 TRACE("(%x%08x)\n", (ULONG
)(tStart
>> 32), (ULONG
)tStart
);
541 This
->filter
.state
= State_Running
;
546 /** IBaseFilter methods **/
548 static HRESULT WINAPI
AsyncReader_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
550 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
551 TRACE("(%s, %p)\n", debugstr_w(Id
), ppPin
);
556 if (strcmpW(Id
, wszOutputPinName
))
559 return VFW_E_NOT_FOUND
;
562 *ppPin
= This
->pOutputPin
;
567 static const IBaseFilterVtbl AsyncReader_Vtbl
=
569 AsyncReader_QueryInterface
,
570 BaseFilterImpl_AddRef
,
572 BaseFilterImpl_GetClassID
,
576 BaseFilterImpl_GetState
,
577 BaseFilterImpl_SetSyncSource
,
578 BaseFilterImpl_GetSyncSource
,
579 BaseFilterImpl_EnumPins
,
581 BaseFilterImpl_QueryFilterInfo
,
582 BaseFilterImpl_JoinFilterGraph
,
583 BaseFilterImpl_QueryVendorInfo
586 static HRESULT WINAPI
FileSource_QueryInterface(IFileSourceFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
588 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
590 return IBaseFilter_QueryInterface(&This
->filter
.IBaseFilter_iface
, riid
, ppv
);
593 static ULONG WINAPI
FileSource_AddRef(IFileSourceFilter
* iface
)
595 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
597 return IBaseFilter_AddRef(&This
->filter
.IBaseFilter_iface
);
600 static ULONG WINAPI
FileSource_Release(IFileSourceFilter
* iface
)
602 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
604 return IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);
607 static HRESULT WINAPI
FileSource_Load(IFileSourceFilter
* iface
, LPCOLESTR pszFileName
, const AM_MEDIA_TYPE
* pmt
)
611 IAsyncReader
* pReader
= NULL
;
612 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
614 TRACE("(%s, %p)\n", debugstr_w(pszFileName
), pmt
);
620 /* FIXME: check the sharing values that native uses */
621 hFile
= CreateFileW(pszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_FLAG_OVERLAPPED
, NULL
);
623 if (hFile
== INVALID_HANDLE_VALUE
)
625 return HRESULT_FROM_WIN32(GetLastError());
629 hr
= FileAsyncReader_Construct(hFile
, &This
->filter
.IBaseFilter_iface
, &This
->filter
.csFilter
, &This
->pOutputPin
);
630 BaseFilterImpl_IncrementPinVersion(&This
->filter
);
633 hr
= IPin_QueryInterface(This
->pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
635 /* store file name & media type */
638 CoTaskMemFree(This
->pszFileName
);
640 FreeMediaType(This
->pmt
);
642 This
->pszFileName
= CoTaskMemAlloc((strlenW(pszFileName
) + 1) * sizeof(WCHAR
));
643 strcpyW(This
->pszFileName
, pszFileName
);
645 This
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
648 This
->pmt
->bFixedSizeSamples
= TRUE
;
649 This
->pmt
->bTemporalCompression
= FALSE
;
650 This
->pmt
->cbFormat
= 0;
651 This
->pmt
->pbFormat
= NULL
;
652 This
->pmt
->pUnk
= NULL
;
653 This
->pmt
->lSampleSize
= 0;
654 This
->pmt
->formattype
= FORMAT_None
;
655 hr
= GetClassMediaFile(pReader
, pszFileName
, &This
->pmt
->majortype
, &This
->pmt
->subtype
, NULL
);
658 This
->pmt
->majortype
= MEDIATYPE_Stream
;
659 This
->pmt
->subtype
= MEDIASUBTYPE_NULL
;
664 CopyMediaType(This
->pmt
, pmt
);
668 IAsyncReader_Release(pReader
);
672 if (This
->pOutputPin
)
674 IPin_Release(This
->pOutputPin
);
675 This
->pOutputPin
= NULL
;
678 CoTaskMemFree(This
->pszFileName
);
680 FreeMediaType(This
->pmt
);
681 This
->pszFileName
= NULL
;
687 /* FIXME: check return codes */
691 static HRESULT WINAPI
FileSource_GetCurFile(IFileSourceFilter
* iface
, LPOLESTR
* ppszFileName
, AM_MEDIA_TYPE
* pmt
)
693 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
695 TRACE("(%p, %p)\n", ppszFileName
, pmt
);
700 /* copy file name & media type if available, otherwise clear the outputs */
701 if (This
->pszFileName
)
703 *ppszFileName
= CoTaskMemAlloc((strlenW(This
->pszFileName
) + 1) * sizeof(WCHAR
));
704 strcpyW(*ppszFileName
, This
->pszFileName
);
707 *ppszFileName
= NULL
;
712 CopyMediaType(pmt
, This
->pmt
);
714 ZeroMemory(pmt
, sizeof(*pmt
));
720 static const IFileSourceFilterVtbl FileSource_Vtbl
=
722 FileSource_QueryInterface
,
726 FileSource_GetCurFile
730 /* the dwUserData passed back to user */
731 typedef struct DATAREQUEST
733 IMediaSample
* pSample
; /* sample passed to us by user */
734 DWORD_PTR dwUserData
; /* user data passed to us */
735 OVERLAPPED ovl
; /* our overlapped structure */
738 typedef struct FileAsyncReader
741 IAsyncReader IAsyncReader_iface
;
743 ALLOCATOR_PROPERTIES allocProps
;
746 /* Why would you need more? Every sample has its own handle */
750 CRITICAL_SECTION csList
; /* critical section to prevent concurrency issues */
751 DATAREQUEST
*sample_list
;
753 /* Have a handle for every sample, and then one more as flushing handle */
757 static inline FileAsyncReader
*impl_from_IPin(IPin
*iface
)
759 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
.IPin_iface
);
762 static inline FileAsyncReader
*impl_from_BasePin(BasePin
*iface
)
764 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
);
767 static inline FileAsyncReader
*impl_from_BaseOutputPin(BaseOutputPin
*iface
)
769 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
);
772 static inline BaseOutputPin
*impl_BaseOutputPin_from_BasePin(BasePin
*iface
)
774 return CONTAINING_RECORD(iface
, BaseOutputPin
, pin
);
777 static inline FileAsyncReader
*impl_from_IAsyncReader(IAsyncReader
*iface
)
779 return CONTAINING_RECORD(iface
, FileAsyncReader
, IAsyncReader_iface
);
782 static HRESULT WINAPI
FileAsyncReaderPin_QueryAccept(IPin
*iface
, const AM_MEDIA_TYPE
*pmt
)
784 FileAsyncReader
*This
= impl_from_IPin(iface
);
785 AM_MEDIA_TYPE
*pmt_filter
= impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
;
787 FIXME("(%p, %p)\n", iface
, pmt
);
789 if (IsEqualGUID(&pmt
->majortype
, &pmt_filter
->majortype
) &&
790 IsEqualGUID(&pmt
->subtype
, &pmt_filter
->subtype
) &&
791 IsEqualGUID(&pmt
->formattype
, &FORMAT_None
))
797 static HRESULT WINAPI
FileAsyncReaderPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
)
799 FileAsyncReader
*This
= impl_from_BasePin(iface
);
803 return VFW_S_NO_MORE_ITEMS
;
804 CopyMediaType(pmt
, impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
);
808 /* overridden pin functions */
810 static HRESULT WINAPI
FileAsyncReaderPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
812 FileAsyncReader
*This
= impl_from_IPin(iface
);
813 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
817 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IPin
))
818 *ppv
= &This
->pin
.pin
.IPin_iface
;
819 else if (IsEqualIID(riid
, &IID_IAsyncReader
))
820 *ppv
= &This
->IAsyncReader_iface
;
824 IUnknown_AddRef((IUnknown
*)*ppv
);
828 if (!IsEqualIID(riid
, &IID_IMediaSeeking
))
829 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
831 return E_NOINTERFACE
;
834 static ULONG WINAPI
FileAsyncReaderPin_Release(IPin
* iface
)
836 FileAsyncReader
*This
= impl_from_IPin(iface
);
837 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
840 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
844 CoTaskMemFree(This
->sample_list
);
845 if (This
->handle_list
)
847 for (x
= 0; x
<= This
->samples
; ++x
)
848 CloseHandle(This
->handle_list
[x
]);
849 CoTaskMemFree(This
->handle_list
);
851 CloseHandle(This
->hFile
);
852 This
->csList
.DebugInfo
->Spare
[0] = 0;
853 DeleteCriticalSection(&This
->csList
);
854 BaseOutputPin_Destroy(&This
->pin
);
860 static const IPinVtbl FileAsyncReaderPin_Vtbl
=
862 FileAsyncReaderPin_QueryInterface
,
864 FileAsyncReaderPin_Release
,
865 BaseOutputPinImpl_Connect
,
866 BaseOutputPinImpl_ReceiveConnection
,
867 BasePinImpl_Disconnect
,
868 BasePinImpl_ConnectedTo
,
869 BasePinImpl_ConnectionMediaType
,
870 BasePinImpl_QueryPinInfo
,
871 BasePinImpl_QueryDirection
,
873 FileAsyncReaderPin_QueryAccept
,
874 BasePinImpl_EnumMediaTypes
,
875 BasePinImpl_QueryInternalConnections
,
876 BaseOutputPinImpl_EndOfStream
,
877 BaseOutputPinImpl_BeginFlush
,
878 BaseOutputPinImpl_EndFlush
,
879 BasePinImpl_NewSegment
882 /* Function called as a helper to IPin_Connect */
883 /* specific AM_MEDIA_TYPE - it cannot be NULL */
884 /* this differs from standard OutputPin_AttemptConnection only in that it
885 * doesn't need the IMemInputPin interface on the receiving pin */
886 static HRESULT WINAPI
FileAsyncReaderPin_AttemptConnection(BasePin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
888 BaseOutputPin
*This
= impl_BaseOutputPin_from_BasePin(iface
);
891 TRACE("(%p, %p)\n", pReceivePin
, pmt
);
892 dump_AM_MEDIA_TYPE(pmt
);
894 /* FIXME: call queryacceptproc */
896 This
->pin
.pConnectedTo
= pReceivePin
;
897 IPin_AddRef(pReceivePin
);
898 CopyMediaType(&This
->pin
.mtCurrent
, pmt
);
900 hr
= IPin_ReceiveConnection(pReceivePin
, &iface
->IPin_iface
, pmt
);
904 IPin_Release(This
->pin
.pConnectedTo
);
905 This
->pin
.pConnectedTo
= NULL
;
906 FreeMediaType(&This
->pin
.mtCurrent
);
909 TRACE(" -- %x\n", hr
);
913 static HRESULT WINAPI
FileAsyncReaderPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
)
915 FileAsyncReader
*This
= impl_from_BaseOutputPin(iface
);
916 ALLOCATOR_PROPERTIES actual
;
918 if (ppropInputRequest
->cbAlign
&& ppropInputRequest
->cbAlign
!= This
->allocProps
.cbAlign
)
919 FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This
->allocProps
.cbAlign
, ppropInputRequest
->cbAlign
);
920 if (ppropInputRequest
->cbPrefix
)
921 FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This
->allocProps
.cbPrefix
, ppropInputRequest
->cbPrefix
);
922 if (ppropInputRequest
->cbBuffer
)
923 FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This
->allocProps
.cbBuffer
, ppropInputRequest
->cbBuffer
);
924 if (ppropInputRequest
->cBuffers
)
925 FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This
->allocProps
.cBuffers
, ppropInputRequest
->cBuffers
);
927 return IMemAllocator_SetProperties(pAlloc
, &This
->allocProps
, &actual
);
930 static const BaseOutputPinFuncTable output_BaseOutputFuncTable
= {
933 FileAsyncReaderPin_AttemptConnection
,
934 BasePinImpl_GetMediaTypeVersion
,
935 FileAsyncReaderPin_GetMediaType
937 FileAsyncReaderPin_DecideBufferSize
,
938 BaseOutputPinImpl_DecideAllocator
,
939 BaseOutputPinImpl_BreakConnect
942 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
948 piOutput
.dir
= PINDIR_OUTPUT
;
949 piOutput
.pFilter
= pBaseFilter
;
950 strcpyW(piOutput
.achName
, wszOutputPinName
);
951 hr
= BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl
, sizeof(FileAsyncReader
), &piOutput
, &output_BaseOutputFuncTable
, pCritSec
, ppPin
);
955 FileAsyncReader
*pPinImpl
= (FileAsyncReader
*)*ppPin
;
956 pPinImpl
->IAsyncReader_iface
.lpVtbl
= &FileAsyncReader_Vtbl
;
957 pPinImpl
->hFile
= hFile
;
958 pPinImpl
->bFlushing
= FALSE
;
959 pPinImpl
->sample_list
= NULL
;
960 pPinImpl
->handle_list
= NULL
;
961 pPinImpl
->queued_number
= 0;
962 InitializeCriticalSection(&pPinImpl
->csList
);
963 pPinImpl
->csList
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": FileAsyncReader.csList");
970 static HRESULT WINAPI
FileAsyncReader_QueryInterface(IAsyncReader
* iface
, REFIID riid
, LPVOID
* ppv
)
972 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
974 return IPin_QueryInterface(&This
->pin
.pin
.IPin_iface
, riid
, ppv
);
977 static ULONG WINAPI
FileAsyncReader_AddRef(IAsyncReader
* iface
)
979 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
981 return IPin_AddRef(&This
->pin
.pin
.IPin_iface
);
984 static ULONG WINAPI
FileAsyncReader_Release(IAsyncReader
* iface
)
986 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
988 return IPin_Release(&This
->pin
.pin
.IPin_iface
);
991 #define DEF_ALIGNMENT 1
993 static HRESULT WINAPI
FileAsyncReader_RequestAllocator(IAsyncReader
* iface
, IMemAllocator
* pPreferred
, ALLOCATOR_PROPERTIES
* pProps
, IMemAllocator
** ppActual
)
995 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
999 TRACE("(%p, %p, %p)\n", pPreferred
, pProps
, ppActual
);
1001 if (!pProps
->cbAlign
|| (pProps
->cbAlign
% DEF_ALIGNMENT
) != 0)
1002 pProps
->cbAlign
= DEF_ALIGNMENT
;
1006 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1007 /* FIXME: check we are still aligned */
1010 IMemAllocator_AddRef(pPreferred
);
1011 *ppActual
= pPreferred
;
1012 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1019 hr
= CoCreateInstance(&CLSID_MemoryAllocator
, NULL
, CLSCTX_INPROC
, &IID_IMemAllocator
, (LPVOID
*)&pPreferred
);
1023 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1024 /* FIXME: check we are still aligned */
1027 *ppActual
= pPreferred
;
1028 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1035 CoTaskMemFree(This
->sample_list
);
1036 if (This
->handle_list
)
1039 for (x
= 0; x
<= This
->samples
; ++x
)
1040 CloseHandle(This
->handle_list
[x
]);
1041 CoTaskMemFree(This
->handle_list
);
1044 This
->samples
= pProps
->cBuffers
;
1045 This
->oldest_sample
= 0;
1046 TRACE("Samples: %u\n", This
->samples
);
1047 This
->sample_list
= CoTaskMemAlloc(sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1048 This
->handle_list
= CoTaskMemAlloc(sizeof(HANDLE
) * pProps
->cBuffers
* 2);
1050 if (This
->sample_list
&& This
->handle_list
)
1053 ZeroMemory(This
->sample_list
, sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1054 for (x
= 0; x
< This
->samples
; ++x
)
1056 This
->sample_list
[x
].ovl
.hEvent
= This
->handle_list
[x
] = CreateEventW(NULL
, 0, 0, NULL
);
1057 if (x
+ 1 < This
->samples
)
1058 This
->handle_list
[This
->samples
+ 1 + x
] = This
->handle_list
[x
];
1060 This
->handle_list
[This
->samples
] = CreateEventW(NULL
, 1, 0, NULL
);
1061 This
->allocProps
= *pProps
;
1066 CoTaskMemFree(This
->sample_list
);
1067 CoTaskMemFree(This
->handle_list
);
1069 This
->sample_list
= NULL
;
1070 This
->handle_list
= NULL
;
1078 IMemAllocator_Release(pPreferred
);
1081 TRACE("-- %x\n", hr
);
1085 /* we could improve the Request/WaitForNext mechanism by allowing out of order samples.
1086 * however, this would be quite complicated to do and may be a bit error prone */
1087 static HRESULT WINAPI
FileAsyncReader_Request(IAsyncReader
* iface
, IMediaSample
* pSample
, DWORD_PTR dwUser
)
1090 REFERENCE_TIME Start
;
1091 REFERENCE_TIME Stop
;
1092 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1093 LPBYTE pBuffer
= NULL
;
1095 TRACE("(%p, %lx)\n", pSample
, dwUser
);
1100 /* get start and stop positions in bytes */
1102 hr
= IMediaSample_GetTime(pSample
, &Start
, &Stop
);
1105 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1107 EnterCriticalSection(&This
->csList
);
1108 if (This
->bFlushing
)
1110 LeaveCriticalSection(&This
->csList
);
1111 return VFW_E_WRONG_STATE
;
1116 DWORD dwLength
= (DWORD
) BYTES_FROM_MEDIATIME(Stop
- Start
);
1117 DATAREQUEST
*pDataRq
;
1120 /* Try to insert above the waiting sample if possible */
1121 for (x
= This
->oldest_sample
; x
< This
->samples
; ++x
)
1123 if (!This
->sample_list
[x
].pSample
)
1127 if (x
>= This
->samples
)
1128 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1130 if (!This
->sample_list
[x
].pSample
)
1134 /* There must be a sample we have found */
1135 assert(x
< This
->samples
);
1136 ++This
->queued_number
;
1138 pDataRq
= This
->sample_list
+ x
;
1140 pDataRq
->ovl
.u
.s
.Offset
= (DWORD
) BYTES_FROM_MEDIATIME(Start
);
1141 pDataRq
->ovl
.u
.s
.OffsetHigh
= (DWORD
)(BYTES_FROM_MEDIATIME(Start
) >> (sizeof(DWORD
) * 8));
1142 pDataRq
->dwUserData
= dwUser
;
1144 /* we violate traditional COM rules here by maintaining
1145 * a reference to the sample, but not calling AddRef, but
1146 * that's what MSDN says to do */
1147 pDataRq
->pSample
= pSample
;
1149 /* this is definitely not how it is implemented on Win9x
1150 * as they do not support async reads on files, but it is
1151 * sooo much easier to use this than messing around with threads!
1153 if (!ReadFile(This
->hFile
, pBuffer
, dwLength
, NULL
, &pDataRq
->ovl
))
1154 hr
= HRESULT_FROM_WIN32(GetLastError());
1156 /* ERROR_IO_PENDING is not actually an error since this is what we want! */
1157 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1161 LeaveCriticalSection(&This
->csList
);
1163 TRACE("-- %x\n", hr
);
1167 static HRESULT WINAPI
FileAsyncReader_WaitForNext(IAsyncReader
* iface
, DWORD dwTimeout
, IMediaSample
** ppSample
, DWORD_PTR
* pdwUser
)
1170 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1173 TRACE("(%u, %p, %p)\n", dwTimeout
, ppSample
, pdwUser
);
1178 EnterCriticalSection(&This
->csList
);
1179 if (!This
->bFlushing
)
1181 LONG oldest
= This
->oldest_sample
;
1183 if (!This
->queued_number
)
1185 /* It could be that nothing is queued right now, but that can be fixed */
1186 WARN("Called without samples in queue and not flushing!!\n");
1188 LeaveCriticalSection(&This
->csList
);
1190 /* wait for an object to read, or time out */
1191 buffer
= WaitForMultipleObjectsEx(This
->samples
+1, This
->handle_list
+ oldest
, FALSE
, dwTimeout
, TRUE
);
1193 EnterCriticalSection(&This
->csList
);
1194 if (buffer
<= This
->samples
)
1196 /* Re-scale the buffer back to normal */
1199 /* Uh oh, we overshot the flusher handle, renormalize it back to 0..Samples-1 */
1200 if (buffer
> This
->samples
)
1201 buffer
-= This
->samples
+ 1;
1202 assert(buffer
<= This
->samples
);
1205 if (buffer
>= This
->samples
)
1207 if (buffer
!= This
->samples
)
1209 FIXME("Returned: %u (%08x)\n", buffer
, GetLastError());
1213 hr
= VFW_E_WRONG_STATE
;
1217 --This
->queued_number
;
1220 if (This
->bFlushing
&& buffer
== ~0)
1222 for (buffer
= 0; buffer
< This
->samples
; ++buffer
)
1224 if (This
->sample_list
[buffer
].pSample
)
1226 ResetEvent(This
->handle_list
[buffer
]);
1230 if (buffer
== This
->samples
)
1232 assert(!This
->queued_number
);
1237 --This
->queued_number
;
1244 REFERENCE_TIME rtStart
, rtStop
;
1245 REFERENCE_TIME rtSampleStart
, rtSampleStop
;
1246 DATAREQUEST
*pDataRq
= This
->sample_list
+ buffer
;
1249 /* get any errors */
1250 if (!This
->bFlushing
&& !GetOverlappedResult(This
->hFile
, &pDataRq
->ovl
, &dwBytes
, FALSE
))
1251 hr
= HRESULT_FROM_WIN32(GetLastError());
1253 /* Return the sample no matter what so it can be destroyed */
1254 *ppSample
= pDataRq
->pSample
;
1255 *pdwUser
= pDataRq
->dwUserData
;
1257 if (This
->bFlushing
)
1258 hr
= VFW_E_WRONG_STATE
;
1263 /* Set the time on the sample */
1264 IMediaSample_SetActualDataLength(pDataRq
->pSample
, dwBytes
);
1266 rtStart
= (DWORD64
)pDataRq
->ovl
.u
.s
.Offset
+ ((DWORD64
)pDataRq
->ovl
.u
.s
.OffsetHigh
<< 32);
1267 rtStart
= MEDIATIME_FROM_BYTES(rtStart
);
1268 rtStop
= rtStart
+ MEDIATIME_FROM_BYTES(dwBytes
);
1270 IMediaSample_GetTime(pDataRq
->pSample
, &rtSampleStart
, &rtSampleStop
);
1271 assert(rtStart
== rtSampleStart
);
1272 assert(rtStop
<= rtSampleStop
);
1274 IMediaSample_SetTime(pDataRq
->pSample
, &rtStart
, &rtStop
);
1275 assert(rtStart
== rtSampleStart
);
1277 assert(rtStop
== rtSampleStop
);
1279 assert(rtStop
== rtStart
);
1281 This
->sample_list
[buffer
].pSample
= NULL
;
1282 assert(This
->oldest_sample
< This
->samples
);
1284 if (buffer
== This
->oldest_sample
)
1287 for (x
= This
->oldest_sample
+ 1; x
< This
->samples
; ++x
)
1288 if (This
->sample_list
[x
].pSample
)
1290 if (x
>= This
->samples
)
1291 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1292 if (This
->sample_list
[x
].pSample
)
1294 if (This
->oldest_sample
== x
)
1295 /* No samples found, reset to 0 */
1297 This
->oldest_sample
= x
;
1300 LeaveCriticalSection(&This
->csList
);
1302 TRACE("-- %x\n", hr
);
1306 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
);
1308 static HRESULT WINAPI
FileAsyncReader_SyncReadAligned(IAsyncReader
* iface
, IMediaSample
* pSample
)
1311 REFERENCE_TIME tStart
;
1312 REFERENCE_TIME tStop
;
1315 TRACE("(%p)\n", pSample
);
1317 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
1320 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1323 hr
= FileAsyncReader_SyncRead(iface
,
1324 BYTES_FROM_MEDIATIME(tStart
),
1325 (LONG
) BYTES_FROM_MEDIATIME(tStop
- tStart
),
1328 TRACE("-- %x\n", hr
);
1332 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
)
1336 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1338 TRACE("(%x%08x, %d, %p)\n", (ULONG
)(llPosition
>> 32), (ULONG
)llPosition
, lLength
, pBuffer
);
1340 ZeroMemory(&ovl
, sizeof(ovl
));
1342 ovl
.hEvent
= CreateEventW(NULL
, 0, 0, NULL
);
1343 /* NOTE: llPosition is the actual byte position to start reading from */
1344 ovl
.u
.s
.Offset
= (DWORD
) llPosition
;
1345 ovl
.u
.s
.OffsetHigh
= (DWORD
) (llPosition
>> (sizeof(DWORD
) * 8));
1347 if (!ReadFile(This
->hFile
, pBuffer
, lLength
, NULL
, &ovl
))
1348 hr
= HRESULT_FROM_WIN32(GetLastError());
1350 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1357 if (!GetOverlappedResult(This
->hFile
, &ovl
, &dwBytesRead
, TRUE
))
1358 hr
= HRESULT_FROM_WIN32(GetLastError());
1361 CloseHandle(ovl
.hEvent
);
1363 TRACE("-- %x\n", hr
);
1367 static HRESULT WINAPI
FileAsyncReader_Length(IAsyncReader
* iface
, LONGLONG
* pTotal
, LONGLONG
* pAvailable
)
1371 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1373 TRACE("(%p, %p)\n", pTotal
, pAvailable
);
1375 if (((dwSizeLow
= GetFileSize(This
->hFile
, &dwSizeHigh
)) == -1) &&
1376 (GetLastError() != NO_ERROR
))
1377 return HRESULT_FROM_WIN32(GetLastError());
1379 *pTotal
= (LONGLONG
)dwSizeLow
| (LONGLONG
)dwSizeHigh
<< (sizeof(DWORD
) * 8);
1381 *pAvailable
= *pTotal
;
1386 static HRESULT WINAPI
FileAsyncReader_BeginFlush(IAsyncReader
* iface
)
1388 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1392 EnterCriticalSection(&This
->csList
);
1393 This
->bFlushing
= TRUE
;
1394 CancelIo(This
->hFile
);
1395 SetEvent(This
->handle_list
[This
->samples
]);
1396 LeaveCriticalSection(&This
->csList
);
1401 static HRESULT WINAPI
FileAsyncReader_EndFlush(IAsyncReader
* iface
)
1403 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1408 EnterCriticalSection(&This
->csList
);
1409 ResetEvent(This
->handle_list
[This
->samples
]);
1410 This
->bFlushing
= FALSE
;
1411 for (x
= 0; x
< This
->samples
; ++x
)
1412 assert(!This
->sample_list
[x
].pSample
);
1414 LeaveCriticalSection(&This
->csList
);
1419 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
=
1421 FileAsyncReader_QueryInterface
,
1422 FileAsyncReader_AddRef
,
1423 FileAsyncReader_Release
,
1424 FileAsyncReader_RequestAllocator
,
1425 FileAsyncReader_Request
,
1426 FileAsyncReader_WaitForNext
,
1427 FileAsyncReader_SyncReadAligned
,
1428 FileAsyncReader_SyncRead
,
1429 FileAsyncReader_Length
,
1430 FileAsyncReader_BeginFlush
,
1431 FileAsyncReader_EndFlush
,
1435 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1436 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1437 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
1440 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1441 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1442 return IUnknown_AddRef((IUnknown
*)This
);
1445 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1446 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1447 return IUnknown_Release((IUnknown
*)This
);
1450 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1451 return AM_FILTER_MISC_FLAGS_IS_SOURCE
;
1454 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1455 AMFilterMiscFlags_QueryInterface
,
1456 AMFilterMiscFlags_AddRef
,
1457 AMFilterMiscFlags_Release
,
1458 AMFilterMiscFlags_GetMiscFlags