1 /* DirectShow FilterGraph object (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2004 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
34 #include "quartz_private.h"
40 #include "wine/unicode.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
46 HWND hWnd; /* Target window */
47 long msg; /* User window message */
48 long instance; /* User data */
49 int disabled; /* Disabled messages posting */
53 long lEventCode; /* Event code */
54 LONG_PTR lParam1; /* Param1 */
55 LONG_PTR lParam2; /* Param2 */
58 /* messages ring implementation for queuing events (taken from winmm) */
59 #define EVENTS_RING_BUFFER_INCREMENT 64
65 CRITICAL_SECTION msg_crst;
66 HANDLE msg_event; /* Signaled for no empty queue */
69 static int EventsQueue_Init(EventsQueue* omr)
73 omr->msg_event = CreateEventW(NULL, TRUE, FALSE, NULL);
74 omr->ring_buffer_size = EVENTS_RING_BUFFER_INCREMENT;
75 omr->messages = CoTaskMemAlloc(omr->ring_buffer_size * sizeof(Event));
76 ZeroMemory(omr->messages, omr->ring_buffer_size * sizeof(Event));
78 InitializeCriticalSection(&omr->msg_crst);
79 omr->msg_crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": EventsQueue.msg_crst");
83 static int EventsQueue_Destroy(EventsQueue* omr)
85 CloseHandle(omr->msg_event);
86 CoTaskMemFree(omr->messages);
87 omr->msg_crst.DebugInfo->Spare[0] = 0;
88 DeleteCriticalSection(&omr->msg_crst);
92 static int EventsQueue_PutEvent(EventsQueue* omr, const Event* evt)
94 EnterCriticalSection(&omr->msg_crst);
95 if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
97 int old_ring_buffer_size = omr->ring_buffer_size;
98 omr->ring_buffer_size += EVENTS_RING_BUFFER_INCREMENT;
99 TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
100 omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(Event));
101 /* Now we need to rearrange the ring buffer so that the new
102 buffers just allocated are in between omr->msg_tosave and
105 if (omr->msg_tosave < omr->msg_toget)
107 memmove(&(omr->messages[omr->msg_toget + EVENTS_RING_BUFFER_INCREMENT]),
108 &(omr->messages[omr->msg_toget]),
109 sizeof(Event)*(old_ring_buffer_size - omr->msg_toget)
111 omr->msg_toget += EVENTS_RING_BUFFER_INCREMENT;
114 omr->messages[omr->msg_tosave] = *evt;
115 SetEvent(omr->msg_event);
116 omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
117 LeaveCriticalSection(&omr->msg_crst);
121 static int EventsQueue_GetEvent(EventsQueue* omr, Event* evt, long msTimeOut)
123 if (WaitForSingleObject(omr->msg_event, msTimeOut) != WAIT_OBJECT_0)
126 EnterCriticalSection(&omr->msg_crst);
128 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
130 LeaveCriticalSection(&omr->msg_crst);
134 *evt = omr->messages[omr->msg_toget];
135 omr->msg_toget = (omr->msg_toget + 1) % omr->ring_buffer_size;
137 /* Mark the buffer as empty if needed */
138 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
139 ResetEvent(omr->msg_event);
141 LeaveCriticalSection(&omr->msg_crst);
145 #define MAX_ITF_CACHE_ENTRIES 3
146 typedef struct _ITF_CACHE_ENTRY {
152 typedef struct _IFilterGraphImpl {
153 const IFilterGraph2Vtbl *IFilterGraph2_vtbl;
154 const IMediaControlVtbl *IMediaControl_vtbl;
155 const IMediaSeekingVtbl *IMediaSeeking_vtbl;
156 const IBasicAudioVtbl *IBasicAudio_vtbl;
157 const IBasicVideoVtbl *IBasicVideo_vtbl;
158 const IVideoWindowVtbl *IVideoWindow_vtbl;
159 const IMediaEventExVtbl *IMediaEventEx_vtbl;
160 const IMediaFilterVtbl *IMediaFilter_vtbl;
161 const IMediaEventSinkVtbl *IMediaEventSink_vtbl;
162 const IGraphConfigVtbl *IGraphConfig_vtbl;
163 const IMediaPositionVtbl *IMediaPosition_vtbl;
164 const IUnknownVtbl * IInner_vtbl;
165 /* IAMGraphStreams */
172 /* IRegisterServiceProvider */
173 /* IResourceMananger */
174 /* IServiceProvider */
175 /* IVideoFrameStep */
178 IFilterMapper2 * pFilterMapper2;
179 IBaseFilter ** ppFiltersInGraph;
180 LPWSTR * pFilterNames;
184 IReferenceClock *refClock;
186 HANDLE hEventCompletion;
187 int CompletionStatus;
191 int HandleEcComplete;
193 int HandleEcClockChanged;
196 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
197 int nItfCacheEntries;
198 IUnknown * pUnkOuter;
206 static HRESULT WINAPI Filtergraph_QueryInterface(IFilterGraphImpl *This,
207 REFIID riid, LPVOID * ppv);
208 static ULONG WINAPI Filtergraph_AddRef(IFilterGraphImpl *This);
209 static ULONG WINAPI Filtergraph_Release(IFilterGraphImpl *This);
211 static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown * iface,
214 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
215 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
217 if (This->bAggregatable)
218 This->bUnkOuterValid = TRUE;
220 if (IsEqualGUID(&IID_IUnknown, riid)) {
221 *ppvObj = &(This->IInner_vtbl);
222 TRACE(" returning IUnknown interface (%p)\n", *ppvObj);
223 } else if (IsEqualGUID(&IID_IFilterGraph, riid) ||
224 IsEqualGUID(&IID_IFilterGraph2, riid) ||
225 IsEqualGUID(&IID_IGraphBuilder, riid)) {
226 *ppvObj = &(This->IFilterGraph2_vtbl);
227 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
228 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
229 *ppvObj = &(This->IMediaControl_vtbl);
230 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
231 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
232 *ppvObj = &(This->IMediaSeeking_vtbl);
233 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
234 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
235 *ppvObj = &(This->IBasicAudio_vtbl);
236 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
237 } else if (IsEqualGUID(&IID_IBasicVideo, riid)) {
238 *ppvObj = &(This->IBasicVideo_vtbl);
239 TRACE(" returning IBasicVideo interface (%p)\n", *ppvObj);
240 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
241 *ppvObj = &(This->IVideoWindow_vtbl);
242 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
243 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
244 IsEqualGUID(&IID_IMediaEventEx, riid)) {
245 *ppvObj = &(This->IMediaEventEx_vtbl);
246 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
247 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
248 IsEqualGUID(&IID_IPersist, riid)) {
249 *ppvObj = &(This->IMediaFilter_vtbl);
250 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
251 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
252 *ppvObj = &(This->IMediaEventSink_vtbl);
253 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
254 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
255 *ppvObj = &(This->IGraphConfig_vtbl);
256 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
257 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
258 *ppvObj = &(This->IMediaPosition_vtbl);
259 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
262 FIXME("unknown interface %s\n", debugstr_guid(riid));
263 return E_NOINTERFACE;
266 IUnknown_AddRef((IUnknown *)(*ppvObj));
270 static ULONG WINAPI FilterGraphInner_AddRef(IUnknown * iface) {
271 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
272 ULONG ref = InterlockedIncrement(&This->ref);
274 TRACE("(%p)->(): new ref = %d\n", This, ref);
279 static ULONG WINAPI FilterGraphInner_Release(IUnknown * iface) {
280 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
281 ULONG ref = InterlockedDecrement(&This->ref);
283 TRACE("(%p)->(): new ref = %d\n", This, ref);
288 IMediaControl_Stop((IMediaControl*)&(This->IMediaControl_vtbl));
290 IReferenceClock_Release(This->refClock);
292 while (This->nFilters)
293 IFilterGraph2_RemoveFilter((IFilterGraph2*)This, This->ppFiltersInGraph[0]);
295 for (i = 0; i < This->nItfCacheEntries; i++)
297 if (This->ItfCacheEntries[i].iface)
298 IUnknown_Release(This->ItfCacheEntries[i].iface);
300 IFilterMapper2_Release(This->pFilterMapper2);
301 CloseHandle(This->hEventCompletion);
302 EventsQueue_Destroy(&This->evqueue);
303 This->cs.DebugInfo->Spare[0] = 0;
304 DeleteCriticalSection(&This->cs);
305 CoTaskMemFree(This->ppFiltersInGraph);
306 CoTaskMemFree(This->pFilterNames);
313 /*** IUnknown methods ***/
314 static HRESULT WINAPI FilterGraph2_QueryInterface(IFilterGraph2 *iface,
317 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
319 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
320 return Filtergraph_QueryInterface(This, riid, ppvObj);
323 static ULONG WINAPI FilterGraph2_AddRef(IFilterGraph2 *iface) {
324 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
326 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
328 return Filtergraph_AddRef(This);
331 static ULONG WINAPI FilterGraph2_Release(IFilterGraph2 *iface) {
332 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
334 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
336 return Filtergraph_Release(This);
339 /*** IFilterGraph methods ***/
340 static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface,
341 IBaseFilter *pFilter,
343 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
346 WCHAR* wszFilterName = NULL;
347 int duplicate_name = FALSE;
349 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
354 wszFilterName = CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
358 /* Check if name already exists */
359 for(i = 0; i < This->nFilters; i++)
360 if (!strcmpW(This->pFilterNames[i], pName))
362 duplicate_name = TRUE;
367 /* If no name given or name already existing, generate one */
368 if (!pName || duplicate_name)
370 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
371 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
373 for (j = 0; j < 10000 ; j++)
377 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
379 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
380 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
382 /* Check if the generated name already exists */
383 for(i = 0; i < This->nFilters; i++)
384 if (!strcmpW(This->pFilterNames[i], wszFilterName))
387 /* Compute next index and exit if generated name is suitable */
388 if (This->nameIndex++ == 10000)
390 if (i == This->nFilters)
393 /* Unable to find a suitable name */
396 CoTaskMemFree(wszFilterName);
397 return VFW_E_DUPLICATE_NAME;
401 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
403 if (This->nFilters + 1 > This->filterCapacity)
405 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
406 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
407 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
408 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
409 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
410 if (!This->filterCapacity)
412 CoTaskMemFree(This->ppFiltersInGraph);
413 CoTaskMemFree(This->pFilterNames);
415 This->ppFiltersInGraph = ppNewFilters;
416 This->pFilterNames = pNewNames;
417 This->filterCapacity = newCapacity;
420 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
424 IBaseFilter_AddRef(pFilter);
425 This->ppFiltersInGraph[This->nFilters] = pFilter;
426 This->pFilterNames[This->nFilters] = wszFilterName;
428 IBaseFilter_SetSyncSource(pFilter, This->refClock);
431 CoTaskMemFree(wszFilterName);
433 if (SUCCEEDED(hr) && duplicate_name)
434 return VFW_S_DUPLICATE_NAME;
439 static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface,
440 IBaseFilter *pFilter) {
441 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
445 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
447 /* FIXME: check graph is stopped */
449 for (i = 0; i < This->nFilters; i++)
451 if (This->ppFiltersInGraph[i] == pFilter)
453 IEnumPins *penumpins;
454 IBaseFilter_Stop(pFilter);
455 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
458 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK) {
461 IPin_ConnectedTo(ppin, &victim);
464 h = IPin_Disconnect(victim);
465 TRACE("Disconnect other side: %08x\n", h);
466 if (h == VFW_E_NOT_STOPPED)
469 IPin_QueryPinInfo(victim, &pinfo);
470 IBaseFilter_Stop(pinfo.pFilter);
471 IBaseFilter_Release(pinfo.pFilter);
472 h = IPin_Disconnect(victim);
473 TRACE("Disconnect retry: %08x\n", h);
475 IPin_Release(victim);
477 h = IPin_Disconnect(ppin);
478 TRACE("Disconnect 2: %08x\n", h);
480 IEnumPins_Release(penumpins);
483 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
486 IBaseFilter_SetSyncSource(pFilter, NULL);
487 IBaseFilter_Release(pFilter);
488 CoTaskMemFree(This->pFilterNames[i]);
489 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
490 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
492 /* Invalidate interfaces in the cache */
493 for (i = 0; i < This->nItfCacheEntries; i++)
494 if (pFilter == This->ItfCacheEntries[i].filter)
496 IUnknown_Release(This->ItfCacheEntries[i].iface);
497 This->ItfCacheEntries[i].iface = NULL;
498 This->ItfCacheEntries[i].filter = NULL;
506 return hr; /* FIXME: check this error code */
509 static HRESULT WINAPI FilterGraph2_EnumFilters(IFilterGraph2 *iface,
510 IEnumFilters **ppEnum) {
511 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
513 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
515 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
518 static HRESULT WINAPI FilterGraph2_FindFilterByName(IFilterGraph2 *iface,
520 IBaseFilter **ppFilter) {
521 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
524 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
529 for (i = 0; i < This->nFilters; i++)
531 if (!strcmpW(pName, This->pFilterNames[i]))
533 *ppFilter = This->ppFiltersInGraph[i];
534 IBaseFilter_AddRef(*ppFilter);
540 return VFW_E_NOT_FOUND;
543 /* NOTE: despite the implication, it doesn't matter which
544 * way round you put in the input and output pins */
545 static HRESULT WINAPI FilterGraph2_ConnectDirect(IFilterGraph2 *iface,
548 const AM_MEDIA_TYPE *pmt) {
552 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
554 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
556 /* FIXME: check pins are in graph */
558 if (TRACE_ON(quartz))
562 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
566 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
567 IBaseFilter_Release(PinInfo.pFilter);
569 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
573 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
574 IBaseFilter_Release(PinInfo.pFilter);
577 hr = IPin_QueryDirection(ppinIn, &dir);
580 if (dir == PINDIR_INPUT)
581 hr = IPin_Connect(ppinOut, ppinIn, pmt);
583 hr = IPin_Connect(ppinIn, ppinOut, pmt);
589 static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface,
591 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
592 IPin *pConnectedTo = NULL;
594 PIN_DIRECTION pindir;
596 IPin_QueryDirection(ppin, &pindir);
597 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
599 TRACE("Querying connected to failed: %x\n", hr);
602 IPin_Disconnect(ppin);
603 IPin_Disconnect(pConnectedTo);
604 if (pindir == PINDIR_INPUT)
605 hr = IPin_Connect(pConnectedTo, ppin, NULL);
607 hr = IPin_Connect(ppin, pConnectedTo, NULL);
608 IPin_Release(pConnectedTo);
610 ERR("Reconnecting pins failed, pins are not connected now..\n");
611 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
615 static HRESULT WINAPI FilterGraph2_Disconnect(IFilterGraph2 *iface,
617 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
619 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
621 return IPin_Disconnect(ppin);
624 static HRESULT WINAPI FilterGraph2_SetDefaultSyncSource(IFilterGraph2 *iface) {
625 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
626 IReferenceClock *pClock = NULL;
629 TRACE("(%p/%p)->() semi-stub\n", iface, This);
631 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pClock);
635 hr = IMediaFilter_SetSyncSource((IMediaFilter*)&(This->IMediaFilter_vtbl), pClock);
636 IReferenceClock_Release(pClock);
642 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
644 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
645 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
646 IPropertyBag * pPropBagCat = NULL;
650 V_VT(pvar) = VT_BSTR;
652 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
655 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
658 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
661 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
664 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
667 IPropertyBag_Release(pPropBagCat);
672 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
677 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
678 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
681 } else if (hr == S_FALSE) {
682 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
683 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
685 ERR("Error (%x)\n", hr);
687 } else if (hr == E_NOTIMPL) {
688 /* Input connected to all outputs */
689 IEnumPins* penumpins;
692 TRACE("E_NOTIMPL\n");
693 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
695 ERR("filter Enumpins failed (%x)\n", hr);
699 /* Count output pins */
700 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
701 PIN_DIRECTION pindir;
702 IPin_QueryDirection(ppin, &pindir);
703 if (pindir == PINDIR_OUTPUT)
707 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
708 /* Retrieve output pins */
709 IEnumPins_Reset(penumpins);
711 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
712 PIN_DIRECTION pindir;
713 IPin_QueryDirection(ppin, &pindir);
714 if (pindir == PINDIR_OUTPUT)
715 (*pppins)[i++] = ppin;
719 IEnumPins_Release(penumpins);
722 ERR("Next failed (%x)\n", hr);
725 } else if (FAILED(hr)) {
726 ERR("Cannot get internal connection (%x)\n", hr);
734 /*** IGraphBuilder methods ***/
735 static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface,
738 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
741 IEnumMediaTypes* penummt;
743 IEnumPins* penumpins;
744 IEnumMoniker* pEnumMoniker;
752 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
754 if (TRACE_ON(quartz))
756 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
760 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
761 IBaseFilter_Release(PinInfo.pFilter);
763 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
767 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
768 IBaseFilter_Release(PinInfo.pFilter);
771 /* Try direct connection first */
772 hr = IPin_Connect(ppinOut, ppinIn, NULL);
776 TRACE("Direct connection failed, trying to insert other filters\n");
778 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
782 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
783 IBaseFilter_Release(PinInfo.pFilter);
787 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
788 * filter to the minor mediatype of input pin of the renderer */
789 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
791 ERR("EnumMediaTypes (%x)\n", hr);
795 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
797 ERR("IEnumMediaTypes_Next (%x)\n", hr);
802 ERR("No media type found!\n");
805 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
806 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
808 /* Try to find a suitable filter that can connect to the pin to render */
809 tab[0] = mt->majortype;
810 tab[1] = mt->subtype;
811 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
813 ERR("Unable to enum filters (%x)\n", hr);
817 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
822 IPin* ppinfilter = NULL;
823 IBaseFilter* pfilter = NULL;
825 hr = GetFilterInfo(pMoniker, &clsid, &var);
826 IMoniker_Release(pMoniker);
828 ERR("Unable to retrieve filter info (%x)\n", hr);
832 if (IsEqualGUID(&clsid, &FilterCLSID)) {
833 /* Skip filter (same as the one the output pin belongs to) */
837 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
839 ERR("Unable to create filter (%x), trying next one\n", hr);
843 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
845 ERR("Unable to add filter (%x)\n", hr);
846 IBaseFilter_Release(pfilter);
851 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
853 ERR("Enumpins (%x)\n", hr);
857 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
858 IEnumPins_Release(penumpins);
861 ERR("Next (%x)\n", hr);
869 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
871 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
874 TRACE("Successfully connected to filter, follow chain...\n");
876 /* Render all output pins of the filter by calling IFilterGraph2_Render on each of them */
877 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
882 IPin_Disconnect(ppinOut);
885 TRACE("pins to consider: %d\n", nb);
886 for(i = 0; i < nb; i++) {
887 TRACE("Processing pin %d\n", i);
888 hr = IFilterGraph2_Connect(iface, ppins[i], ppinIn);
890 TRACE("Cannot render pin %p (%x)\n", ppinfilter, hr);
892 IPin_Release(ppins[i]);
893 if (SUCCEEDED(hr)) break;
895 while (++i < nb) IPin_Release(ppins[i]);
896 CoTaskMemFree(ppins);
897 IPin_Release(ppinfilter);
898 IBaseFilter_Release(pfilter);
903 if (ppinfilter) IPin_Release(ppinfilter);
905 IFilterGraph2_RemoveFilter(iface, pfilter);
906 IBaseFilter_Release(pfilter);
910 IEnumMediaTypes_Release(penummt);
916 static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface,
918 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
919 IEnumMediaTypes* penummt;
924 IEnumMoniker* pEnumMoniker;
929 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
931 if (TRACE_ON(quartz))
935 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
939 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
940 IBaseFilter_Release(PinInfo.pFilter);
943 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
945 ERR("EnumMediaTypes (%x)\n", hr);
951 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
953 ERR("IEnumMediaTypes_Next (%x)\n", hr);
958 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
959 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
961 /* Try to find a suitable renderer with the same media type */
962 tab[0] = mt->majortype;
964 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL);
966 ERR("Unable to enum filters (%x)\n", hr);
970 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
975 IBaseFilter* pfilter = NULL;
976 IEnumPins* penumpins;
979 hr = GetFilterInfo(pMoniker, &clsid, &var);
980 IMoniker_Release(pMoniker);
982 ERR("Unable to retrieve filter info (%x)\n", hr);
986 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
988 ERR("Unable to create filter (%x), trying next one\n", hr);
992 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
994 ERR("Unable to add filter (%x)\n", hr);
995 IBaseFilter_Release(pfilter);
1000 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1002 ERR("Splitter Enumpins (%x)\n", hr);
1005 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
1006 IEnumPins_Release(penumpins);
1008 ERR("Next (%x)\n", hr);
1016 /* Connect the pin to render to the renderer */
1017 hr = IFilterGraph2_Connect(iface, ppinOut, ppinfilter);
1019 TRACE("Unable to connect to renderer (%x)\n", hr);
1020 IPin_Release(ppinfilter);
1023 IPin_Release(ppinfilter);
1024 IBaseFilter_Release(pfilter);
1030 IFilterGraph2_RemoveFilter(iface, pfilter);
1031 IBaseFilter_Release(pfilter);
1035 DeleteMediaType(mt);
1039 IEnumMediaTypes_Release(penummt);
1044 static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface,
1045 LPCWSTR lpcwstrFile,
1046 LPCWSTR lpcwstrPlayList) {
1047 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1048 static const WCHAR string[] = {'R','e','a','d','e','r',0};
1049 IBaseFilter* preader = NULL;
1050 IBaseFilter* psplitter = NULL;
1051 IPin* ppinreader = NULL;
1052 IPin* ppinsplitter = NULL;
1053 IEnumPins* penumpins;
1056 IEnumMoniker* pEnumMoniker = NULL;
1058 IPin** ppins = NULL;
1061 IFileSourceFilter* pfile = NULL;
1065 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1067 if (lpcwstrPlayList != NULL)
1068 return E_INVALIDARG;
1070 hr = IFilterGraph2_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1072 /* Retrieve file media type */
1074 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1075 if (SUCCEEDED(hr)) {
1076 hr = IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1077 IFileSourceFilter_Release(pfile);
1081 hr = IBaseFilter_EnumPins(preader, &penumpins);
1082 if (SUCCEEDED(hr)) {
1083 hr = IEnumPins_Next(penumpins, 1, &ppinreader, &pin);
1084 IEnumPins_Release(penumpins);
1087 if (SUCCEEDED(hr)) {
1088 tab[0] = mt.majortype;
1089 tab[1] = mt.subtype;
1090 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1096 IPin_Release(ppinreader);
1098 IEnumMoniker_Release(pEnumMoniker);
1100 IFilterGraph2_RemoveFilter(iface, preader);
1101 IBaseFilter_Release(preader);
1106 hr = VFW_E_CANNOT_RENDER;
1107 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1112 hr = GetFilterInfo(pMoniker, &clsid, &var);
1113 IMoniker_Release(pMoniker);
1115 ERR("Unable to retrieve filter info (%x)\n", hr);
1119 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&psplitter);
1121 ERR("Unable to create filter (%x), trying next one\n", hr);
1125 hr = IFilterGraph2_AddFilter(iface, psplitter, V_UNION(&var, bstrVal));
1127 ERR("Unable add filter (%x)\n", hr);
1128 IBaseFilter_Release(psplitter);
1132 /* Connect file source and splitter filters together */
1133 /* Make the splitter analyze incoming data */
1135 hr = IBaseFilter_EnumPins(psplitter, &penumpins);
1136 if (SUCCEEDED(hr)) {
1137 hr = IEnumPins_Next(penumpins, 1, &ppinsplitter, &pin);
1138 IEnumPins_Release(penumpins);
1142 hr = IPin_Connect(ppinreader, ppinsplitter, NULL);
1144 /* Make sure there's some output pins in the filter */
1146 hr = GetInternalConnections(psplitter, ppinsplitter, &ppins, &nb);
1147 if (SUCCEEDED(hr)) {
1149 IPin_Disconnect(ppinreader);
1150 TRACE("No output pins found in filter\n");
1151 hr = VFW_E_CANNOT_RENDER;
1156 IPin_Release(ppinsplitter);
1157 ppinsplitter = NULL;
1159 if (SUCCEEDED(hr)) {
1160 TRACE("Successfully connected to filter\n");
1164 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1167 CoTaskMemFree(ppins);
1170 IFilterGraph2_RemoveFilter(iface, psplitter);
1171 IBaseFilter_Release(psplitter);
1175 /* Render all output pin of the splitter by calling IFilterGraph2_Render on each of them */
1176 if (SUCCEEDED(hr)) {
1179 TRACE("pins to consider: %d\n", nb);
1180 for(i = 0; i < nb; i++) {
1181 TRACE("Processing pin %d\n", i);
1182 hr = IFilterGraph2_Render(iface, ppins[i]);
1184 ERR("Cannot render pin %p (%x)\n", ppins[i], hr);
1187 IPin_Release(ppins[i]);
1189 CoTaskMemFree(ppins);
1191 hr = (partial ? VFW_S_PARTIAL_RENDER : S_OK);
1194 IPin_Release(ppinreader);
1195 IBaseFilter_Release(preader);
1197 IBaseFilter_Release(psplitter);
1202 static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface,
1203 LPCWSTR lpcwstrFileName,
1204 LPCWSTR lpcwstrFilterName,
1205 IBaseFilter **ppFilter) {
1206 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1208 IBaseFilter* preader;
1209 IFileSourceFilter* pfile = NULL;
1213 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1215 /* Instantiate a file source filter */
1216 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1218 ERR("Unable to create file source filter (%x)\n", hr);
1222 hr = IFilterGraph2_AddFilter(iface, preader, lpcwstrFilterName);
1224 ERR("Unable add filter (%x)\n", hr);
1225 IBaseFilter_Release(preader);
1229 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1231 ERR("Unable to get IFileSourceInterface (%x)\n", hr);
1235 /* Load the file in the file source filter */
1236 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1238 ERR("Load (%x)\n", hr);
1242 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1244 ERR("GetCurFile (%x)\n", hr);
1247 TRACE("File %s\n", debugstr_w(filename));
1248 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1249 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1252 *ppFilter = preader;
1253 IFileSourceFilter_Release(pfile);
1259 IFileSourceFilter_Release(pfile);
1260 IFilterGraph2_RemoveFilter(iface, preader);
1261 IBaseFilter_Release(preader);
1266 static HRESULT WINAPI FilterGraph2_SetLogFile(IFilterGraph2 *iface,
1268 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1270 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1275 static HRESULT WINAPI FilterGraph2_Abort(IFilterGraph2 *iface) {
1276 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1278 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1283 static HRESULT WINAPI FilterGraph2_ShouldOperationContinue(IFilterGraph2 *iface) {
1284 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1286 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1291 /*** IFilterGraph2 methods ***/
1292 static HRESULT WINAPI FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2 *iface,
1295 LPCWSTR lpcwstrFilterName,
1296 IBaseFilter **ppFilter) {
1297 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1299 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This, iface, pMoniker, pCtx, debugstr_w(lpcwstrFilterName), ppFilter);
1304 static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface,
1306 const AM_MEDIA_TYPE *pmt) {
1307 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1309 TRACE("(%p/%p)->(%p %p): stub !!!\n", This, iface, ppin, pmt);
1314 static HRESULT WINAPI FilterGraph2_RenderEx(IFilterGraph2 *iface,
1318 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1320 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This, iface, pPinOut, dwFlags, pvContext);
1326 static const IFilterGraph2Vtbl IFilterGraph2_VTable =
1328 FilterGraph2_QueryInterface,
1329 FilterGraph2_AddRef,
1330 FilterGraph2_Release,
1331 FilterGraph2_AddFilter,
1332 FilterGraph2_RemoveFilter,
1333 FilterGraph2_EnumFilters,
1334 FilterGraph2_FindFilterByName,
1335 FilterGraph2_ConnectDirect,
1336 FilterGraph2_Reconnect,
1337 FilterGraph2_Disconnect,
1338 FilterGraph2_SetDefaultSyncSource,
1339 FilterGraph2_Connect,
1340 FilterGraph2_Render,
1341 FilterGraph2_RenderFile,
1342 FilterGraph2_AddSourceFilter,
1343 FilterGraph2_SetLogFile,
1345 FilterGraph2_ShouldOperationContinue,
1346 FilterGraph2_AddSourceFilterForMoniker,
1347 FilterGraph2_ReconnectEx,
1348 FilterGraph2_RenderEx
1351 /*** IUnknown methods ***/
1352 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1355 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1357 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1359 return Filtergraph_QueryInterface(This, riid, ppvObj);
1362 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1363 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1365 TRACE("(%p/%p)->()\n", This, iface);
1367 return Filtergraph_AddRef(This);
1370 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1371 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1373 TRACE("(%p/%p)->()\n", This, iface);
1375 return Filtergraph_Release(This);
1379 /*** IDispatch methods ***/
1380 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1382 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1384 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1389 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1392 ITypeInfo**ppTInfo) {
1393 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1395 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1400 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1406 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1408 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1413 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1414 DISPID dispIdMember,
1418 DISPPARAMS*pDispParams,
1420 EXCEPINFO*pExepInfo,
1422 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1424 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1429 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *);
1431 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter)
1440 TRACE("%p %p\n", pGraph, pOutputPin);
1441 PinInfo.pFilter = NULL;
1443 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1447 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1449 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1450 IPin_Release(pInputPin);
1457 TRACE("Reached a renderer\n");
1458 /* Count renderers for end of stream notification */
1459 pGraph->nRenderers++;
1463 for(i = 0; i < nb; i++)
1465 /* Explore the graph downstream from this pin
1466 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1467 * several input pins are connected to the same output (a MUX for instance). */
1468 ExploreGraph(pGraph, ppPins[i], FoundFilter);
1469 IPin_Release(ppPins[i]);
1472 CoTaskMemFree(ppPins);
1474 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1475 LeaveCriticalSection(&pGraph->cs);
1476 FoundFilter(PinInfo.pFilter);
1477 EnterCriticalSection(&pGraph->cs);
1480 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1484 static HRESULT WINAPI SendRun(IBaseFilter *pFilter) {
1486 IReferenceClock *clock = NULL;
1488 IBaseFilter_GetSyncSource(pFilter, &clock);
1491 IReferenceClock_GetTime(clock, &time);
1497 IReferenceClock_Release(clock);
1500 return IBaseFilter_Run(pFilter, time);
1503 static HRESULT WINAPI SendPause(IBaseFilter *pFilter) {
1504 return IBaseFilter_Pause(pFilter);
1507 static HRESULT WINAPI SendStop(IBaseFilter *pFilter) {
1508 return IBaseFilter_Stop(pFilter);
1511 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter) {
1512 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1514 IBaseFilter* pfilter;
1520 TRACE("(%p/%p)->()\n", This, iface);
1522 /* Explorer the graph from source filters to renderers, determine renderers
1523 * number and run filters from renderers to source filters */
1524 This->nRenderers = 0;
1525 ResetEvent(This->hEventCompletion);
1527 for(i = 0; i < This->nFilters; i++)
1530 pfilter = This->ppFiltersInGraph[i];
1531 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1534 ERR("Enum pins failed %x\n", hr);
1537 /* Check if it is a source filter */
1538 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1540 IPin_QueryDirection(pPin, &dir);
1542 if (dir == PINDIR_INPUT)
1550 TRACE("Found a source filter %p\n", pfilter);
1551 IEnumPins_Reset(pEnum);
1552 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1554 /* Explore the graph downstream from this pin */
1555 ExploreGraph(This, pPin, FoundFilter);
1558 FoundFilter(pfilter);
1560 IEnumPins_Release(pEnum);
1566 /*** IMediaControl methods ***/
1567 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1568 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1569 TRACE("(%p/%p)->()\n", This, iface);
1571 if (This->state == State_Running) return S_OK;
1573 EnterCriticalSection(&This->cs);
1576 IReferenceClock_GetTime(This->refClock, &This->start_time);
1577 This->start_time += 500000;
1579 else This->position = This->start_time = 0;
1581 SendFilterMessage(iface, SendRun);
1582 This->state = State_Running;
1583 LeaveCriticalSection(&This->cs);
1587 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1588 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1589 TRACE("(%p/%p)->()\n", This, iface);
1591 if (This->state == State_Paused) return S_OK;
1593 EnterCriticalSection(&This->cs);
1594 if (This->state == State_Running && This->refClock)
1596 LONGLONG time = This->start_time;
1597 IReferenceClock_GetTime(This->refClock, &time);
1598 This->position += time - This->start_time;
1601 SendFilterMessage(iface, SendPause);
1602 This->state = State_Paused;
1603 LeaveCriticalSection(&This->cs);
1607 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
1608 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1609 TRACE("(%p/%p)->()\n", This, iface);
1611 if (This->state == State_Stopped) return S_OK;
1613 EnterCriticalSection(&This->cs);
1614 if (This->state == State_Running && This->refClock)
1616 LONGLONG time = This->start_time;
1617 IReferenceClock_GetTime(This->refClock, &time);
1618 This->position += time - This->start_time;
1621 if (This->state == State_Running) SendFilterMessage(iface, SendPause);
1622 SendFilterMessage(iface, SendStop);
1623 This->state = State_Stopped;
1624 LeaveCriticalSection(&This->cs);
1628 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
1630 OAFilterState *pfs) {
1631 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1633 TRACE("(%p/%p)->(%d, %p): semi-stub !!!\n", This, iface, msTimeout, pfs);
1635 EnterCriticalSection(&This->cs);
1639 LeaveCriticalSection(&This->cs);
1644 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
1646 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1648 FIXME("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
1653 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
1655 IDispatch **ppUnk) {
1656 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1658 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
1663 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
1664 IDispatch **ppUnk) {
1665 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1667 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1672 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
1673 IDispatch **ppUnk) {
1674 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1676 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1681 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
1682 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1684 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1690 static const IMediaControlVtbl IMediaControl_VTable =
1692 MediaControl_QueryInterface,
1693 MediaControl_AddRef,
1694 MediaControl_Release,
1695 MediaControl_GetTypeInfoCount,
1696 MediaControl_GetTypeInfo,
1697 MediaControl_GetIDsOfNames,
1698 MediaControl_Invoke,
1702 MediaControl_GetState,
1703 MediaControl_RenderFile,
1704 MediaControl_AddSourceFilter,
1705 MediaControl_get_FilterCollection,
1706 MediaControl_get_RegFilterCollection,
1707 MediaControl_StopWhenReady
1711 /*** IUnknown methods ***/
1712 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
1715 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1717 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1719 return Filtergraph_QueryInterface(This, riid, ppvObj);
1722 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
1723 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1725 TRACE("(%p/%p)->()\n", This, iface);
1727 return Filtergraph_AddRef(This);
1730 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
1731 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1733 TRACE("(%p/%p)->()\n", This, iface);
1735 return Filtergraph_Release(This);
1738 typedef HRESULT WINAPI (*fnFoundSeek)(IFilterGraphImpl *This, IMediaSeeking*, DWORD_PTR arg);
1740 static HRESULT all_renderers_seek(IFilterGraphImpl *This, fnFoundSeek FoundSeek, DWORD_PTR arg) {
1741 BOOL allnotimpl = TRUE;
1743 IBaseFilter* pfilter;
1745 HRESULT hr, hr_return = S_OK;
1750 TRACE("(%p)->(%p %08lx)\n", This, FoundSeek, arg);
1751 /* Send a message to all renderers, they are responsible for broadcasting it further */
1753 for(i = 0; i < This->nFilters; i++)
1755 BOOL renderer = TRUE;
1756 pfilter = This->ppFiltersInGraph[i];
1757 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1760 ERR("Enum pins failed %x\n", hr);
1763 /* Check if it is a source filter */
1764 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1766 IPin_QueryDirection(pPin, &dir);
1768 if (dir != PINDIR_INPUT)
1774 IEnumPins_Release(pEnum);
1777 IMediaSeeking *seek = NULL;
1778 IBaseFilter_QueryInterface(pfilter, &IID_IMediaSeeking, (void**)&seek);
1781 LeaveCriticalSection(&This->cs);
1782 hr = FoundSeek(This, seek, arg);
1783 EnterCriticalSection(&This->cs);
1784 IMediaSeeking_Release(seek);
1785 if (hr_return != E_NOTIMPL)
1787 if (hr_return == S_OK || (FAILED(hr) && hr != E_NOTIMPL && !FAILED(hr_return)))
1797 static HRESULT WINAPI FoundCapabilities(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pcaps)
1802 hr = IMediaSeeking_GetCapabilities(seek, &caps);
1806 /* Only add common capabilities everything supports */
1807 *(DWORD*)pcaps &= caps;
1812 /*** IMediaSeeking methods ***/
1813 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
1814 DWORD *pCapabilities) {
1815 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1817 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
1822 EnterCriticalSection(&This->cs);
1823 *pCapabilities = 0xffffffff;
1825 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
1826 LeaveCriticalSection(&This->cs);
1831 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
1832 DWORD *pCapabilities) {
1833 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1836 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
1841 EnterCriticalSection(&This->cs);
1842 originalcaps = *pCapabilities;
1843 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
1844 LeaveCriticalSection(&This->cs);
1849 if (!*pCapabilities)
1851 if (*pCapabilities != originalcaps)
1856 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
1857 const GUID *pFormat) {
1858 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1863 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
1865 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
1867 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
1874 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
1876 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1881 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This, iface, pFormat);
1882 memcpy(pFormat, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
1887 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
1889 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1894 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
1895 memcpy(pFormat, &This->timeformatseek, sizeof(GUID));
1900 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
1901 const GUID *pFormat) {
1902 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1904 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
1908 if (memcmp(pFormat, &This->timeformatseek, sizeof(GUID)))
1914 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
1915 const GUID *pFormat) {
1916 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1921 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
1923 if (This->state != State_Stopped)
1924 return VFW_E_WRONG_STATE;
1926 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
1928 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
1929 return E_INVALIDARG;
1935 static HRESULT WINAPI FoundDuration(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pduration)
1938 LONGLONG duration = 0, *pdur = (LONGLONG*)pduration;
1940 hr = IMediaSeeking_GetDuration(seek, &duration);
1944 /* FIXME: Minimum or maximum duration? Assuming minimum */
1945 if (duration > 0 && *pdur < duration)
1951 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
1952 LONGLONG *pDuration) {
1953 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1956 TRACE("(%p/%p)->(%p)\n", This, iface, pDuration);
1961 EnterCriticalSection(&This->cs);
1963 hr = all_renderers_seek(This, FoundDuration, (DWORD_PTR)pDuration);
1964 LeaveCriticalSection(&This->cs);
1966 TRACE("--->%08x\n", hr);
1970 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
1972 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1974 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pStop);
1979 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
1980 LONGLONG *pCurrent) {
1981 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1987 EnterCriticalSection(&This->cs);
1988 if (This->state == State_Running && This->refClock)
1990 IReferenceClock_GetTime(This->refClock, &time);
1992 time += This->position - This->start_time;
1993 if (time < This->position)
1994 time = This->position;
1998 *pCurrent = This->position;
1999 LeaveCriticalSection(&This->cs);
2000 TRACE("Time: %lld.%03lld\n", *pCurrent / 10000000, (*pCurrent / 10000)%1000);
2005 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
2007 const GUID *pTargetFormat,
2009 const GUID *pSourceFormat) {
2010 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2012 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
2013 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
2018 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
2020 DWORD dwCurrentFlags,
2022 DWORD dwStopFlags) {
2023 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2025 FIXME("(%p/%p)->(%p, %08x, %p, %08x): stub !!!\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
2030 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
2033 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2036 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pCurrent, pStop);
2037 hr = IMediaSeeking_GetCurrentPosition(iface, pCurrent);
2039 hr = IMediaSeeking_GetStopPosition(iface, pStop);
2044 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
2045 LONGLONG *pEarliest,
2046 LONGLONG *pLatest) {
2047 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2049 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
2054 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
2056 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2058 FIXME("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
2063 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
2065 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2067 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
2072 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
2073 LONGLONG *pllPreroll) {
2074 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2076 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
2082 static const IMediaSeekingVtbl IMediaSeeking_VTable =
2084 MediaSeeking_QueryInterface,
2085 MediaSeeking_AddRef,
2086 MediaSeeking_Release,
2087 MediaSeeking_GetCapabilities,
2088 MediaSeeking_CheckCapabilities,
2089 MediaSeeking_IsFormatSupported,
2090 MediaSeeking_QueryPreferredFormat,
2091 MediaSeeking_GetTimeFormat,
2092 MediaSeeking_IsUsingTimeFormat,
2093 MediaSeeking_SetTimeFormat,
2094 MediaSeeking_GetDuration,
2095 MediaSeeking_GetStopPosition,
2096 MediaSeeking_GetCurrentPosition,
2097 MediaSeeking_ConvertTimeFormat,
2098 MediaSeeking_SetPositions,
2099 MediaSeeking_GetPositions,
2100 MediaSeeking_GetAvailable,
2101 MediaSeeking_SetRate,
2102 MediaSeeking_GetRate,
2103 MediaSeeking_GetPreroll
2106 /*** IUnknown methods ***/
2107 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj){
2108 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
2110 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2112 return Filtergraph_QueryInterface(This, riid, ppvObj);
2115 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface){
2116 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
2118 TRACE("(%p/%p)->()\n", This, iface);
2120 return Filtergraph_AddRef(This);
2123 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface){
2124 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
2126 TRACE("(%p/%p)->()\n", This, iface);
2128 return Filtergraph_Release(This);
2131 /*** IDispatch methods ***/
2132 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
2133 FIXME("(%p) stub!\n", iface);
2137 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
2138 FIXME("(%p) stub!\n", iface);
2142 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
2143 FIXME("(%p) stub!\n", iface);
2147 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
2148 FIXME("(%p) stub!\n", iface);
2152 /*** IMediaPosition methods ***/
2153 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength){
2154 FIXME("(%p)->(%p) stub!\n", iface, plength);
2158 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime){
2159 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2163 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime){
2164 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2168 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime){
2169 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2173 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime){
2174 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2178 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
2179 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2183 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
2184 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2188 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate){
2189 FIXME("(%p)->(%f) stub!\n", iface, dRate);
2193 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate){
2194 FIXME("(%p)->(%p) stub!\n", iface, pdRate);
2198 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
2199 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
2203 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
2204 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
2209 static const IMediaPositionVtbl IMediaPosition_VTable =
2211 MediaPosition_QueryInterface,
2212 MediaPosition_AddRef,
2213 MediaPosition_Release,
2214 MediaPosition_GetTypeInfoCount,
2215 MediaPosition_GetTypeInfo,
2216 MediaPosition_GetIDsOfNames,
2217 MediaPosition_Invoke,
2218 MediaPosition_get_Duration,
2219 MediaPosition_put_CurrentPosition,
2220 MediaPosition_get_CurrentPosition,
2221 MediaPosition_get_StopTime,
2222 MediaPosition_put_StopTime,
2223 MediaPosition_get_PrerollTime,
2224 MediaPosition_put_PrerollTime,
2225 MediaPosition_put_Rate,
2226 MediaPosition_get_Rate,
2227 MediaPosition_CanSeekForward,
2228 MediaPosition_CanSeekBackward
2231 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
2233 HRESULT hr = E_NOINTERFACE;
2237 /* Check if the interface type is already registered */
2238 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
2239 if (riid == pGraph->ItfCacheEntries[entry].riid)
2241 if (pGraph->ItfCacheEntries[entry].iface)
2243 /* Return the interface if available */
2244 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
2250 if (entry >= MAX_ITF_CACHE_ENTRIES)
2252 FIXME("Not enough space to store interface in the cache\n");
2253 return E_OUTOFMEMORY;
2256 /* Find a filter supporting the requested interface */
2257 for (i = 0; i < pGraph->nFilters; i++)
2259 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
2262 pGraph->ItfCacheEntries[entry].riid = riid;
2263 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
2264 pGraph->ItfCacheEntries[entry].iface = (IUnknown*)*ppvObj;
2265 if (entry >= pGraph->nItfCacheEntries)
2266 pGraph->nItfCacheEntries++;
2269 if (hr != E_NOINTERFACE)
2276 /*** IUnknown methods ***/
2277 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
2280 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2282 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2284 return Filtergraph_QueryInterface(This, riid, ppvObj);
2287 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
2288 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2290 TRACE("(%p/%p)->()\n", This, iface);
2292 return Filtergraph_AddRef(This);
2295 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
2296 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2298 TRACE("(%p/%p)->()\n", This, iface);
2300 return Filtergraph_Release(This);
2303 /*** IDispatch methods ***/
2304 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
2306 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2307 IBasicAudio* pBasicAudio;
2310 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2312 EnterCriticalSection(&This->cs);
2314 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2317 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
2319 LeaveCriticalSection(&This->cs);
2324 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
2327 ITypeInfo**ppTInfo) {
2328 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2329 IBasicAudio* pBasicAudio;
2332 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2334 EnterCriticalSection(&This->cs);
2336 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2339 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
2341 LeaveCriticalSection(&This->cs);
2346 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
2352 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2353 IBasicAudio* pBasicAudio;
2356 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2358 EnterCriticalSection(&This->cs);
2360 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2363 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2365 LeaveCriticalSection(&This->cs);
2370 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2371 DISPID dispIdMember,
2375 DISPPARAMS*pDispParams,
2377 EXCEPINFO*pExepInfo,
2379 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2380 IBasicAudio* pBasicAudio;
2383 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p)\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2385 EnterCriticalSection(&This->cs);
2387 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2390 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2392 LeaveCriticalSection(&This->cs);
2397 /*** IBasicAudio methods ***/
2398 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2400 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2401 IBasicAudio* pBasicAudio;
2404 TRACE("(%p/%p)->(%ld)\n", This, iface, lVolume);
2406 EnterCriticalSection(&This->cs);
2408 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2411 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2413 LeaveCriticalSection(&This->cs);
2418 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2420 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2421 IBasicAudio* pBasicAudio;
2424 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2426 EnterCriticalSection(&This->cs);
2428 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2431 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2433 LeaveCriticalSection(&This->cs);
2438 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2440 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2441 IBasicAudio* pBasicAudio;
2444 TRACE("(%p/%p)->(%ld)\n", This, iface, lBalance);
2446 EnterCriticalSection(&This->cs);
2448 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2451 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2453 LeaveCriticalSection(&This->cs);
2458 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2460 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2461 IBasicAudio* pBasicAudio;
2464 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2466 EnterCriticalSection(&This->cs);
2468 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2471 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2473 LeaveCriticalSection(&This->cs);
2478 static const IBasicAudioVtbl IBasicAudio_VTable =
2480 BasicAudio_QueryInterface,
2483 BasicAudio_GetTypeInfoCount,
2484 BasicAudio_GetTypeInfo,
2485 BasicAudio_GetIDsOfNames,
2487 BasicAudio_put_Volume,
2488 BasicAudio_get_Volume,
2489 BasicAudio_put_Balance,
2490 BasicAudio_get_Balance
2493 /*** IUnknown methods ***/
2494 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo *iface,
2497 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2499 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2501 return Filtergraph_QueryInterface(This, riid, ppvObj);
2504 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo *iface) {
2505 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2507 TRACE("(%p/%p)->()\n", This, iface);
2509 return Filtergraph_AddRef(This);
2512 static ULONG WINAPI BasicVideo_Release(IBasicVideo *iface) {
2513 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2515 TRACE("(%p/%p)->()\n", This, iface);
2517 return Filtergraph_Release(This);
2520 /*** IDispatch methods ***/
2521 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo *iface,
2523 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2524 IBasicVideo* pBasicVideo;
2527 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2529 EnterCriticalSection(&This->cs);
2531 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2534 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
2536 LeaveCriticalSection(&This->cs);
2541 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo *iface,
2544 ITypeInfo**ppTInfo) {
2545 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2546 IBasicVideo* pBasicVideo;
2549 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2551 EnterCriticalSection(&This->cs);
2553 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2556 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
2558 LeaveCriticalSection(&This->cs);
2563 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo *iface,
2569 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2570 IBasicVideo* pBasicVideo;
2573 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2575 EnterCriticalSection(&This->cs);
2577 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2580 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
2582 LeaveCriticalSection(&This->cs);
2587 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo *iface,
2588 DISPID dispIdMember,
2592 DISPPARAMS*pDispParams,
2594 EXCEPINFO*pExepInfo,
2596 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2597 IBasicVideo* pBasicVideo;
2600 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p)\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2602 EnterCriticalSection(&This->cs);
2604 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2607 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2609 LeaveCriticalSection(&This->cs);
2614 /*** IBasicVideo methods ***/
2615 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo *iface,
2616 REFTIME *pAvgTimePerFrame) {
2617 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2618 IBasicVideo* pBasicVideo;
2621 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
2623 EnterCriticalSection(&This->cs);
2625 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2628 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
2630 LeaveCriticalSection(&This->cs);
2635 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo *iface,
2637 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2638 IBasicVideo* pBasicVideo;
2641 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
2643 EnterCriticalSection(&This->cs);
2645 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2648 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
2650 LeaveCriticalSection(&This->cs);
2655 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo *iface,
2656 long *pBitErrorRate) {
2657 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2658 IBasicVideo* pBasicVideo;
2661 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
2663 EnterCriticalSection(&This->cs);
2665 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2668 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
2670 LeaveCriticalSection(&This->cs);
2675 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo *iface,
2676 long *pVideoWidth) {
2677 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2678 IBasicVideo* pBasicVideo;
2681 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
2683 EnterCriticalSection(&This->cs);
2685 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2688 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
2690 LeaveCriticalSection(&This->cs);
2695 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo *iface,
2696 long *pVideoHeight) {
2697 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2698 IBasicVideo* pBasicVideo;
2701 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
2703 EnterCriticalSection(&This->cs);
2705 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2708 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
2710 LeaveCriticalSection(&This->cs);
2715 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo *iface,
2717 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2718 IBasicVideo* pBasicVideo;
2721 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
2723 EnterCriticalSection(&This->cs);
2725 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2728 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
2730 LeaveCriticalSection(&This->cs);
2735 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo *iface,
2736 long *pSourceLeft) {
2737 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2738 IBasicVideo* pBasicVideo;
2741 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
2743 EnterCriticalSection(&This->cs);
2745 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2748 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
2750 LeaveCriticalSection(&This->cs);
2755 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo *iface,
2757 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2758 IBasicVideo* pBasicVideo;
2761 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
2763 EnterCriticalSection(&This->cs);
2765 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2768 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
2770 LeaveCriticalSection(&This->cs);
2775 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo *iface,
2776 long *pSourceWidth) {
2777 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2778 IBasicVideo* pBasicVideo;
2781 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
2783 EnterCriticalSection(&This->cs);
2785 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2788 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
2790 LeaveCriticalSection(&This->cs);
2795 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo *iface,
2797 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2798 IBasicVideo* pBasicVideo;
2801 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
2803 EnterCriticalSection(&This->cs);
2805 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2808 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
2810 LeaveCriticalSection(&This->cs);
2815 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo *iface,
2817 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2818 IBasicVideo* pBasicVideo;
2821 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
2823 EnterCriticalSection(&This->cs);
2825 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2828 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
2830 LeaveCriticalSection(&This->cs);
2835 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo *iface,
2836 long SourceHeight) {
2837 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2838 IBasicVideo* pBasicVideo;
2841 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
2843 EnterCriticalSection(&This->cs);
2845 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2848 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
2850 LeaveCriticalSection(&This->cs);
2855 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo *iface,
2856 long *pSourceHeight) {
2857 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2858 IBasicVideo* pBasicVideo;
2861 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
2863 EnterCriticalSection(&This->cs);
2865 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2868 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
2870 LeaveCriticalSection(&This->cs);
2875 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo *iface,
2876 long DestinationLeft) {
2877 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2878 IBasicVideo* pBasicVideo;
2881 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
2883 EnterCriticalSection(&This->cs);
2885 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2888 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
2890 LeaveCriticalSection(&This->cs);
2895 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo *iface,
2896 long *pDestinationLeft) {
2897 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2898 IBasicVideo* pBasicVideo;
2901 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
2903 EnterCriticalSection(&This->cs);
2905 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2908 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
2910 LeaveCriticalSection(&This->cs);
2915 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo *iface,
2916 long DestinationWidth) {
2917 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2918 IBasicVideo* pBasicVideo;
2921 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
2923 EnterCriticalSection(&This->cs);
2925 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2928 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
2930 LeaveCriticalSection(&This->cs);
2935 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo *iface,
2936 long *pDestinationWidth) {
2937 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2938 IBasicVideo* pBasicVideo;
2941 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
2943 EnterCriticalSection(&This->cs);
2945 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2948 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
2950 LeaveCriticalSection(&This->cs);
2955 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo *iface,
2956 long DestinationTop) {
2957 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2958 IBasicVideo* pBasicVideo;
2961 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
2963 EnterCriticalSection(&This->cs);
2965 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2968 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
2970 LeaveCriticalSection(&This->cs);
2975 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo *iface,
2976 long *pDestinationTop) {
2977 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2978 IBasicVideo* pBasicVideo;
2981 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
2983 EnterCriticalSection(&This->cs);
2985 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2988 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
2990 LeaveCriticalSection(&This->cs);
2995 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo *iface,
2996 long DestinationHeight) {
2997 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2998 IBasicVideo* pBasicVideo;
3001 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
3003 EnterCriticalSection(&This->cs);
3005 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3008 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
3010 LeaveCriticalSection(&This->cs);
3015 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo *iface,
3016 long *pDestinationHeight) {
3017 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3018 IBasicVideo* pBasicVideo;
3021 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
3023 EnterCriticalSection(&This->cs);
3025 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3028 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
3030 LeaveCriticalSection(&This->cs);
3035 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo *iface,
3040 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3041 IBasicVideo* pBasicVideo;
3044 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
3046 EnterCriticalSection(&This->cs);
3048 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3051 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
3053 LeaveCriticalSection(&This->cs);
3058 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo *iface,
3063 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3064 IBasicVideo* pBasicVideo;
3067 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3069 EnterCriticalSection(&This->cs);
3071 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3074 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3076 LeaveCriticalSection(&This->cs);
3081 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo *iface) {
3082 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3083 IBasicVideo* pBasicVideo;
3086 TRACE("(%p/%p)->()\n", This, iface);
3088 EnterCriticalSection(&This->cs);
3090 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3093 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
3095 LeaveCriticalSection(&This->cs);
3100 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo *iface,
3105 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3106 IBasicVideo* pBasicVideo;
3109 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
3111 EnterCriticalSection(&This->cs);
3113 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3116 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
3118 LeaveCriticalSection(&This->cs);
3123 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo *iface,
3128 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3129 IBasicVideo* pBasicVideo;
3132 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3134 EnterCriticalSection(&This->cs);
3136 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3139 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3141 LeaveCriticalSection(&This->cs);
3146 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
3147 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3148 IBasicVideo* pBasicVideo;
3151 TRACE("(%p/%p)->()\n", This, iface);
3153 EnterCriticalSection(&This->cs);
3155 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3158 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
3160 LeaveCriticalSection(&This->cs);
3165 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo *iface,
3168 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3169 IBasicVideo* pBasicVideo;
3172 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3174 EnterCriticalSection(&This->cs);
3176 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3179 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
3181 LeaveCriticalSection(&This->cs);
3186 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo *iface,
3191 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3192 IBasicVideo* pBasicVideo;
3195 TRACE("(%p/%p)->(%ld, %ld, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
3197 EnterCriticalSection(&This->cs);
3199 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3202 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
3204 LeaveCriticalSection(&This->cs);
3209 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo *iface,
3212 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3213 IBasicVideo* pBasicVideo;
3216 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
3218 EnterCriticalSection(&This->cs);
3220 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3223 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
3225 LeaveCriticalSection(&This->cs);
3230 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo *iface) {
3231 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3232 IBasicVideo* pBasicVideo;
3235 TRACE("(%p/%p)->()\n", This, iface);
3237 EnterCriticalSection(&This->cs);
3239 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3242 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
3244 LeaveCriticalSection(&This->cs);
3249 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo *iface) {
3250 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3251 IBasicVideo* pBasicVideo;
3254 TRACE("(%p/%p)->()\n", This, iface);
3256 EnterCriticalSection(&This->cs);
3258 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3261 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
3263 LeaveCriticalSection(&This->cs);
3269 static const IBasicVideoVtbl IBasicVideo_VTable =
3271 BasicVideo_QueryInterface,
3274 BasicVideo_GetTypeInfoCount,
3275 BasicVideo_GetTypeInfo,
3276 BasicVideo_GetIDsOfNames,
3278 BasicVideo_get_AvgTimePerFrame,
3279 BasicVideo_get_BitRate,
3280 BasicVideo_get_BitErrorRate,
3281 BasicVideo_get_VideoWidth,
3282 BasicVideo_get_VideoHeight,
3283 BasicVideo_put_SourceLeft,
3284 BasicVideo_get_SourceLeft,
3285 BasicVideo_put_SourceWidth,
3286 BasicVideo_get_SourceWidth,
3287 BasicVideo_put_SourceTop,
3288 BasicVideo_get_SourceTop,
3289 BasicVideo_put_SourceHeight,
3290 BasicVideo_get_SourceHeight,
3291 BasicVideo_put_DestinationLeft,
3292 BasicVideo_get_DestinationLeft,
3293 BasicVideo_put_DestinationWidth,
3294 BasicVideo_get_DestinationWidth,
3295 BasicVideo_put_DestinationTop,
3296 BasicVideo_get_DestinationTop,
3297 BasicVideo_put_DestinationHeight,
3298 BasicVideo_get_DestinationHeight,
3299 BasicVideo_SetSourcePosition,
3300 BasicVideo_GetSourcePosition,
3301 BasicVideo_SetDefaultSourcePosition,
3302 BasicVideo_SetDestinationPosition,
3303 BasicVideo_GetDestinationPosition,
3304 BasicVideo_SetDefaultDestinationPosition,
3305 BasicVideo_GetVideoSize,
3306 BasicVideo_GetVideoPaletteEntries,
3307 BasicVideo_GetCurrentImage,
3308 BasicVideo_IsUsingDefaultSource,
3309 BasicVideo_IsUsingDefaultDestination
3313 /*** IUnknown methods ***/
3314 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
3317 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3319 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3321 return Filtergraph_QueryInterface(This, riid, ppvObj);
3324 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
3325 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3327 TRACE("(%p/%p)->()\n", This, iface);
3329 return Filtergraph_AddRef(This);
3332 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
3333 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3335 TRACE("(%p/%p)->()\n", This, iface);
3337 return Filtergraph_Release(This);
3340 /*** IDispatch methods ***/
3341 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
3343 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3344 IVideoWindow* pVideoWindow;
3347 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3349 EnterCriticalSection(&This->cs);
3351 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3354 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
3356 LeaveCriticalSection(&This->cs);
3361 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3364 ITypeInfo**ppTInfo) {
3365 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3366 IVideoWindow* pVideoWindow;
3369 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3371 EnterCriticalSection(&This->cs);
3373 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3376 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3378 LeaveCriticalSection(&This->cs);
3383 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3389 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3390 IVideoWindow* pVideoWindow;
3393 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3395 EnterCriticalSection(&This->cs);
3397 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3400 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3402 LeaveCriticalSection(&This->cs);
3407 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3408 DISPID dispIdMember,
3412 DISPPARAMS*pDispParams,
3414 EXCEPINFO*pExepInfo,
3416 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3417 IVideoWindow* pVideoWindow;
3420 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p)\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3422 EnterCriticalSection(&This->cs);
3424 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3427 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3429 LeaveCriticalSection(&This->cs);
3435 /*** IVideoWindow methods ***/
3436 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3438 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3439 IVideoWindow* pVideoWindow;
3442 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3444 EnterCriticalSection(&This->cs);
3446 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3449 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3451 LeaveCriticalSection(&This->cs);
3456 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3458 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3459 IVideoWindow* pVideoWindow;
3462 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3464 EnterCriticalSection(&This->cs);
3466 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3469 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3471 LeaveCriticalSection(&This->cs);
3476 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3478 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3479 IVideoWindow* pVideoWindow;
3482 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyle);
3484 EnterCriticalSection(&This->cs);
3486 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3489 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
3491 LeaveCriticalSection(&This->cs);
3496 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
3497 long *WindowStyle) {
3498 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3499 IVideoWindow* pVideoWindow;
3502 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
3504 EnterCriticalSection(&This->cs);
3506 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3509 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
3511 LeaveCriticalSection(&This->cs);
3516 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
3517 long WindowStyleEx) {
3518 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3519 IVideoWindow* pVideoWindow;
3522 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
3524 EnterCriticalSection(&This->cs);
3526 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3529 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
3531 LeaveCriticalSection(&This->cs);
3536 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
3537 long *WindowStyleEx) {
3538 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3539 IVideoWindow* pVideoWindow;
3542 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
3544 EnterCriticalSection(&This->cs);
3546 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3549 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
3551 LeaveCriticalSection(&This->cs);
3556 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
3558 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3559 IVideoWindow* pVideoWindow;
3562 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
3564 EnterCriticalSection(&This->cs);
3566 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3569 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
3571 LeaveCriticalSection(&This->cs);
3576 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
3578 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3579 IVideoWindow* pVideoWindow;
3582 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
3584 EnterCriticalSection(&This->cs);
3586 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3589 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
3591 LeaveCriticalSection(&This->cs);
3596 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
3598 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3599 IVideoWindow* pVideoWindow;
3602 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowState);
3604 EnterCriticalSection(&This->cs);
3606 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3609 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
3611 LeaveCriticalSection(&This->cs);
3616 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
3617 long *WindowState) {
3618 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3619 IVideoWindow* pVideoWindow;
3622 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
3624 EnterCriticalSection(&This->cs);
3626 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3629 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
3631 LeaveCriticalSection(&This->cs);
3636 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
3637 long BackgroundPalette) {
3638 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3639 IVideoWindow* pVideoWindow;
3642 TRACE("(%p/%p)->(%ld)\n", This, iface, BackgroundPalette);
3644 EnterCriticalSection(&This->cs);
3646 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3649 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
3651 LeaveCriticalSection(&This->cs);
3656 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
3657 long *pBackgroundPalette) {
3658 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3659 IVideoWindow* pVideoWindow;
3662 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
3664 EnterCriticalSection(&This->cs);
3666 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3669 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
3671 LeaveCriticalSection(&This->cs);
3676 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
3678 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3679 IVideoWindow* pVideoWindow;
3682 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
3684 EnterCriticalSection(&This->cs);
3686 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3689 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
3691 LeaveCriticalSection(&This->cs);
3696 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
3698 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3699 IVideoWindow* pVideoWindow;
3702 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
3704 EnterCriticalSection(&This->cs);
3706 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3709 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
3711 LeaveCriticalSection(&This->cs);
3716 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
3718 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3719 IVideoWindow* pVideoWindow;
3722 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
3724 EnterCriticalSection(&This->cs);
3726 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3729 hr = IVideoWindow_put_Left(pVideoWindow, Left);
3731 LeaveCriticalSection(&This->cs);
3736 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
3738 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3739 IVideoWindow* pVideoWindow;
3742 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
3744 EnterCriticalSection(&This->cs);
3746 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3749 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
3751 LeaveCriticalSection(&This->cs);
3756 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
3758 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3759 IVideoWindow* pVideoWindow;
3762 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
3764 EnterCriticalSection(&This->cs);
3766 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3769 hr = IVideoWindow_put_Width(pVideoWindow, Width);
3771 LeaveCriticalSection(&This->cs);
3776 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
3778 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3779 IVideoWindow* pVideoWindow;
3782 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
3784 EnterCriticalSection(&This->cs);
3786 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3789 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
3791 LeaveCriticalSection(&This->cs);
3796 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
3798 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3799 IVideoWindow* pVideoWindow;
3802 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
3804 EnterCriticalSection(&This->cs);
3806 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3809 hr = IVideoWindow_put_Top(pVideoWindow, Top);
3811 LeaveCriticalSection(&This->cs);
3816 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
3818 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3819 IVideoWindow* pVideoWindow;
3822 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
3824 EnterCriticalSection(&This->cs);
3826 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3829 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
3831 LeaveCriticalSection(&This->cs);
3836 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
3838 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3839 IVideoWindow* pVideoWindow;
3842 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
3844 EnterCriticalSection(&This->cs);
3846 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3849 hr = IVideoWindow_put_Height(pVideoWindow, Height);
3851 LeaveCriticalSection(&This->cs);
3856 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
3858 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3859 IVideoWindow* pVideoWindow;
3862 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
3864 EnterCriticalSection(&This->cs);
3866 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3869 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
3871 LeaveCriticalSection(&This->cs);
3876 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
3878 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3879 IVideoWindow* pVideoWindow;
3882 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
3884 EnterCriticalSection(&This->cs);
3886 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3889 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
3891 LeaveCriticalSection(&This->cs);
3896 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
3898 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3899 IVideoWindow* pVideoWindow;
3902 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
3904 EnterCriticalSection(&This->cs);
3906 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3909 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
3911 LeaveCriticalSection(&This->cs);
3916 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
3918 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3919 IVideoWindow* pVideoWindow;
3922 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
3924 EnterCriticalSection(&This->cs);
3926 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3929 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
3931 LeaveCriticalSection(&This->cs);
3936 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
3938 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3939 IVideoWindow* pVideoWindow;
3942 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
3944 EnterCriticalSection(&This->cs);
3946 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3949 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
3951 LeaveCriticalSection(&This->cs);
3956 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
3958 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3959 IVideoWindow* pVideoWindow;
3962 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
3964 EnterCriticalSection(&This->cs);
3966 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3969 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
3971 LeaveCriticalSection(&This->cs);
3976 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
3978 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3979 IVideoWindow* pVideoWindow;
3982 TRACE("(%p/%p)->(%ld)\n", This, iface, Color);
3984 EnterCriticalSection(&This->cs);
3986 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3989 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
3991 LeaveCriticalSection(&This->cs);
3996 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
3997 long *FullScreenMode) {
3998 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3999 IVideoWindow* pVideoWindow;
4002 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
4004 EnterCriticalSection(&This->cs);
4006 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4009 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
4011 LeaveCriticalSection(&This->cs);
4016 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
4017 long FullScreenMode) {
4018 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4019 IVideoWindow* pVideoWindow;
4022 TRACE("(%p/%p)->(%ld)\n", This, iface, FullScreenMode);
4024 EnterCriticalSection(&This->cs);
4026 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4029 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
4031 LeaveCriticalSection(&This->cs);
4036 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
4038 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4039 IVideoWindow* pVideoWindow;
4042 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
4044 EnterCriticalSection(&This->cs);
4046 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4049 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
4051 LeaveCriticalSection(&This->cs);
4056 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
4061 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4062 IVideoWindow* pVideoWindow;
4065 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
4067 EnterCriticalSection(&This->cs);
4069 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4072 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
4074 LeaveCriticalSection(&This->cs);
4079 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
4084 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4085 IVideoWindow* pVideoWindow;
4088 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
4090 EnterCriticalSection(&This->cs);
4092 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4095 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
4097 LeaveCriticalSection(&This->cs);
4102 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
4107 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4108 IVideoWindow* pVideoWindow;
4111 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4113 EnterCriticalSection(&This->cs);
4115 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4118 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4120 LeaveCriticalSection(&This->cs);
4125 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
4128 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4129 IVideoWindow* pVideoWindow;
4132 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4134 EnterCriticalSection(&This->cs);
4136 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4139 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
4141 LeaveCriticalSection(&This->cs);
4146 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
4149 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4150 IVideoWindow* pVideoWindow;
4153 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4155 EnterCriticalSection(&This->cs);
4157 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4160 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
4162 LeaveCriticalSection(&This->cs);
4167 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
4172 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4173 IVideoWindow* pVideoWindow;
4176 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4178 EnterCriticalSection(&This->cs);
4180 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4183 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4185 LeaveCriticalSection(&This->cs);
4190 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
4192 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4193 IVideoWindow* pVideoWindow;
4196 TRACE("(%p/%p)->(%ld)\n", This, iface, HideCursor);
4198 EnterCriticalSection(&This->cs);
4200 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4203 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
4205 LeaveCriticalSection(&This->cs);
4210 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
4211 long *CursorHidden) {
4212 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4213 IVideoWindow* pVideoWindow;
4216 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
4218 EnterCriticalSection(&This->cs);
4220 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4223 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
4225 LeaveCriticalSection(&This->cs);
4231 static const IVideoWindowVtbl IVideoWindow_VTable =
4233 VideoWindow_QueryInterface,
4235 VideoWindow_Release,
4236 VideoWindow_GetTypeInfoCount,
4237 VideoWindow_GetTypeInfo,
4238 VideoWindow_GetIDsOfNames,
4240 VideoWindow_put_Caption,
4241 VideoWindow_get_Caption,
4242 VideoWindow_put_WindowStyle,
4243 VideoWindow_get_WindowStyle,
4244 VideoWindow_put_WindowStyleEx,
4245 VideoWindow_get_WindowStyleEx,
4246 VideoWindow_put_AutoShow,
4247 VideoWindow_get_AutoShow,
4248 VideoWindow_put_WindowState,
4249 VideoWindow_get_WindowState,
4250 VideoWindow_put_BackgroundPalette,
4251 VideoWindow_get_BackgroundPalette,
4252 VideoWindow_put_Visible,
4253 VideoWindow_get_Visible,
4254 VideoWindow_put_Left,
4255 VideoWindow_get_Left,
4256 VideoWindow_put_Width,
4257 VideoWindow_get_Width,
4258 VideoWindow_put_Top,
4259 VideoWindow_get_Top,
4260 VideoWindow_put_Height,
4261 VideoWindow_get_Height,
4262 VideoWindow_put_Owner,
4263 VideoWindow_get_Owner,
4264 VideoWindow_put_MessageDrain,
4265 VideoWindow_get_MessageDrain,
4266 VideoWindow_get_BorderColor,
4267 VideoWindow_put_BorderColor,
4268 VideoWindow_get_FullScreenMode,
4269 VideoWindow_put_FullScreenMode,
4270 VideoWindow_SetWindowForeground,
4271 VideoWindow_NotifyOwnerMessage,
4272 VideoWindow_SetWindowPosition,
4273 VideoWindow_GetWindowPosition,
4274 VideoWindow_GetMinIdealImageSize,
4275 VideoWindow_GetMaxIdealImageSize,
4276 VideoWindow_GetRestorePosition,
4277 VideoWindow_HideCursor,
4278 VideoWindow_IsCursorHidden
4282 /*** IUnknown methods ***/
4283 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
4286 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4288 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
4290 return Filtergraph_QueryInterface(This, riid, ppvObj);
4293 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
4294 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4296 TRACE("(%p/%p)->()\n", This, iface);
4298 return Filtergraph_AddRef(This);
4301 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
4302 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4304 TRACE("(%p/%p)->()\n", This, iface);
4306 return Filtergraph_Release(This);
4309 /*** IDispatch methods ***/
4310 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
4312 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4314 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
4319 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
4322 ITypeInfo**ppTInfo) {
4323 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4325 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
4330 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
4336 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4338 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4343 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
4344 DISPID dispIdMember,
4348 DISPPARAMS*pDispParams,
4350 EXCEPINFO*pExepInfo,
4352 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4354 TRACE("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
4359 /*** IMediaEvent methods ***/
4360 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4362 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4364 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4366 *hEvent = (OAEVENT)This->evqueue.msg_event;
4371 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4376 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4379 TRACE("(%p/%p)->(%p, %p, %p, %ld)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4381 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4383 *lEventCode = evt.lEventCode;
4384 *lParam1 = evt.lParam1;
4385 *lParam2 = evt.lParam2;
4393 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4396 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4398 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, msTimeout, pEvCode);
4400 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4402 *pEvCode = This->CompletionStatus;
4410 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4412 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4414 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4416 if (lEvCode == EC_COMPLETE)
4417 This->HandleEcComplete = FALSE;
4418 else if (lEvCode == EC_REPAINT)
4419 This->HandleEcRepaint = FALSE;
4420 else if (lEvCode == EC_CLOCK_CHANGED)
4421 This->HandleEcClockChanged = FALSE;
4428 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4430 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4432 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4434 if (lEvCode == EC_COMPLETE)
4435 This->HandleEcComplete = TRUE;
4436 else if (lEvCode == EC_REPAINT)
4437 This->HandleEcRepaint = TRUE;
4438 else if (lEvCode == EC_CLOCK_CHANGED)
4439 This->HandleEcClockChanged = TRUE;
4446 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4450 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4452 TRACE("(%p/%p)->(%ld, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4457 /*** IMediaEventEx methods ***/
4458 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4461 LONG_PTR lInstanceData) {
4462 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4464 TRACE("(%p/%p)->(%08x, %ld, %08lx)\n", This, iface, (DWORD) hwnd, lMsg, lInstanceData);
4466 This->notif.hWnd = (HWND)hwnd;
4467 This->notif.msg = lMsg;
4468 This->notif.instance = (long) lInstanceData;
4473 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4474 long lNoNotifyFlags) {
4475 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4477 TRACE("(%p/%p)->(%ld)\n", This, iface, lNoNotifyFlags);
4479 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4480 return E_INVALIDARG;
4482 This->notif.disabled = lNoNotifyFlags;
4487 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
4488 long *lplNoNotifyFlags) {
4489 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4491 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
4493 if (!lplNoNotifyFlags)
4496 *lplNoNotifyFlags = This->notif.disabled;
4502 static const IMediaEventExVtbl IMediaEventEx_VTable =
4504 MediaEvent_QueryInterface,
4507 MediaEvent_GetTypeInfoCount,
4508 MediaEvent_GetTypeInfo,
4509 MediaEvent_GetIDsOfNames,
4511 MediaEvent_GetEventHandle,
4512 MediaEvent_GetEvent,
4513 MediaEvent_WaitForCompletion,
4514 MediaEvent_CancelDefaultHandling,
4515 MediaEvent_RestoreDefaultHandling,
4516 MediaEvent_FreeEventParams,
4517 MediaEvent_SetNotifyWindow,
4518 MediaEvent_SetNotifyFlags,
4519 MediaEvent_GetNotifyFlags
4523 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
4525 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4527 return Filtergraph_QueryInterface(This, riid, ppv);
4530 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
4532 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4534 return Filtergraph_AddRef(This);
4537 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
4539 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4541 return Filtergraph_Release(This);
4544 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
4546 FIXME("(%p): stub\n", pClassID);
4551 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
4553 FIXME("(): stub\n");
4558 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
4560 FIXME("(): stub\n");
4565 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
4567 FIXME("(0x%s): stub\n", wine_dbgstr_longlong(tStart));
4572 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
4574 FIXME("(%d, %p): stub\n", dwMsTimeout, pState);
4579 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
4581 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4585 TRACE("(%p/%p)->(%p)\n", iface, This, pClock);
4587 EnterCriticalSection(&This->cs);
4589 for (i = 0;i < This->nFilters;i++)
4591 hr = IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], pClock);
4599 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], This->refClock);
4604 IReferenceClock_Release(This->refClock);
4605 This->refClock = pClock;
4607 IReferenceClock_AddRef(This->refClock);
4609 if (This->HandleEcClockChanged)
4611 IMediaEventSink *pEventSink;
4614 eshr = IMediaFilter_QueryInterface(iface, &IID_IMediaEventSink, (LPVOID)&pEventSink);
4615 if (SUCCEEDED(eshr))
4617 IMediaEventSink_Notify(pEventSink, EC_CLOCK_CHANGED, 0, 0);
4618 IMediaEventSink_Release(pEventSink);
4623 LeaveCriticalSection(&This->cs);
4628 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
4630 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4632 TRACE("(%p/%p)->(%p)\n", iface, This, ppClock);
4637 EnterCriticalSection(&This->cs);
4639 *ppClock = This->refClock;
4641 IReferenceClock_AddRef(*ppClock);
4643 LeaveCriticalSection(&This->cs);
4648 static const IMediaFilterVtbl IMediaFilter_VTable =
4650 MediaFilter_QueryInterface,
4652 MediaFilter_Release,
4653 MediaFilter_GetClassID,
4657 MediaFilter_GetState,
4658 MediaFilter_SetSyncSource,
4659 MediaFilter_GetSyncSource
4662 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
4664 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4666 return Filtergraph_QueryInterface(This, riid, ppv);
4669 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
4671 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4673 return Filtergraph_AddRef(This);
4676 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
4678 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4680 return Filtergraph_Release(This);
4683 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
4685 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4688 TRACE("(%p/%p)->(%ld, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
4690 /* We need thread safety here, let's use the events queue's one */
4691 EnterCriticalSection(&This->evqueue.msg_crst);
4693 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
4695 TRACE("Process EC_COMPLETE notification\n");
4696 if (++This->EcCompleteCount == This->nRenderers)
4698 evt.lEventCode = EC_COMPLETE;
4701 TRACE("Send EC_COMPLETE to app\n");
4702 EventsQueue_PutEvent(&This->evqueue, &evt);
4703 if (!This->notif.disabled && This->notif.hWnd)
4705 TRACE("Send Window message\n");
4706 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4708 This->CompletionStatus = EC_COMPLETE;
4709 SetEvent(This->hEventCompletion);
4712 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
4714 /* FIXME: Not handled yet */
4718 evt.lEventCode = EventCode;
4719 evt.lParam1 = EventParam1;
4720 evt.lParam2 = EventParam2;
4721 EventsQueue_PutEvent(&This->evqueue, &evt);
4722 if (!This->notif.disabled && This->notif.hWnd)
4723 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4726 LeaveCriticalSection(&This->evqueue.msg_crst);
4730 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
4732 MediaEventSink_QueryInterface,
4733 MediaEventSink_AddRef,
4734 MediaEventSink_Release,
4735 MediaEventSink_Notify
4738 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
4740 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4742 return Filtergraph_QueryInterface(This, riid, ppv);
4745 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
4747 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4749 return Filtergraph_AddRef(This);
4752 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
4754 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4756 return Filtergraph_Release(This);
4759 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
4762 const AM_MEDIA_TYPE* pmtFirstConnection,
4763 IBaseFilter* pUsingFilter,
4767 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4769 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
4774 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
4775 IGraphConfigCallback* pCallback,
4780 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4782 FIXME("(%p)->(%p, %p, %x, %p): stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
4787 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
4788 IBaseFilter* pFilter)
4790 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4792 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4797 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
4798 IEnumFilters** pEnum)
4800 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4802 FIXME("(%p)->(%p): stub!\n", This, pEnum);
4807 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
4808 IBaseFilter* pFilter)
4810 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4812 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4817 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
4818 REFERENCE_TIME* prtStart)
4820 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4822 FIXME("(%p)->(%p): stub!\n", This, prtStart);
4827 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
4829 IPinConnection* pConnection,
4832 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4834 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
4839 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
4840 IBaseFilter* pFilter,
4843 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4845 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4850 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
4851 IBaseFilter* pFilter,
4854 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4856 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
4861 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
4862 IBaseFilter* pFilter,
4865 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4867 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4872 static const IGraphConfigVtbl IGraphConfig_VTable =
4874 GraphConfig_QueryInterface,
4876 GraphConfig_Release,
4877 GraphConfig_Reconnect,
4878 GraphConfig_Reconfigure,
4879 GraphConfig_AddFilterToCache,
4880 GraphConfig_EnumCacheFilter,
4881 GraphConfig_RemoveFilterFromCache,
4882 GraphConfig_GetStartTime,
4883 GraphConfig_PushThroughData,
4884 GraphConfig_SetFilterFlags,
4885 GraphConfig_GetFilterFlags,
4886 GraphConfig_RemoveFilterEx
4889 static const IUnknownVtbl IInner_VTable =
4891 FilterGraphInner_QueryInterface,
4892 FilterGraphInner_AddRef,
4893 FilterGraphInner_Release
4896 static HRESULT WINAPI Filtergraph_QueryInterface(IFilterGraphImpl *This,
4899 if (This->bAggregatable)
4900 This->bUnkOuterValid = TRUE;
4902 if (This->pUnkOuter)
4904 if (This->bAggregatable)
4905 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
4907 if (IsEqualIID(riid, &IID_IUnknown))
4911 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
4912 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
4913 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
4914 This->bAggregatable = TRUE;
4919 return E_NOINTERFACE;
4922 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
4925 static ULONG WINAPI Filtergraph_AddRef(IFilterGraphImpl *This) {
4926 if (This->pUnkOuter && This->bUnkOuterValid)
4927 return IUnknown_AddRef(This->pUnkOuter);
4928 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
4931 static ULONG WINAPI Filtergraph_Release(IFilterGraphImpl *This) {
4932 if (This->pUnkOuter && This->bUnkOuterValid)
4933 return IUnknown_Release(This->pUnkOuter);
4934 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
4937 /* This is the only function that actually creates a FilterGraph class... */
4938 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4940 IFilterGraphImpl *fimpl;
4943 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
4947 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
4948 fimpl->pUnkOuter = pUnkOuter;
4949 fimpl->bUnkOuterValid = FALSE;
4950 fimpl->bAggregatable = FALSE;
4951 fimpl->IInner_vtbl = &IInner_VTable;
4952 fimpl->IFilterGraph2_vtbl = &IFilterGraph2_VTable;
4953 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
4954 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
4955 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
4956 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
4957 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
4958 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
4959 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
4960 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
4961 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
4962 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
4964 fimpl->ppFiltersInGraph = NULL;
4965 fimpl->pFilterNames = NULL;
4966 fimpl->nFilters = 0;
4967 fimpl->filterCapacity = 0;
4968 fimpl->nameIndex = 1;
4969 fimpl->refClock = NULL;
4970 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
4971 fimpl->HandleEcComplete = TRUE;
4972 fimpl->HandleEcRepaint = TRUE;
4973 fimpl->HandleEcClockChanged = TRUE;
4974 fimpl->notif.hWnd = 0;
4975 fimpl->notif.disabled = FALSE;
4976 fimpl->nRenderers = 0;
4977 fimpl->EcCompleteCount = 0;
4978 fimpl->state = State_Stopped;
4979 EventsQueue_Init(&fimpl->evqueue);
4980 InitializeCriticalSection(&fimpl->cs);
4981 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
4982 fimpl->nItfCacheEntries = 0;
4983 memcpy(&fimpl->timeformatseek, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
4984 fimpl->start_time = fimpl->position = 0;
4986 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
4988 ERR("Unable to create filter mapper (%x)\n", hr);
4991 IFilterGraph2_SetDefaultSyncSource((IFilterGraph2*)fimpl);
4997 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4999 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5000 return FilterGraph_create(pUnkOuter, ppObj);