quartz: Don't release filters when they connect.
[wine/wine64.git] / dlls / quartz / filtergraph.c
blobc301220af9a81010ea63ff72d44bcd5c1c6e4e1e
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
24 #include "config.h"
25 #include <stdarg.h>
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "dshow.h"
33 #include "wine/debug.h"
34 #include "quartz_private.h"
35 #include "ole2.h"
36 #include "olectl.h"
37 #include "strmif.h"
38 #include "vfwmsgs.h"
39 #include "evcode.h"
40 #include "wine/unicode.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
45 typedef struct {
46 HWND hWnd; /* Target window */
47 long msg; /* User window message */
48 long instance; /* User data */
49 int disabled; /* Disabled messages posting */
50 } WndNotify;
52 typedef struct {
53 long lEventCode; /* Event code */
54 LONG_PTR lParam1; /* Param1 */
55 LONG_PTR lParam2; /* Param2 */
56 } Event;
58 /* messages ring implementation for queuing events (taken from winmm) */
59 #define EVENTS_RING_BUFFER_INCREMENT 64
60 typedef struct {
61 Event* messages;
62 int ring_buffer_size;
63 int msg_tosave;
64 int msg_toget;
65 CRITICAL_SECTION msg_crst;
66 HANDLE msg_event; /* Signaled for no empty queue */
67 } EventsQueue;
69 static int EventsQueue_Init(EventsQueue* omr)
71 omr->msg_toget = 0;
72 omr->msg_tosave = 0;
73 omr->msg_event = CreateEventW(NULL, TRUE, FALSE, NULL);
74 omr->ring_buffer_size = EVENTS_RING_BUFFER_INCREMENT;
75 omr->messages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,omr->ring_buffer_size * sizeof(Event));
77 InitializeCriticalSection(&omr->msg_crst);
78 return TRUE;
81 static int EventsQueue_Destroy(EventsQueue* omr)
83 CloseHandle(omr->msg_event);
84 HeapFree(GetProcessHeap(),0,omr->messages);
85 DeleteCriticalSection(&omr->msg_crst);
86 return TRUE;
89 static int EventsQueue_PutEvent(EventsQueue* omr, Event* evt)
91 EnterCriticalSection(&omr->msg_crst);
92 if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
94 int old_ring_buffer_size = omr->ring_buffer_size;
95 omr->ring_buffer_size += EVENTS_RING_BUFFER_INCREMENT;
96 TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
97 omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(Event));
98 /* Now we need to rearrange the ring buffer so that the new
99 buffers just allocated are in between omr->msg_tosave and
100 omr->msg_toget.
102 if (omr->msg_tosave < omr->msg_toget)
104 memmove(&(omr->messages[omr->msg_toget + EVENTS_RING_BUFFER_INCREMENT]),
105 &(omr->messages[omr->msg_toget]),
106 sizeof(Event)*(old_ring_buffer_size - omr->msg_toget)
108 omr->msg_toget += EVENTS_RING_BUFFER_INCREMENT;
111 omr->messages[omr->msg_tosave] = *evt;
112 SetEvent(omr->msg_event);
113 omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
114 LeaveCriticalSection(&omr->msg_crst);
115 return TRUE;
118 static int EventsQueue_GetEvent(EventsQueue* omr, Event* evt, long msTimeOut)
120 if (WaitForSingleObject(omr->msg_event, msTimeOut) != WAIT_OBJECT_0)
121 return FALSE;
123 EnterCriticalSection(&omr->msg_crst);
125 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
127 LeaveCriticalSection(&omr->msg_crst);
128 return FALSE;
131 *evt = omr->messages[omr->msg_toget];
132 omr->msg_toget = (omr->msg_toget + 1) % omr->ring_buffer_size;
134 /* Mark the buffer as empty if needed */
135 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
136 ResetEvent(omr->msg_event);
138 LeaveCriticalSection(&omr->msg_crst);
139 return TRUE;
142 #define MAX_ITF_CACHE_ENTRIES 3
143 typedef struct _ITF_CACHE_ENTRY {
144 const IID* riid;
145 IBaseFilter* filter;
146 IUnknown* iface;
147 } ITF_CACHE_ENTRY;
149 typedef struct _IFilterGraphImpl {
150 const IGraphBuilderVtbl *IGraphBuilder_vtbl;
151 const IMediaControlVtbl *IMediaControl_vtbl;
152 const IMediaSeekingVtbl *IMediaSeeking_vtbl;
153 const IBasicAudioVtbl *IBasicAudio_vtbl;
154 const IBasicVideoVtbl *IBasicVideo_vtbl;
155 const IVideoWindowVtbl *IVideoWindow_vtbl;
156 const IMediaEventExVtbl *IMediaEventEx_vtbl;
157 const IMediaFilterVtbl *IMediaFilter_vtbl;
158 const IMediaEventSinkVtbl *IMediaEventSink_vtbl;
159 const IGraphConfigVtbl *IGraphConfig_vtbl;
160 const IMediaPositionVtbl *IMediaPosition_vtbl;
161 /* IAMGraphStreams */
162 /* IAMStats */
163 /* IBasicVideo2 */
164 /* IFilterChain */
165 /* IFilterGraph2 */
166 /* IFilterMapper2 */
167 /* IGraphVersion */
168 /* IQueueCommand */
169 /* IRegisterServiceProvider */
170 /* IResourceMananger */
171 /* IServiceProvider */
172 /* IVideoFrameStep */
174 LONG ref;
175 IFilterMapper2 * pFilterMapper2;
176 IBaseFilter ** ppFiltersInGraph;
177 LPWSTR * pFilterNames;
178 int nFilters;
179 int filterCapacity;
180 long nameIndex;
181 EventsQueue evqueue;
182 HANDLE hEventCompletion;
183 int CompletionStatus;
184 WndNotify notif;
185 int nRenderers;
186 int EcCompleteCount;
187 int HandleEcComplete;
188 int HandleEcRepaint;
189 OAFilterState state;
190 CRITICAL_SECTION cs;
191 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
192 int nItfCacheEntries;
193 } IFilterGraphImpl;
196 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
197 REFIID riid,
198 LPVOID *ppvObj) {
199 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
201 if (IsEqualGUID(&IID_IUnknown, riid) ||
202 IsEqualGUID(&IID_IFilterGraph, riid) ||
203 IsEqualGUID(&IID_IGraphBuilder, riid)) {
204 *ppvObj = &(This->IGraphBuilder_vtbl);
205 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
206 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
207 *ppvObj = &(This->IMediaControl_vtbl);
208 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
209 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
210 *ppvObj = &(This->IMediaSeeking_vtbl);
211 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
212 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
213 *ppvObj = &(This->IBasicAudio_vtbl);
214 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
215 } else if (IsEqualGUID(&IID_IBasicVideo, riid)) {
216 *ppvObj = &(This->IBasicVideo_vtbl);
217 TRACE(" returning IBasicVideo interface (%p)\n", *ppvObj);
218 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
219 *ppvObj = &(This->IVideoWindow_vtbl);
220 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
221 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
222 IsEqualGUID(&IID_IMediaEventEx, riid)) {
223 *ppvObj = &(This->IMediaEventEx_vtbl);
224 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
225 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
226 IsEqualGUID(&IID_IPersist, riid)) {
227 *ppvObj = &(This->IMediaFilter_vtbl);
228 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
229 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
230 *ppvObj = &(This->IMediaEventSink_vtbl);
231 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
232 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
233 *ppvObj = &(This->IGraphConfig_vtbl);
234 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
235 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
236 *ppvObj = &(This->IMediaPosition_vtbl);
237 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
238 } else {
239 *ppvObj = NULL;
240 FIXME("unknown interface %s\n", debugstr_guid(riid));
241 return E_NOINTERFACE;
244 InterlockedIncrement(&This->ref);
245 return S_OK;
248 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This) {
249 ULONG ref = InterlockedIncrement(&This->ref);
251 TRACE("(%p)->(): new ref = %d\n", This, ref);
253 return ref;
256 static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
257 ULONG ref = InterlockedDecrement(&This->ref);
259 TRACE("(%p)->(): new ref = %d\n", This, ref);
261 if (ref == 0) {
262 int i;
263 for (i = 0; i < This->nFilters; i++)
264 IBaseFilter_Release(This->ppFiltersInGraph[i]);
265 for (i = 0; i < This->nItfCacheEntries; i++)
266 IUnknown_Release(This->ItfCacheEntries[i].iface);
267 IFilterMapper2_Release(This->pFilterMapper2);
268 CloseHandle(This->hEventCompletion);
269 EventsQueue_Destroy(&This->evqueue);
270 DeleteCriticalSection(&This->cs);
271 HeapFree(GetProcessHeap(), 0, This->ppFiltersInGraph);
272 HeapFree(GetProcessHeap(), 0, This->pFilterNames);
273 HeapFree(GetProcessHeap(), 0, This);
275 return ref;
279 /*** IUnknown methods ***/
280 static HRESULT WINAPI GraphBuilder_QueryInterface(IGraphBuilder *iface,
281 REFIID riid,
282 LPVOID*ppvObj) {
283 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
285 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
286 return Filtergraph_QueryInterface(This, riid, ppvObj);
289 static ULONG WINAPI GraphBuilder_AddRef(IGraphBuilder *iface) {
290 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
292 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
294 return Filtergraph_AddRef(This);
297 static ULONG WINAPI GraphBuilder_Release(IGraphBuilder *iface) {
298 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
300 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
302 return Filtergraph_Release(This);
305 /*** IFilterGraph methods ***/
306 static HRESULT WINAPI GraphBuilder_AddFilter(IGraphBuilder *iface,
307 IBaseFilter *pFilter,
308 LPCWSTR pName) {
309 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
310 HRESULT hr;
311 int i,j;
312 WCHAR* wszFilterName = NULL;
313 int duplicate_name = FALSE;
315 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
317 wszFilterName = (WCHAR*) CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
319 if (pName)
321 /* Check if name already exists */
322 for(i = 0; i < This->nFilters; i++)
323 if (!strcmpW(This->pFilterNames[i], pName))
325 duplicate_name = TRUE;
326 break;
330 /* If no name given or name already existing, generate one */
331 if (!pName || duplicate_name)
333 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
334 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
336 for (j = 0; j < 10000 ; j++)
338 /* Create name */
339 if (pName)
340 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
341 else
342 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
343 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
345 /* Check if the generated name already exists */
346 for(i = 0; i < This->nFilters; i++)
347 if (!strcmpW(This->pFilterNames[i], wszFilterName))
348 break;
350 /* Compute next index and exit if generated name is suitable */
351 if (This->nameIndex++ == 10000)
352 This->nameIndex = 1;
353 if (i == This->nFilters)
354 break;
356 /* Unable to find a suitable name */
357 if (j == 10000)
359 CoTaskMemFree(wszFilterName);
360 return VFW_E_DUPLICATE_NAME;
363 else
364 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
366 if (This->nFilters + 1 > This->filterCapacity)
368 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
369 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
370 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
371 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
372 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
373 if (!This->filterCapacity)
375 CoTaskMemFree(This->ppFiltersInGraph);
376 CoTaskMemFree(This->pFilterNames);
378 This->ppFiltersInGraph = ppNewFilters;
379 This->pFilterNames = pNewNames;
380 This->filterCapacity = newCapacity;
383 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
385 if (SUCCEEDED(hr))
387 IBaseFilter_AddRef(pFilter);
388 This->ppFiltersInGraph[This->nFilters] = pFilter;
389 This->pFilterNames[This->nFilters] = wszFilterName;
390 This->nFilters++;
392 else
393 CoTaskMemFree(wszFilterName);
395 if (SUCCEEDED(hr) && duplicate_name)
396 return VFW_S_DUPLICATE_NAME;
398 return hr;
401 static HRESULT WINAPI GraphBuilder_RemoveFilter(IGraphBuilder *iface,
402 IBaseFilter *pFilter) {
403 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
404 int i;
405 HRESULT hr = E_FAIL;
407 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
409 /* FIXME: check graph is stopped */
411 for (i = 0; i < This->nFilters; i++)
413 if (This->ppFiltersInGraph[i] == pFilter)
415 /* FIXME: disconnect pins */
416 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
417 if (SUCCEEDED(hr))
419 IPin_Release(pFilter);
420 CoTaskMemFree(This->pFilterNames[i]);
421 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
422 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
423 This->nFilters--;
424 /* Invalidate interfaces in the cache */
425 for (i = 0; i < This->nItfCacheEntries; i++)
426 if (pFilter == This->ItfCacheEntries[i].filter)
428 IUnknown_Release(This->ItfCacheEntries[i].iface);
429 This->ItfCacheEntries[i].iface = NULL;
430 This->ItfCacheEntries[i].filter = NULL;
432 return S_OK;
434 break;
438 return hr; /* FIXME: check this error code */
441 static HRESULT WINAPI GraphBuilder_EnumFilters(IGraphBuilder *iface,
442 IEnumFilters **ppEnum) {
443 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
445 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
447 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
450 static HRESULT WINAPI GraphBuilder_FindFilterByName(IGraphBuilder *iface,
451 LPCWSTR pName,
452 IBaseFilter **ppFilter) {
453 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
454 int i;
456 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
458 *ppFilter = NULL;
460 for (i = 0; i < This->nFilters; i++)
462 if (!strcmpW(pName, This->pFilterNames[i]))
464 *ppFilter = This->ppFiltersInGraph[i];
465 IBaseFilter_AddRef(*ppFilter);
466 return S_OK;
470 return E_FAIL; /* FIXME: check this error code */
473 /* NOTE: despite the implication, it doesn't matter which
474 * way round you put in the input and output pins */
475 static HRESULT WINAPI GraphBuilder_ConnectDirect(IGraphBuilder *iface,
476 IPin *ppinIn,
477 IPin *ppinOut,
478 const AM_MEDIA_TYPE *pmt) {
479 PIN_DIRECTION dir;
480 HRESULT hr;
482 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
484 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
486 /* FIXME: check pins are in graph */
488 if (TRACE_ON(quartz))
490 PIN_INFO PinInfo;
492 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
493 if (FAILED(hr))
494 return hr;
496 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
497 IBaseFilter_Release(PinInfo.pFilter);
499 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
500 if (FAILED(hr))
501 return hr;
503 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
504 IBaseFilter_Release(PinInfo.pFilter);
507 hr = IPin_QueryDirection(ppinIn, &dir);
508 if (SUCCEEDED(hr))
510 if (dir == PINDIR_INPUT)
511 hr = IPin_Connect(ppinOut, ppinIn, pmt);
512 else
513 hr = IPin_Connect(ppinIn, ppinOut, pmt);
516 return hr;
519 static HRESULT WINAPI GraphBuilder_Reconnect(IGraphBuilder *iface,
520 IPin *ppin) {
521 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
522 IPin *pConnectedTo = NULL;
523 HRESULT hr;
524 PIN_DIRECTION pindir;
526 IPin_QueryDirection(ppin, &pindir);
527 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
528 if (FAILED(hr)) {
529 TRACE("Querying connected to failed: %x\n", hr);
530 return hr;
532 IPin_Disconnect(ppin);
533 IPin_Disconnect(pConnectedTo);
534 if (pindir == PINDIR_INPUT)
535 hr = IPin_Connect(pConnectedTo, ppin, NULL);
536 else
537 hr = IPin_Connect(ppin, pConnectedTo, NULL);
538 IPin_Release(pConnectedTo);
539 if (FAILED(hr))
540 ERR("Reconnecting pins failed, pins are not connected now..\n");
541 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
542 return hr;
545 static HRESULT WINAPI GraphBuilder_Disconnect(IGraphBuilder *iface,
546 IPin *ppin) {
547 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
549 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
551 return IPin_Disconnect(ppin);
554 static HRESULT WINAPI GraphBuilder_SetDefaultSyncSource(IGraphBuilder *iface) {
555 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
557 TRACE("(%p/%p)->(): stub !!!\n", iface, This);
559 return S_OK;
562 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
564 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
565 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
566 IPropertyBag * pPropBagCat = NULL;
567 HRESULT hr;
569 VariantInit(pvar);
570 V_VT(pvar) = VT_BSTR;
572 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
574 if (SUCCEEDED(hr))
575 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
577 if (SUCCEEDED(hr))
578 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
580 if (SUCCEEDED(hr))
581 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
583 if (SUCCEEDED(hr))
584 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
586 if (pPropBagCat)
587 IPropertyBag_Release(pPropBagCat);
589 return hr;
592 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
594 HRESULT hr;
595 ULONG nb = 0;
597 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
598 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
599 if (hr == S_OK) {
600 /* Rendered input */
601 } else if (hr == S_FALSE) {
602 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
603 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
604 if (hr != S_OK) {
605 ERR("Error (%x)\n", hr);
607 } else if (hr == E_NOTIMPL) {
608 /* Input connected to all outputs */
609 IEnumPins* penumpins;
610 IPin* ppin;
611 int i = 0;
612 TRACE("E_NOTIMPL\n");
613 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
614 if (FAILED(hr)) {
615 ERR("filter Enumpins failed (%x)\n", hr);
616 return hr;
618 i = 0;
619 /* Count output pins */
620 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
621 PIN_DIRECTION pindir;
622 IPin_QueryDirection(ppin, &pindir);
623 if (pindir == PINDIR_OUTPUT)
624 i++;
625 IPin_Release(ppin);
627 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
628 /* Retrieve output pins */
629 IEnumPins_Reset(penumpins);
630 i = 0;
631 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
632 PIN_DIRECTION pindir;
633 IPin_QueryDirection(ppin, &pindir);
634 if (pindir == PINDIR_OUTPUT)
635 (*pppins)[i++] = ppin;
636 else
637 IPin_Release(ppin);
639 nb = i;
640 if (FAILED(hr)) {
641 ERR("Next failed (%x)\n", hr);
642 return hr;
644 IEnumPins_Release(penumpins);
645 } else if (FAILED(hr)) {
646 ERR("Cannot get internal connection (%x)\n", hr);
647 return hr;
650 *pnb = nb;
651 return S_OK;
654 /*** IGraphBuilder methods ***/
655 static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
656 IPin *ppinOut,
657 IPin *ppinIn) {
658 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
659 HRESULT hr;
660 AM_MEDIA_TYPE* mt;
661 IEnumMediaTypes* penummt;
662 ULONG nbmt;
663 IEnumPins* penumpins;
664 IEnumMoniker* pEnumMoniker;
665 GUID tab[2];
666 ULONG nb;
667 IMoniker* pMoniker;
668 ULONG pin;
669 PIN_INFO PinInfo;
670 CLSID FilterCLSID;
672 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
674 if (TRACE_ON(quartz))
676 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
677 if (FAILED(hr))
678 return hr;
680 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
681 IBaseFilter_Release(PinInfo.pFilter);
683 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
684 if (FAILED(hr))
685 return hr;
687 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
688 IBaseFilter_Release(PinInfo.pFilter);
691 /* Try direct connection first */
692 hr = IPin_Connect(ppinOut, ppinIn, NULL);
693 if (SUCCEEDED(hr)) {
694 return S_OK;
696 TRACE("Direct connection failed, trying to insert other filters\n");
698 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
699 if (FAILED(hr))
700 return hr;
702 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
703 if (FAILED(hr))
704 return hr;
706 IBaseFilter_Release(PinInfo.pFilter);
708 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
709 * filter to the minor mediatype of input pin of the renderer */
710 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
711 if (FAILED(hr)) {
712 ERR("EnumMediaTypes (%x)\n", hr);
713 return hr;
716 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
717 if (FAILED(hr)) {
718 ERR("IEnumMediaTypes_Next (%x)\n", hr);
719 return hr;
722 if (!nbmt) {
723 ERR("No media type found!\n");
724 return S_OK;
726 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
727 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
729 /* Try to find a suitable filter that can connect to the pin to render */
730 tab[0] = mt->majortype;
731 tab[1] = mt->subtype;
732 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
733 if (FAILED(hr)) {
734 ERR("Unable to enum filters (%x)\n", hr);
735 return hr;
738 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
740 VARIANT var;
741 GUID clsid;
742 IPin** ppins;
743 IPin* ppinfilter = NULL;
744 IBaseFilter* pfilter = NULL;
746 hr = GetFilterInfo(pMoniker, &clsid, &var);
747 IMoniker_Release(pMoniker);
748 if (FAILED(hr)) {
749 ERR("Unable to retrieve filter info (%x)\n", hr);
750 goto error;
753 if (IsEqualGUID(&clsid, &FilterCLSID)) {
754 /* Skip filter (same as the one the output pin belongs to) */
755 goto error;
758 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
759 if (FAILED(hr)) {
760 ERR("Unable to create filter (%x), trying next one\n", hr);
761 goto error;
764 hr = IGraphBuilder_AddFilter(iface, pfilter, NULL);
765 if (FAILED(hr)) {
766 ERR("Unable to add filter (%x)\n", hr);
767 IBaseFilter_Release(pfilter);
768 pfilter = NULL;
769 goto error;
772 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
773 if (FAILED(hr)) {
774 ERR("Enumpins (%x)\n", hr);
775 goto error;
778 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
779 IEnumPins_Release(penumpins);
781 if (FAILED(hr)) {
782 ERR("Next (%x)\n", hr);
783 goto error;
785 if (pin == 0) {
786 ERR("No Pin\n");
787 goto error;
790 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
791 if (FAILED(hr)) {
792 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
793 goto error;
795 TRACE("Successfully connected to filter, follow chain...\n");
797 /* Render all output pins of the filter by calling IGraphBuilder_Render on each of them */
798 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
800 if (SUCCEEDED(hr)) {
801 int i;
802 if (nb == 0) {
803 IPin_Disconnect(ppinOut);
804 goto error;
806 TRACE("pins to consider: %d\n", nb);
807 for(i = 0; i < nb; i++) {
808 TRACE("Processing pin %d\n", i);
809 hr = IGraphBuilder_Connect(iface, ppins[i], ppinIn);
810 if (FAILED(hr)) {
811 TRACE("Cannot render pin %p (%x)\n", ppinfilter, hr);
813 IPin_Release(ppins[i]);
814 if (SUCCEEDED(hr)) break;
816 while (++i < nb) IPin_Release(ppins[i]);
817 CoTaskMemFree(ppins);
818 IPin_Release(ppinfilter);
819 break;
822 error:
823 if (ppinfilter) IPin_Release(ppinfilter);
824 if (pfilter) {
825 IGraphBuilder_RemoveFilter(iface, pfilter);
826 IBaseFilter_Release(pfilter);
830 IEnumMediaTypes_Release(penummt);
831 DeleteMediaType(mt);
833 return S_OK;
836 static HRESULT WINAPI GraphBuilder_Render(IGraphBuilder *iface,
837 IPin *ppinOut) {
838 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
839 IEnumMediaTypes* penummt;
840 AM_MEDIA_TYPE* mt;
841 ULONG nbmt;
842 HRESULT hr;
844 IEnumMoniker* pEnumMoniker;
845 GUID tab[2];
846 ULONG nb;
847 IMoniker* pMoniker;
849 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
851 if (TRACE_ON(quartz))
853 PIN_INFO PinInfo;
855 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
856 if (FAILED(hr))
857 return hr;
859 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
860 IBaseFilter_Release(PinInfo.pFilter);
863 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
864 if (FAILED(hr)) {
865 ERR("EnumMediaTypes (%x)\n", hr);
866 return hr;
869 while(1)
871 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
872 if (FAILED(hr)) {
873 ERR("IEnumMediaTypes_Next (%x)\n", hr);
874 return hr;
876 if (!nbmt)
877 break;
878 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
879 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
881 /* Try to find a suitable renderer with the same media type */
882 tab[0] = mt->majortype;
883 tab[1] = GUID_NULL;
884 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL);
885 if (FAILED(hr)) {
886 ERR("Unable to enum filters (%x)\n", hr);
887 return hr;
890 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
892 VARIANT var;
893 GUID clsid;
894 IPin* ppinfilter;
895 IBaseFilter* pfilter = NULL;
896 IEnumPins* penumpins;
897 ULONG pin;
899 hr = GetFilterInfo(pMoniker, &clsid, &var);
900 IMoniker_Release(pMoniker);
901 if (FAILED(hr)) {
902 ERR("Unable to retrieve filter info (%x)\n", hr);
903 goto error;
906 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
907 if (FAILED(hr)) {
908 ERR("Unable to create filter (%x), trying next one\n", hr);
909 goto error;
912 hr = IGraphBuilder_AddFilter(iface, pfilter, NULL);
913 if (FAILED(hr)) {
914 ERR("Unable to add filter (%x)\n", hr);
915 pfilter = NULL;
916 goto error;
919 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
920 if (FAILED(hr)) {
921 ERR("Splitter Enumpins (%x)\n", hr);
922 goto error;
924 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
925 if (FAILED(hr)) {
926 ERR("Next (%x)\n", hr);
927 goto error;
929 if (pin == 0) {
930 ERR("No Pin\n");
931 goto error;
933 IEnumPins_Release(penumpins);
935 /* Connect the pin to render to the renderer */
936 hr = IGraphBuilder_Connect(iface, ppinOut, ppinfilter);
937 if (FAILED(hr)) {
938 TRACE("Unable to connect to renderer (%x)\n", hr);
939 goto error;
941 break;
943 error:
944 if (pfilter) {
945 IGraphBuilder_RemoveFilter(iface, pfilter);
946 IBaseFilter_Release(pfilter);
950 DeleteMediaType(mt);
951 break;
954 IEnumMediaTypes_Release(penummt);
956 return S_OK;
959 static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
960 LPCWSTR lpcwstrFile,
961 LPCWSTR lpcwstrPlayList) {
962 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
963 static const WCHAR string[] = {'R','e','a','d','e','r',0};
964 IBaseFilter* preader = NULL;
965 IBaseFilter* psplitter = NULL;
966 IPin* ppinreader;
967 IPin* ppinsplitter;
968 IEnumPins* penumpins;
969 ULONG pin;
970 HRESULT hr;
971 IEnumMoniker* pEnumMoniker = NULL;
972 GUID tab[2];
973 IPin** ppins = NULL;
974 ULONG nb;
975 IMoniker* pMoniker;
976 IFileSourceFilter* pfile = NULL;
977 AM_MEDIA_TYPE mt;
978 WCHAR* filename;
980 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
982 if (lpcwstrPlayList != NULL)
983 return E_INVALIDARG;
985 hr = IGraphBuilder_AddSourceFilter(iface, lpcwstrFile, string, &preader);
987 /* Retrieve file media type */
988 if (SUCCEEDED(hr))
989 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
990 if (SUCCEEDED(hr)) {
991 hr = IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
992 IFileSourceFilter_Release(pfile);
995 if (SUCCEEDED(hr))
996 hr = IBaseFilter_EnumPins(preader, &penumpins);
997 if (SUCCEEDED(hr)) {
998 hr = IEnumPins_Next(penumpins, 1, &ppinreader, &pin);
999 IEnumPins_Release(penumpins);
1002 if (SUCCEEDED(hr)) {
1003 tab[0] = mt.majortype;
1004 tab[1] = mt.subtype;
1005 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1008 if (FAILED(hr))
1010 if (pEnumMoniker)
1011 IEnumMoniker_Release(pEnumMoniker);
1012 if (preader) {
1013 IGraphBuilder_RemoveFilter(iface, preader);
1014 IBaseFilter_Release(preader);
1016 return hr;
1019 hr = VFW_E_CANNOT_RENDER;
1020 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1022 VARIANT var;
1023 GUID clsid;
1025 hr = GetFilterInfo(pMoniker, &clsid, &var);
1026 IMoniker_Release(pMoniker);
1027 if (FAILED(hr)) {
1028 ERR("Unable to retrieve filter info (%x)\n", hr);
1029 continue;
1032 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&psplitter);
1033 if (FAILED(hr)) {
1034 ERR("Unable to create filter (%x), trying next one\n", hr);
1035 continue;
1038 hr = IGraphBuilder_AddFilter(iface, psplitter, NULL);
1039 if (FAILED(hr)) {
1040 ERR("Unable add filter (%x)\n", hr);
1041 IBaseFilter_Release(psplitter);
1042 continue;
1045 /* Connect file source and splitter filters together */
1046 /* Make the splitter analyze incoming data */
1048 hr = IBaseFilter_EnumPins(psplitter, &penumpins);
1049 if (SUCCEEDED(hr)) {
1050 hr = IEnumPins_Next(penumpins, 1, &ppinsplitter, &pin);
1051 IEnumPins_Release(penumpins);
1054 if (SUCCEEDED(hr))
1055 hr = IPin_Connect(ppinreader, ppinsplitter, NULL);
1057 /* Make sure there's some output pins in the filter */
1058 if (SUCCEEDED(hr))
1059 hr = GetInternalConnections(psplitter, ppinsplitter, &ppins, &nb);
1060 if (SUCCEEDED(hr)) {
1061 if(nb == 0) {
1062 IPin_Disconnect(ppinreader);
1063 TRACE("No output pins found in filter\n");
1064 hr = VFW_E_CANNOT_RENDER;
1068 IPin_Release(ppinsplitter);
1069 ppinsplitter = NULL;
1071 if (SUCCEEDED(hr)) {
1072 TRACE("Successfully connected to filter\n");
1073 break;
1076 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1078 if (ppins) {
1079 CoTaskMemFree(ppins);
1080 ppins = NULL;
1082 IGraphBuilder_RemoveFilter(iface, psplitter);
1083 IBaseFilter_Release(psplitter);
1084 psplitter = NULL;
1087 /* Render all output pin of the splitter by calling IGraphBuilder_Render on each of them */
1088 if (SUCCEEDED(hr)) {
1089 int partial = 0;
1090 int i;
1091 TRACE("pins to consider: %d\n", nb);
1092 for(i = 0; i < nb; i++) {
1093 TRACE("Processing pin %d\n", i);
1094 hr = IGraphBuilder_Render(iface, ppins[i]);
1095 if (FAILED(hr)) {
1096 ERR("Cannot render pin %p (%x)\n", ppins[i], hr);
1097 partial = 1;
1099 IPin_Release(ppins[i]);
1101 CoTaskMemFree(ppins);
1103 hr = (partial ? VFW_S_PARTIAL_RENDER : S_OK);
1106 return hr;
1109 static HRESULT WINAPI GraphBuilder_AddSourceFilter(IGraphBuilder *iface,
1110 LPCWSTR lpcwstrFileName,
1111 LPCWSTR lpcwstrFilterName,
1112 IBaseFilter **ppFilter) {
1113 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1114 HRESULT hr;
1115 IBaseFilter* preader;
1116 IFileSourceFilter* pfile = NULL;
1117 AM_MEDIA_TYPE mt;
1118 WCHAR* filename;
1120 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1122 /* Instantiate a file source filter */
1123 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1124 if (FAILED(hr)) {
1125 ERR("Unable to create file source filter (%x)\n", hr);
1126 return hr;
1129 hr = IGraphBuilder_AddFilter(iface, preader, lpcwstrFilterName);
1130 if (FAILED(hr)) {
1131 ERR("Unable add filter (%x)\n", hr);
1132 IBaseFilter_Release(preader);
1133 return hr;
1136 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1137 if (FAILED(hr)) {
1138 ERR("Unable to get IFileSourceInterface (%x)\n", hr);
1139 goto error;
1142 /* Load the file in the file source filter */
1143 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1144 if (FAILED(hr)) {
1145 ERR("Load (%x)\n", hr);
1146 goto error;
1149 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1150 if (FAILED(hr)) {
1151 ERR("GetCurFile (%x)\n", hr);
1152 goto error;
1154 TRACE("File %s\n", debugstr_w(filename));
1155 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1156 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1158 if (ppFilter)
1159 *ppFilter = preader;
1161 return S_OK;
1163 error:
1164 if (pfile)
1165 IFileSourceFilter_Release(pfile);
1166 IGraphBuilder_RemoveFilter(iface, preader);
1167 IBaseFilter_Release(preader);
1169 return hr;
1172 static HRESULT WINAPI GraphBuilder_SetLogFile(IGraphBuilder *iface,
1173 DWORD_PTR hFile) {
1174 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1176 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1178 return S_OK;
1181 static HRESULT WINAPI GraphBuilder_Abort(IGraphBuilder *iface) {
1182 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1184 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1186 return S_OK;
1189 static HRESULT WINAPI GraphBuilder_ShouldOperationContinue(IGraphBuilder *iface) {
1190 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1192 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1194 return S_OK;
1198 static const IGraphBuilderVtbl IGraphBuilder_VTable =
1200 GraphBuilder_QueryInterface,
1201 GraphBuilder_AddRef,
1202 GraphBuilder_Release,
1203 GraphBuilder_AddFilter,
1204 GraphBuilder_RemoveFilter,
1205 GraphBuilder_EnumFilters,
1206 GraphBuilder_FindFilterByName,
1207 GraphBuilder_ConnectDirect,
1208 GraphBuilder_Reconnect,
1209 GraphBuilder_Disconnect,
1210 GraphBuilder_SetDefaultSyncSource,
1211 GraphBuilder_Connect,
1212 GraphBuilder_Render,
1213 GraphBuilder_RenderFile,
1214 GraphBuilder_AddSourceFilter,
1215 GraphBuilder_SetLogFile,
1216 GraphBuilder_Abort,
1217 GraphBuilder_ShouldOperationContinue
1220 /*** IUnknown methods ***/
1221 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1222 REFIID riid,
1223 LPVOID*ppvObj) {
1224 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1226 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1228 return Filtergraph_QueryInterface(This, riid, ppvObj);
1231 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1232 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1234 TRACE("(%p/%p)->()\n", This, iface);
1236 return Filtergraph_AddRef(This);
1239 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1240 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1242 TRACE("(%p/%p)->()\n", This, iface);
1244 return Filtergraph_Release(This);
1248 /*** IDispatch methods ***/
1249 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1250 UINT*pctinfo) {
1251 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1253 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1255 return S_OK;
1258 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1259 UINT iTInfo,
1260 LCID lcid,
1261 ITypeInfo**ppTInfo) {
1262 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1264 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1266 return S_OK;
1269 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1270 REFIID riid,
1271 LPOLESTR*rgszNames,
1272 UINT cNames,
1273 LCID lcid,
1274 DISPID*rgDispId) {
1275 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1277 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1279 return S_OK;
1282 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1283 DISPID dispIdMember,
1284 REFIID riid,
1285 LCID lcid,
1286 WORD wFlags,
1287 DISPPARAMS*pDispParams,
1288 VARIANT*pVarResult,
1289 EXCEPINFO*pExepInfo,
1290 UINT*puArgErr) {
1291 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1293 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);
1295 return S_OK;
1298 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *);
1300 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter)
1302 HRESULT hr;
1303 IPin* pInputPin;
1304 IPin** ppPins;
1305 ULONG nb;
1306 ULONG i;
1307 PIN_INFO PinInfo;
1309 TRACE("%p %p\n", pGraph, pOutputPin);
1310 PinInfo.pFilter = NULL;
1312 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1314 if (SUCCEEDED(hr))
1315 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1317 if (SUCCEEDED(hr))
1318 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1320 if (SUCCEEDED(hr))
1322 if (nb == 0)
1324 TRACE("Reached a renderer\n");
1325 /* Count renderers for end of stream notification */
1326 pGraph->nRenderers++;
1328 else
1330 for(i = 0; i < nb; i++)
1332 /* Explore the graph downstream from this pin
1333 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1334 * several input pins are connected to the same output (a MUX for instance). */
1335 ExploreGraph(pGraph, ppPins[i], FoundFilter);
1336 IPin_Release(ppPins[i]);
1339 CoTaskMemFree(ppPins);
1341 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1342 FoundFilter(PinInfo.pFilter);
1345 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1346 return hr;
1349 static HRESULT WINAPI SendRun(IBaseFilter *pFilter) {
1350 return IBaseFilter_Run(pFilter, 0);
1353 static HRESULT WINAPI SendPause(IBaseFilter *pFilter) {
1354 return IBaseFilter_Pause(pFilter);
1357 static HRESULT WINAPI SendStop(IBaseFilter *pFilter) {
1358 return IBaseFilter_Stop(pFilter);
1361 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter) {
1362 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1363 int i;
1364 IBaseFilter* pfilter;
1365 IEnumPins* pEnum;
1366 HRESULT hr;
1367 IPin* pPin;
1368 DWORD dummy;
1369 PIN_DIRECTION dir;
1370 TRACE("(%p/%p)->()\n", This, iface);
1372 /* Explorer the graph from source filters to renderers, determine renderers
1373 * number and run filters from renderers to source filters */
1374 This->nRenderers = 0;
1375 ResetEvent(This->hEventCompletion);
1377 for(i = 0; i < This->nFilters; i++)
1379 BOOL source = TRUE;
1380 pfilter = This->ppFiltersInGraph[i];
1381 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1382 if (hr != S_OK)
1384 ERR("Enum pins failed %x\n", hr);
1385 continue;
1387 /* Check if it is a source filter */
1388 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1390 IPin_QueryDirection(pPin, &dir);
1391 IPin_Release(pPin);
1392 if (dir == PINDIR_INPUT)
1394 source = FALSE;
1395 break;
1398 if (source)
1400 TRACE("Found a source filter %p\n", pfilter);
1401 IEnumPins_Reset(pEnum);
1402 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1404 /* Explore the graph downstream from this pin */
1405 ExploreGraph(This, pPin, FoundFilter);
1406 IPin_Release(pPin);
1408 FoundFilter(pfilter);
1410 IEnumPins_Release(pEnum);
1413 return S_FALSE;
1416 /*** IMediaControl methods ***/
1417 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1418 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1419 TRACE("(%p/%p)->()\n", This, iface);
1421 if (This->state == State_Running) return S_OK;
1423 EnterCriticalSection(&This->cs);
1424 SendFilterMessage(iface, SendRun);
1425 This->state = State_Running;
1426 LeaveCriticalSection(&This->cs);
1427 return S_FALSE;
1430 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1431 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1432 TRACE("(%p/%p)->()\n", This, iface);
1434 if (This->state == State_Paused) return S_OK;
1436 EnterCriticalSection(&This->cs);
1437 SendFilterMessage(iface, SendPause);
1438 This->state = State_Paused;
1439 LeaveCriticalSection(&This->cs);
1440 return S_FALSE;
1443 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
1444 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1445 TRACE("(%p/%p)->()\n", This, iface);
1447 if (This->state == State_Stopped) return S_OK;
1449 EnterCriticalSection(&This->cs);
1450 if (This->state == State_Running) SendFilterMessage(iface, SendPause);
1451 SendFilterMessage(iface, SendStop);
1452 This->state = State_Stopped;
1453 LeaveCriticalSection(&This->cs);
1454 return S_FALSE;
1457 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
1458 LONG msTimeout,
1459 OAFilterState *pfs) {
1460 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1462 TRACE("(%p/%p)->(%d, %p): semi-stub !!!\n", This, iface, msTimeout, pfs);
1464 EnterCriticalSection(&This->cs);
1466 *pfs = This->state;
1468 LeaveCriticalSection(&This->cs);
1470 return S_OK;
1473 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
1474 BSTR strFilename) {
1475 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1477 TRACE("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
1479 return S_OK;
1482 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
1483 BSTR strFilename,
1484 IDispatch **ppUnk) {
1485 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1487 TRACE("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
1489 return S_OK;
1492 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
1493 IDispatch **ppUnk) {
1494 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1496 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1498 return S_OK;
1501 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
1502 IDispatch **ppUnk) {
1503 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1505 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1507 return S_OK;
1510 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
1511 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1513 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1515 return S_OK;
1519 static const IMediaControlVtbl IMediaControl_VTable =
1521 MediaControl_QueryInterface,
1522 MediaControl_AddRef,
1523 MediaControl_Release,
1524 MediaControl_GetTypeInfoCount,
1525 MediaControl_GetTypeInfo,
1526 MediaControl_GetIDsOfNames,
1527 MediaControl_Invoke,
1528 MediaControl_Run,
1529 MediaControl_Pause,
1530 MediaControl_Stop,
1531 MediaControl_GetState,
1532 MediaControl_RenderFile,
1533 MediaControl_AddSourceFilter,
1534 MediaControl_get_FilterCollection,
1535 MediaControl_get_RegFilterCollection,
1536 MediaControl_StopWhenReady
1540 /*** IUnknown methods ***/
1541 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
1542 REFIID riid,
1543 LPVOID*ppvObj) {
1544 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1546 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1548 return Filtergraph_QueryInterface(This, riid, ppvObj);
1551 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
1552 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1554 TRACE("(%p/%p)->()\n", This, iface);
1556 return Filtergraph_AddRef(This);
1559 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
1560 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1562 TRACE("(%p/%p)->()\n", This, iface);
1564 return Filtergraph_Release(This);
1567 /*** IMediaSeeking methods ***/
1568 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
1569 DWORD *pCapabilities) {
1570 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1572 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1574 return S_OK;
1577 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
1578 DWORD *pCapabilities) {
1579 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1581 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1583 return S_OK;
1586 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
1587 const GUID *pFormat) {
1588 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1590 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1592 return S_OK;
1595 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
1596 GUID *pFormat) {
1597 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1599 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1601 return S_OK;
1604 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
1605 GUID *pFormat) {
1606 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1608 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1610 return S_OK;
1613 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
1614 const GUID *pFormat) {
1615 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1617 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1619 return S_OK;
1622 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
1623 const GUID *pFormat) {
1624 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1626 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1628 return S_OK;
1631 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
1632 LONGLONG *pDuration) {
1633 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1635 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pDuration);
1637 return S_OK;
1640 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
1641 LONGLONG *pStop) {
1642 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1644 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pStop);
1646 return S_OK;
1649 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
1650 LONGLONG *pCurrent) {
1651 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1653 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCurrent);
1655 return S_OK;
1658 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
1659 LONGLONG *pTarget,
1660 const GUID *pTargetFormat,
1661 LONGLONG Source,
1662 const GUID *pSourceFormat) {
1663 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1665 TRACE("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
1666 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
1668 return S_OK;
1671 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
1672 LONGLONG *pCurrent,
1673 DWORD dwCurrentFlags,
1674 LONGLONG *pStop,
1675 DWORD dwStopFlags) {
1676 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1678 TRACE("(%p/%p)->(%p, %08x, %p, %08x): stub !!!\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
1680 return S_OK;
1683 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
1684 LONGLONG *pCurrent,
1685 LONGLONG *pStop) {
1686 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1688 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pCurrent, pStop);
1690 return S_OK;
1693 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
1694 LONGLONG *pEarliest,
1695 LONGLONG *pLatest) {
1696 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1698 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
1700 return S_OK;
1703 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
1704 double dRate) {
1705 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1707 TRACE("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
1709 return S_OK;
1712 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
1713 double *pdRate) {
1714 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1716 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
1718 return S_OK;
1721 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
1722 LONGLONG *pllPreroll) {
1723 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1725 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
1727 return S_OK;
1731 static const IMediaSeekingVtbl IMediaSeeking_VTable =
1733 MediaSeeking_QueryInterface,
1734 MediaSeeking_AddRef,
1735 MediaSeeking_Release,
1736 MediaSeeking_GetCapabilities,
1737 MediaSeeking_CheckCapabilities,
1738 MediaSeeking_IsFormatSupported,
1739 MediaSeeking_QueryPreferredFormat,
1740 MediaSeeking_GetTimeFormat,
1741 MediaSeeking_IsUsingTimeFormat,
1742 MediaSeeking_SetTimeFormat,
1743 MediaSeeking_GetDuration,
1744 MediaSeeking_GetStopPosition,
1745 MediaSeeking_GetCurrentPosition,
1746 MediaSeeking_ConvertTimeFormat,
1747 MediaSeeking_SetPositions,
1748 MediaSeeking_GetPositions,
1749 MediaSeeking_GetAvailable,
1750 MediaSeeking_SetRate,
1751 MediaSeeking_GetRate,
1752 MediaSeeking_GetPreroll
1755 /*** IUnknown methods ***/
1756 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObject){
1757 FIXME("(%p) stub!\n", iface);
1758 return E_NOTIMPL;
1761 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface){
1762 FIXME("(%p) stub!\n", iface);
1763 return E_NOTIMPL;
1766 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface){
1767 FIXME("(%p) stub!\n", iface);
1768 return E_NOTIMPL;
1771 /*** IDispatch methods ***/
1772 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
1773 FIXME("(%p) stub!\n", iface);
1774 return E_NOTIMPL;
1777 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
1778 FIXME("(%p) stub!\n", iface);
1779 return E_NOTIMPL;
1782 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
1783 FIXME("(%p) stub!\n", iface);
1784 return E_NOTIMPL;
1787 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
1788 FIXME("(%p) stub!\n", iface);
1789 return E_NOTIMPL;
1792 /*** IMediaPosition methods ***/
1793 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength){
1794 FIXME("(%p)->(%p) stub!\n", iface, plength);
1795 return E_NOTIMPL;
1798 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime){
1799 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1800 return E_NOTIMPL;
1803 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime){
1804 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1805 return E_NOTIMPL;
1808 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime){
1809 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1810 return E_NOTIMPL;
1813 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime){
1814 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1815 return E_NOTIMPL;
1818 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
1819 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1820 return E_NOTIMPL;
1823 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
1824 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1825 return E_NOTIMPL;
1828 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate){
1829 FIXME("(%p)->(%f) stub!\n", iface, dRate);
1830 return E_NOTIMPL;
1833 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate){
1834 FIXME("(%p)->(%p) stub!\n", iface, pdRate);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
1839 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
1840 return E_NOTIMPL;
1843 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
1844 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
1845 return E_NOTIMPL;
1849 static const IMediaPositionVtbl IMediaPosition_VTable =
1851 MediaPosition_QueryInterface,
1852 MediaPosition_AddRef,
1853 MediaPosition_Release,
1854 MediaPosition_GetTypeInfoCount,
1855 MediaPosition_GetTypeInfo,
1856 MediaPosition_GetIDsOfNames,
1857 MediaPosition_Invoke,
1858 MediaPosition_get_Duration,
1859 MediaPosition_put_CurrentPosition,
1860 MediaPosition_get_CurrentPosition,
1861 MediaPosition_get_StopTime,
1862 MediaPosition_put_StopTime,
1863 MediaPosition_get_PrerollTime,
1864 MediaPosition_put_PrerollTime,
1865 MediaPosition_put_Rate,
1866 MediaPosition_get_Rate,
1867 MediaPosition_CanSeekForward,
1868 MediaPosition_CanSeekBackward
1871 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
1873 HRESULT hr = E_NOINTERFACE;
1874 int i;
1875 int entry;
1877 /* Check if the interface type is already registered */
1878 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
1879 if (riid == pGraph->ItfCacheEntries[entry].riid)
1881 if (pGraph->ItfCacheEntries[entry].iface)
1883 /* Return the interface if available */
1884 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
1885 return S_OK;
1887 break;
1890 if (entry >= MAX_ITF_CACHE_ENTRIES)
1892 FIXME("Not enough space to store interface in the cache\n");
1893 return E_OUTOFMEMORY;
1896 /* Find a filter supporting the requested interface */
1897 for (i = 0; i < pGraph->nFilters; i++)
1899 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
1900 if (hr == S_OK)
1902 pGraph->ItfCacheEntries[entry].riid = riid;
1903 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
1904 pGraph->ItfCacheEntries[entry].iface = (IUnknown*)*ppvObj;
1905 if (entry >= pGraph->nItfCacheEntries)
1906 pGraph->nItfCacheEntries++;
1907 return S_OK;
1909 if (hr != E_NOINTERFACE)
1910 return hr;
1913 return hr;
1916 /*** IUnknown methods ***/
1917 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
1918 REFIID riid,
1919 LPVOID*ppvObj) {
1920 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1922 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1924 return Filtergraph_QueryInterface(This, riid, ppvObj);
1927 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
1928 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1930 TRACE("(%p/%p)->()\n", This, iface);
1932 return Filtergraph_AddRef(This);
1935 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
1936 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1938 TRACE("(%p/%p)->()\n", This, iface);
1940 return Filtergraph_Release(This);
1943 /*** IDispatch methods ***/
1944 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
1945 UINT*pctinfo) {
1946 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1947 IBasicAudio* pBasicAudio;
1948 HRESULT hr;
1950 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
1952 EnterCriticalSection(&This->cs);
1954 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
1956 if (hr == S_OK)
1957 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
1959 LeaveCriticalSection(&This->cs);
1961 return hr;
1964 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
1965 UINT iTInfo,
1966 LCID lcid,
1967 ITypeInfo**ppTInfo) {
1968 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1969 IBasicAudio* pBasicAudio;
1970 HRESULT hr;
1972 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
1974 EnterCriticalSection(&This->cs);
1976 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
1978 if (hr == S_OK)
1979 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
1981 LeaveCriticalSection(&This->cs);
1983 return hr;
1986 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
1987 REFIID riid,
1988 LPOLESTR*rgszNames,
1989 UINT cNames,
1990 LCID lcid,
1991 DISPID*rgDispId) {
1992 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1993 IBasicAudio* pBasicAudio;
1994 HRESULT hr;
1996 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1998 EnterCriticalSection(&This->cs);
2000 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2002 if (hr == S_OK)
2003 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2005 LeaveCriticalSection(&This->cs);
2007 return hr;
2010 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2011 DISPID dispIdMember,
2012 REFIID riid,
2013 LCID lcid,
2014 WORD wFlags,
2015 DISPPARAMS*pDispParams,
2016 VARIANT*pVarResult,
2017 EXCEPINFO*pExepInfo,
2018 UINT*puArgErr) {
2019 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2020 IBasicAudio* pBasicAudio;
2021 HRESULT hr;
2023 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);
2025 EnterCriticalSection(&This->cs);
2027 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2029 if (hr == S_OK)
2030 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2032 LeaveCriticalSection(&This->cs);
2034 return hr;
2037 /*** IBasicAudio methods ***/
2038 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2039 long lVolume) {
2040 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2041 IBasicAudio* pBasicAudio;
2042 HRESULT hr;
2044 TRACE("(%p/%p)->(%ld)\n", This, iface, lVolume);
2046 EnterCriticalSection(&This->cs);
2048 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2050 if (hr == S_OK)
2051 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2053 LeaveCriticalSection(&This->cs);
2055 return hr;
2058 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2059 long *plVolume) {
2060 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2061 IBasicAudio* pBasicAudio;
2062 HRESULT hr;
2064 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2066 EnterCriticalSection(&This->cs);
2068 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2070 if (hr == S_OK)
2071 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2073 LeaveCriticalSection(&This->cs);
2075 return hr;
2078 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2079 long lBalance) {
2080 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2081 IBasicAudio* pBasicAudio;
2082 HRESULT hr;
2084 TRACE("(%p/%p)->(%ld)\n", This, iface, lBalance);
2086 EnterCriticalSection(&This->cs);
2088 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2090 if (hr == S_OK)
2091 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2093 LeaveCriticalSection(&This->cs);
2095 return hr;
2098 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2099 long *plBalance) {
2100 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2101 IBasicAudio* pBasicAudio;
2102 HRESULT hr;
2104 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2106 EnterCriticalSection(&This->cs);
2108 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2110 if (hr == S_OK)
2111 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2113 LeaveCriticalSection(&This->cs);
2115 return hr;
2118 static const IBasicAudioVtbl IBasicAudio_VTable =
2120 BasicAudio_QueryInterface,
2121 BasicAudio_AddRef,
2122 BasicAudio_Release,
2123 BasicAudio_GetTypeInfoCount,
2124 BasicAudio_GetTypeInfo,
2125 BasicAudio_GetIDsOfNames,
2126 BasicAudio_Invoke,
2127 BasicAudio_put_Volume,
2128 BasicAudio_get_Volume,
2129 BasicAudio_put_Balance,
2130 BasicAudio_get_Balance
2133 /*** IUnknown methods ***/
2134 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo *iface,
2135 REFIID riid,
2136 LPVOID*ppvObj) {
2137 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2139 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2141 return Filtergraph_QueryInterface(This, riid, ppvObj);
2144 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo *iface) {
2145 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2147 TRACE("(%p/%p)->()\n", This, iface);
2149 return Filtergraph_AddRef(This);
2152 static ULONG WINAPI BasicVideo_Release(IBasicVideo *iface) {
2153 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2155 TRACE("(%p/%p)->()\n", This, iface);
2157 return Filtergraph_Release(This);
2160 /*** IDispatch methods ***/
2161 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo *iface,
2162 UINT*pctinfo) {
2163 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2164 IBasicVideo* pBasicVideo;
2165 HRESULT hr;
2167 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2169 EnterCriticalSection(&This->cs);
2171 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2173 if (hr == S_OK)
2174 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
2176 LeaveCriticalSection(&This->cs);
2178 return hr;
2181 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo *iface,
2182 UINT iTInfo,
2183 LCID lcid,
2184 ITypeInfo**ppTInfo) {
2185 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2186 IBasicVideo* pBasicVideo;
2187 HRESULT hr;
2189 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2191 EnterCriticalSection(&This->cs);
2193 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2195 if (hr == S_OK)
2196 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
2198 LeaveCriticalSection(&This->cs);
2200 return hr;
2203 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo *iface,
2204 REFIID riid,
2205 LPOLESTR*rgszNames,
2206 UINT cNames,
2207 LCID lcid,
2208 DISPID*rgDispId) {
2209 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2210 IBasicVideo* pBasicVideo;
2211 HRESULT hr;
2213 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2215 EnterCriticalSection(&This->cs);
2217 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2219 if (hr == S_OK)
2220 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
2222 LeaveCriticalSection(&This->cs);
2224 return hr;
2227 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo *iface,
2228 DISPID dispIdMember,
2229 REFIID riid,
2230 LCID lcid,
2231 WORD wFlags,
2232 DISPPARAMS*pDispParams,
2233 VARIANT*pVarResult,
2234 EXCEPINFO*pExepInfo,
2235 UINT*puArgErr) {
2236 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2237 IBasicVideo* pBasicVideo;
2238 HRESULT hr;
2240 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);
2242 EnterCriticalSection(&This->cs);
2244 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2246 if (hr == S_OK)
2247 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2249 LeaveCriticalSection(&This->cs);
2251 return hr;
2254 /*** IBasicVideo methods ***/
2255 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo *iface,
2256 REFTIME *pAvgTimePerFrame) {
2257 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2258 IBasicVideo* pBasicVideo;
2259 HRESULT hr;
2261 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
2263 EnterCriticalSection(&This->cs);
2265 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2267 if (hr == S_OK)
2268 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
2270 LeaveCriticalSection(&This->cs);
2272 return hr;
2275 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo *iface,
2276 long *pBitRate) {
2277 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2278 IBasicVideo* pBasicVideo;
2279 HRESULT hr;
2281 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
2283 EnterCriticalSection(&This->cs);
2285 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2287 if (hr == S_OK)
2288 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
2290 LeaveCriticalSection(&This->cs);
2292 return hr;
2295 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo *iface,
2296 long *pBitErrorRate) {
2297 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2298 IBasicVideo* pBasicVideo;
2299 HRESULT hr;
2301 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
2303 EnterCriticalSection(&This->cs);
2305 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2307 if (hr == S_OK)
2308 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
2310 LeaveCriticalSection(&This->cs);
2312 return hr;
2315 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo *iface,
2316 long *pVideoWidth) {
2317 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2318 IBasicVideo* pBasicVideo;
2319 HRESULT hr;
2321 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
2323 EnterCriticalSection(&This->cs);
2325 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2327 if (hr == S_OK)
2328 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
2330 LeaveCriticalSection(&This->cs);
2332 return hr;
2335 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo *iface,
2336 long *pVideoHeight) {
2337 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2338 IBasicVideo* pBasicVideo;
2339 HRESULT hr;
2341 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
2343 EnterCriticalSection(&This->cs);
2345 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2347 if (hr == S_OK)
2348 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
2350 LeaveCriticalSection(&This->cs);
2352 return hr;
2355 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo *iface,
2356 long SourceLeft) {
2357 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2358 IBasicVideo* pBasicVideo;
2359 HRESULT hr;
2361 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
2363 EnterCriticalSection(&This->cs);
2365 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2367 if (hr == S_OK)
2368 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
2370 LeaveCriticalSection(&This->cs);
2372 return hr;
2375 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo *iface,
2376 long *pSourceLeft) {
2377 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2378 IBasicVideo* pBasicVideo;
2379 HRESULT hr;
2381 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
2383 EnterCriticalSection(&This->cs);
2385 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2387 if (hr == S_OK)
2388 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
2390 LeaveCriticalSection(&This->cs);
2392 return hr;
2395 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo *iface,
2396 long SourceWidth) {
2397 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2398 IBasicVideo* pBasicVideo;
2399 HRESULT hr;
2401 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
2403 EnterCriticalSection(&This->cs);
2405 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2407 if (hr == S_OK)
2408 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
2410 LeaveCriticalSection(&This->cs);
2412 return hr;
2415 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo *iface,
2416 long *pSourceWidth) {
2417 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2418 IBasicVideo* pBasicVideo;
2419 HRESULT hr;
2421 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
2423 EnterCriticalSection(&This->cs);
2425 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2427 if (hr == S_OK)
2428 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
2430 LeaveCriticalSection(&This->cs);
2432 return hr;
2435 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo *iface,
2436 long SourceTop) {
2437 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2438 IBasicVideo* pBasicVideo;
2439 HRESULT hr;
2441 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
2443 EnterCriticalSection(&This->cs);
2445 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2447 if (hr == S_OK)
2448 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
2450 LeaveCriticalSection(&This->cs);
2452 return hr;
2455 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo *iface,
2456 long *pSourceTop) {
2457 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2458 IBasicVideo* pBasicVideo;
2459 HRESULT hr;
2461 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
2463 EnterCriticalSection(&This->cs);
2465 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2467 if (hr == S_OK)
2468 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
2470 LeaveCriticalSection(&This->cs);
2472 return hr;
2475 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo *iface,
2476 long SourceHeight) {
2477 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2478 IBasicVideo* pBasicVideo;
2479 HRESULT hr;
2481 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
2483 EnterCriticalSection(&This->cs);
2485 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2487 if (hr == S_OK)
2488 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
2490 LeaveCriticalSection(&This->cs);
2492 return hr;
2495 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo *iface,
2496 long *pSourceHeight) {
2497 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2498 IBasicVideo* pBasicVideo;
2499 HRESULT hr;
2501 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
2503 EnterCriticalSection(&This->cs);
2505 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2507 if (hr == S_OK)
2508 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
2510 LeaveCriticalSection(&This->cs);
2512 return hr;
2515 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo *iface,
2516 long DestinationLeft) {
2517 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2518 IBasicVideo* pBasicVideo;
2519 HRESULT hr;
2521 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
2523 EnterCriticalSection(&This->cs);
2525 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2527 if (hr == S_OK)
2528 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
2530 LeaveCriticalSection(&This->cs);
2532 return hr;
2535 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo *iface,
2536 long *pDestinationLeft) {
2537 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2538 IBasicVideo* pBasicVideo;
2539 HRESULT hr;
2541 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
2543 EnterCriticalSection(&This->cs);
2545 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2547 if (hr == S_OK)
2548 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
2550 LeaveCriticalSection(&This->cs);
2552 return hr;
2555 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo *iface,
2556 long DestinationWidth) {
2557 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2558 IBasicVideo* pBasicVideo;
2559 HRESULT hr;
2561 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
2563 EnterCriticalSection(&This->cs);
2565 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2567 if (hr == S_OK)
2568 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
2570 LeaveCriticalSection(&This->cs);
2572 return hr;
2575 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo *iface,
2576 long *pDestinationWidth) {
2577 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2578 IBasicVideo* pBasicVideo;
2579 HRESULT hr;
2581 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
2583 EnterCriticalSection(&This->cs);
2585 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2587 if (hr == S_OK)
2588 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
2590 LeaveCriticalSection(&This->cs);
2592 return hr;
2595 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo *iface,
2596 long DestinationTop) {
2597 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2598 IBasicVideo* pBasicVideo;
2599 HRESULT hr;
2601 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
2603 EnterCriticalSection(&This->cs);
2605 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2607 if (hr == S_OK)
2608 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
2610 LeaveCriticalSection(&This->cs);
2612 return hr;
2615 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo *iface,
2616 long *pDestinationTop) {
2617 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2618 IBasicVideo* pBasicVideo;
2619 HRESULT hr;
2621 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
2623 EnterCriticalSection(&This->cs);
2625 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2627 if (hr == S_OK)
2628 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
2630 LeaveCriticalSection(&This->cs);
2632 return hr;
2635 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo *iface,
2636 long DestinationHeight) {
2637 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2638 IBasicVideo* pBasicVideo;
2639 HRESULT hr;
2641 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
2643 EnterCriticalSection(&This->cs);
2645 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2647 if (hr == S_OK)
2648 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
2650 LeaveCriticalSection(&This->cs);
2652 return hr;
2655 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo *iface,
2656 long *pDestinationHeight) {
2657 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2658 IBasicVideo* pBasicVideo;
2659 HRESULT hr;
2661 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
2663 EnterCriticalSection(&This->cs);
2665 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2667 if (hr == S_OK)
2668 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
2670 LeaveCriticalSection(&This->cs);
2672 return hr;
2675 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo *iface,
2676 long Left,
2677 long Top,
2678 long Width,
2679 long Height) {
2680 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2681 IBasicVideo* pBasicVideo;
2682 HRESULT hr;
2684 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2686 EnterCriticalSection(&This->cs);
2688 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2690 if (hr == S_OK)
2691 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
2693 LeaveCriticalSection(&This->cs);
2695 return hr;
2698 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo *iface,
2699 long *pLeft,
2700 long *pTop,
2701 long *pWidth,
2702 long *pHeight) {
2703 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2704 IBasicVideo* pBasicVideo;
2705 HRESULT hr;
2707 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2709 EnterCriticalSection(&This->cs);
2711 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2713 if (hr == S_OK)
2714 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2716 LeaveCriticalSection(&This->cs);
2718 return hr;
2721 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo *iface) {
2722 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2723 IBasicVideo* pBasicVideo;
2724 HRESULT hr;
2726 TRACE("(%p/%p)->()\n", This, iface);
2728 EnterCriticalSection(&This->cs);
2730 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2732 if (hr == S_OK)
2733 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
2735 LeaveCriticalSection(&This->cs);
2737 return hr;
2740 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo *iface,
2741 long Left,
2742 long Top,
2743 long Width,
2744 long Height) {
2745 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2746 IBasicVideo* pBasicVideo;
2747 HRESULT hr;
2749 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2751 EnterCriticalSection(&This->cs);
2753 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2755 if (hr == S_OK)
2756 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
2758 LeaveCriticalSection(&This->cs);
2760 return hr;
2763 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo *iface,
2764 long *pLeft,
2765 long *pTop,
2766 long *pWidth,
2767 long *pHeight) {
2768 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2769 IBasicVideo* pBasicVideo;
2770 HRESULT hr;
2772 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2774 EnterCriticalSection(&This->cs);
2776 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2778 if (hr == S_OK)
2779 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2781 LeaveCriticalSection(&This->cs);
2783 return hr;
2786 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
2787 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2788 IBasicVideo* pBasicVideo;
2789 HRESULT hr;
2791 TRACE("(%p/%p)->()\n", This, iface);
2793 EnterCriticalSection(&This->cs);
2795 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2797 if (hr == S_OK)
2798 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
2800 LeaveCriticalSection(&This->cs);
2802 return hr;
2805 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo *iface,
2806 long *pWidth,
2807 long *pHeight) {
2808 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2809 IBasicVideo* pBasicVideo;
2810 HRESULT hr;
2812 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
2814 EnterCriticalSection(&This->cs);
2816 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2818 if (hr == S_OK)
2819 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
2821 LeaveCriticalSection(&This->cs);
2823 return hr;
2826 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo *iface,
2827 long StartIndex,
2828 long Entries,
2829 long *pRetrieved,
2830 long *pPalette) {
2831 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2832 IBasicVideo* pBasicVideo;
2833 HRESULT hr;
2835 TRACE("(%p/%p)->(%ld, %ld, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
2837 EnterCriticalSection(&This->cs);
2839 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2841 if (hr == S_OK)
2842 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
2844 LeaveCriticalSection(&This->cs);
2846 return hr;
2849 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo *iface,
2850 long *pBufferSize,
2851 long *pDIBImage) {
2852 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2853 IBasicVideo* pBasicVideo;
2854 HRESULT hr;
2856 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
2858 EnterCriticalSection(&This->cs);
2860 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2862 if (hr == S_OK)
2863 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
2865 LeaveCriticalSection(&This->cs);
2867 return hr;
2870 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo *iface) {
2871 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2872 IBasicVideo* pBasicVideo;
2873 HRESULT hr;
2875 TRACE("(%p/%p)->()\n", This, iface);
2877 EnterCriticalSection(&This->cs);
2879 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2881 if (hr == S_OK)
2882 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
2884 LeaveCriticalSection(&This->cs);
2886 return hr;
2889 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo *iface) {
2890 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2891 IBasicVideo* pBasicVideo;
2892 HRESULT hr;
2894 TRACE("(%p/%p)->()\n", This, iface);
2896 EnterCriticalSection(&This->cs);
2898 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2900 if (hr == S_OK)
2901 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
2903 LeaveCriticalSection(&This->cs);
2905 return hr;
2909 static const IBasicVideoVtbl IBasicVideo_VTable =
2911 BasicVideo_QueryInterface,
2912 BasicVideo_AddRef,
2913 BasicVideo_Release,
2914 BasicVideo_GetTypeInfoCount,
2915 BasicVideo_GetTypeInfo,
2916 BasicVideo_GetIDsOfNames,
2917 BasicVideo_Invoke,
2918 BasicVideo_get_AvgTimePerFrame,
2919 BasicVideo_get_BitRate,
2920 BasicVideo_get_BitErrorRate,
2921 BasicVideo_get_VideoWidth,
2922 BasicVideo_get_VideoHeight,
2923 BasicVideo_put_SourceLeft,
2924 BasicVideo_get_SourceLeft,
2925 BasicVideo_put_SourceWidth,
2926 BasicVideo_get_SourceWidth,
2927 BasicVideo_put_SourceTop,
2928 BasicVideo_get_SourceTop,
2929 BasicVideo_put_SourceHeight,
2930 BasicVideo_get_SourceHeight,
2931 BasicVideo_put_DestinationLeft,
2932 BasicVideo_get_DestinationLeft,
2933 BasicVideo_put_DestinationWidth,
2934 BasicVideo_get_DestinationWidth,
2935 BasicVideo_put_DestinationTop,
2936 BasicVideo_get_DestinationTop,
2937 BasicVideo_put_DestinationHeight,
2938 BasicVideo_get_DestinationHeight,
2939 BasicVideo_SetSourcePosition,
2940 BasicVideo_GetSourcePosition,
2941 BasicVideo_SetDefaultSourcePosition,
2942 BasicVideo_SetDestinationPosition,
2943 BasicVideo_GetDestinationPosition,
2944 BasicVideo_SetDefaultDestinationPosition,
2945 BasicVideo_GetVideoSize,
2946 BasicVideo_GetVideoPaletteEntries,
2947 BasicVideo_GetCurrentImage,
2948 BasicVideo_IsUsingDefaultSource,
2949 BasicVideo_IsUsingDefaultDestination
2953 /*** IUnknown methods ***/
2954 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
2955 REFIID riid,
2956 LPVOID*ppvObj) {
2957 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
2959 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2961 return Filtergraph_QueryInterface(This, riid, ppvObj);
2964 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
2965 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
2967 TRACE("(%p/%p)->()\n", This, iface);
2969 return Filtergraph_AddRef(This);
2972 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
2973 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
2975 TRACE("(%p/%p)->()\n", This, iface);
2977 return Filtergraph_Release(This);
2980 /*** IDispatch methods ***/
2981 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
2982 UINT*pctinfo) {
2983 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
2984 IVideoWindow* pVideoWindow;
2985 HRESULT hr;
2987 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2989 EnterCriticalSection(&This->cs);
2991 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
2993 if (hr == S_OK)
2994 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
2996 LeaveCriticalSection(&This->cs);
2998 return hr;
3001 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3002 UINT iTInfo,
3003 LCID lcid,
3004 ITypeInfo**ppTInfo) {
3005 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3006 IVideoWindow* pVideoWindow;
3007 HRESULT hr;
3009 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3011 EnterCriticalSection(&This->cs);
3013 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3015 if (hr == S_OK)
3016 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3018 LeaveCriticalSection(&This->cs);
3020 return hr;
3023 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3024 REFIID riid,
3025 LPOLESTR*rgszNames,
3026 UINT cNames,
3027 LCID lcid,
3028 DISPID*rgDispId) {
3029 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3030 IVideoWindow* pVideoWindow;
3031 HRESULT hr;
3033 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3035 EnterCriticalSection(&This->cs);
3037 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3039 if (hr == S_OK)
3040 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3042 LeaveCriticalSection(&This->cs);
3044 return hr;
3047 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3048 DISPID dispIdMember,
3049 REFIID riid,
3050 LCID lcid,
3051 WORD wFlags,
3052 DISPPARAMS*pDispParams,
3053 VARIANT*pVarResult,
3054 EXCEPINFO*pExepInfo,
3055 UINT*puArgErr) {
3056 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3057 IVideoWindow* pVideoWindow;
3058 HRESULT hr;
3060 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);
3062 EnterCriticalSection(&This->cs);
3064 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3066 if (hr == S_OK)
3067 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3069 LeaveCriticalSection(&This->cs);
3071 return hr;
3075 /*** IVideoWindow methods ***/
3076 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3077 BSTR strCaption) {
3078 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3079 IVideoWindow* pVideoWindow;
3080 HRESULT hr;
3082 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3084 EnterCriticalSection(&This->cs);
3086 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3088 if (hr == S_OK)
3089 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3091 LeaveCriticalSection(&This->cs);
3093 return hr;
3096 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3097 BSTR *strCaption) {
3098 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3099 IVideoWindow* pVideoWindow;
3100 HRESULT hr;
3102 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3104 EnterCriticalSection(&This->cs);
3106 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3108 if (hr == S_OK)
3109 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3111 LeaveCriticalSection(&This->cs);
3113 return hr;
3116 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3117 long WindowStyle) {
3118 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3119 IVideoWindow* pVideoWindow;
3120 HRESULT hr;
3122 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyle);
3124 EnterCriticalSection(&This->cs);
3126 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3128 if (hr == S_OK)
3129 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
3131 LeaveCriticalSection(&This->cs);
3133 return hr;
3136 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
3137 long *WindowStyle) {
3138 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3139 IVideoWindow* pVideoWindow;
3140 HRESULT hr;
3142 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
3144 EnterCriticalSection(&This->cs);
3146 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3148 if (hr == S_OK)
3149 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
3151 LeaveCriticalSection(&This->cs);
3153 return hr;
3156 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
3157 long WindowStyleEx) {
3158 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3159 IVideoWindow* pVideoWindow;
3160 HRESULT hr;
3162 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
3164 EnterCriticalSection(&This->cs);
3166 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3168 if (hr == S_OK)
3169 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
3171 LeaveCriticalSection(&This->cs);
3173 return hr;
3176 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
3177 long *WindowStyleEx) {
3178 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3179 IVideoWindow* pVideoWindow;
3180 HRESULT hr;
3182 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
3184 EnterCriticalSection(&This->cs);
3186 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3188 if (hr == S_OK)
3189 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
3191 LeaveCriticalSection(&This->cs);
3193 return hr;
3196 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
3197 long AutoShow) {
3198 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3199 IVideoWindow* pVideoWindow;
3200 HRESULT hr;
3202 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
3204 EnterCriticalSection(&This->cs);
3206 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3208 if (hr == S_OK)
3209 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
3211 LeaveCriticalSection(&This->cs);
3213 return hr;
3216 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
3217 long *AutoShow) {
3218 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3219 IVideoWindow* pVideoWindow;
3220 HRESULT hr;
3222 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
3224 EnterCriticalSection(&This->cs);
3226 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3228 if (hr == S_OK)
3229 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
3231 LeaveCriticalSection(&This->cs);
3233 return hr;
3236 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
3237 long WindowState) {
3238 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3239 IVideoWindow* pVideoWindow;
3240 HRESULT hr;
3242 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowState);
3244 EnterCriticalSection(&This->cs);
3246 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3248 if (hr == S_OK)
3249 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
3251 LeaveCriticalSection(&This->cs);
3253 return hr;
3256 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
3257 long *WindowState) {
3258 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3259 IVideoWindow* pVideoWindow;
3260 HRESULT hr;
3262 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
3264 EnterCriticalSection(&This->cs);
3266 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3268 if (hr == S_OK)
3269 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
3271 LeaveCriticalSection(&This->cs);
3273 return hr;
3276 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
3277 long BackgroundPalette) {
3278 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3279 IVideoWindow* pVideoWindow;
3280 HRESULT hr;
3282 TRACE("(%p/%p)->(%ld)\n", This, iface, BackgroundPalette);
3284 EnterCriticalSection(&This->cs);
3286 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3288 if (hr == S_OK)
3289 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
3291 LeaveCriticalSection(&This->cs);
3293 return hr;
3296 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
3297 long *pBackgroundPalette) {
3298 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3299 IVideoWindow* pVideoWindow;
3300 HRESULT hr;
3302 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
3304 EnterCriticalSection(&This->cs);
3306 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3308 if (hr == S_OK)
3309 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
3311 LeaveCriticalSection(&This->cs);
3313 return hr;
3316 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
3317 long Visible) {
3318 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3319 IVideoWindow* pVideoWindow;
3320 HRESULT hr;
3322 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
3324 EnterCriticalSection(&This->cs);
3326 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3328 if (hr == S_OK)
3329 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
3331 LeaveCriticalSection(&This->cs);
3333 return hr;
3336 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
3337 long *pVisible) {
3338 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3339 IVideoWindow* pVideoWindow;
3340 HRESULT hr;
3342 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
3344 EnterCriticalSection(&This->cs);
3346 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3348 if (hr == S_OK)
3349 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
3351 LeaveCriticalSection(&This->cs);
3353 return hr;
3356 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
3357 long Left) {
3358 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3359 IVideoWindow* pVideoWindow;
3360 HRESULT hr;
3362 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
3364 EnterCriticalSection(&This->cs);
3366 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3368 if (hr == S_OK)
3369 hr = IVideoWindow_put_Left(pVideoWindow, Left);
3371 LeaveCriticalSection(&This->cs);
3373 return hr;
3376 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
3377 long *pLeft) {
3378 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3379 IVideoWindow* pVideoWindow;
3380 HRESULT hr;
3382 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
3384 EnterCriticalSection(&This->cs);
3386 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3388 if (hr == S_OK)
3389 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
3391 LeaveCriticalSection(&This->cs);
3393 return hr;
3396 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
3397 long Width) {
3398 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3399 IVideoWindow* pVideoWindow;
3400 HRESULT hr;
3402 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
3404 EnterCriticalSection(&This->cs);
3406 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3408 if (hr == S_OK)
3409 hr = IVideoWindow_put_Width(pVideoWindow, Width);
3411 LeaveCriticalSection(&This->cs);
3413 return hr;
3416 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
3417 long *pWidth) {
3418 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3419 IVideoWindow* pVideoWindow;
3420 HRESULT hr;
3422 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
3424 EnterCriticalSection(&This->cs);
3426 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3428 if (hr == S_OK)
3429 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
3431 LeaveCriticalSection(&This->cs);
3433 return hr;
3436 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
3437 long Top) {
3438 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3439 IVideoWindow* pVideoWindow;
3440 HRESULT hr;
3442 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
3444 EnterCriticalSection(&This->cs);
3446 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3448 if (hr == S_OK)
3449 hr = IVideoWindow_put_Top(pVideoWindow, Top);
3451 LeaveCriticalSection(&This->cs);
3453 return hr;
3456 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
3457 long *pTop) {
3458 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3459 IVideoWindow* pVideoWindow;
3460 HRESULT hr;
3462 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
3464 EnterCriticalSection(&This->cs);
3466 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3468 if (hr == S_OK)
3469 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
3471 LeaveCriticalSection(&This->cs);
3473 return hr;
3476 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
3477 long Height) {
3478 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3479 IVideoWindow* pVideoWindow;
3480 HRESULT hr;
3482 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
3484 EnterCriticalSection(&This->cs);
3486 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3488 if (hr == S_OK)
3489 hr = IVideoWindow_put_Height(pVideoWindow, Height);
3491 LeaveCriticalSection(&This->cs);
3493 return hr;
3496 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
3497 long *pHeight) {
3498 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3499 IVideoWindow* pVideoWindow;
3500 HRESULT hr;
3502 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
3504 EnterCriticalSection(&This->cs);
3506 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3508 if (hr == S_OK)
3509 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
3511 LeaveCriticalSection(&This->cs);
3513 return hr;
3516 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
3517 OAHWND Owner) {
3518 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3519 IVideoWindow* pVideoWindow;
3520 HRESULT hr;
3522 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
3524 EnterCriticalSection(&This->cs);
3526 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3528 if (hr == S_OK)
3529 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
3531 LeaveCriticalSection(&This->cs);
3533 return hr;
3536 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
3537 OAHWND *Owner) {
3538 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3539 IVideoWindow* pVideoWindow;
3540 HRESULT hr;
3542 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
3544 EnterCriticalSection(&This->cs);
3546 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3548 if (hr == S_OK)
3549 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
3551 LeaveCriticalSection(&This->cs);
3553 return hr;
3556 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
3557 OAHWND Drain) {
3558 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3559 IVideoWindow* pVideoWindow;
3560 HRESULT hr;
3562 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
3564 EnterCriticalSection(&This->cs);
3566 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3568 if (hr == S_OK)
3569 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
3571 LeaveCriticalSection(&This->cs);
3573 return hr;
3576 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
3577 OAHWND *Drain) {
3578 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3579 IVideoWindow* pVideoWindow;
3580 HRESULT hr;
3582 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
3584 EnterCriticalSection(&This->cs);
3586 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3588 if (hr == S_OK)
3589 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
3591 LeaveCriticalSection(&This->cs);
3593 return hr;
3596 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
3597 long *Color) {
3598 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3599 IVideoWindow* pVideoWindow;
3600 HRESULT hr;
3602 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
3604 EnterCriticalSection(&This->cs);
3606 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3608 if (hr == S_OK)
3609 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
3611 LeaveCriticalSection(&This->cs);
3613 return hr;
3616 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
3617 long Color) {
3618 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3619 IVideoWindow* pVideoWindow;
3620 HRESULT hr;
3622 TRACE("(%p/%p)->(%ld)\n", This, iface, Color);
3624 EnterCriticalSection(&This->cs);
3626 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3628 if (hr == S_OK)
3629 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
3631 LeaveCriticalSection(&This->cs);
3633 return hr;
3636 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
3637 long *FullScreenMode) {
3638 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3639 IVideoWindow* pVideoWindow;
3640 HRESULT hr;
3642 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
3644 EnterCriticalSection(&This->cs);
3646 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3648 if (hr == S_OK)
3649 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
3651 LeaveCriticalSection(&This->cs);
3653 return hr;
3656 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
3657 long FullScreenMode) {
3658 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3659 IVideoWindow* pVideoWindow;
3660 HRESULT hr;
3662 TRACE("(%p/%p)->(%ld)\n", This, iface, FullScreenMode);
3664 EnterCriticalSection(&This->cs);
3666 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3668 if (hr == S_OK)
3669 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
3671 LeaveCriticalSection(&This->cs);
3673 return hr;
3676 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
3677 long Focus) {
3678 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3679 IVideoWindow* pVideoWindow;
3680 HRESULT hr;
3682 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
3684 EnterCriticalSection(&This->cs);
3686 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3688 if (hr == S_OK)
3689 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
3691 LeaveCriticalSection(&This->cs);
3693 return hr;
3696 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
3697 OAHWND hwnd,
3698 long uMsg,
3699 LONG_PTR wParam,
3700 LONG_PTR lParam) {
3701 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3702 IVideoWindow* pVideoWindow;
3703 HRESULT hr;
3705 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
3707 EnterCriticalSection(&This->cs);
3709 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3711 if (hr == S_OK)
3712 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
3714 LeaveCriticalSection(&This->cs);
3716 return hr;
3719 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
3720 long Left,
3721 long Top,
3722 long Width,
3723 long Height) {
3724 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3725 IVideoWindow* pVideoWindow;
3726 HRESULT hr;
3728 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
3730 EnterCriticalSection(&This->cs);
3732 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3734 if (hr == S_OK)
3735 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
3737 LeaveCriticalSection(&This->cs);
3739 return hr;
3742 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
3743 long *pLeft,
3744 long *pTop,
3745 long *pWidth,
3746 long *pHeight) {
3747 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3748 IVideoWindow* pVideoWindow;
3749 HRESULT hr;
3751 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3753 EnterCriticalSection(&This->cs);
3755 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3757 if (hr == S_OK)
3758 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3760 LeaveCriticalSection(&This->cs);
3762 return hr;
3765 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
3766 long *pWidth,
3767 long *pHeight) {
3768 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3769 IVideoWindow* pVideoWindow;
3770 HRESULT hr;
3772 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3774 EnterCriticalSection(&This->cs);
3776 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3778 if (hr == S_OK)
3779 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
3781 LeaveCriticalSection(&This->cs);
3783 return hr;
3786 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
3787 long *pWidth,
3788 long *pHeight) {
3789 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3790 IVideoWindow* pVideoWindow;
3791 HRESULT hr;
3793 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3795 EnterCriticalSection(&This->cs);
3797 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3799 if (hr == S_OK)
3800 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
3802 LeaveCriticalSection(&This->cs);
3804 return hr;
3807 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
3808 long *pLeft,
3809 long *pTop,
3810 long *pWidth,
3811 long *pHeight) {
3812 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3813 IVideoWindow* pVideoWindow;
3814 HRESULT hr;
3816 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3818 EnterCriticalSection(&This->cs);
3820 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3822 if (hr == S_OK)
3823 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3825 LeaveCriticalSection(&This->cs);
3827 return hr;
3830 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
3831 long HideCursor) {
3832 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3833 IVideoWindow* pVideoWindow;
3834 HRESULT hr;
3836 TRACE("(%p/%p)->(%ld)\n", This, iface, HideCursor);
3838 EnterCriticalSection(&This->cs);
3840 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3842 if (hr == S_OK)
3843 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
3845 LeaveCriticalSection(&This->cs);
3847 return hr;
3850 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
3851 long *CursorHidden) {
3852 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3853 IVideoWindow* pVideoWindow;
3854 HRESULT hr;
3856 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
3858 EnterCriticalSection(&This->cs);
3860 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3862 if (hr == S_OK)
3863 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
3865 LeaveCriticalSection(&This->cs);
3867 return hr;
3871 static const IVideoWindowVtbl IVideoWindow_VTable =
3873 VideoWindow_QueryInterface,
3874 VideoWindow_AddRef,
3875 VideoWindow_Release,
3876 VideoWindow_GetTypeInfoCount,
3877 VideoWindow_GetTypeInfo,
3878 VideoWindow_GetIDsOfNames,
3879 VideoWindow_Invoke,
3880 VideoWindow_put_Caption,
3881 VideoWindow_get_Caption,
3882 VideoWindow_put_WindowStyle,
3883 VideoWindow_get_WindowStyle,
3884 VideoWindow_put_WindowStyleEx,
3885 VideoWindow_get_WindowStyleEx,
3886 VideoWindow_put_AutoShow,
3887 VideoWindow_get_AutoShow,
3888 VideoWindow_put_WindowState,
3889 VideoWindow_get_WindowState,
3890 VideoWindow_put_BackgroundPalette,
3891 VideoWindow_get_BackgroundPalette,
3892 VideoWindow_put_Visible,
3893 VideoWindow_get_Visible,
3894 VideoWindow_put_Left,
3895 VideoWindow_get_Left,
3896 VideoWindow_put_Width,
3897 VideoWindow_get_Width,
3898 VideoWindow_put_Top,
3899 VideoWindow_get_Top,
3900 VideoWindow_put_Height,
3901 VideoWindow_get_Height,
3902 VideoWindow_put_Owner,
3903 VideoWindow_get_Owner,
3904 VideoWindow_put_MessageDrain,
3905 VideoWindow_get_MessageDrain,
3906 VideoWindow_get_BorderColor,
3907 VideoWindow_put_BorderColor,
3908 VideoWindow_get_FullScreenMode,
3909 VideoWindow_put_FullScreenMode,
3910 VideoWindow_SetWindowForeground,
3911 VideoWindow_NotifyOwnerMessage,
3912 VideoWindow_SetWindowPosition,
3913 VideoWindow_GetWindowPosition,
3914 VideoWindow_GetMinIdealImageSize,
3915 VideoWindow_GetMaxIdealImageSize,
3916 VideoWindow_GetRestorePosition,
3917 VideoWindow_HideCursor,
3918 VideoWindow_IsCursorHidden
3922 /*** IUnknown methods ***/
3923 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
3924 REFIID riid,
3925 LPVOID*ppvObj) {
3926 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3928 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3930 return Filtergraph_QueryInterface(This, riid, ppvObj);
3933 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
3934 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3936 TRACE("(%p/%p)->()\n", This, iface);
3938 return Filtergraph_AddRef(This);
3941 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
3942 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3944 TRACE("(%p/%p)->()\n", This, iface);
3946 return Filtergraph_Release(This);
3949 /*** IDispatch methods ***/
3950 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
3951 UINT*pctinfo) {
3952 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3954 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
3956 return S_OK;
3959 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
3960 UINT iTInfo,
3961 LCID lcid,
3962 ITypeInfo**ppTInfo) {
3963 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3965 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
3967 return S_OK;
3970 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
3971 REFIID riid,
3972 LPOLESTR*rgszNames,
3973 UINT cNames,
3974 LCID lcid,
3975 DISPID*rgDispId) {
3976 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3978 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3980 return S_OK;
3983 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
3984 DISPID dispIdMember,
3985 REFIID riid,
3986 LCID lcid,
3987 WORD wFlags,
3988 DISPPARAMS*pDispParams,
3989 VARIANT*pVarResult,
3990 EXCEPINFO*pExepInfo,
3991 UINT*puArgErr) {
3992 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3994 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);
3996 return S_OK;
3999 /*** IMediaEvent methods ***/
4000 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4001 OAEVENT *hEvent) {
4002 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4004 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4006 *hEvent = (OAEVENT)This->evqueue.msg_event;
4008 return S_OK;
4011 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4012 long *lEventCode,
4013 LONG_PTR *lParam1,
4014 LONG_PTR *lParam2,
4015 long msTimeout) {
4016 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4017 Event evt;
4019 TRACE("(%p/%p)->(%p, %p, %p, %ld)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4021 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4023 *lEventCode = evt.lEventCode;
4024 *lParam1 = evt.lParam1;
4025 *lParam2 = evt.lParam2;
4026 return S_OK;
4029 *lEventCode = 0;
4030 return E_ABORT;
4033 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4034 long msTimeout,
4035 long *pEvCode) {
4036 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4038 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, msTimeout, pEvCode);
4040 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4042 *pEvCode = This->CompletionStatus;
4043 return S_OK;
4046 *pEvCode = 0;
4047 return E_ABORT;
4050 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4051 long lEvCode) {
4052 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4054 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4056 if (lEvCode == EC_COMPLETE)
4057 This->HandleEcComplete = FALSE;
4058 else if (lEvCode == EC_REPAINT)
4059 This->HandleEcRepaint = FALSE;
4060 else
4061 return S_FALSE;
4063 return S_OK;
4066 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4067 long lEvCode) {
4068 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4070 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4072 if (lEvCode == EC_COMPLETE)
4073 This->HandleEcComplete = TRUE;
4074 else if (lEvCode == EC_REPAINT)
4075 This->HandleEcRepaint = TRUE;
4076 else
4077 return S_FALSE;
4079 return S_OK;
4082 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4083 long lEvCode,
4084 LONG_PTR lParam1,
4085 LONG_PTR lParam2) {
4086 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4088 TRACE("(%p/%p)->(%ld, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4090 return S_OK;
4093 /*** IMediaEventEx methods ***/
4094 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4095 OAHWND hwnd,
4096 long lMsg,
4097 LONG_PTR lInstanceData) {
4098 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4100 TRACE("(%p/%p)->(%08x, %ld, %08lx)\n", This, iface, (DWORD) hwnd, lMsg, lInstanceData);
4102 This->notif.hWnd = (HWND)hwnd;
4103 This->notif.msg = lMsg;
4104 This->notif.instance = (long) lInstanceData;
4106 return S_OK;
4109 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4110 long lNoNotifyFlags) {
4111 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4113 TRACE("(%p/%p)->(%ld)\n", This, iface, lNoNotifyFlags);
4115 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4116 return E_INVALIDARG;
4118 This->notif.disabled = lNoNotifyFlags;
4120 return S_OK;
4123 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
4124 long *lplNoNotifyFlags) {
4125 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4127 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
4129 if (!lplNoNotifyFlags)
4130 return E_POINTER;
4132 *lplNoNotifyFlags = This->notif.disabled;
4134 return S_OK;
4138 static const IMediaEventExVtbl IMediaEventEx_VTable =
4140 MediaEvent_QueryInterface,
4141 MediaEvent_AddRef,
4142 MediaEvent_Release,
4143 MediaEvent_GetTypeInfoCount,
4144 MediaEvent_GetTypeInfo,
4145 MediaEvent_GetIDsOfNames,
4146 MediaEvent_Invoke,
4147 MediaEvent_GetEventHandle,
4148 MediaEvent_GetEvent,
4149 MediaEvent_WaitForCompletion,
4150 MediaEvent_CancelDefaultHandling,
4151 MediaEvent_RestoreDefaultHandling,
4152 MediaEvent_FreeEventParams,
4153 MediaEvent_SetNotifyWindow,
4154 MediaEvent_SetNotifyFlags,
4155 MediaEvent_GetNotifyFlags
4159 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
4161 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4163 return Filtergraph_QueryInterface(This, riid, ppv);
4166 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
4168 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4170 return Filtergraph_AddRef(This);
4173 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
4175 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4177 return Filtergraph_Release(This);
4180 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
4182 FIXME("(%p): stub\n", pClassID);
4184 return E_NOTIMPL;
4187 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
4189 FIXME("(): stub\n");
4191 return E_NOTIMPL;
4194 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
4196 FIXME("(): stub\n");
4198 return E_NOTIMPL;
4201 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
4203 FIXME("(0x%s): stub\n", wine_dbgstr_longlong(tStart));
4205 return E_NOTIMPL;
4208 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
4210 FIXME("(%d, %p): stub\n", dwMsTimeout, pState);
4212 return E_NOTIMPL;
4215 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
4217 FIXME("(%p): stub\n", pClock);
4219 return E_NOTIMPL;
4222 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
4224 FIXME("(%p): stub\n", ppClock);
4226 return E_NOTIMPL;
4229 static const IMediaFilterVtbl IMediaFilter_VTable =
4231 MediaFilter_QueryInterface,
4232 MediaFilter_AddRef,
4233 MediaFilter_Release,
4234 MediaFilter_GetClassID,
4235 MediaFilter_Stop,
4236 MediaFilter_Pause,
4237 MediaFilter_Run,
4238 MediaFilter_GetState,
4239 MediaFilter_SetSyncSource,
4240 MediaFilter_GetSyncSource
4243 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
4245 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4247 return Filtergraph_QueryInterface(This, riid, ppv);
4250 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
4252 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4254 return Filtergraph_AddRef(This);
4257 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
4259 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4261 return Filtergraph_Release(This);
4264 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
4266 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4267 Event evt;
4269 TRACE("(%p/%p)->(%ld, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
4271 /* We need thread safety here, let's use the events queue's one */
4272 EnterCriticalSection(&This->evqueue.msg_crst);
4274 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
4276 TRACE("Process EC_COMPLETE notification\n");
4277 if (++This->EcCompleteCount == This->nRenderers)
4279 evt.lEventCode = EC_COMPLETE;
4280 evt.lParam1 = S_OK;
4281 evt.lParam2 = 0;
4282 TRACE("Send EC_COMPLETE to app\n");
4283 EventsQueue_PutEvent(&This->evqueue, &evt);
4284 if (!This->notif.disabled && This->notif.hWnd)
4286 TRACE("Send Window message\n");
4287 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4289 This->CompletionStatus = EC_COMPLETE;
4290 SetEvent(This->hEventCompletion);
4293 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
4295 /* FIXME: Not handled yet */
4297 else
4299 evt.lEventCode = EventCode;
4300 evt.lParam1 = EventParam1;
4301 evt.lParam2 = EventParam2;
4302 EventsQueue_PutEvent(&This->evqueue, &evt);
4303 if (!This->notif.disabled && This->notif.hWnd)
4304 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4307 LeaveCriticalSection(&This->evqueue.msg_crst);
4308 return S_OK;
4311 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
4313 MediaEventSink_QueryInterface,
4314 MediaEventSink_AddRef,
4315 MediaEventSink_Release,
4316 MediaEventSink_Notify
4319 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
4321 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4323 return Filtergraph_QueryInterface(This, riid, ppv);
4326 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
4328 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4330 return Filtergraph_AddRef(This);
4333 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
4335 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4337 return Filtergraph_Release(This);
4340 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
4341 IPin* pOutputPin,
4342 IPin* pInputPin,
4343 const AM_MEDIA_TYPE* pmtFirstConnection,
4344 IBaseFilter* pUsingFilter,
4345 HANDLE hAbortEvent,
4346 DWORD dwFlags)
4348 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4350 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
4352 return E_NOTIMPL;
4355 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
4356 IGraphConfigCallback* pCallback,
4357 PVOID pvContext,
4358 DWORD dwFlags,
4359 HANDLE hAbortEvent)
4361 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4363 FIXME("(%p)->(%p, %p, %x, %p): stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
4365 return E_NOTIMPL;
4368 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
4369 IBaseFilter* pFilter)
4371 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4373 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4375 return E_NOTIMPL;
4378 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
4379 IEnumFilters** pEnum)
4381 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4383 FIXME("(%p)->(%p): stub!\n", This, pEnum);
4385 return E_NOTIMPL;
4388 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
4389 IBaseFilter* pFilter)
4391 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4393 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4395 return E_NOTIMPL;
4398 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
4399 REFERENCE_TIME* prtStart)
4401 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4403 FIXME("(%p)->(%p): stub!\n", This, prtStart);
4405 return E_NOTIMPL;
4408 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
4409 IPin* pOutputPin,
4410 IPinConnection* pConnection,
4411 HANDLE hEventAbort)
4413 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4415 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
4417 return E_NOTIMPL;
4420 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
4421 IBaseFilter* pFilter,
4422 DWORD dwFlags)
4424 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4426 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4428 return E_NOTIMPL;
4431 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
4432 IBaseFilter* pFilter,
4433 DWORD* dwFlags)
4435 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4437 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
4439 return E_NOTIMPL;
4442 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
4443 IBaseFilter* pFilter,
4444 DWORD dwFlags)
4446 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4448 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4450 return E_NOTIMPL;
4453 static const IGraphConfigVtbl IGraphConfig_VTable =
4455 GraphConfig_QueryInterface,
4456 GraphConfig_AddRef,
4457 GraphConfig_Release,
4458 GraphConfig_Reconnect,
4459 GraphConfig_Reconfigure,
4460 GraphConfig_AddFilterToCache,
4461 GraphConfig_EnumCacheFilter,
4462 GraphConfig_RemoveFilterFromCache,
4463 GraphConfig_GetStartTime,
4464 GraphConfig_PushThroughData,
4465 GraphConfig_SetFilterFlags,
4466 GraphConfig_GetFilterFlags,
4467 GraphConfig_RemoveFilterEx
4470 /* This is the only function that actually creates a FilterGraph class... */
4471 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4473 IFilterGraphImpl *fimpl;
4474 HRESULT hr;
4476 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
4478 if( pUnkOuter )
4479 return CLASS_E_NOAGGREGATION;
4481 fimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(*fimpl));
4482 fimpl->IGraphBuilder_vtbl = &IGraphBuilder_VTable;
4483 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
4484 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
4485 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
4486 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
4487 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
4488 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
4489 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
4490 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
4491 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
4492 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
4493 fimpl->ref = 1;
4494 fimpl->ppFiltersInGraph = NULL;
4495 fimpl->pFilterNames = NULL;
4496 fimpl->nFilters = 0;
4497 fimpl->filterCapacity = 0;
4498 fimpl->nameIndex = 1;
4499 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
4500 fimpl->HandleEcComplete = TRUE;
4501 fimpl->HandleEcRepaint = TRUE;
4502 fimpl->notif.hWnd = 0;
4503 fimpl->notif.disabled = FALSE;
4504 fimpl->nRenderers = 0;
4505 fimpl->EcCompleteCount = 0;
4506 fimpl->state = State_Stopped;
4507 EventsQueue_Init(&fimpl->evqueue);
4508 InitializeCriticalSection(&fimpl->cs);
4509 fimpl->nItfCacheEntries = 0;
4511 hr = CoCreateInstance(&CLSID_FilterMapper, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
4512 if (FAILED(hr)) {
4513 ERR("Unable to create filter mapper (%x)\n", hr);
4514 return hr;
4517 *ppObj = fimpl;
4518 return S_OK;
4521 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4523 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
4524 return FilterGraph_create(pUnkOuter, ppObj);