dmband: Rewrite band lbin list parsing.
[wine.git] / dlls / qcap / tests / qcap.c
bloba1e3e31bfff242cf5fb2f2c4c1edc2e30c4d5aa2
1 /*
2 * QCAP tests
4 * Copyright 2013 Damjan Jovanovic
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 <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #define COBJMACROS
26 #include <dshow.h>
27 #include <guiddef.h>
28 #include <devguid.h>
29 #include <stdio.h>
31 #include "wine/strmbase.h"
32 #include "wine/test.h"
34 #define DEFINE_EXPECT(func) \
35 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
37 #define SET_EXPECT(func) \
38 expect_ ## func = TRUE
40 #define CHECK_EXPECT2(func) \
41 do { \
42 ok(expect_ ##func, "unexpected call " #func "\n"); \
43 called_ ## func = TRUE; \
44 }while(0)
46 #define CHECK_EXPECT(func) \
47 do { \
48 CHECK_EXPECT2(func); \
49 expect_ ## func = FALSE; \
50 }while(0)
52 #define CHECK_CALLED(func) \
53 do { \
54 ok(called_ ## func, "expected " #func "\n"); \
55 expect_ ## func = called_ ## func = FALSE; \
56 }while(0)
58 DEFINE_EXPECT(ReceiveConnection);
59 DEFINE_EXPECT(GetAllocatorRequirements);
60 DEFINE_EXPECT(NotifyAllocator);
61 DEFINE_EXPECT(Reconnect);
62 DEFINE_EXPECT(MediaSeeking_GetPositions);
63 DEFINE_EXPECT(MemAllocator_GetProperties);
64 DEFINE_EXPECT(MemInputPin_QueryInterface_IStream);
65 DEFINE_EXPECT(MediaSample_QueryInterface_MediaSample2);
66 DEFINE_EXPECT(MediaSample_IsDiscontinuity);
67 DEFINE_EXPECT(MediaSample_IsPreroll);
68 DEFINE_EXPECT(MediaSample_IsSyncPoint);
69 DEFINE_EXPECT(MediaSample_GetTime);
70 DEFINE_EXPECT(MediaSample_GetMediaType);
71 DEFINE_EXPECT(MediaSample_GetPointer);
72 DEFINE_EXPECT(MediaSample_GetActualDataLength);
73 DEFINE_EXPECT(MediaSample_GetSize);
74 DEFINE_EXPECT(MediaSample_GetMediaTime);
76 typedef enum {
77 SOURCE_FILTER,
78 SINK_FILTER,
79 INTERMEDIATE_FILTER,
80 NOT_FILTER
81 } filter_type;
83 static const char* debugstr_filter_type(filter_type type)
85 switch(type) {
86 case SOURCE_FILTER:
87 return "SOURCE_FILTER";
88 case SINK_FILTER:
89 return "SINK_FILTER";
90 case INTERMEDIATE_FILTER:
91 return "INTERMEDIATE_FILTER";
92 default:
93 return "NOT_FILTER";
97 typedef enum {
98 BASEFILTER_ENUMPINS,
99 ENUMPINS_NEXT,
100 PIN_QUERYDIRECTION,
101 PIN_CONNECTEDTO,
102 PIN_QUERYPININFO,
103 KSPROPERTYSET_GET,
104 PIN_ENUMMEDIATYPES,
105 ENUMMEDIATYPES_RESET,
106 ENUMMEDIATYPES_NEXT,
107 GRAPHBUILDER_CONNECT,
108 BASEFILTER_GETSTATE,
109 BASEFILTER_QUERYINTERFACE,
111 } call_id;
113 static const struct {
114 call_id call_id;
115 filter_type filter_type;
116 BOOL wine_missing;
117 BOOL wine_extra;
118 BOOL optional; /* fails on wine if missing */
119 BOOL broken;
120 } *current_calls_list;
121 int call_no;
123 static void check_calls_list(const char *func, call_id id, filter_type type)
125 if(!current_calls_list)
126 return;
128 while(current_calls_list[call_no].wine_missing || current_calls_list[call_no].wine_extra ||
129 current_calls_list[call_no].optional || current_calls_list[call_no].broken) {
130 if(current_calls_list[call_no].wine_missing) {
131 todo_wine ok((current_calls_list[call_no].call_id == id && current_calls_list[call_no].filter_type == type) ||
132 broken(current_calls_list[call_no].optional && (current_calls_list[call_no].call_id != id ||
133 current_calls_list[call_no].filter_type != type)),
134 "missing call, got %s(%d), expected %d (%d)\n", func, id, current_calls_list[call_no].call_id, call_no);
136 if(current_calls_list[call_no].call_id != id || current_calls_list[call_no].filter_type != type)
137 call_no++;
138 else
139 break;
140 }else if(current_calls_list[call_no].wine_extra) {
141 todo_wine ok(current_calls_list[call_no].call_id != id || current_calls_list[call_no].filter_type != type,
142 "extra call, got %s(%d) (%d)\n", func, id, call_no);
144 if(current_calls_list[call_no].call_id == id && current_calls_list[call_no].filter_type == type) {
145 call_no++;
146 return;
148 call_no++;
149 }else if(current_calls_list[call_no].optional) {
150 ok((current_calls_list[call_no].call_id == id && current_calls_list[call_no].filter_type == type) ||
151 broken(current_calls_list[call_no].call_id != id || current_calls_list[call_no].filter_type != type),
152 "unexpected call: %s on %s (%d)\n", func, debugstr_filter_type(type), call_no);
154 if(current_calls_list[call_no].call_id != id || current_calls_list[call_no].filter_type != type)
155 call_no++;
156 else
157 break;
158 }else if(current_calls_list[call_no].broken) {
159 ok(broken(current_calls_list[call_no].call_id == id && current_calls_list[call_no].filter_type == type) ||
160 (current_calls_list[call_no].call_id != id || current_calls_list[call_no].filter_type != type),
161 "unexpected call: %s on %s (%d)\n", func, debugstr_filter_type(type), call_no);
163 if(current_calls_list[call_no].call_id == id && current_calls_list[call_no].filter_type == type)
164 break;
165 call_no++;
169 ok(current_calls_list[call_no].call_id == id, "unexpected call: %s on %s (%d)\n",
170 func, debugstr_filter_type(type), call_no);
171 if(current_calls_list[call_no].call_id != id)
172 return;
174 ok(current_calls_list[call_no].filter_type == type, "unexpected call: %s on %s (%d)\n",
175 func, debugstr_filter_type(type), call_no);
176 if(current_calls_list[call_no].filter_type != type)
177 return;
179 call_no++;
182 static HRESULT WINAPI GraphBuilder_QueryInterface(
183 IGraphBuilder *iface, REFIID riid, void **ppv)
185 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IFilterGraph)
186 || IsEqualIID(riid, &IID_IGraphBuilder))
188 *ppv = iface;
189 return S_OK;
192 ok(IsEqualIID(riid, &IID_IMediaEvent) || IsEqualIID(riid, &IID_IMediaEventSink),
193 "QueryInterface(%s)\n", wine_dbgstr_guid(riid));
194 *ppv = NULL;
195 return E_NOINTERFACE;
198 static ULONG WINAPI GraphBuilder_AddRef(IGraphBuilder *iface)
200 return 2;
203 static ULONG WINAPI GraphBuilder_Release(IGraphBuilder *iface)
205 return 1;
208 static HRESULT WINAPI GraphBuilder_AddFilter(IGraphBuilder *iface,
209 IBaseFilter *pFilter, LPCWSTR pName)
211 ok(0, "unexpected call\n");
212 return E_NOTIMPL;
215 static HRESULT WINAPI GraphBuilder_RemoveFilter(
216 IGraphBuilder *iface, IBaseFilter *pFilter)
218 ok(0, "unexpected call\n");
219 return E_NOTIMPL;
222 static HRESULT WINAPI GraphBuilder_EnumFilters(
223 IGraphBuilder *iface, IEnumFilters **ppEnum)
225 ok(0, "unexpected call\n");
226 return E_NOTIMPL;
229 static HRESULT WINAPI GraphBuilder_FindFilterByName(IGraphBuilder *iface,
230 LPCWSTR pName, IBaseFilter **ppFilter)
232 ok(0, "unexpected call\n");
233 return E_NOTIMPL;
236 static HRESULT WINAPI GraphBuilder_ConnectDirect(IGraphBuilder *iface,
237 IPin *ppinOut, IPin *ppinIn, const AM_MEDIA_TYPE *pmt)
239 ok(0, "unexpected call\n");
240 return E_NOTIMPL;
243 static HRESULT WINAPI GraphBuilder_Reconnect(IGraphBuilder *iface, IPin *ppin)
245 CHECK_EXPECT(Reconnect);
246 return S_OK;
249 static HRESULT WINAPI GraphBuilder_Disconnect(IGraphBuilder *iface, IPin *ppin)
251 ok(0, "unexpected call\n");
252 return E_NOTIMPL;
255 static HRESULT WINAPI GraphBuilder_SetDefaultSyncSource(IGraphBuilder *iface)
257 ok(0, "unexpected call\n");
258 return E_NOTIMPL;
261 static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface, IPin *ppinOut, IPin *ppinIn)
263 check_calls_list("GraphBuilder_Connect", GRAPHBUILDER_CONNECT, NOT_FILTER);
264 return S_OK;
267 static HRESULT WINAPI GraphBuilder_Render(IGraphBuilder *iface, IPin *ppinOut)
269 ok(0, "unexpected call\n");
270 return E_NOTIMPL;
273 static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
274 LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
276 ok(0, "unexpected call\n");
277 return E_NOTIMPL;
280 static HRESULT WINAPI GraphBuilder_AddSourceFilter(IGraphBuilder *iface, LPCWSTR lpcwstrFileName,
281 LPCWSTR lpcwstrFilterName, IBaseFilter **ppFilter)
283 ok(0, "unexpected call\n");
284 return E_NOTIMPL;
287 static HRESULT WINAPI GraphBuilder_SetLogFile(IGraphBuilder *iface, DWORD_PTR hFile)
289 ok(0, "unexpected call\n");
290 return E_NOTIMPL;
293 static HRESULT WINAPI GraphBuilder_Abort(IGraphBuilder *iface)
295 ok(0, "unexpected call\n");
296 return E_NOTIMPL;
299 static HRESULT WINAPI GraphBuilder_ShouldOperationContinue(IGraphBuilder *iface)
301 ok(0, "unexpected call\n");
302 return E_NOTIMPL;
305 static const IGraphBuilderVtbl GraphBuilder_vtbl = {
306 GraphBuilder_QueryInterface,
307 GraphBuilder_AddRef,
308 GraphBuilder_Release,
309 GraphBuilder_AddFilter,
310 GraphBuilder_RemoveFilter,
311 GraphBuilder_EnumFilters,
312 GraphBuilder_FindFilterByName,
313 GraphBuilder_ConnectDirect,
314 GraphBuilder_Reconnect,
315 GraphBuilder_Disconnect,
316 GraphBuilder_SetDefaultSyncSource,
317 GraphBuilder_Connect,
318 GraphBuilder_Render,
319 GraphBuilder_RenderFile,
320 GraphBuilder_AddSourceFilter,
321 GraphBuilder_SetLogFile,
322 GraphBuilder_Abort,
323 GraphBuilder_ShouldOperationContinue
326 static IGraphBuilder GraphBuilder = {&GraphBuilder_vtbl};
328 typedef struct {
329 IBaseFilter IBaseFilter_iface;
330 IEnumPins IEnumPins_iface;
331 IPin IPin_iface;
332 IKsPropertySet IKsPropertySet_iface;
333 IMemInputPin IMemInputPin_iface;
334 IMediaSeeking IMediaSeeking_iface;
335 IEnumMediaTypes IEnumMediaTypes_iface;
337 PIN_DIRECTION dir;
338 filter_type filter_type;
340 int enum_pins_pos;
341 int enum_media_types_pos;
342 } test_filter;
344 static test_filter* impl_from_IBaseFilter(IBaseFilter *iface)
346 return CONTAINING_RECORD(iface, test_filter, IBaseFilter_iface);
349 static HRESULT WINAPI BaseFilter_QueryInterface(IBaseFilter *iface, REFIID riid, void **ppv)
351 test_filter *This = impl_from_IBaseFilter(iface);
353 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPersist)
354 || IsEqualIID(riid, &IID_IMediaFilter) || IsEqualIID(riid, &IID_IBaseFilter)) {
355 *ppv = iface;
356 return S_OK;
359 check_calls_list("BaseFilter_QueryInterface", BASEFILTER_QUERYINTERFACE, This->filter_type);
360 ok(IsEqualIID(riid, &IID_IPin), "riid = %s\n", wine_dbgstr_guid(riid));
361 return E_NOINTERFACE;
364 static ULONG WINAPI BaseFilter_AddRef(IBaseFilter *iface)
366 return 2;
369 static ULONG WINAPI BaseFilter_Release(IBaseFilter *iface)
371 return 1;
374 static HRESULT WINAPI BaseFilter_GetClassID(IBaseFilter *iface, CLSID *pClassID)
376 ok(0, "unexpected call\n");
377 return E_NOTIMPL;
380 static HRESULT WINAPI BaseFilter_Stop(IBaseFilter *iface)
382 ok(0, "unexpected call\n");
383 return E_NOTIMPL;
386 static HRESULT WINAPI BaseFilter_Pause(IBaseFilter *iface)
388 ok(0, "unexpected call\n");
389 return E_NOTIMPL;
392 static HRESULT WINAPI BaseFilter_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
394 ok(0, "unexpected call\n");
395 return E_NOTIMPL;
398 static HRESULT WINAPI BaseFilter_GetState(IBaseFilter *iface,
399 DWORD dwMilliSecsTimeout, FILTER_STATE *State)
401 test_filter *This = impl_from_IBaseFilter(iface);
402 check_calls_list("BaseFilter_GetState", BASEFILTER_GETSTATE, This->filter_type);
403 return E_NOTIMPL;
406 static HRESULT WINAPI BaseFilter_SetSyncSource(
407 IBaseFilter *iface, IReferenceClock *pClock)
409 ok(0, "unexpected call\n");
410 return E_NOTIMPL;
413 static HRESULT WINAPI BaseFilter_GetSyncSource(
414 IBaseFilter *iface, IReferenceClock **pClock)
416 ok(0, "unexpected call\n");
417 return E_NOTIMPL;
420 static HRESULT WINAPI BaseFilter_EnumPins(
421 IBaseFilter *iface, IEnumPins **ppEnum)
423 test_filter *This = impl_from_IBaseFilter(iface);
424 check_calls_list("BaseFilter_EnumPins", BASEFILTER_ENUMPINS, This->filter_type);
426 *ppEnum = &This->IEnumPins_iface;
427 This->enum_pins_pos = 0;
428 return S_OK;
431 static HRESULT WINAPI BaseFilter_FindPin(IBaseFilter *iface,
432 LPCWSTR Id, IPin **ppPin)
434 ok(0, "unexpected call\n");
435 return E_NOTIMPL;
438 static HRESULT WINAPI BaseFilter_QueryFilterInfo(IBaseFilter *iface, FILTER_INFO *pInfo)
440 ok(0, "unexpected call\n");
441 return E_NOTIMPL;
444 static HRESULT WINAPI BaseFilter_JoinFilterGraph(IBaseFilter *iface,
445 IFilterGraph *pGraph, LPCWSTR pName)
447 ok(0, "unexpected call\n");
448 return E_NOTIMPL;
451 static HRESULT WINAPI BaseFilter_QueryVendorInfo(IBaseFilter *iface, LPWSTR *pVendorInfo)
453 ok(0, "unexpected call\n");
454 return E_NOTIMPL;
457 static const IBaseFilterVtbl BaseFilterVtbl = {
458 BaseFilter_QueryInterface,
459 BaseFilter_AddRef,
460 BaseFilter_Release,
461 BaseFilter_GetClassID,
462 BaseFilter_Stop,
463 BaseFilter_Pause,
464 BaseFilter_Run,
465 BaseFilter_GetState,
466 BaseFilter_SetSyncSource,
467 BaseFilter_GetSyncSource,
468 BaseFilter_EnumPins,
469 BaseFilter_FindPin,
470 BaseFilter_QueryFilterInfo,
471 BaseFilter_JoinFilterGraph,
472 BaseFilter_QueryVendorInfo
475 static test_filter* impl_from_IEnumPins(IEnumPins *iface)
477 return CONTAINING_RECORD(iface, test_filter, IEnumPins_iface);
480 static HRESULT WINAPI EnumPins_QueryInterface(IEnumPins *iface, REFIID riid, void **ppv)
482 ok(0, "unexpected call\n");
483 return E_NOTIMPL;
486 static ULONG WINAPI EnumPins_AddRef(IEnumPins *iface)
488 return 2;
491 static ULONG WINAPI EnumPins_Release(IEnumPins *iface)
493 return 1;
496 static HRESULT WINAPI EnumPins_Next(IEnumPins *iface,
497 ULONG cPins, IPin **ppPins, ULONG *pcFetched)
499 test_filter *This = impl_from_IEnumPins(iface);
500 check_calls_list("EnumPins_Next", ENUMPINS_NEXT, This->filter_type);
502 ok(cPins == 1, "cPins = %ld\n", cPins);
503 ok(ppPins != NULL, "ppPins == NULL\n");
504 ok(pcFetched != NULL, "pcFetched == NULL\n");
506 if(This->enum_pins_pos++ < (This->filter_type == INTERMEDIATE_FILTER ? 2 : 1)) {
507 *ppPins = &This->IPin_iface;
508 *pcFetched = 1;
509 return S_OK;
511 *pcFetched = 0;
512 return S_FALSE;
515 static HRESULT WINAPI EnumPins_Skip(IEnumPins *iface, ULONG cPins)
517 ok(0, "unexpected call\n");
518 return E_NOTIMPL;
521 static HRESULT WINAPI EnumPins_Reset(IEnumPins *iface)
523 ok(0, "unexpected call\n");
524 return E_NOTIMPL;
527 static HRESULT WINAPI EnumPins_Clone(IEnumPins *iface, IEnumPins **ppEnum)
529 ok(0, "unexpected call\n");
530 return E_NOTIMPL;
533 static const IEnumPinsVtbl EnumPinsVtbl = {
534 EnumPins_QueryInterface,
535 EnumPins_AddRef,
536 EnumPins_Release,
537 EnumPins_Next,
538 EnumPins_Skip,
539 EnumPins_Reset,
540 EnumPins_Clone
543 static test_filter* impl_from_IPin(IPin *iface)
545 return CONTAINING_RECORD(iface, test_filter, IPin_iface);
548 static HRESULT WINAPI Pin_QueryInterface(IPin *iface, REFIID riid, void **ppv)
550 test_filter *This = impl_from_IPin(iface);
552 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin)) {
553 *ppv = iface;
554 return S_OK;
557 if(IsEqualIID(riid, &IID_IKsPropertySet)) {
558 *ppv = &This->IKsPropertySet_iface;
559 return S_OK;
562 if(IsEqualIID(riid, &IID_IMemInputPin)) {
563 *ppv = &This->IMemInputPin_iface;
564 return S_OK;
567 if(IsEqualIID(riid, &IID_IMediaSeeking)) {
568 *ppv = &This->IMediaSeeking_iface;
569 return S_OK;
572 ok(0, "unexpected call: %s\n", wine_dbgstr_guid(riid));
573 *ppv = NULL;
574 return E_NOINTERFACE;
577 static ULONG WINAPI Pin_AddRef(IPin *iface)
579 return 2;
582 static ULONG WINAPI Pin_Release(IPin *iface)
584 return 1;
587 static HRESULT WINAPI Pin_Connect(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
589 ok(0, "unexpected call\n");
590 return E_NOTIMPL;
593 static HRESULT WINAPI Pin_ReceiveConnection(IPin *iface,
594 IPin *pConnector, const AM_MEDIA_TYPE *pmt)
596 CHECK_EXPECT(ReceiveConnection);
598 ok(IsEqualIID(&pmt->majortype, &MEDIATYPE_Stream), "majortype = %s\n",
599 wine_dbgstr_guid(&pmt->majortype));
600 ok(IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_Avi), "subtype = %s\n",
601 wine_dbgstr_guid(&pmt->subtype));
602 ok(pmt->bFixedSizeSamples, "bFixedSizeSamples = %x\n", pmt->bFixedSizeSamples);
603 ok(!pmt->bTemporalCompression, "bTemporalCompression = %x\n", pmt->bTemporalCompression);
604 ok(pmt->lSampleSize == 1, "lSampleSize = %ld\n", pmt->lSampleSize);
605 ok(IsEqualIID(&pmt->formattype, &GUID_NULL), "formattype = %s\n",
606 wine_dbgstr_guid(&pmt->formattype));
607 ok(!pmt->pUnk, "pUnk = %p\n", pmt->pUnk);
608 ok(!pmt->cbFormat, "cbFormat = %ld\n", pmt->cbFormat);
609 ok(!pmt->pbFormat, "pbFormat = %p\n", pmt->pbFormat);
610 return S_OK;
613 static HRESULT WINAPI Pin_Disconnect(IPin *iface)
615 ok(0, "unexpected call\n");
616 return E_NOTIMPL;
619 static HRESULT WINAPI Pin_ConnectedTo(IPin *iface, IPin **pPin)
621 test_filter *This = impl_from_IPin(iface);
622 check_calls_list("Pin_ConnectedTo", PIN_CONNECTEDTO, This->filter_type);
624 *pPin = NULL;
625 return S_OK;
628 static HRESULT WINAPI Pin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *pmt)
630 ok(0, "unexpected call\n");
631 return E_NOTIMPL;
634 static HRESULT WINAPI Pin_QueryPinInfo(IPin *iface, PIN_INFO *pInfo)
636 test_filter *This = impl_from_IPin(iface);
637 check_calls_list("Pin_QueryPinInfo", PIN_QUERYPININFO, This->filter_type);
638 return E_NOTIMPL;
641 static HRESULT WINAPI Pin_QueryDirection(IPin *iface, PIN_DIRECTION *pPinDir)
643 test_filter *This = impl_from_IPin(iface);
644 check_calls_list("Pin_QueryDirection", PIN_QUERYDIRECTION, This->filter_type);
646 *pPinDir = This->dir;
647 if(This->filter_type==INTERMEDIATE_FILTER && This->enum_pins_pos==2)
648 *pPinDir = PINDIR_INPUT;
649 return S_OK;
652 static HRESULT WINAPI Pin_QueryId(IPin *iface, LPWSTR *Id)
654 ok(0, "unexpected call\n");
655 return E_NOTIMPL;
658 static HRESULT WINAPI Pin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
660 ok(0, "unexpected call\n");
661 return E_NOTIMPL;
664 static HRESULT WINAPI Pin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
666 test_filter *This = impl_from_IPin(iface);
667 check_calls_list("Pin_EnumMediaTypes", PIN_ENUMMEDIATYPES, This->filter_type);
669 ok(ppEnum != NULL, "ppEnum == NULL\n");
670 *ppEnum = &This->IEnumMediaTypes_iface;
671 return S_OK;
674 static HRESULT WINAPI Pin_QueryInternalConnections(IPin *iface, IPin **apPin, ULONG *nPin)
676 ok(0, "unexpected call\n");
677 return E_NOTIMPL;
680 static HRESULT WINAPI Pin_EndOfStream(IPin *iface)
682 ok(0, "unexpected call\n");
683 return E_NOTIMPL;
686 static HRESULT WINAPI Pin_BeginFlush(IPin *iface)
688 ok(0, "unexpected call\n");
689 return E_NOTIMPL;
692 static HRESULT WINAPI Pin_EndFlush(IPin *iface)
694 ok(0, "unexpected call\n");
695 return E_NOTIMPL;
698 static HRESULT WINAPI Pin_NewSegment(IPin *iface, REFERENCE_TIME tStart,
699 REFERENCE_TIME tStop, double dRate)
701 ok(0, "unexpected call\n");
702 return E_NOTIMPL;
705 static const IPinVtbl PinVtbl = {
706 Pin_QueryInterface,
707 Pin_AddRef,
708 Pin_Release,
709 Pin_Connect,
710 Pin_ReceiveConnection,
711 Pin_Disconnect,
712 Pin_ConnectedTo,
713 Pin_ConnectionMediaType,
714 Pin_QueryPinInfo,
715 Pin_QueryDirection,
716 Pin_QueryId,
717 Pin_QueryAccept,
718 Pin_EnumMediaTypes,
719 Pin_QueryInternalConnections,
720 Pin_EndOfStream,
721 Pin_BeginFlush,
722 Pin_EndFlush,
723 Pin_NewSegment
726 static test_filter* impl_from_IKsPropertySet(IKsPropertySet *iface)
728 return CONTAINING_RECORD(iface, test_filter, IKsPropertySet_iface);
731 static HRESULT WINAPI KsPropertySet_QueryInterface(IKsPropertySet *iface, REFIID riid, void **ppv)
733 ok(0, "unexpected call\n");
734 return E_NOTIMPL;
737 static ULONG WINAPI KsPropertySet_AddRef(IKsPropertySet *iface)
739 return 2;
742 static ULONG WINAPI KsPropertySet_Release(IKsPropertySet *iface)
744 return 1;
747 static HRESULT WINAPI KsPropertySet_Set(IKsPropertySet *iface, REFGUID guidPropSet, DWORD dwPropID,
748 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData)
750 ok(0, "unexpected call\n");
751 return E_NOTIMPL;
754 static HRESULT WINAPI KsPropertySet_Get(IKsPropertySet *iface, REFGUID guidPropSet, DWORD dwPropID,
755 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData, DWORD *pcbReturned)
757 test_filter *This = impl_from_IKsPropertySet(iface);
758 check_calls_list("KsPropertySet_Get", KSPROPERTYSET_GET, This->filter_type);
760 ok(IsEqualIID(guidPropSet, &AMPROPSETID_Pin), "guidPropSet = %s\n", wine_dbgstr_guid(guidPropSet));
761 ok(dwPropID == 0, "dwPropID = %ld\n", dwPropID);
762 ok(pInstanceData == NULL, "pInstanceData != NULL\n");
763 ok(cbInstanceData == 0, "cbInstanceData != 0\n");
764 ok(cbPropData == sizeof(GUID), "cbPropData = %ld\n", cbPropData);
765 *pcbReturned = sizeof(GUID);
766 memcpy(pPropData, &PIN_CATEGORY_EDS, sizeof(GUID));
767 return S_OK;
770 static HRESULT WINAPI KsPropertySet_QuerySupported(IKsPropertySet *iface,
771 REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport)
773 ok(0, "unexpected call\n");
774 return E_NOTIMPL;
777 static const IKsPropertySetVtbl KsPropertySetVtbl = {
778 KsPropertySet_QueryInterface,
779 KsPropertySet_AddRef,
780 KsPropertySet_Release,
781 KsPropertySet_Set,
782 KsPropertySet_Get,
783 KsPropertySet_QuerySupported
786 static IStream *avi_stream;
787 static HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin *iface, REFIID riid, void **ppv)
789 if(IsEqualIID(riid, &IID_IStream)) {
790 CHECK_EXPECT(MemInputPin_QueryInterface_IStream);
792 if(!avi_stream)
793 return E_NOINTERFACE;
795 *ppv = avi_stream;
796 IStream_AddRef(avi_stream);
797 return S_OK;
800 ok(0, "unexpected call: %s\n", wine_dbgstr_guid(riid));
801 return E_NOTIMPL;
804 static ULONG WINAPI MemInputPin_AddRef(IMemInputPin *iface)
806 return 2;
809 static ULONG WINAPI MemInputPin_Release(IMemInputPin *iface)
811 return 1;
814 static HRESULT WINAPI MemInputPin_GetAllocator(IMemInputPin *iface, IMemAllocator **ppAllocator)
816 ok(0, "unexpected call\n");
817 return E_NOTIMPL;
820 static HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin *iface,
821 IMemAllocator *pAllocator, BOOL bReadOnly)
823 ALLOCATOR_PROPERTIES ap;
824 HRESULT hr;
826 CHECK_EXPECT(NotifyAllocator);
828 ok(pAllocator != NULL, "pAllocator = %p\n", pAllocator);
829 ok(bReadOnly, "bReadOnly = %x\n", bReadOnly);
831 hr = IMemAllocator_GetProperties(pAllocator, &ap);
832 ok(hr == S_OK, "Got hr %#lx.\n", hr);
833 ok(ap.cBuffers == 32, "cBuffers = %ld\n", ap.cBuffers);
834 ok(ap.cbBuffer == 0, "cbBuffer = %ld\n", ap.cbBuffer);
835 ok(ap.cbAlign == 1, "cbAlign = %ld\n", ap.cbAlign);
836 ok(ap.cbPrefix == 0, "cbPrefix = %ld\n", ap.cbPrefix);
837 return S_OK;
840 static HRESULT WINAPI MemInputPin_GetAllocatorRequirements(
841 IMemInputPin *iface, ALLOCATOR_PROPERTIES *pProps)
843 CHECK_EXPECT(GetAllocatorRequirements);
844 return E_NOTIMPL;
847 static HRESULT WINAPI MemInputPin_Receive(IMemInputPin *iface, IMediaSample *pSample)
849 REFERENCE_TIME off, tmp;
850 LARGE_INTEGER li;
851 BYTE *data;
852 HRESULT hr;
854 hr = IMediaSample_GetTime(pSample, &off, &tmp);
855 ok(hr == S_OK, "Got hr %#lx.\n", hr);
856 hr = IMediaSample_GetPointer(pSample, &data);
857 ok(hr == S_OK, "Got hr %#lx.\n", hr);
858 li.QuadPart = off;
859 IStream_Seek(avi_stream, li, STREAM_SEEK_SET, NULL);
860 IStream_Write(avi_stream, data, IMediaSample_GetActualDataLength(pSample), NULL);
861 return S_OK;
864 static HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin *iface,
865 IMediaSample **pSamples, LONG nSamples, LONG *nSamplesProcessed)
867 ok(0, "unexpected call\n");
868 return E_NOTIMPL;
871 static HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin *iface)
873 ok(0, "unexpected call\n");
874 return E_NOTIMPL;
877 static const IMemInputPinVtbl MemInputPinVtbl = {
878 MemInputPin_QueryInterface,
879 MemInputPin_AddRef,
880 MemInputPin_Release,
881 MemInputPin_GetAllocator,
882 MemInputPin_NotifyAllocator,
883 MemInputPin_GetAllocatorRequirements,
884 MemInputPin_Receive,
885 MemInputPin_ReceiveMultiple,
886 MemInputPin_ReceiveCanBlock
889 static HRESULT WINAPI MediaSeeking_QueryInterface(
890 IMediaSeeking *iface, REFIID riid, void **ppv)
892 ok(0, "unexpected call\n");
893 return E_NOTIMPL;
896 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface)
898 return 2;
901 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface)
903 return 1;
906 static HRESULT WINAPI MediaSeeking_GetCapabilities(
907 IMediaSeeking *iface, DWORD *pCapabilities)
909 ok(0, "unexpected call\n");
910 return E_NOTIMPL;
913 static HRESULT WINAPI MediaSeeking_CheckCapabilities(
914 IMediaSeeking *iface, DWORD *pCapabilities)
916 ok(0, "unexpected call\n");
917 return E_NOTIMPL;
920 static HRESULT WINAPI MediaSeeking_IsFormatSupported(
921 IMediaSeeking *iface, const GUID *pFormat)
923 ok(0, "unexpected call\n");
924 return E_NOTIMPL;
927 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(
928 IMediaSeeking *iface, GUID *pFormat)
930 ok(0, "unexpected call\n");
931 return E_NOTIMPL;
934 static HRESULT WINAPI MediaSeeking_GetTimeFormat(
935 IMediaSeeking *iface, GUID *pFormat)
937 ok(0, "unexpected call\n");
938 return E_NOTIMPL;
941 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(
942 IMediaSeeking *iface, const GUID *pFormat)
944 ok(0, "unexpected call\n");
945 return E_NOTIMPL;
948 static HRESULT WINAPI MediaSeeking_SetTimeFormat(
949 IMediaSeeking *iface, const GUID *pFormat)
951 ok(0, "unexpected call\n");
952 return E_NOTIMPL;
955 static HRESULT WINAPI MediaSeeking_GetDuration(
956 IMediaSeeking *iface, LONGLONG *pDuration)
958 ok(0, "unexpected call\n");
959 return E_NOTIMPL;
962 static HRESULT WINAPI MediaSeeking_GetStopPosition(
963 IMediaSeeking *iface, LONGLONG *pStop)
965 ok(0, "unexpected call\n");
966 return E_NOTIMPL;
969 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(
970 IMediaSeeking *iface, LONGLONG *pCurrent)
972 ok(0, "unexpected call\n");
973 return E_NOTIMPL;
976 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *pTarget,
977 const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat)
979 ok(0, "unexpected call\n");
980 return E_NOTIMPL;
983 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface, LONGLONG *pCurrent,
984 DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)
986 ok(0, "unexpected call\n");
987 return E_NOTIMPL;
990 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
991 LONGLONG *pCurrent, LONGLONG *pStop)
993 CHECK_EXPECT(MediaSeeking_GetPositions);
994 return E_NOTIMPL;
997 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
998 LONGLONG *pEarliest, LONGLONG *pLatest)
1000 ok(0, "unexpected call\n");
1001 return E_NOTIMPL;
1004 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface, double dRate)
1006 ok(0, "unexpected call\n");
1007 return E_NOTIMPL;
1010 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface, double *pdRate)
1012 ok(0, "unexpected call\n");
1013 return E_NOTIMPL;
1016 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface, LONGLONG *pllPreroll)
1018 ok(0, "unexpected call\n");
1019 return E_NOTIMPL;
1022 static const IMediaSeekingVtbl MediaSeekingVtbl = {
1023 MediaSeeking_QueryInterface,
1024 MediaSeeking_AddRef,
1025 MediaSeeking_Release,
1026 MediaSeeking_GetCapabilities,
1027 MediaSeeking_CheckCapabilities,
1028 MediaSeeking_IsFormatSupported,
1029 MediaSeeking_QueryPreferredFormat,
1030 MediaSeeking_GetTimeFormat,
1031 MediaSeeking_IsUsingTimeFormat,
1032 MediaSeeking_SetTimeFormat,
1033 MediaSeeking_GetDuration,
1034 MediaSeeking_GetStopPosition,
1035 MediaSeeking_GetCurrentPosition,
1036 MediaSeeking_ConvertTimeFormat,
1037 MediaSeeking_SetPositions,
1038 MediaSeeking_GetPositions,
1039 MediaSeeking_GetAvailable,
1040 MediaSeeking_SetRate,
1041 MediaSeeking_GetRate,
1042 MediaSeeking_GetPreroll
1045 static test_filter* impl_from_IEnumMediaTypes(IEnumMediaTypes *iface)
1047 return CONTAINING_RECORD(iface, test_filter, IEnumMediaTypes_iface);
1050 static HRESULT WINAPI EnumMediaTypes_QueryInterface(IEnumMediaTypes *iface, REFIID riid, void **ppv)
1052 ok(0, "unexpected call\n");
1053 return E_NOTIMPL;
1056 static ULONG WINAPI EnumMediaTypes_AddRef(IEnumMediaTypes *iface)
1058 return 2;
1061 static ULONG WINAPI EnumMediaTypes_Release(IEnumMediaTypes *iface)
1063 return 1;
1066 static HRESULT WINAPI EnumMediaTypes_Next(IEnumMediaTypes *iface, ULONG cMediaTypes,
1067 AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched)
1069 test_filter *This = impl_from_IEnumMediaTypes(iface);
1070 check_calls_list("EnumMediaTypes_Next", ENUMMEDIATYPES_NEXT, This->filter_type);
1072 ok(cMediaTypes == 1, "cMediaTypes = %ld\n", cMediaTypes);
1073 ok(ppMediaTypes != NULL, "ppMediaTypes == NULL\n");
1074 ok(pcFetched != NULL, "pcFetched == NULL\n");
1076 if(!This->enum_media_types_pos++) {
1077 ppMediaTypes[0] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
1078 memset(ppMediaTypes[0], 0, sizeof(AM_MEDIA_TYPE));
1079 ppMediaTypes[0]->majortype = MEDIATYPE_Video;
1080 *pcFetched = 1;
1081 return S_OK;
1084 *pcFetched = 0;
1085 return S_FALSE;
1088 static HRESULT WINAPI EnumMediaTypes_Skip(IEnumMediaTypes *iface, ULONG cMediaTypes)
1090 ok(0, "unexpected call\n");
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI EnumMediaTypes_Reset(IEnumMediaTypes *iface)
1096 test_filter *This = impl_from_IEnumMediaTypes(iface);
1097 check_calls_list("EnumMediaTypes_Reset", ENUMMEDIATYPES_RESET, This->filter_type);
1099 This->enum_media_types_pos = 0;
1100 return S_OK;
1103 static HRESULT WINAPI EnumMediaTypes_Clone(IEnumMediaTypes *iface, IEnumMediaTypes **ppEnum)
1105 ok(0, "unexpected call\n");
1106 return E_NOTIMPL;
1109 static const IEnumMediaTypesVtbl EnumMediaTypesVtbl = {
1110 EnumMediaTypes_QueryInterface,
1111 EnumMediaTypes_AddRef,
1112 EnumMediaTypes_Release,
1113 EnumMediaTypes_Next,
1114 EnumMediaTypes_Skip,
1115 EnumMediaTypes_Reset,
1116 EnumMediaTypes_Clone
1119 static void init_test_filter(test_filter *This, PIN_DIRECTION dir, filter_type type)
1121 memset(This, 0, sizeof(*This));
1122 This->IBaseFilter_iface.lpVtbl = &BaseFilterVtbl;
1123 This->IEnumPins_iface.lpVtbl = &EnumPinsVtbl;
1124 This->IPin_iface.lpVtbl = &PinVtbl;
1125 This->IKsPropertySet_iface.lpVtbl = &KsPropertySetVtbl;
1126 This->IMemInputPin_iface.lpVtbl = &MemInputPinVtbl;
1127 This->IMediaSeeking_iface.lpVtbl = &MediaSeekingVtbl;
1128 This->IEnumMediaTypes_iface.lpVtbl = &EnumMediaTypesVtbl;
1130 This->dir = dir;
1131 This->filter_type = type;
1134 static HRESULT WINAPI MemAllocator_QueryInterface(IMemAllocator *iface, REFIID riid, void **ppvObject)
1136 if(IsEqualIID(riid, &IID_IUnknown)) {
1137 *ppvObject = iface;
1138 return S_OK;
1141 ok(0, "unexpected call: %s\n", wine_dbgstr_guid(riid));
1142 return E_NOTIMPL;
1145 static ULONG WINAPI MemAllocator_AddRef(IMemAllocator *iface)
1147 return 2;
1150 static ULONG WINAPI MemAllocator_Release(IMemAllocator *iface)
1152 return 1;
1155 static HRESULT WINAPI MemAllocator_SetProperties(IMemAllocator *iface,
1156 ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual)
1158 ok(0, "unexpected call\n");
1159 return E_NOTIMPL;
1162 static HRESULT WINAPI MemAllocator_GetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *pProps)
1164 CHECK_EXPECT2(MemAllocator_GetProperties);
1166 pProps->cBuffers = 1;
1167 pProps->cbBuffer = 1024;
1168 pProps->cbAlign = 0;
1169 pProps->cbPrefix = 0;
1170 return S_OK;
1173 static HRESULT WINAPI MemAllocator_Commit(IMemAllocator *iface)
1175 ok(0, "unexpected call\n");
1176 return E_NOTIMPL;
1179 static HRESULT WINAPI MemAllocator_Decommit(IMemAllocator *iface)
1181 ok(0, "unexpected call\n");
1182 return E_NOTIMPL;
1185 static HRESULT WINAPI MemAllocator_GetBuffer(IMemAllocator *iface, IMediaSample **ppBuffer,
1186 REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime, DWORD dwFlags)
1188 ok(0, "unexpected call\n");
1189 return E_NOTIMPL;
1192 static HRESULT WINAPI MemAllocator_ReleaseBuffer(IMemAllocator *iface, IMediaSample *pBuffer)
1194 ok(0, "unexpected call\n");
1195 return E_NOTIMPL;
1198 static const IMemAllocatorVtbl MemAllocatorVtbl = {
1199 MemAllocator_QueryInterface,
1200 MemAllocator_AddRef,
1201 MemAllocator_Release,
1202 MemAllocator_SetProperties,
1203 MemAllocator_GetProperties,
1204 MemAllocator_Commit,
1205 MemAllocator_Decommit,
1206 MemAllocator_GetBuffer,
1207 MemAllocator_ReleaseBuffer
1209 IMemAllocator MemAllocator = {&MemAllocatorVtbl};
1211 static HRESULT WINAPI MediaSample_QueryInterface(IMediaSample* This, REFIID riid, void **ppv)
1213 if(IsEqualIID(riid, &IID_IMediaSample2))
1214 CHECK_EXPECT(MediaSample_QueryInterface_MediaSample2);
1215 else
1216 ok(0, "MediaSample_QueryInterface: %s\n", wine_dbgstr_guid(riid));
1218 *ppv = NULL;
1219 return E_NOINTERFACE;
1222 static ULONG WINAPI MediaSample_AddRef(IMediaSample* This)
1224 return 2;
1227 static ULONG WINAPI MediaSample_Release(IMediaSample* This)
1229 return 1;
1232 static BYTE buf[1024];
1233 static HRESULT WINAPI MediaSample_GetPointer(IMediaSample* This, BYTE **ppBuffer)
1235 CHECK_EXPECT2(MediaSample_GetPointer);
1236 *ppBuffer = buf;
1237 memset(buf, 'z', sizeof(buf));
1238 return S_OK;
1241 static LONG WINAPI MediaSample_GetSize(IMediaSample* This)
1243 CHECK_EXPECT2(MediaSample_GetSize);
1244 return sizeof(buf);
1247 static REFERENCE_TIME start_time, end_time;
1248 static HRESULT WINAPI MediaSample_GetTime(IMediaSample* This,
1249 REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
1251 CHECK_EXPECT2(MediaSample_GetTime);
1252 *pTimeStart = start_time;
1253 *pTimeEnd = end_time;
1254 return S_OK;
1257 static HRESULT WINAPI MediaSample_SetTime(IMediaSample* This,
1258 REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
1260 ok(0, "unexpected call\n");
1261 return E_NOTIMPL;
1264 static HRESULT WINAPI MediaSample_IsSyncPoint(IMediaSample* This)
1266 CHECK_EXPECT2(MediaSample_IsSyncPoint);
1267 return S_OK;
1270 static HRESULT WINAPI MediaSample_SetSyncPoint(IMediaSample* This, BOOL bIsSyncPoint)
1272 ok(0, "unexpected call\n");
1273 return E_NOTIMPL;
1276 static HRESULT WINAPI MediaSample_IsPreroll(IMediaSample* This)
1278 CHECK_EXPECT2(MediaSample_IsPreroll);
1279 return S_FALSE;
1282 static HRESULT WINAPI MediaSample_SetPreroll(IMediaSample* This, BOOL bIsPreroll)
1284 ok(0, "unexpected call\n");
1285 return E_NOTIMPL;
1288 static LONG WINAPI MediaSample_GetActualDataLength(IMediaSample* This)
1290 CHECK_EXPECT2(MediaSample_GetActualDataLength);
1291 return sizeof(buf);
1294 static HRESULT WINAPI MediaSample_SetActualDataLength(IMediaSample* This, LONG length)
1296 ok(0, "unexpected call\n");
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI MediaSample_GetMediaType(IMediaSample* This, AM_MEDIA_TYPE **ppMediaType)
1302 CHECK_EXPECT2(MediaSample_GetMediaType);
1303 *ppMediaType = NULL;
1304 return S_FALSE;
1307 static HRESULT WINAPI MediaSample_SetMediaType(IMediaSample* This, AM_MEDIA_TYPE *pMediaType)
1309 ok(0, "unexpected call\n");
1310 return E_NOTIMPL;
1313 static HRESULT WINAPI MediaSample_IsDiscontinuity(IMediaSample* This)
1315 CHECK_EXPECT(MediaSample_IsDiscontinuity);
1316 return S_FALSE;
1319 static HRESULT WINAPI MediaSample_SetDiscontinuity(IMediaSample* This, BOOL bDiscontinuity)
1321 ok(0, "unexpected call\n");
1322 return E_NOTIMPL;
1325 static HRESULT WINAPI MediaSample_GetMediaTime(IMediaSample* This,
1326 LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
1328 CHECK_EXPECT(MediaSample_GetMediaTime);
1329 return E_NOTIMPL;
1332 static HRESULT WINAPI MediaSample_SetMediaTime(IMediaSample* This,
1333 LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
1335 ok(0, "unexpected call\n");
1336 return E_NOTIMPL;
1339 static const IMediaSampleVtbl MediaSampleVtbl = {
1340 MediaSample_QueryInterface,
1341 MediaSample_AddRef,
1342 MediaSample_Release,
1343 MediaSample_GetPointer,
1344 MediaSample_GetSize,
1345 MediaSample_GetTime,
1346 MediaSample_SetTime,
1347 MediaSample_IsSyncPoint,
1348 MediaSample_SetSyncPoint,
1349 MediaSample_IsPreroll,
1350 MediaSample_SetPreroll,
1351 MediaSample_GetActualDataLength,
1352 MediaSample_SetActualDataLength,
1353 MediaSample_GetMediaType,
1354 MediaSample_SetMediaType,
1355 MediaSample_IsDiscontinuity,
1356 MediaSample_SetDiscontinuity,
1357 MediaSample_GetMediaTime,
1358 MediaSample_SetMediaTime,
1360 IMediaSample MediaSample = {&MediaSampleVtbl};
1362 static void test_AviMux(char *arg)
1364 test_filter source_filter, sink_filter;
1365 VIDEOINFO videoinfo;
1366 IPin *avimux_in, *avimux_out, *pin;
1367 AM_MEDIA_TYPE source_media_type;
1368 PIN_DIRECTION dir;
1369 IBaseFilter *avimux;
1370 IEnumPins *ep;
1371 IMemInputPin *memin;
1372 ALLOCATOR_PROPERTIES props;
1373 IMemAllocator *memalloc;
1374 IConfigInterleaving *ci;
1375 FILTER_STATE state;
1376 HRESULT hr;
1377 ULONG ref;
1379 init_test_filter(&source_filter, PINDIR_OUTPUT, SOURCE_FILTER);
1380 init_test_filter(&sink_filter, PINDIR_INPUT, SINK_FILTER);
1382 hr = CoCreateInstance(&CLSID_AviDest, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void**)&avimux);
1383 ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG),
1384 "Got hr %#lx.\n", hr);
1385 if(hr != S_OK) {
1386 win_skip("AVI Mux filter is not registered\n");
1387 return;
1390 hr = IBaseFilter_EnumPins(avimux, &ep);
1391 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1393 hr = IEnumPins_Next(ep, 1, &avimux_out, NULL);
1394 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1395 hr = IPin_QueryDirection(avimux_out, &dir);
1396 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1397 ok(dir == PINDIR_OUTPUT, "dir = %d\n", dir);
1399 hr = IEnumPins_Next(ep, 1, &avimux_in, NULL);
1400 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1401 hr = IPin_QueryDirection(avimux_in, &dir);
1402 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1403 ok(dir == PINDIR_INPUT, "dir = %d\n", dir);
1404 IEnumPins_Release(ep);
1406 hr = IPin_ReceiveConnection(avimux_in, &source_filter.IPin_iface, NULL);
1407 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
1409 current_calls_list = NULL;
1410 memset(&source_media_type, 0, sizeof(AM_MEDIA_TYPE));
1411 memset(&videoinfo, 0, sizeof(VIDEOINFO));
1412 source_media_type.majortype = MEDIATYPE_Video;
1413 source_media_type.subtype = MEDIASUBTYPE_RGB32;
1414 source_media_type.formattype = FORMAT_VideoInfo;
1415 source_media_type.bFixedSizeSamples = TRUE;
1416 source_media_type.lSampleSize = 40000;
1417 source_media_type.cbFormat = sizeof(VIDEOINFO);
1418 source_media_type.pbFormat = (BYTE*)&videoinfo;
1419 videoinfo.AvgTimePerFrame = 333333;
1420 videoinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1421 videoinfo.bmiHeader.biWidth = 100;
1422 videoinfo.bmiHeader.biHeight = 100;
1423 videoinfo.bmiHeader.biPlanes = 1;
1424 videoinfo.bmiHeader.biBitCount = 32;
1425 videoinfo.bmiHeader.biSizeImage = 40000;
1426 videoinfo.bmiHeader.biClrImportant = 256;
1427 hr = IPin_ReceiveConnection(avimux_in, &source_filter.IPin_iface, &source_media_type);
1428 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1430 hr = IPin_ConnectedTo(avimux_in, &pin);
1431 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1432 ok(pin == &source_filter.IPin_iface, "incorrect pin: %p, expected %p\n",
1433 pin, &source_filter.IPin_iface);
1435 hr = IPin_Connect(avimux_out, &source_filter.IPin_iface, NULL);
1436 ok(hr == VFW_E_INVALID_DIRECTION, "Got hr %#lx.\n", hr);
1438 hr = IBaseFilter_JoinFilterGraph(avimux, (IFilterGraph*)&GraphBuilder, NULL);
1439 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1441 SET_EXPECT(ReceiveConnection);
1442 SET_EXPECT(GetAllocatorRequirements);
1443 SET_EXPECT(NotifyAllocator);
1444 SET_EXPECT(Reconnect);
1445 hr = IPin_Connect(avimux_out, &sink_filter.IPin_iface, NULL);
1446 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1447 CHECK_CALLED(ReceiveConnection);
1448 CHECK_CALLED(GetAllocatorRequirements);
1449 CHECK_CALLED(NotifyAllocator);
1450 CHECK_CALLED(Reconnect);
1452 hr = IPin_ConnectedTo(avimux_out, &pin);
1453 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1454 ok(pin == &sink_filter.IPin_iface, "incorrect pin: %p, expected %p\n",
1455 pin, &source_filter.IPin_iface);
1457 hr = IPin_QueryInterface(avimux_in, &IID_IMemInputPin, (void**)&memin);
1458 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1460 props.cBuffers = 0xdeadbee1;
1461 props.cbBuffer = 0xdeadbee2;
1462 props.cbAlign = 0xdeadbee3;
1463 props.cbPrefix = 0xdeadbee4;
1464 hr = IMemInputPin_GetAllocatorRequirements(memin, &props);
1465 ok(hr==S_OK || broken(hr==E_INVALIDARG), "Got hr %#lx.\n", hr);
1466 if(hr == S_OK) {
1467 ok(props.cBuffers == 0xdeadbee1, "cBuffers = %ld\n", props.cBuffers);
1468 ok(props.cbBuffer == 0xdeadbee2, "cbBuffer = %ld\n", props.cbBuffer);
1469 ok(props.cbAlign == 1, "cbAlign = %ld\n", props.cbAlign);
1470 ok(props.cbPrefix == 8, "cbPrefix = %ld\n", props.cbPrefix);
1473 hr = IMemInputPin_GetAllocator(memin, &memalloc);
1474 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1476 props.cBuffers = 0xdeadbee1;
1477 props.cbBuffer = 0xdeadbee2;
1478 props.cbAlign = 0xdeadbee3;
1479 props.cbPrefix = 0xdeadbee4;
1480 hr = IMemAllocator_GetProperties(memalloc, &props);
1481 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1482 ok(props.cBuffers == 0, "cBuffers = %ld\n", props.cBuffers);
1483 ok(props.cbBuffer == 0, "cbBuffer = %ld\n", props.cbBuffer);
1484 ok(props.cbAlign == 0, "cbAlign = %ld\n", props.cbAlign);
1485 ok(props.cbPrefix == 0, "cbPrefix = %ld\n", props.cbPrefix);
1486 IMemAllocator_Release(memalloc);
1488 hr = IBaseFilter_QueryInterface(avimux, &IID_IConfigInterleaving, (void**)&ci);
1489 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1490 hr = IConfigInterleaving_put_Mode(ci, 5);
1491 ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
1492 SET_EXPECT(Reconnect);
1493 hr = IConfigInterleaving_put_Mode(ci, INTERLEAVE_FULL);
1494 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1495 CHECK_CALLED(Reconnect);
1496 IConfigInterleaving_Release(ci);
1498 hr = IBaseFilter_GetState(avimux, 0, &state);
1499 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1500 ok(state == State_Stopped, "state = %d\n", state);
1502 SET_EXPECT(MemAllocator_GetProperties);
1503 hr = IMemInputPin_NotifyAllocator(memin, &MemAllocator, TRUE);
1504 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1505 CHECK_CALLED(MemAllocator_GetProperties);
1507 hr = IMemInputPin_GetAllocator(memin, &memalloc);
1508 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1509 ok(memalloc != &MemAllocator, "memalloc == &MemAllocator\n");
1510 IMemAllocator_Release(memalloc);
1512 hr = CreateStreamOnHGlobal(NULL, TRUE, &avi_stream);
1513 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1514 SET_EXPECT(MediaSeeking_GetPositions);
1515 SET_EXPECT(MemInputPin_QueryInterface_IStream);
1516 hr = IBaseFilter_Run(avimux, 0);
1517 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1518 CHECK_CALLED(MediaSeeking_GetPositions);
1520 hr = IBaseFilter_GetState(avimux, 0, &state);
1521 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1522 ok(state == State_Running, "state = %d\n", state);
1524 SET_EXPECT(MediaSample_QueryInterface_MediaSample2);
1525 SET_EXPECT(MediaSample_IsDiscontinuity);
1526 SET_EXPECT(MediaSample_IsPreroll);
1527 SET_EXPECT(MediaSample_IsSyncPoint);
1528 SET_EXPECT(MediaSample_GetTime);
1529 SET_EXPECT(MediaSample_GetMediaType);
1530 SET_EXPECT(MediaSample_GetPointer);
1531 SET_EXPECT(MediaSample_GetActualDataLength);
1532 SET_EXPECT(MediaSample_GetSize);
1533 SET_EXPECT(MediaSample_GetMediaTime);
1534 start_time = end_time = 0;
1535 hr = IMemInputPin_Receive(memin, &MediaSample);
1536 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1537 CHECK_CALLED(MediaSample_QueryInterface_MediaSample2);
1538 todo_wine CHECK_CALLED(MediaSample_IsDiscontinuity);
1539 todo_wine CHECK_CALLED(MediaSample_IsPreroll);
1540 CHECK_CALLED(MediaSample_IsSyncPoint);
1541 CHECK_CALLED(MediaSample_GetTime);
1542 todo_wine CHECK_CALLED(MediaSample_GetMediaType);
1543 CHECK_CALLED(MediaSample_GetPointer);
1544 CHECK_CALLED(MediaSample_GetActualDataLength);
1545 todo_wine CHECK_CALLED(MediaSample_GetSize);
1546 todo_wine CHECK_CALLED(MediaSample_GetMediaTime);
1548 SET_EXPECT(MediaSample_QueryInterface_MediaSample2);
1549 SET_EXPECT(MediaSample_IsDiscontinuity);
1550 SET_EXPECT(MediaSample_IsPreroll);
1551 SET_EXPECT(MediaSample_IsSyncPoint);
1552 SET_EXPECT(MediaSample_GetTime);
1553 SET_EXPECT(MediaSample_GetMediaType);
1554 SET_EXPECT(MediaSample_GetPointer);
1555 SET_EXPECT(MediaSample_GetActualDataLength);
1556 SET_EXPECT(MediaSample_GetSize);
1557 SET_EXPECT(MediaSample_GetMediaTime);
1558 hr = IMemInputPin_Receive(memin, &MediaSample);
1559 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1560 CHECK_CALLED(MediaSample_QueryInterface_MediaSample2);
1561 todo_wine CHECK_CALLED(MediaSample_IsDiscontinuity);
1562 todo_wine CHECK_CALLED(MediaSample_IsPreroll);
1563 CHECK_CALLED(MediaSample_IsSyncPoint);
1564 CHECK_CALLED(MediaSample_GetTime);
1565 todo_wine CHECK_CALLED(MediaSample_GetMediaType);
1566 CHECK_CALLED(MediaSample_GetPointer);
1567 CHECK_CALLED(MediaSample_GetActualDataLength);
1568 todo_wine CHECK_CALLED(MediaSample_GetSize);
1569 todo_wine CHECK_CALLED(MediaSample_GetMediaTime);
1571 SET_EXPECT(MediaSample_QueryInterface_MediaSample2);
1572 SET_EXPECT(MediaSample_IsDiscontinuity);
1573 SET_EXPECT(MediaSample_IsPreroll);
1574 SET_EXPECT(MediaSample_IsSyncPoint);
1575 SET_EXPECT(MediaSample_GetTime);
1576 SET_EXPECT(MediaSample_GetMediaType);
1577 SET_EXPECT(MediaSample_GetPointer);
1578 SET_EXPECT(MediaSample_GetActualDataLength);
1579 SET_EXPECT(MediaSample_GetSize);
1580 SET_EXPECT(MediaSample_GetMediaTime);
1581 start_time = 20000000;
1582 end_time = 21000000;
1583 hr = IMemInputPin_Receive(memin, &MediaSample);
1584 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1585 CHECK_CALLED(MediaSample_QueryInterface_MediaSample2);
1586 todo_wine CHECK_CALLED(MediaSample_IsDiscontinuity);
1587 todo_wine CHECK_CALLED(MediaSample_IsPreroll);
1588 CHECK_CALLED(MediaSample_IsSyncPoint);
1589 CHECK_CALLED(MediaSample_GetTime);
1590 todo_wine CHECK_CALLED(MediaSample_GetMediaType);
1591 CHECK_CALLED(MediaSample_GetPointer);
1592 CHECK_CALLED(MediaSample_GetActualDataLength);
1593 todo_wine CHECK_CALLED(MediaSample_GetSize);
1594 todo_wine CHECK_CALLED(MediaSample_GetMediaTime);
1595 IMemInputPin_Release(memin);
1597 hr = IBaseFilter_Stop(avimux);
1598 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1599 CHECK_CALLED(MemInputPin_QueryInterface_IStream);
1601 hr = IBaseFilter_GetState(avimux, 0, &state);
1602 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1603 ok(state == State_Stopped, "state = %d\n", state);
1605 hr = IPin_Disconnect(avimux_out);
1606 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1608 IPin_Release(avimux_in);
1609 IPin_Release(avimux_out);
1610 ref = IBaseFilter_Release(avimux);
1611 ok(ref == 0, "Avi Mux filter was not destroyed (%ld)\n", ref);
1613 if(arg && !strcmp(arg, "save")) {
1614 LARGE_INTEGER li;
1615 char buf[1024];
1616 ULONG read;
1617 HANDLE *f;
1619 f = CreateFileA("avimux.avi", GENERIC_WRITE, 0, NULL,
1620 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1621 ok(f != INVALID_HANDLE_VALUE, "CreateFile failed\n");
1623 li.QuadPart = 0;
1624 hr = IStream_Seek(avi_stream, li, STREAM_SEEK_SET, NULL);
1625 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1627 while(1) {
1628 hr = IStream_Read(avi_stream, buf, sizeof(buf), &read);
1629 if(FAILED(hr)) {
1630 ok(0, "Got hr %#lx.\n", hr);
1631 break;
1633 if(!read)
1634 break;
1635 ok(WriteFile(f, buf, read, &read, NULL), "WriteFile failed\n");
1636 if(hr == S_FALSE)
1637 break;
1639 CloseHandle(f);
1642 ref = IStream_Release(avi_stream);
1643 ok(ref == 0, "IStream was not destroyed (%ld)\n", ref);
1646 START_TEST(qcap)
1648 if (SUCCEEDED(CoInitialize(NULL)))
1650 int arg_c;
1651 char **arg_v;
1653 arg_c = winetest_get_mainargs(&arg_v);
1655 test_AviMux(arg_c>2 ? arg_v[2] : NULL);
1657 CoUninitialize();
1659 else
1660 skip("CoInitialize failed\n");