quartz: Implement Get/SetSyncSource for the FilterGraph's IMediaFilter interface.
[wine/gsoc_dplay.git] / dlls / quartz / filtergraph.c
blob8f87870e37a3d179900b9e21ae573f582633c8cc
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 = CoTaskMemAlloc(omr->ring_buffer_size * sizeof(Event));
76 ZeroMemory(omr->messages, omr->ring_buffer_size * sizeof(Event));
78 InitializeCriticalSection(&omr->msg_crst);
79 omr->msg_crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": EventsQueue.msg_crst");
80 return TRUE;
83 static int EventsQueue_Destroy(EventsQueue* omr)
85 CloseHandle(omr->msg_event);
86 CoTaskMemFree(omr->messages);
87 omr->msg_crst.DebugInfo->Spare[0] = 0;
88 DeleteCriticalSection(&omr->msg_crst);
89 return TRUE;
92 static int EventsQueue_PutEvent(EventsQueue* omr, Event* evt)
94 EnterCriticalSection(&omr->msg_crst);
95 if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
97 int old_ring_buffer_size = omr->ring_buffer_size;
98 omr->ring_buffer_size += EVENTS_RING_BUFFER_INCREMENT;
99 TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
100 omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(Event));
101 /* Now we need to rearrange the ring buffer so that the new
102 buffers just allocated are in between omr->msg_tosave and
103 omr->msg_toget.
105 if (omr->msg_tosave < omr->msg_toget)
107 memmove(&(omr->messages[omr->msg_toget + EVENTS_RING_BUFFER_INCREMENT]),
108 &(omr->messages[omr->msg_toget]),
109 sizeof(Event)*(old_ring_buffer_size - omr->msg_toget)
111 omr->msg_toget += EVENTS_RING_BUFFER_INCREMENT;
114 omr->messages[omr->msg_tosave] = *evt;
115 SetEvent(omr->msg_event);
116 omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
117 LeaveCriticalSection(&omr->msg_crst);
118 return TRUE;
121 static int EventsQueue_GetEvent(EventsQueue* omr, Event* evt, long msTimeOut)
123 if (WaitForSingleObject(omr->msg_event, msTimeOut) != WAIT_OBJECT_0)
124 return FALSE;
126 EnterCriticalSection(&omr->msg_crst);
128 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
130 LeaveCriticalSection(&omr->msg_crst);
131 return FALSE;
134 *evt = omr->messages[omr->msg_toget];
135 omr->msg_toget = (omr->msg_toget + 1) % omr->ring_buffer_size;
137 /* Mark the buffer as empty if needed */
138 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
139 ResetEvent(omr->msg_event);
141 LeaveCriticalSection(&omr->msg_crst);
142 return TRUE;
145 #define MAX_ITF_CACHE_ENTRIES 3
146 typedef struct _ITF_CACHE_ENTRY {
147 const IID* riid;
148 IBaseFilter* filter;
149 IUnknown* iface;
150 } ITF_CACHE_ENTRY;
152 typedef struct _IFilterGraphImpl {
153 const IGraphBuilderVtbl *IGraphBuilder_vtbl;
154 const IMediaControlVtbl *IMediaControl_vtbl;
155 const IMediaSeekingVtbl *IMediaSeeking_vtbl;
156 const IBasicAudioVtbl *IBasicAudio_vtbl;
157 const IBasicVideoVtbl *IBasicVideo_vtbl;
158 const IVideoWindowVtbl *IVideoWindow_vtbl;
159 const IMediaEventExVtbl *IMediaEventEx_vtbl;
160 const IMediaFilterVtbl *IMediaFilter_vtbl;
161 const IMediaEventSinkVtbl *IMediaEventSink_vtbl;
162 const IGraphConfigVtbl *IGraphConfig_vtbl;
163 const IMediaPositionVtbl *IMediaPosition_vtbl;
164 /* IAMGraphStreams */
165 /* IAMStats */
166 /* IBasicVideo2 */
167 /* IFilterChain */
168 /* IFilterGraph2 */
169 /* IFilterMapper2 */
170 /* IGraphVersion */
171 /* IQueueCommand */
172 /* IRegisterServiceProvider */
173 /* IResourceMananger */
174 /* IServiceProvider */
175 /* IVideoFrameStep */
177 LONG ref;
178 IFilterMapper2 * pFilterMapper2;
179 IBaseFilter ** ppFiltersInGraph;
180 LPWSTR * pFilterNames;
181 int nFilters;
182 int filterCapacity;
183 long nameIndex;
184 IReferenceClock *refClock;
185 EventsQueue evqueue;
186 HANDLE hEventCompletion;
187 int CompletionStatus;
188 WndNotify notif;
189 int nRenderers;
190 int EcCompleteCount;
191 int HandleEcComplete;
192 int HandleEcRepaint;
193 OAFilterState state;
194 CRITICAL_SECTION cs;
195 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
196 int nItfCacheEntries;
197 } IFilterGraphImpl;
200 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
201 REFIID riid,
202 LPVOID *ppvObj) {
203 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
205 if (IsEqualGUID(&IID_IUnknown, riid) ||
206 IsEqualGUID(&IID_IFilterGraph, riid) ||
207 IsEqualGUID(&IID_IGraphBuilder, riid)) {
208 *ppvObj = &(This->IGraphBuilder_vtbl);
209 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
210 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
211 *ppvObj = &(This->IMediaControl_vtbl);
212 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
213 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
214 *ppvObj = &(This->IMediaSeeking_vtbl);
215 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
216 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
217 *ppvObj = &(This->IBasicAudio_vtbl);
218 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
219 } else if (IsEqualGUID(&IID_IBasicVideo, riid)) {
220 *ppvObj = &(This->IBasicVideo_vtbl);
221 TRACE(" returning IBasicVideo interface (%p)\n", *ppvObj);
222 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
223 *ppvObj = &(This->IVideoWindow_vtbl);
224 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
225 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
226 IsEqualGUID(&IID_IMediaEventEx, riid)) {
227 *ppvObj = &(This->IMediaEventEx_vtbl);
228 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
229 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
230 IsEqualGUID(&IID_IPersist, riid)) {
231 *ppvObj = &(This->IMediaFilter_vtbl);
232 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
233 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
234 *ppvObj = &(This->IMediaEventSink_vtbl);
235 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
236 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
237 *ppvObj = &(This->IGraphConfig_vtbl);
238 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
239 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
240 *ppvObj = &(This->IMediaPosition_vtbl);
241 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
242 } else {
243 *ppvObj = NULL;
244 FIXME("unknown interface %s\n", debugstr_guid(riid));
245 return E_NOINTERFACE;
248 InterlockedIncrement(&This->ref);
249 return S_OK;
252 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This) {
253 ULONG ref = InterlockedIncrement(&This->ref);
255 TRACE("(%p)->(): new ref = %d\n", This, ref);
257 return ref;
260 static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
261 ULONG ref = InterlockedDecrement(&This->ref);
263 TRACE("(%p)->(): new ref = %d\n", This, ref);
265 if (ref == 0) {
266 int i;
268 if (This->refClock)
269 IReferenceClock_Release(This->refClock);
271 for (i = 0; i < This->nFilters; i++)
273 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], NULL);
274 IBaseFilter_Release(This->ppFiltersInGraph[i]);
276 for (i = 0; i < This->nItfCacheEntries; i++)
277 IUnknown_Release(This->ItfCacheEntries[i].iface);
278 IFilterMapper2_Release(This->pFilterMapper2);
279 CloseHandle(This->hEventCompletion);
280 EventsQueue_Destroy(&This->evqueue);
281 This->cs.DebugInfo->Spare[0] = 0;
282 DeleteCriticalSection(&This->cs);
283 CoTaskMemFree(This->ppFiltersInGraph);
284 CoTaskMemFree(This->pFilterNames);
285 CoTaskMemFree(This);
287 return ref;
291 /*** IUnknown methods ***/
292 static HRESULT WINAPI GraphBuilder_QueryInterface(IGraphBuilder *iface,
293 REFIID riid,
294 LPVOID*ppvObj) {
295 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
297 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
298 return Filtergraph_QueryInterface(This, riid, ppvObj);
301 static ULONG WINAPI GraphBuilder_AddRef(IGraphBuilder *iface) {
302 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
304 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
306 return Filtergraph_AddRef(This);
309 static ULONG WINAPI GraphBuilder_Release(IGraphBuilder *iface) {
310 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
312 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
314 return Filtergraph_Release(This);
317 /*** IFilterGraph methods ***/
318 static HRESULT WINAPI GraphBuilder_AddFilter(IGraphBuilder *iface,
319 IBaseFilter *pFilter,
320 LPCWSTR pName) {
321 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
322 HRESULT hr;
323 int i,j;
324 WCHAR* wszFilterName = NULL;
325 int duplicate_name = FALSE;
327 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
329 wszFilterName = (WCHAR*) CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
331 if (pName)
333 /* Check if name already exists */
334 for(i = 0; i < This->nFilters; i++)
335 if (!strcmpW(This->pFilterNames[i], pName))
337 duplicate_name = TRUE;
338 break;
342 /* If no name given or name already existing, generate one */
343 if (!pName || duplicate_name)
345 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
346 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
348 for (j = 0; j < 10000 ; j++)
350 /* Create name */
351 if (pName)
352 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
353 else
354 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
355 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
357 /* Check if the generated name already exists */
358 for(i = 0; i < This->nFilters; i++)
359 if (!strcmpW(This->pFilterNames[i], wszFilterName))
360 break;
362 /* Compute next index and exit if generated name is suitable */
363 if (This->nameIndex++ == 10000)
364 This->nameIndex = 1;
365 if (i == This->nFilters)
366 break;
368 /* Unable to find a suitable name */
369 if (j == 10000)
371 CoTaskMemFree(wszFilterName);
372 return VFW_E_DUPLICATE_NAME;
375 else
376 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
378 if (This->nFilters + 1 > This->filterCapacity)
380 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
381 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
382 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
383 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
384 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
385 if (!This->filterCapacity)
387 CoTaskMemFree(This->ppFiltersInGraph);
388 CoTaskMemFree(This->pFilterNames);
390 This->ppFiltersInGraph = ppNewFilters;
391 This->pFilterNames = pNewNames;
392 This->filterCapacity = newCapacity;
395 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
397 if (SUCCEEDED(hr))
399 IBaseFilter_AddRef(pFilter);
400 This->ppFiltersInGraph[This->nFilters] = pFilter;
401 This->pFilterNames[This->nFilters] = wszFilterName;
402 This->nFilters++;
403 IBaseFilter_SetSyncSource(pFilter, This->refClock);
405 else
406 CoTaskMemFree(wszFilterName);
408 if (SUCCEEDED(hr) && duplicate_name)
409 return VFW_S_DUPLICATE_NAME;
411 return hr;
414 static HRESULT WINAPI GraphBuilder_RemoveFilter(IGraphBuilder *iface,
415 IBaseFilter *pFilter) {
416 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
417 int i;
418 HRESULT hr = E_FAIL;
420 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
422 /* FIXME: check graph is stopped */
424 for (i = 0; i < This->nFilters; i++)
426 if (This->ppFiltersInGraph[i] == pFilter)
428 IEnumPins *penumpins;
429 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
430 if (SUCCEEDED(hr)) {
431 IPin *ppin;
432 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK) {
433 IPin_Disconnect(ppin);
434 IPin_Release(ppin);
436 IEnumPins_Release(penumpins);
439 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
440 if (SUCCEEDED(hr))
442 IBaseFilter_SetSyncSource(pFilter, NULL);
443 IBaseFilter_Release(pFilter);
444 CoTaskMemFree(This->pFilterNames[i]);
445 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
446 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
447 This->nFilters--;
448 /* Invalidate interfaces in the cache */
449 for (i = 0; i < This->nItfCacheEntries; i++)
450 if (pFilter == This->ItfCacheEntries[i].filter)
452 IUnknown_Release(This->ItfCacheEntries[i].iface);
453 This->ItfCacheEntries[i].iface = NULL;
454 This->ItfCacheEntries[i].filter = NULL;
456 return S_OK;
458 break;
462 return hr; /* FIXME: check this error code */
465 static HRESULT WINAPI GraphBuilder_EnumFilters(IGraphBuilder *iface,
466 IEnumFilters **ppEnum) {
467 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
469 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
471 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
474 static HRESULT WINAPI GraphBuilder_FindFilterByName(IGraphBuilder *iface,
475 LPCWSTR pName,
476 IBaseFilter **ppFilter) {
477 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
478 int i;
480 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
482 *ppFilter = NULL;
484 for (i = 0; i < This->nFilters; i++)
486 if (!strcmpW(pName, This->pFilterNames[i]))
488 *ppFilter = This->ppFiltersInGraph[i];
489 IBaseFilter_AddRef(*ppFilter);
490 return S_OK;
494 return E_FAIL; /* FIXME: check this error code */
497 /* NOTE: despite the implication, it doesn't matter which
498 * way round you put in the input and output pins */
499 static HRESULT WINAPI GraphBuilder_ConnectDirect(IGraphBuilder *iface,
500 IPin *ppinIn,
501 IPin *ppinOut,
502 const AM_MEDIA_TYPE *pmt) {
503 PIN_DIRECTION dir;
504 HRESULT hr;
506 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
508 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
510 /* FIXME: check pins are in graph */
512 if (TRACE_ON(quartz))
514 PIN_INFO PinInfo;
516 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
517 if (FAILED(hr))
518 return hr;
520 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
521 IBaseFilter_Release(PinInfo.pFilter);
523 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
524 if (FAILED(hr))
525 return hr;
527 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
528 IBaseFilter_Release(PinInfo.pFilter);
531 hr = IPin_QueryDirection(ppinIn, &dir);
532 if (SUCCEEDED(hr))
534 if (dir == PINDIR_INPUT)
535 hr = IPin_Connect(ppinOut, ppinIn, pmt);
536 else
537 hr = IPin_Connect(ppinIn, ppinOut, pmt);
540 return hr;
543 static HRESULT WINAPI GraphBuilder_Reconnect(IGraphBuilder *iface,
544 IPin *ppin) {
545 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
546 IPin *pConnectedTo = NULL;
547 HRESULT hr;
548 PIN_DIRECTION pindir;
550 IPin_QueryDirection(ppin, &pindir);
551 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
552 if (FAILED(hr)) {
553 TRACE("Querying connected to failed: %x\n", hr);
554 return hr;
556 IPin_Disconnect(ppin);
557 IPin_Disconnect(pConnectedTo);
558 if (pindir == PINDIR_INPUT)
559 hr = IPin_Connect(pConnectedTo, ppin, NULL);
560 else
561 hr = IPin_Connect(ppin, pConnectedTo, NULL);
562 IPin_Release(pConnectedTo);
563 if (FAILED(hr))
564 ERR("Reconnecting pins failed, pins are not connected now..\n");
565 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
566 return hr;
569 static HRESULT WINAPI GraphBuilder_Disconnect(IGraphBuilder *iface,
570 IPin *ppin) {
571 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
573 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
575 return IPin_Disconnect(ppin);
578 static HRESULT WINAPI GraphBuilder_SetDefaultSyncSource(IGraphBuilder *iface) {
579 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
581 TRACE("(%p/%p)->(): stub !!!\n", iface, This);
583 return S_OK;
586 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
588 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
589 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
590 IPropertyBag * pPropBagCat = NULL;
591 HRESULT hr;
593 VariantInit(pvar);
594 V_VT(pvar) = VT_BSTR;
596 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
598 if (SUCCEEDED(hr))
599 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
601 if (SUCCEEDED(hr))
602 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
604 if (SUCCEEDED(hr))
605 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
607 if (SUCCEEDED(hr))
608 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
610 if (pPropBagCat)
611 IPropertyBag_Release(pPropBagCat);
613 return hr;
616 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
618 HRESULT hr;
619 ULONG nb = 0;
621 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
622 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
623 if (hr == S_OK) {
624 /* Rendered input */
625 } else if (hr == S_FALSE) {
626 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
627 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
628 if (hr != S_OK) {
629 ERR("Error (%x)\n", hr);
631 } else if (hr == E_NOTIMPL) {
632 /* Input connected to all outputs */
633 IEnumPins* penumpins;
634 IPin* ppin;
635 int i = 0;
636 TRACE("E_NOTIMPL\n");
637 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
638 if (FAILED(hr)) {
639 ERR("filter Enumpins failed (%x)\n", hr);
640 return hr;
642 i = 0;
643 /* Count output pins */
644 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
645 PIN_DIRECTION pindir;
646 IPin_QueryDirection(ppin, &pindir);
647 if (pindir == PINDIR_OUTPUT)
648 i++;
649 IPin_Release(ppin);
651 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
652 /* Retrieve output pins */
653 IEnumPins_Reset(penumpins);
654 i = 0;
655 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
656 PIN_DIRECTION pindir;
657 IPin_QueryDirection(ppin, &pindir);
658 if (pindir == PINDIR_OUTPUT)
659 (*pppins)[i++] = ppin;
660 else
661 IPin_Release(ppin);
663 IEnumPins_Release(penumpins);
664 nb = i;
665 if (FAILED(hr)) {
666 ERR("Next failed (%x)\n", hr);
667 return hr;
669 } else if (FAILED(hr)) {
670 ERR("Cannot get internal connection (%x)\n", hr);
671 return hr;
674 *pnb = nb;
675 return S_OK;
678 /*** IGraphBuilder methods ***/
679 static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
680 IPin *ppinOut,
681 IPin *ppinIn) {
682 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
683 HRESULT hr;
684 AM_MEDIA_TYPE* mt;
685 IEnumMediaTypes* penummt;
686 ULONG nbmt;
687 IEnumPins* penumpins;
688 IEnumMoniker* pEnumMoniker;
689 GUID tab[2];
690 ULONG nb;
691 IMoniker* pMoniker;
692 ULONG pin;
693 PIN_INFO PinInfo;
694 CLSID FilterCLSID;
696 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
698 if (TRACE_ON(quartz))
700 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
701 if (FAILED(hr))
702 return hr;
704 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
705 IBaseFilter_Release(PinInfo.pFilter);
707 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
708 if (FAILED(hr))
709 return hr;
711 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
712 IBaseFilter_Release(PinInfo.pFilter);
715 /* Try direct connection first */
716 hr = IPin_Connect(ppinOut, ppinIn, NULL);
717 if (SUCCEEDED(hr)) {
718 return S_OK;
720 TRACE("Direct connection failed, trying to insert other filters\n");
722 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
723 if (FAILED(hr))
724 return hr;
726 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
727 IBaseFilter_Release(PinInfo.pFilter);
728 if (FAILED(hr))
729 return hr;
731 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
732 * filter to the minor mediatype of input pin of the renderer */
733 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
734 if (FAILED(hr)) {
735 ERR("EnumMediaTypes (%x)\n", hr);
736 return hr;
739 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
740 if (FAILED(hr)) {
741 ERR("IEnumMediaTypes_Next (%x)\n", hr);
742 return hr;
745 if (!nbmt) {
746 ERR("No media type found!\n");
747 return S_OK;
749 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
750 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
752 /* Try to find a suitable filter that can connect to the pin to render */
753 tab[0] = mt->majortype;
754 tab[1] = mt->subtype;
755 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
756 if (FAILED(hr)) {
757 ERR("Unable to enum filters (%x)\n", hr);
758 return hr;
761 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
763 VARIANT var;
764 GUID clsid;
765 IPin** ppins;
766 IPin* ppinfilter = NULL;
767 IBaseFilter* pfilter = NULL;
769 hr = GetFilterInfo(pMoniker, &clsid, &var);
770 IMoniker_Release(pMoniker);
771 if (FAILED(hr)) {
772 ERR("Unable to retrieve filter info (%x)\n", hr);
773 goto error;
776 if (IsEqualGUID(&clsid, &FilterCLSID)) {
777 /* Skip filter (same as the one the output pin belongs to) */
778 goto error;
781 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
782 if (FAILED(hr)) {
783 ERR("Unable to create filter (%x), trying next one\n", hr);
784 goto error;
787 hr = IGraphBuilder_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
788 if (FAILED(hr)) {
789 ERR("Unable to add filter (%x)\n", hr);
790 IBaseFilter_Release(pfilter);
791 pfilter = NULL;
792 goto error;
795 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
796 if (FAILED(hr)) {
797 ERR("Enumpins (%x)\n", hr);
798 goto error;
801 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
802 IEnumPins_Release(penumpins);
804 if (FAILED(hr)) {
805 ERR("Next (%x)\n", hr);
806 goto error;
808 if (pin == 0) {
809 ERR("No Pin\n");
810 goto error;
813 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
814 if (FAILED(hr)) {
815 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
816 goto error;
818 TRACE("Successfully connected to filter, follow chain...\n");
820 /* Render all output pins of the filter by calling IGraphBuilder_Render on each of them */
821 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
823 if (SUCCEEDED(hr)) {
824 int i;
825 if (nb == 0) {
826 IPin_Disconnect(ppinOut);
827 goto error;
829 TRACE("pins to consider: %d\n", nb);
830 for(i = 0; i < nb; i++) {
831 TRACE("Processing pin %d\n", i);
832 hr = IGraphBuilder_Connect(iface, ppins[i], ppinIn);
833 if (FAILED(hr)) {
834 TRACE("Cannot render pin %p (%x)\n", ppinfilter, hr);
836 IPin_Release(ppins[i]);
837 if (SUCCEEDED(hr)) break;
839 while (++i < nb) IPin_Release(ppins[i]);
840 CoTaskMemFree(ppins);
841 IPin_Release(ppinfilter);
842 IBaseFilter_Release(pfilter);
843 break;
846 error:
847 if (ppinfilter) IPin_Release(ppinfilter);
848 if (pfilter) {
849 IGraphBuilder_RemoveFilter(iface, pfilter);
850 IBaseFilter_Release(pfilter);
854 IEnumMediaTypes_Release(penummt);
855 DeleteMediaType(mt);
857 return S_OK;
860 static HRESULT WINAPI GraphBuilder_Render(IGraphBuilder *iface,
861 IPin *ppinOut) {
862 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
863 IEnumMediaTypes* penummt;
864 AM_MEDIA_TYPE* mt;
865 ULONG nbmt;
866 HRESULT hr;
868 IEnumMoniker* pEnumMoniker;
869 GUID tab[2];
870 ULONG nb;
871 IMoniker* pMoniker;
873 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
875 if (TRACE_ON(quartz))
877 PIN_INFO PinInfo;
879 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
880 if (FAILED(hr))
881 return hr;
883 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
884 IBaseFilter_Release(PinInfo.pFilter);
887 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
888 if (FAILED(hr)) {
889 ERR("EnumMediaTypes (%x)\n", hr);
890 return hr;
893 while(1)
895 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
896 if (FAILED(hr)) {
897 ERR("IEnumMediaTypes_Next (%x)\n", hr);
898 return hr;
900 if (!nbmt)
901 break;
902 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
903 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
905 /* Try to find a suitable renderer with the same media type */
906 tab[0] = mt->majortype;
907 tab[1] = GUID_NULL;
908 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL);
909 if (FAILED(hr)) {
910 ERR("Unable to enum filters (%x)\n", hr);
911 return hr;
914 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
916 VARIANT var;
917 GUID clsid;
918 IPin* ppinfilter;
919 IBaseFilter* pfilter = NULL;
920 IEnumPins* penumpins;
921 ULONG pin;
923 hr = GetFilterInfo(pMoniker, &clsid, &var);
924 IMoniker_Release(pMoniker);
925 if (FAILED(hr)) {
926 ERR("Unable to retrieve filter info (%x)\n", hr);
927 goto error;
930 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
931 if (FAILED(hr)) {
932 ERR("Unable to create filter (%x), trying next one\n", hr);
933 goto error;
936 hr = IGraphBuilder_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
937 if (FAILED(hr)) {
938 ERR("Unable to add filter (%x)\n", hr);
939 IBaseFilter_Release(pfilter);
940 pfilter = NULL;
941 goto error;
944 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
945 if (FAILED(hr)) {
946 ERR("Splitter Enumpins (%x)\n", hr);
947 goto error;
949 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
950 IEnumPins_Release(penumpins);
951 if (FAILED(hr)) {
952 ERR("Next (%x)\n", hr);
953 goto error;
955 if (pin == 0) {
956 ERR("No Pin\n");
957 goto error;
960 /* Connect the pin to render to the renderer */
961 hr = IGraphBuilder_Connect(iface, ppinOut, ppinfilter);
962 if (FAILED(hr)) {
963 TRACE("Unable to connect to renderer (%x)\n", hr);
964 IPin_Release(ppinfilter);
965 goto error;
967 IPin_Release(ppinfilter);
968 IBaseFilter_Release(pfilter);
969 pfilter = NULL;
970 break;
972 error:
973 if (pfilter) {
974 IGraphBuilder_RemoveFilter(iface, pfilter);
975 IBaseFilter_Release(pfilter);
979 DeleteMediaType(mt);
980 break;
983 IEnumMediaTypes_Release(penummt);
985 return S_OK;
988 static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
989 LPCWSTR lpcwstrFile,
990 LPCWSTR lpcwstrPlayList) {
991 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
992 static const WCHAR string[] = {'R','e','a','d','e','r',0};
993 IBaseFilter* preader = NULL;
994 IBaseFilter* psplitter = NULL;
995 IPin* ppinreader = NULL;
996 IPin* ppinsplitter;
997 IEnumPins* penumpins;
998 ULONG pin;
999 HRESULT hr;
1000 IEnumMoniker* pEnumMoniker = NULL;
1001 GUID tab[2];
1002 IPin** ppins = NULL;
1003 ULONG nb;
1004 IMoniker* pMoniker;
1005 IFileSourceFilter* pfile = NULL;
1006 AM_MEDIA_TYPE mt;
1007 WCHAR* filename;
1009 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1011 if (lpcwstrPlayList != NULL)
1012 return E_INVALIDARG;
1014 hr = IGraphBuilder_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1016 /* Retrieve file media type */
1017 if (SUCCEEDED(hr))
1018 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1019 if (SUCCEEDED(hr)) {
1020 hr = IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1021 IFileSourceFilter_Release(pfile);
1024 if (SUCCEEDED(hr))
1025 hr = IBaseFilter_EnumPins(preader, &penumpins);
1026 if (SUCCEEDED(hr)) {
1027 hr = IEnumPins_Next(penumpins, 1, &ppinreader, &pin);
1028 IEnumPins_Release(penumpins);
1031 if (SUCCEEDED(hr)) {
1032 tab[0] = mt.majortype;
1033 tab[1] = mt.subtype;
1034 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1037 if (FAILED(hr))
1039 if (ppinreader)
1040 IPin_Release(ppinreader);
1041 if (pEnumMoniker)
1042 IEnumMoniker_Release(pEnumMoniker);
1043 if (preader) {
1044 IGraphBuilder_RemoveFilter(iface, preader);
1045 IBaseFilter_Release(preader);
1047 return hr;
1050 hr = VFW_E_CANNOT_RENDER;
1051 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1053 VARIANT var;
1054 GUID clsid;
1056 hr = GetFilterInfo(pMoniker, &clsid, &var);
1057 IMoniker_Release(pMoniker);
1058 if (FAILED(hr)) {
1059 ERR("Unable to retrieve filter info (%x)\n", hr);
1060 continue;
1063 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&psplitter);
1064 if (FAILED(hr)) {
1065 ERR("Unable to create filter (%x), trying next one\n", hr);
1066 continue;
1069 hr = IGraphBuilder_AddFilter(iface, psplitter, V_UNION(&var, bstrVal));
1070 if (FAILED(hr)) {
1071 ERR("Unable add filter (%x)\n", hr);
1072 IBaseFilter_Release(psplitter);
1073 continue;
1076 /* Connect file source and splitter filters together */
1077 /* Make the splitter analyze incoming data */
1079 hr = IBaseFilter_EnumPins(psplitter, &penumpins);
1080 if (SUCCEEDED(hr)) {
1081 hr = IEnumPins_Next(penumpins, 1, &ppinsplitter, &pin);
1082 IEnumPins_Release(penumpins);
1085 if (SUCCEEDED(hr))
1086 hr = IPin_Connect(ppinreader, ppinsplitter, NULL);
1088 /* Make sure there's some output pins in the filter */
1089 if (SUCCEEDED(hr))
1090 hr = GetInternalConnections(psplitter, ppinsplitter, &ppins, &nb);
1091 if (SUCCEEDED(hr)) {
1092 if(nb == 0) {
1093 IPin_Disconnect(ppinreader);
1094 TRACE("No output pins found in filter\n");
1095 hr = VFW_E_CANNOT_RENDER;
1099 if (ppinsplitter)
1100 IPin_Release(ppinsplitter);
1101 ppinsplitter = NULL;
1103 if (SUCCEEDED(hr)) {
1104 TRACE("Successfully connected to filter\n");
1105 break;
1108 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1110 if (ppins) {
1111 CoTaskMemFree(ppins);
1112 ppins = NULL;
1114 IGraphBuilder_RemoveFilter(iface, psplitter);
1115 IBaseFilter_Release(psplitter);
1116 psplitter = NULL;
1119 /* Render all output pin of the splitter by calling IGraphBuilder_Render on each of them */
1120 if (SUCCEEDED(hr)) {
1121 int partial = 0;
1122 int i;
1123 TRACE("pins to consider: %d\n", nb);
1124 for(i = 0; i < nb; i++) {
1125 TRACE("Processing pin %d\n", i);
1126 hr = IGraphBuilder_Render(iface, ppins[i]);
1127 if (FAILED(hr)) {
1128 ERR("Cannot render pin %p (%x)\n", ppins[i], hr);
1129 partial = 1;
1131 IPin_Release(ppins[i]);
1133 CoTaskMemFree(ppins);
1135 hr = (partial ? VFW_S_PARTIAL_RENDER : S_OK);
1138 IPin_Release(ppinreader);
1139 IBaseFilter_Release(preader);
1140 if (psplitter)
1141 IBaseFilter_Release(psplitter);
1143 return hr;
1146 static HRESULT WINAPI GraphBuilder_AddSourceFilter(IGraphBuilder *iface,
1147 LPCWSTR lpcwstrFileName,
1148 LPCWSTR lpcwstrFilterName,
1149 IBaseFilter **ppFilter) {
1150 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1151 HRESULT hr;
1152 IBaseFilter* preader;
1153 IFileSourceFilter* pfile = NULL;
1154 AM_MEDIA_TYPE mt;
1155 WCHAR* filename;
1157 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1159 /* Instantiate a file source filter */
1160 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1161 if (FAILED(hr)) {
1162 ERR("Unable to create file source filter (%x)\n", hr);
1163 return hr;
1166 hr = IGraphBuilder_AddFilter(iface, preader, lpcwstrFilterName);
1167 if (FAILED(hr)) {
1168 ERR("Unable add filter (%x)\n", hr);
1169 IBaseFilter_Release(preader);
1170 return hr;
1173 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1174 if (FAILED(hr)) {
1175 ERR("Unable to get IFileSourceInterface (%x)\n", hr);
1176 goto error;
1179 /* Load the file in the file source filter */
1180 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1181 if (FAILED(hr)) {
1182 ERR("Load (%x)\n", hr);
1183 goto error;
1186 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1187 if (FAILED(hr)) {
1188 ERR("GetCurFile (%x)\n", hr);
1189 goto error;
1191 TRACE("File %s\n", debugstr_w(filename));
1192 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1193 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1195 if (ppFilter)
1196 *ppFilter = preader;
1197 IFileSourceFilter_Release(pfile);
1199 return S_OK;
1201 error:
1202 if (pfile)
1203 IFileSourceFilter_Release(pfile);
1204 IGraphBuilder_RemoveFilter(iface, preader);
1205 IBaseFilter_Release(preader);
1207 return hr;
1210 static HRESULT WINAPI GraphBuilder_SetLogFile(IGraphBuilder *iface,
1211 DWORD_PTR hFile) {
1212 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1214 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1216 return S_OK;
1219 static HRESULT WINAPI GraphBuilder_Abort(IGraphBuilder *iface) {
1220 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1222 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1224 return S_OK;
1227 static HRESULT WINAPI GraphBuilder_ShouldOperationContinue(IGraphBuilder *iface) {
1228 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1230 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1232 return S_OK;
1236 static const IGraphBuilderVtbl IGraphBuilder_VTable =
1238 GraphBuilder_QueryInterface,
1239 GraphBuilder_AddRef,
1240 GraphBuilder_Release,
1241 GraphBuilder_AddFilter,
1242 GraphBuilder_RemoveFilter,
1243 GraphBuilder_EnumFilters,
1244 GraphBuilder_FindFilterByName,
1245 GraphBuilder_ConnectDirect,
1246 GraphBuilder_Reconnect,
1247 GraphBuilder_Disconnect,
1248 GraphBuilder_SetDefaultSyncSource,
1249 GraphBuilder_Connect,
1250 GraphBuilder_Render,
1251 GraphBuilder_RenderFile,
1252 GraphBuilder_AddSourceFilter,
1253 GraphBuilder_SetLogFile,
1254 GraphBuilder_Abort,
1255 GraphBuilder_ShouldOperationContinue
1258 /*** IUnknown methods ***/
1259 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1260 REFIID riid,
1261 LPVOID*ppvObj) {
1262 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1264 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1266 return Filtergraph_QueryInterface(This, riid, ppvObj);
1269 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1270 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1272 TRACE("(%p/%p)->()\n", This, iface);
1274 return Filtergraph_AddRef(This);
1277 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1278 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1280 TRACE("(%p/%p)->()\n", This, iface);
1282 return Filtergraph_Release(This);
1286 /*** IDispatch methods ***/
1287 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1288 UINT*pctinfo) {
1289 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1291 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1293 return S_OK;
1296 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1297 UINT iTInfo,
1298 LCID lcid,
1299 ITypeInfo**ppTInfo) {
1300 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1302 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1304 return S_OK;
1307 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1308 REFIID riid,
1309 LPOLESTR*rgszNames,
1310 UINT cNames,
1311 LCID lcid,
1312 DISPID*rgDispId) {
1313 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1315 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1317 return S_OK;
1320 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1321 DISPID dispIdMember,
1322 REFIID riid,
1323 LCID lcid,
1324 WORD wFlags,
1325 DISPPARAMS*pDispParams,
1326 VARIANT*pVarResult,
1327 EXCEPINFO*pExepInfo,
1328 UINT*puArgErr) {
1329 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1331 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);
1333 return S_OK;
1336 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *);
1338 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter)
1340 HRESULT hr;
1341 IPin* pInputPin;
1342 IPin** ppPins;
1343 ULONG nb;
1344 ULONG i;
1345 PIN_INFO PinInfo;
1347 TRACE("%p %p\n", pGraph, pOutputPin);
1348 PinInfo.pFilter = NULL;
1350 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1352 if (SUCCEEDED(hr))
1354 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1355 if (SUCCEEDED(hr))
1356 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1357 IPin_Release(pInputPin);
1360 if (SUCCEEDED(hr))
1362 if (nb == 0)
1364 TRACE("Reached a renderer\n");
1365 /* Count renderers for end of stream notification */
1366 pGraph->nRenderers++;
1368 else
1370 for(i = 0; i < nb; i++)
1372 /* Explore the graph downstream from this pin
1373 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1374 * several input pins are connected to the same output (a MUX for instance). */
1375 ExploreGraph(pGraph, ppPins[i], FoundFilter);
1376 IPin_Release(ppPins[i]);
1379 CoTaskMemFree(ppPins);
1381 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1382 FoundFilter(PinInfo.pFilter);
1385 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1386 return hr;
1389 static HRESULT WINAPI SendRun(IBaseFilter *pFilter) {
1390 return IBaseFilter_Run(pFilter, 0);
1393 static HRESULT WINAPI SendPause(IBaseFilter *pFilter) {
1394 return IBaseFilter_Pause(pFilter);
1397 static HRESULT WINAPI SendStop(IBaseFilter *pFilter) {
1398 return IBaseFilter_Stop(pFilter);
1401 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter) {
1402 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1403 int i;
1404 IBaseFilter* pfilter;
1405 IEnumPins* pEnum;
1406 HRESULT hr;
1407 IPin* pPin;
1408 DWORD dummy;
1409 PIN_DIRECTION dir;
1410 TRACE("(%p/%p)->()\n", This, iface);
1412 /* Explorer the graph from source filters to renderers, determine renderers
1413 * number and run filters from renderers to source filters */
1414 This->nRenderers = 0;
1415 ResetEvent(This->hEventCompletion);
1417 for(i = 0; i < This->nFilters; i++)
1419 BOOL source = TRUE;
1420 pfilter = This->ppFiltersInGraph[i];
1421 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1422 if (hr != S_OK)
1424 ERR("Enum pins failed %x\n", hr);
1425 continue;
1427 /* Check if it is a source filter */
1428 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1430 IPin_QueryDirection(pPin, &dir);
1431 IPin_Release(pPin);
1432 if (dir == PINDIR_INPUT)
1434 source = FALSE;
1435 break;
1438 if (source)
1440 TRACE("Found a source filter %p\n", pfilter);
1441 IEnumPins_Reset(pEnum);
1442 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1444 /* Explore the graph downstream from this pin */
1445 ExploreGraph(This, pPin, FoundFilter);
1446 IPin_Release(pPin);
1448 FoundFilter(pfilter);
1450 IEnumPins_Release(pEnum);
1453 return S_FALSE;
1456 /*** IMediaControl methods ***/
1457 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1458 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1459 TRACE("(%p/%p)->()\n", This, iface);
1461 if (This->state == State_Running) return S_OK;
1463 EnterCriticalSection(&This->cs);
1464 SendFilterMessage(iface, SendRun);
1465 This->state = State_Running;
1466 LeaveCriticalSection(&This->cs);
1467 return S_FALSE;
1470 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1471 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1472 TRACE("(%p/%p)->()\n", This, iface);
1474 if (This->state == State_Paused) return S_OK;
1476 EnterCriticalSection(&This->cs);
1477 SendFilterMessage(iface, SendPause);
1478 This->state = State_Paused;
1479 LeaveCriticalSection(&This->cs);
1480 return S_FALSE;
1483 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
1484 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1485 TRACE("(%p/%p)->()\n", This, iface);
1487 if (This->state == State_Stopped) return S_OK;
1489 EnterCriticalSection(&This->cs);
1490 if (This->state == State_Running) SendFilterMessage(iface, SendPause);
1491 SendFilterMessage(iface, SendStop);
1492 This->state = State_Stopped;
1493 LeaveCriticalSection(&This->cs);
1494 return S_FALSE;
1497 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
1498 LONG msTimeout,
1499 OAFilterState *pfs) {
1500 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1502 TRACE("(%p/%p)->(%d, %p): semi-stub !!!\n", This, iface, msTimeout, pfs);
1504 EnterCriticalSection(&This->cs);
1506 *pfs = This->state;
1508 LeaveCriticalSection(&This->cs);
1510 return S_OK;
1513 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
1514 BSTR strFilename) {
1515 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1517 TRACE("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
1519 return S_OK;
1522 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
1523 BSTR strFilename,
1524 IDispatch **ppUnk) {
1525 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1527 TRACE("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
1529 return S_OK;
1532 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
1533 IDispatch **ppUnk) {
1534 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1536 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1538 return S_OK;
1541 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
1542 IDispatch **ppUnk) {
1543 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1545 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1547 return S_OK;
1550 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
1551 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1553 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1555 return S_OK;
1559 static const IMediaControlVtbl IMediaControl_VTable =
1561 MediaControl_QueryInterface,
1562 MediaControl_AddRef,
1563 MediaControl_Release,
1564 MediaControl_GetTypeInfoCount,
1565 MediaControl_GetTypeInfo,
1566 MediaControl_GetIDsOfNames,
1567 MediaControl_Invoke,
1568 MediaControl_Run,
1569 MediaControl_Pause,
1570 MediaControl_Stop,
1571 MediaControl_GetState,
1572 MediaControl_RenderFile,
1573 MediaControl_AddSourceFilter,
1574 MediaControl_get_FilterCollection,
1575 MediaControl_get_RegFilterCollection,
1576 MediaControl_StopWhenReady
1580 /*** IUnknown methods ***/
1581 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
1582 REFIID riid,
1583 LPVOID*ppvObj) {
1584 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1586 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1588 return Filtergraph_QueryInterface(This, riid, ppvObj);
1591 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
1592 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1594 TRACE("(%p/%p)->()\n", This, iface);
1596 return Filtergraph_AddRef(This);
1599 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
1600 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1602 TRACE("(%p/%p)->()\n", This, iface);
1604 return Filtergraph_Release(This);
1607 /*** IMediaSeeking methods ***/
1608 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
1609 DWORD *pCapabilities) {
1610 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1612 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1614 return S_OK;
1617 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
1618 DWORD *pCapabilities) {
1619 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1621 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1623 return S_OK;
1626 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
1627 const GUID *pFormat) {
1628 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1630 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1632 return S_OK;
1635 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
1636 GUID *pFormat) {
1637 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1639 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1641 return S_OK;
1644 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
1645 GUID *pFormat) {
1646 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1648 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1650 return S_OK;
1653 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
1654 const GUID *pFormat) {
1655 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1657 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1659 return S_OK;
1662 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
1663 const GUID *pFormat) {
1664 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1666 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1668 return S_OK;
1671 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
1672 LONGLONG *pDuration) {
1673 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1675 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pDuration);
1677 return S_OK;
1680 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
1681 LONGLONG *pStop) {
1682 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1684 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pStop);
1686 return S_OK;
1689 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
1690 LONGLONG *pCurrent) {
1691 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1693 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCurrent);
1695 return S_OK;
1698 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
1699 LONGLONG *pTarget,
1700 const GUID *pTargetFormat,
1701 LONGLONG Source,
1702 const GUID *pSourceFormat) {
1703 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1705 TRACE("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
1706 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
1708 return S_OK;
1711 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
1712 LONGLONG *pCurrent,
1713 DWORD dwCurrentFlags,
1714 LONGLONG *pStop,
1715 DWORD dwStopFlags) {
1716 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1718 TRACE("(%p/%p)->(%p, %08x, %p, %08x): stub !!!\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
1720 return S_OK;
1723 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
1724 LONGLONG *pCurrent,
1725 LONGLONG *pStop) {
1726 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1728 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pCurrent, pStop);
1730 return S_OK;
1733 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
1734 LONGLONG *pEarliest,
1735 LONGLONG *pLatest) {
1736 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1738 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
1740 return S_OK;
1743 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
1744 double dRate) {
1745 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1747 TRACE("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
1749 return S_OK;
1752 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
1753 double *pdRate) {
1754 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1756 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
1758 return S_OK;
1761 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
1762 LONGLONG *pllPreroll) {
1763 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1765 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
1767 return S_OK;
1771 static const IMediaSeekingVtbl IMediaSeeking_VTable =
1773 MediaSeeking_QueryInterface,
1774 MediaSeeking_AddRef,
1775 MediaSeeking_Release,
1776 MediaSeeking_GetCapabilities,
1777 MediaSeeking_CheckCapabilities,
1778 MediaSeeking_IsFormatSupported,
1779 MediaSeeking_QueryPreferredFormat,
1780 MediaSeeking_GetTimeFormat,
1781 MediaSeeking_IsUsingTimeFormat,
1782 MediaSeeking_SetTimeFormat,
1783 MediaSeeking_GetDuration,
1784 MediaSeeking_GetStopPosition,
1785 MediaSeeking_GetCurrentPosition,
1786 MediaSeeking_ConvertTimeFormat,
1787 MediaSeeking_SetPositions,
1788 MediaSeeking_GetPositions,
1789 MediaSeeking_GetAvailable,
1790 MediaSeeking_SetRate,
1791 MediaSeeking_GetRate,
1792 MediaSeeking_GetPreroll
1795 /*** IUnknown methods ***/
1796 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj){
1797 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1799 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1801 return Filtergraph_QueryInterface(This, riid, ppvObj);
1804 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface){
1805 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1807 TRACE("(%p/%p)->()\n", This, iface);
1809 return Filtergraph_AddRef(This);
1812 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface){
1813 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1815 TRACE("(%p/%p)->()\n", This, iface);
1817 return Filtergraph_Release(This);
1820 /*** IDispatch methods ***/
1821 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
1822 FIXME("(%p) stub!\n", iface);
1823 return E_NOTIMPL;
1826 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
1827 FIXME("(%p) stub!\n", iface);
1828 return E_NOTIMPL;
1831 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
1832 FIXME("(%p) stub!\n", iface);
1833 return E_NOTIMPL;
1836 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
1837 FIXME("(%p) stub!\n", iface);
1838 return E_NOTIMPL;
1841 /*** IMediaPosition methods ***/
1842 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength){
1843 FIXME("(%p)->(%p) stub!\n", iface, plength);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime){
1848 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1849 return E_NOTIMPL;
1852 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime){
1853 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime){
1858 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1859 return E_NOTIMPL;
1862 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime){
1863 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1864 return E_NOTIMPL;
1867 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
1868 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
1873 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate){
1878 FIXME("(%p)->(%f) stub!\n", iface, dRate);
1879 return E_NOTIMPL;
1882 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate){
1883 FIXME("(%p)->(%p) stub!\n", iface, pdRate);
1884 return E_NOTIMPL;
1887 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
1888 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
1889 return E_NOTIMPL;
1892 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
1893 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
1894 return E_NOTIMPL;
1898 static const IMediaPositionVtbl IMediaPosition_VTable =
1900 MediaPosition_QueryInterface,
1901 MediaPosition_AddRef,
1902 MediaPosition_Release,
1903 MediaPosition_GetTypeInfoCount,
1904 MediaPosition_GetTypeInfo,
1905 MediaPosition_GetIDsOfNames,
1906 MediaPosition_Invoke,
1907 MediaPosition_get_Duration,
1908 MediaPosition_put_CurrentPosition,
1909 MediaPosition_get_CurrentPosition,
1910 MediaPosition_get_StopTime,
1911 MediaPosition_put_StopTime,
1912 MediaPosition_get_PrerollTime,
1913 MediaPosition_put_PrerollTime,
1914 MediaPosition_put_Rate,
1915 MediaPosition_get_Rate,
1916 MediaPosition_CanSeekForward,
1917 MediaPosition_CanSeekBackward
1920 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
1922 HRESULT hr = E_NOINTERFACE;
1923 int i;
1924 int entry;
1926 /* Check if the interface type is already registered */
1927 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
1928 if (riid == pGraph->ItfCacheEntries[entry].riid)
1930 if (pGraph->ItfCacheEntries[entry].iface)
1932 /* Return the interface if available */
1933 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
1934 return S_OK;
1936 break;
1939 if (entry >= MAX_ITF_CACHE_ENTRIES)
1941 FIXME("Not enough space to store interface in the cache\n");
1942 return E_OUTOFMEMORY;
1945 /* Find a filter supporting the requested interface */
1946 for (i = 0; i < pGraph->nFilters; i++)
1948 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
1949 if (hr == S_OK)
1951 pGraph->ItfCacheEntries[entry].riid = riid;
1952 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
1953 pGraph->ItfCacheEntries[entry].iface = (IUnknown*)*ppvObj;
1954 if (entry >= pGraph->nItfCacheEntries)
1955 pGraph->nItfCacheEntries++;
1956 return S_OK;
1958 if (hr != E_NOINTERFACE)
1959 return hr;
1962 return hr;
1965 /*** IUnknown methods ***/
1966 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
1967 REFIID riid,
1968 LPVOID*ppvObj) {
1969 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1971 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1973 return Filtergraph_QueryInterface(This, riid, ppvObj);
1976 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
1977 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1979 TRACE("(%p/%p)->()\n", This, iface);
1981 return Filtergraph_AddRef(This);
1984 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
1985 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1987 TRACE("(%p/%p)->()\n", This, iface);
1989 return Filtergraph_Release(This);
1992 /*** IDispatch methods ***/
1993 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
1994 UINT*pctinfo) {
1995 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1996 IBasicAudio* pBasicAudio;
1997 HRESULT hr;
1999 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2001 EnterCriticalSection(&This->cs);
2003 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2005 if (hr == S_OK)
2006 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
2008 LeaveCriticalSection(&This->cs);
2010 return hr;
2013 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
2014 UINT iTInfo,
2015 LCID lcid,
2016 ITypeInfo**ppTInfo) {
2017 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2018 IBasicAudio* pBasicAudio;
2019 HRESULT hr;
2021 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2023 EnterCriticalSection(&This->cs);
2025 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2027 if (hr == S_OK)
2028 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
2030 LeaveCriticalSection(&This->cs);
2032 return hr;
2035 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
2036 REFIID riid,
2037 LPOLESTR*rgszNames,
2038 UINT cNames,
2039 LCID lcid,
2040 DISPID*rgDispId) {
2041 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2042 IBasicAudio* pBasicAudio;
2043 HRESULT hr;
2045 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2047 EnterCriticalSection(&This->cs);
2049 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2051 if (hr == S_OK)
2052 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2054 LeaveCriticalSection(&This->cs);
2056 return hr;
2059 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2060 DISPID dispIdMember,
2061 REFIID riid,
2062 LCID lcid,
2063 WORD wFlags,
2064 DISPPARAMS*pDispParams,
2065 VARIANT*pVarResult,
2066 EXCEPINFO*pExepInfo,
2067 UINT*puArgErr) {
2068 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2069 IBasicAudio* pBasicAudio;
2070 HRESULT hr;
2072 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);
2074 EnterCriticalSection(&This->cs);
2076 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2078 if (hr == S_OK)
2079 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2081 LeaveCriticalSection(&This->cs);
2083 return hr;
2086 /*** IBasicAudio methods ***/
2087 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2088 long lVolume) {
2089 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2090 IBasicAudio* pBasicAudio;
2091 HRESULT hr;
2093 TRACE("(%p/%p)->(%ld)\n", This, iface, lVolume);
2095 EnterCriticalSection(&This->cs);
2097 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2099 if (hr == S_OK)
2100 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2102 LeaveCriticalSection(&This->cs);
2104 return hr;
2107 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2108 long *plVolume) {
2109 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2110 IBasicAudio* pBasicAudio;
2111 HRESULT hr;
2113 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2115 EnterCriticalSection(&This->cs);
2117 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2119 if (hr == S_OK)
2120 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2122 LeaveCriticalSection(&This->cs);
2124 return hr;
2127 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2128 long lBalance) {
2129 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2130 IBasicAudio* pBasicAudio;
2131 HRESULT hr;
2133 TRACE("(%p/%p)->(%ld)\n", This, iface, lBalance);
2135 EnterCriticalSection(&This->cs);
2137 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2139 if (hr == S_OK)
2140 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2142 LeaveCriticalSection(&This->cs);
2144 return hr;
2147 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2148 long *plBalance) {
2149 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2150 IBasicAudio* pBasicAudio;
2151 HRESULT hr;
2153 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2155 EnterCriticalSection(&This->cs);
2157 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2159 if (hr == S_OK)
2160 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2162 LeaveCriticalSection(&This->cs);
2164 return hr;
2167 static const IBasicAudioVtbl IBasicAudio_VTable =
2169 BasicAudio_QueryInterface,
2170 BasicAudio_AddRef,
2171 BasicAudio_Release,
2172 BasicAudio_GetTypeInfoCount,
2173 BasicAudio_GetTypeInfo,
2174 BasicAudio_GetIDsOfNames,
2175 BasicAudio_Invoke,
2176 BasicAudio_put_Volume,
2177 BasicAudio_get_Volume,
2178 BasicAudio_put_Balance,
2179 BasicAudio_get_Balance
2182 /*** IUnknown methods ***/
2183 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo *iface,
2184 REFIID riid,
2185 LPVOID*ppvObj) {
2186 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2188 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2190 return Filtergraph_QueryInterface(This, riid, ppvObj);
2193 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo *iface) {
2194 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2196 TRACE("(%p/%p)->()\n", This, iface);
2198 return Filtergraph_AddRef(This);
2201 static ULONG WINAPI BasicVideo_Release(IBasicVideo *iface) {
2202 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2204 TRACE("(%p/%p)->()\n", This, iface);
2206 return Filtergraph_Release(This);
2209 /*** IDispatch methods ***/
2210 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo *iface,
2211 UINT*pctinfo) {
2212 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2213 IBasicVideo* pBasicVideo;
2214 HRESULT hr;
2216 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2218 EnterCriticalSection(&This->cs);
2220 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2222 if (hr == S_OK)
2223 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
2225 LeaveCriticalSection(&This->cs);
2227 return hr;
2230 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo *iface,
2231 UINT iTInfo,
2232 LCID lcid,
2233 ITypeInfo**ppTInfo) {
2234 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2235 IBasicVideo* pBasicVideo;
2236 HRESULT hr;
2238 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2240 EnterCriticalSection(&This->cs);
2242 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2244 if (hr == S_OK)
2245 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
2247 LeaveCriticalSection(&This->cs);
2249 return hr;
2252 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo *iface,
2253 REFIID riid,
2254 LPOLESTR*rgszNames,
2255 UINT cNames,
2256 LCID lcid,
2257 DISPID*rgDispId) {
2258 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2259 IBasicVideo* pBasicVideo;
2260 HRESULT hr;
2262 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2264 EnterCriticalSection(&This->cs);
2266 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2268 if (hr == S_OK)
2269 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
2271 LeaveCriticalSection(&This->cs);
2273 return hr;
2276 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo *iface,
2277 DISPID dispIdMember,
2278 REFIID riid,
2279 LCID lcid,
2280 WORD wFlags,
2281 DISPPARAMS*pDispParams,
2282 VARIANT*pVarResult,
2283 EXCEPINFO*pExepInfo,
2284 UINT*puArgErr) {
2285 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2286 IBasicVideo* pBasicVideo;
2287 HRESULT hr;
2289 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);
2291 EnterCriticalSection(&This->cs);
2293 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2295 if (hr == S_OK)
2296 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2298 LeaveCriticalSection(&This->cs);
2300 return hr;
2303 /*** IBasicVideo methods ***/
2304 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo *iface,
2305 REFTIME *pAvgTimePerFrame) {
2306 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2307 IBasicVideo* pBasicVideo;
2308 HRESULT hr;
2310 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
2312 EnterCriticalSection(&This->cs);
2314 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2316 if (hr == S_OK)
2317 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
2319 LeaveCriticalSection(&This->cs);
2321 return hr;
2324 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo *iface,
2325 long *pBitRate) {
2326 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2327 IBasicVideo* pBasicVideo;
2328 HRESULT hr;
2330 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
2332 EnterCriticalSection(&This->cs);
2334 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2336 if (hr == S_OK)
2337 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
2339 LeaveCriticalSection(&This->cs);
2341 return hr;
2344 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo *iface,
2345 long *pBitErrorRate) {
2346 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2347 IBasicVideo* pBasicVideo;
2348 HRESULT hr;
2350 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
2352 EnterCriticalSection(&This->cs);
2354 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2356 if (hr == S_OK)
2357 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
2359 LeaveCriticalSection(&This->cs);
2361 return hr;
2364 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo *iface,
2365 long *pVideoWidth) {
2366 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2367 IBasicVideo* pBasicVideo;
2368 HRESULT hr;
2370 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
2372 EnterCriticalSection(&This->cs);
2374 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2376 if (hr == S_OK)
2377 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
2379 LeaveCriticalSection(&This->cs);
2381 return hr;
2384 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo *iface,
2385 long *pVideoHeight) {
2386 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2387 IBasicVideo* pBasicVideo;
2388 HRESULT hr;
2390 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
2392 EnterCriticalSection(&This->cs);
2394 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2396 if (hr == S_OK)
2397 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
2399 LeaveCriticalSection(&This->cs);
2401 return hr;
2404 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo *iface,
2405 long SourceLeft) {
2406 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2407 IBasicVideo* pBasicVideo;
2408 HRESULT hr;
2410 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
2412 EnterCriticalSection(&This->cs);
2414 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2416 if (hr == S_OK)
2417 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
2419 LeaveCriticalSection(&This->cs);
2421 return hr;
2424 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo *iface,
2425 long *pSourceLeft) {
2426 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2427 IBasicVideo* pBasicVideo;
2428 HRESULT hr;
2430 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
2432 EnterCriticalSection(&This->cs);
2434 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2436 if (hr == S_OK)
2437 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
2439 LeaveCriticalSection(&This->cs);
2441 return hr;
2444 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo *iface,
2445 long SourceWidth) {
2446 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2447 IBasicVideo* pBasicVideo;
2448 HRESULT hr;
2450 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
2452 EnterCriticalSection(&This->cs);
2454 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2456 if (hr == S_OK)
2457 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
2459 LeaveCriticalSection(&This->cs);
2461 return hr;
2464 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo *iface,
2465 long *pSourceWidth) {
2466 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2467 IBasicVideo* pBasicVideo;
2468 HRESULT hr;
2470 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
2472 EnterCriticalSection(&This->cs);
2474 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2476 if (hr == S_OK)
2477 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
2479 LeaveCriticalSection(&This->cs);
2481 return hr;
2484 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo *iface,
2485 long SourceTop) {
2486 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2487 IBasicVideo* pBasicVideo;
2488 HRESULT hr;
2490 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
2492 EnterCriticalSection(&This->cs);
2494 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2496 if (hr == S_OK)
2497 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
2499 LeaveCriticalSection(&This->cs);
2501 return hr;
2504 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo *iface,
2505 long *pSourceTop) {
2506 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2507 IBasicVideo* pBasicVideo;
2508 HRESULT hr;
2510 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
2512 EnterCriticalSection(&This->cs);
2514 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2516 if (hr == S_OK)
2517 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
2519 LeaveCriticalSection(&This->cs);
2521 return hr;
2524 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo *iface,
2525 long SourceHeight) {
2526 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2527 IBasicVideo* pBasicVideo;
2528 HRESULT hr;
2530 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
2532 EnterCriticalSection(&This->cs);
2534 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2536 if (hr == S_OK)
2537 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
2539 LeaveCriticalSection(&This->cs);
2541 return hr;
2544 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo *iface,
2545 long *pSourceHeight) {
2546 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2547 IBasicVideo* pBasicVideo;
2548 HRESULT hr;
2550 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
2552 EnterCriticalSection(&This->cs);
2554 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2556 if (hr == S_OK)
2557 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
2559 LeaveCriticalSection(&This->cs);
2561 return hr;
2564 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo *iface,
2565 long DestinationLeft) {
2566 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2567 IBasicVideo* pBasicVideo;
2568 HRESULT hr;
2570 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
2572 EnterCriticalSection(&This->cs);
2574 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2576 if (hr == S_OK)
2577 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
2579 LeaveCriticalSection(&This->cs);
2581 return hr;
2584 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo *iface,
2585 long *pDestinationLeft) {
2586 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2587 IBasicVideo* pBasicVideo;
2588 HRESULT hr;
2590 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
2592 EnterCriticalSection(&This->cs);
2594 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2596 if (hr == S_OK)
2597 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
2599 LeaveCriticalSection(&This->cs);
2601 return hr;
2604 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo *iface,
2605 long DestinationWidth) {
2606 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2607 IBasicVideo* pBasicVideo;
2608 HRESULT hr;
2610 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
2612 EnterCriticalSection(&This->cs);
2614 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2616 if (hr == S_OK)
2617 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
2619 LeaveCriticalSection(&This->cs);
2621 return hr;
2624 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo *iface,
2625 long *pDestinationWidth) {
2626 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2627 IBasicVideo* pBasicVideo;
2628 HRESULT hr;
2630 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
2632 EnterCriticalSection(&This->cs);
2634 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2636 if (hr == S_OK)
2637 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
2639 LeaveCriticalSection(&This->cs);
2641 return hr;
2644 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo *iface,
2645 long DestinationTop) {
2646 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2647 IBasicVideo* pBasicVideo;
2648 HRESULT hr;
2650 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
2652 EnterCriticalSection(&This->cs);
2654 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2656 if (hr == S_OK)
2657 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
2659 LeaveCriticalSection(&This->cs);
2661 return hr;
2664 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo *iface,
2665 long *pDestinationTop) {
2666 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2667 IBasicVideo* pBasicVideo;
2668 HRESULT hr;
2670 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
2672 EnterCriticalSection(&This->cs);
2674 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2676 if (hr == S_OK)
2677 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
2679 LeaveCriticalSection(&This->cs);
2681 return hr;
2684 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo *iface,
2685 long DestinationHeight) {
2686 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2687 IBasicVideo* pBasicVideo;
2688 HRESULT hr;
2690 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
2692 EnterCriticalSection(&This->cs);
2694 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2696 if (hr == S_OK)
2697 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
2699 LeaveCriticalSection(&This->cs);
2701 return hr;
2704 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo *iface,
2705 long *pDestinationHeight) {
2706 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2707 IBasicVideo* pBasicVideo;
2708 HRESULT hr;
2710 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
2712 EnterCriticalSection(&This->cs);
2714 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2716 if (hr == S_OK)
2717 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
2719 LeaveCriticalSection(&This->cs);
2721 return hr;
2724 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo *iface,
2725 long Left,
2726 long Top,
2727 long Width,
2728 long Height) {
2729 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2730 IBasicVideo* pBasicVideo;
2731 HRESULT hr;
2733 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2735 EnterCriticalSection(&This->cs);
2737 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2739 if (hr == S_OK)
2740 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
2742 LeaveCriticalSection(&This->cs);
2744 return hr;
2747 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo *iface,
2748 long *pLeft,
2749 long *pTop,
2750 long *pWidth,
2751 long *pHeight) {
2752 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2753 IBasicVideo* pBasicVideo;
2754 HRESULT hr;
2756 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2758 EnterCriticalSection(&This->cs);
2760 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2762 if (hr == S_OK)
2763 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2765 LeaveCriticalSection(&This->cs);
2767 return hr;
2770 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo *iface) {
2771 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2772 IBasicVideo* pBasicVideo;
2773 HRESULT hr;
2775 TRACE("(%p/%p)->()\n", This, iface);
2777 EnterCriticalSection(&This->cs);
2779 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2781 if (hr == S_OK)
2782 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
2784 LeaveCriticalSection(&This->cs);
2786 return hr;
2789 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo *iface,
2790 long Left,
2791 long Top,
2792 long Width,
2793 long Height) {
2794 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2795 IBasicVideo* pBasicVideo;
2796 HRESULT hr;
2798 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2800 EnterCriticalSection(&This->cs);
2802 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2804 if (hr == S_OK)
2805 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
2807 LeaveCriticalSection(&This->cs);
2809 return hr;
2812 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo *iface,
2813 long *pLeft,
2814 long *pTop,
2815 long *pWidth,
2816 long *pHeight) {
2817 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2818 IBasicVideo* pBasicVideo;
2819 HRESULT hr;
2821 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2823 EnterCriticalSection(&This->cs);
2825 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2827 if (hr == S_OK)
2828 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2830 LeaveCriticalSection(&This->cs);
2832 return hr;
2835 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
2836 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2837 IBasicVideo* pBasicVideo;
2838 HRESULT hr;
2840 TRACE("(%p/%p)->()\n", This, iface);
2842 EnterCriticalSection(&This->cs);
2844 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2846 if (hr == S_OK)
2847 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
2849 LeaveCriticalSection(&This->cs);
2851 return hr;
2854 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo *iface,
2855 long *pWidth,
2856 long *pHeight) {
2857 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2858 IBasicVideo* pBasicVideo;
2859 HRESULT hr;
2861 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
2863 EnterCriticalSection(&This->cs);
2865 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2867 if (hr == S_OK)
2868 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
2870 LeaveCriticalSection(&This->cs);
2872 return hr;
2875 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo *iface,
2876 long StartIndex,
2877 long Entries,
2878 long *pRetrieved,
2879 long *pPalette) {
2880 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2881 IBasicVideo* pBasicVideo;
2882 HRESULT hr;
2884 TRACE("(%p/%p)->(%ld, %ld, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
2886 EnterCriticalSection(&This->cs);
2888 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2890 if (hr == S_OK)
2891 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
2893 LeaveCriticalSection(&This->cs);
2895 return hr;
2898 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo *iface,
2899 long *pBufferSize,
2900 long *pDIBImage) {
2901 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2902 IBasicVideo* pBasicVideo;
2903 HRESULT hr;
2905 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
2907 EnterCriticalSection(&This->cs);
2909 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2911 if (hr == S_OK)
2912 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
2914 LeaveCriticalSection(&This->cs);
2916 return hr;
2919 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo *iface) {
2920 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2921 IBasicVideo* pBasicVideo;
2922 HRESULT hr;
2924 TRACE("(%p/%p)->()\n", This, iface);
2926 EnterCriticalSection(&This->cs);
2928 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2930 if (hr == S_OK)
2931 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
2933 LeaveCriticalSection(&This->cs);
2935 return hr;
2938 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo *iface) {
2939 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2940 IBasicVideo* pBasicVideo;
2941 HRESULT hr;
2943 TRACE("(%p/%p)->()\n", This, iface);
2945 EnterCriticalSection(&This->cs);
2947 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2949 if (hr == S_OK)
2950 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
2952 LeaveCriticalSection(&This->cs);
2954 return hr;
2958 static const IBasicVideoVtbl IBasicVideo_VTable =
2960 BasicVideo_QueryInterface,
2961 BasicVideo_AddRef,
2962 BasicVideo_Release,
2963 BasicVideo_GetTypeInfoCount,
2964 BasicVideo_GetTypeInfo,
2965 BasicVideo_GetIDsOfNames,
2966 BasicVideo_Invoke,
2967 BasicVideo_get_AvgTimePerFrame,
2968 BasicVideo_get_BitRate,
2969 BasicVideo_get_BitErrorRate,
2970 BasicVideo_get_VideoWidth,
2971 BasicVideo_get_VideoHeight,
2972 BasicVideo_put_SourceLeft,
2973 BasicVideo_get_SourceLeft,
2974 BasicVideo_put_SourceWidth,
2975 BasicVideo_get_SourceWidth,
2976 BasicVideo_put_SourceTop,
2977 BasicVideo_get_SourceTop,
2978 BasicVideo_put_SourceHeight,
2979 BasicVideo_get_SourceHeight,
2980 BasicVideo_put_DestinationLeft,
2981 BasicVideo_get_DestinationLeft,
2982 BasicVideo_put_DestinationWidth,
2983 BasicVideo_get_DestinationWidth,
2984 BasicVideo_put_DestinationTop,
2985 BasicVideo_get_DestinationTop,
2986 BasicVideo_put_DestinationHeight,
2987 BasicVideo_get_DestinationHeight,
2988 BasicVideo_SetSourcePosition,
2989 BasicVideo_GetSourcePosition,
2990 BasicVideo_SetDefaultSourcePosition,
2991 BasicVideo_SetDestinationPosition,
2992 BasicVideo_GetDestinationPosition,
2993 BasicVideo_SetDefaultDestinationPosition,
2994 BasicVideo_GetVideoSize,
2995 BasicVideo_GetVideoPaletteEntries,
2996 BasicVideo_GetCurrentImage,
2997 BasicVideo_IsUsingDefaultSource,
2998 BasicVideo_IsUsingDefaultDestination
3002 /*** IUnknown methods ***/
3003 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
3004 REFIID riid,
3005 LPVOID*ppvObj) {
3006 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3008 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3010 return Filtergraph_QueryInterface(This, riid, ppvObj);
3013 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
3014 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3016 TRACE("(%p/%p)->()\n", This, iface);
3018 return Filtergraph_AddRef(This);
3021 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
3022 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3024 TRACE("(%p/%p)->()\n", This, iface);
3026 return Filtergraph_Release(This);
3029 /*** IDispatch methods ***/
3030 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
3031 UINT*pctinfo) {
3032 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3033 IVideoWindow* pVideoWindow;
3034 HRESULT hr;
3036 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3038 EnterCriticalSection(&This->cs);
3040 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3042 if (hr == S_OK)
3043 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
3045 LeaveCriticalSection(&This->cs);
3047 return hr;
3050 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3051 UINT iTInfo,
3052 LCID lcid,
3053 ITypeInfo**ppTInfo) {
3054 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3055 IVideoWindow* pVideoWindow;
3056 HRESULT hr;
3058 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3060 EnterCriticalSection(&This->cs);
3062 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3064 if (hr == S_OK)
3065 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3067 LeaveCriticalSection(&This->cs);
3069 return hr;
3072 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3073 REFIID riid,
3074 LPOLESTR*rgszNames,
3075 UINT cNames,
3076 LCID lcid,
3077 DISPID*rgDispId) {
3078 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3079 IVideoWindow* pVideoWindow;
3080 HRESULT hr;
3082 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3084 EnterCriticalSection(&This->cs);
3086 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3088 if (hr == S_OK)
3089 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3091 LeaveCriticalSection(&This->cs);
3093 return hr;
3096 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3097 DISPID dispIdMember,
3098 REFIID riid,
3099 LCID lcid,
3100 WORD wFlags,
3101 DISPPARAMS*pDispParams,
3102 VARIANT*pVarResult,
3103 EXCEPINFO*pExepInfo,
3104 UINT*puArgErr) {
3105 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3106 IVideoWindow* pVideoWindow;
3107 HRESULT hr;
3109 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);
3111 EnterCriticalSection(&This->cs);
3113 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3115 if (hr == S_OK)
3116 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3118 LeaveCriticalSection(&This->cs);
3120 return hr;
3124 /*** IVideoWindow methods ***/
3125 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3126 BSTR strCaption) {
3127 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3128 IVideoWindow* pVideoWindow;
3129 HRESULT hr;
3131 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3133 EnterCriticalSection(&This->cs);
3135 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3137 if (hr == S_OK)
3138 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3140 LeaveCriticalSection(&This->cs);
3142 return hr;
3145 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3146 BSTR *strCaption) {
3147 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3148 IVideoWindow* pVideoWindow;
3149 HRESULT hr;
3151 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3153 EnterCriticalSection(&This->cs);
3155 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3157 if (hr == S_OK)
3158 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3160 LeaveCriticalSection(&This->cs);
3162 return hr;
3165 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3166 long WindowStyle) {
3167 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3168 IVideoWindow* pVideoWindow;
3169 HRESULT hr;
3171 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyle);
3173 EnterCriticalSection(&This->cs);
3175 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3177 if (hr == S_OK)
3178 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
3180 LeaveCriticalSection(&This->cs);
3182 return hr;
3185 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
3186 long *WindowStyle) {
3187 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3188 IVideoWindow* pVideoWindow;
3189 HRESULT hr;
3191 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
3193 EnterCriticalSection(&This->cs);
3195 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3197 if (hr == S_OK)
3198 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
3200 LeaveCriticalSection(&This->cs);
3202 return hr;
3205 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
3206 long WindowStyleEx) {
3207 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3208 IVideoWindow* pVideoWindow;
3209 HRESULT hr;
3211 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
3213 EnterCriticalSection(&This->cs);
3215 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3217 if (hr == S_OK)
3218 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
3220 LeaveCriticalSection(&This->cs);
3222 return hr;
3225 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
3226 long *WindowStyleEx) {
3227 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3228 IVideoWindow* pVideoWindow;
3229 HRESULT hr;
3231 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
3233 EnterCriticalSection(&This->cs);
3235 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3237 if (hr == S_OK)
3238 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
3240 LeaveCriticalSection(&This->cs);
3242 return hr;
3245 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
3246 long AutoShow) {
3247 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3248 IVideoWindow* pVideoWindow;
3249 HRESULT hr;
3251 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
3253 EnterCriticalSection(&This->cs);
3255 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3257 if (hr == S_OK)
3258 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
3260 LeaveCriticalSection(&This->cs);
3262 return hr;
3265 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
3266 long *AutoShow) {
3267 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3268 IVideoWindow* pVideoWindow;
3269 HRESULT hr;
3271 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
3273 EnterCriticalSection(&This->cs);
3275 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3277 if (hr == S_OK)
3278 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
3280 LeaveCriticalSection(&This->cs);
3282 return hr;
3285 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
3286 long WindowState) {
3287 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3288 IVideoWindow* pVideoWindow;
3289 HRESULT hr;
3291 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowState);
3293 EnterCriticalSection(&This->cs);
3295 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3297 if (hr == S_OK)
3298 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
3300 LeaveCriticalSection(&This->cs);
3302 return hr;
3305 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
3306 long *WindowState) {
3307 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3308 IVideoWindow* pVideoWindow;
3309 HRESULT hr;
3311 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
3313 EnterCriticalSection(&This->cs);
3315 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3317 if (hr == S_OK)
3318 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
3320 LeaveCriticalSection(&This->cs);
3322 return hr;
3325 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
3326 long BackgroundPalette) {
3327 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3328 IVideoWindow* pVideoWindow;
3329 HRESULT hr;
3331 TRACE("(%p/%p)->(%ld)\n", This, iface, BackgroundPalette);
3333 EnterCriticalSection(&This->cs);
3335 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3337 if (hr == S_OK)
3338 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
3340 LeaveCriticalSection(&This->cs);
3342 return hr;
3345 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
3346 long *pBackgroundPalette) {
3347 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3348 IVideoWindow* pVideoWindow;
3349 HRESULT hr;
3351 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
3353 EnterCriticalSection(&This->cs);
3355 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3357 if (hr == S_OK)
3358 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
3360 LeaveCriticalSection(&This->cs);
3362 return hr;
3365 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
3366 long Visible) {
3367 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3368 IVideoWindow* pVideoWindow;
3369 HRESULT hr;
3371 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
3373 EnterCriticalSection(&This->cs);
3375 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3377 if (hr == S_OK)
3378 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
3380 LeaveCriticalSection(&This->cs);
3382 return hr;
3385 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
3386 long *pVisible) {
3387 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3388 IVideoWindow* pVideoWindow;
3389 HRESULT hr;
3391 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
3393 EnterCriticalSection(&This->cs);
3395 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3397 if (hr == S_OK)
3398 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
3400 LeaveCriticalSection(&This->cs);
3402 return hr;
3405 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
3406 long Left) {
3407 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3408 IVideoWindow* pVideoWindow;
3409 HRESULT hr;
3411 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
3413 EnterCriticalSection(&This->cs);
3415 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3417 if (hr == S_OK)
3418 hr = IVideoWindow_put_Left(pVideoWindow, Left);
3420 LeaveCriticalSection(&This->cs);
3422 return hr;
3425 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
3426 long *pLeft) {
3427 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3428 IVideoWindow* pVideoWindow;
3429 HRESULT hr;
3431 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
3433 EnterCriticalSection(&This->cs);
3435 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3437 if (hr == S_OK)
3438 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
3440 LeaveCriticalSection(&This->cs);
3442 return hr;
3445 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
3446 long Width) {
3447 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3448 IVideoWindow* pVideoWindow;
3449 HRESULT hr;
3451 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
3453 EnterCriticalSection(&This->cs);
3455 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3457 if (hr == S_OK)
3458 hr = IVideoWindow_put_Width(pVideoWindow, Width);
3460 LeaveCriticalSection(&This->cs);
3462 return hr;
3465 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
3466 long *pWidth) {
3467 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3468 IVideoWindow* pVideoWindow;
3469 HRESULT hr;
3471 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
3473 EnterCriticalSection(&This->cs);
3475 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3477 if (hr == S_OK)
3478 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
3480 LeaveCriticalSection(&This->cs);
3482 return hr;
3485 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
3486 long Top) {
3487 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3488 IVideoWindow* pVideoWindow;
3489 HRESULT hr;
3491 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
3493 EnterCriticalSection(&This->cs);
3495 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3497 if (hr == S_OK)
3498 hr = IVideoWindow_put_Top(pVideoWindow, Top);
3500 LeaveCriticalSection(&This->cs);
3502 return hr;
3505 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
3506 long *pTop) {
3507 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3508 IVideoWindow* pVideoWindow;
3509 HRESULT hr;
3511 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
3513 EnterCriticalSection(&This->cs);
3515 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3517 if (hr == S_OK)
3518 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
3520 LeaveCriticalSection(&This->cs);
3522 return hr;
3525 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
3526 long Height) {
3527 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3528 IVideoWindow* pVideoWindow;
3529 HRESULT hr;
3531 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
3533 EnterCriticalSection(&This->cs);
3535 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3537 if (hr == S_OK)
3538 hr = IVideoWindow_put_Height(pVideoWindow, Height);
3540 LeaveCriticalSection(&This->cs);
3542 return hr;
3545 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
3546 long *pHeight) {
3547 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3548 IVideoWindow* pVideoWindow;
3549 HRESULT hr;
3551 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
3553 EnterCriticalSection(&This->cs);
3555 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3557 if (hr == S_OK)
3558 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
3560 LeaveCriticalSection(&This->cs);
3562 return hr;
3565 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
3566 OAHWND Owner) {
3567 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3568 IVideoWindow* pVideoWindow;
3569 HRESULT hr;
3571 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
3573 EnterCriticalSection(&This->cs);
3575 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3577 if (hr == S_OK)
3578 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
3580 LeaveCriticalSection(&This->cs);
3582 return hr;
3585 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
3586 OAHWND *Owner) {
3587 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3588 IVideoWindow* pVideoWindow;
3589 HRESULT hr;
3591 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
3593 EnterCriticalSection(&This->cs);
3595 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3597 if (hr == S_OK)
3598 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
3600 LeaveCriticalSection(&This->cs);
3602 return hr;
3605 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
3606 OAHWND Drain) {
3607 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3608 IVideoWindow* pVideoWindow;
3609 HRESULT hr;
3611 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
3613 EnterCriticalSection(&This->cs);
3615 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3617 if (hr == S_OK)
3618 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
3620 LeaveCriticalSection(&This->cs);
3622 return hr;
3625 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
3626 OAHWND *Drain) {
3627 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3628 IVideoWindow* pVideoWindow;
3629 HRESULT hr;
3631 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
3633 EnterCriticalSection(&This->cs);
3635 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3637 if (hr == S_OK)
3638 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
3640 LeaveCriticalSection(&This->cs);
3642 return hr;
3645 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
3646 long *Color) {
3647 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3648 IVideoWindow* pVideoWindow;
3649 HRESULT hr;
3651 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
3653 EnterCriticalSection(&This->cs);
3655 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3657 if (hr == S_OK)
3658 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
3660 LeaveCriticalSection(&This->cs);
3662 return hr;
3665 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
3666 long Color) {
3667 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3668 IVideoWindow* pVideoWindow;
3669 HRESULT hr;
3671 TRACE("(%p/%p)->(%ld)\n", This, iface, Color);
3673 EnterCriticalSection(&This->cs);
3675 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3677 if (hr == S_OK)
3678 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
3680 LeaveCriticalSection(&This->cs);
3682 return hr;
3685 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
3686 long *FullScreenMode) {
3687 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3688 IVideoWindow* pVideoWindow;
3689 HRESULT hr;
3691 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
3693 EnterCriticalSection(&This->cs);
3695 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3697 if (hr == S_OK)
3698 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
3700 LeaveCriticalSection(&This->cs);
3702 return hr;
3705 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
3706 long FullScreenMode) {
3707 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3708 IVideoWindow* pVideoWindow;
3709 HRESULT hr;
3711 TRACE("(%p/%p)->(%ld)\n", This, iface, FullScreenMode);
3713 EnterCriticalSection(&This->cs);
3715 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3717 if (hr == S_OK)
3718 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
3720 LeaveCriticalSection(&This->cs);
3722 return hr;
3725 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
3726 long Focus) {
3727 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3728 IVideoWindow* pVideoWindow;
3729 HRESULT hr;
3731 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
3733 EnterCriticalSection(&This->cs);
3735 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3737 if (hr == S_OK)
3738 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
3740 LeaveCriticalSection(&This->cs);
3742 return hr;
3745 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
3746 OAHWND hwnd,
3747 long uMsg,
3748 LONG_PTR wParam,
3749 LONG_PTR lParam) {
3750 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3751 IVideoWindow* pVideoWindow;
3752 HRESULT hr;
3754 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
3756 EnterCriticalSection(&This->cs);
3758 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3760 if (hr == S_OK)
3761 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
3763 LeaveCriticalSection(&This->cs);
3765 return hr;
3768 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
3769 long Left,
3770 long Top,
3771 long Width,
3772 long Height) {
3773 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3774 IVideoWindow* pVideoWindow;
3775 HRESULT hr;
3777 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
3779 EnterCriticalSection(&This->cs);
3781 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3783 if (hr == S_OK)
3784 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
3786 LeaveCriticalSection(&This->cs);
3788 return hr;
3791 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
3792 long *pLeft,
3793 long *pTop,
3794 long *pWidth,
3795 long *pHeight) {
3796 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3797 IVideoWindow* pVideoWindow;
3798 HRESULT hr;
3800 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3802 EnterCriticalSection(&This->cs);
3804 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3806 if (hr == S_OK)
3807 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3809 LeaveCriticalSection(&This->cs);
3811 return hr;
3814 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
3815 long *pWidth,
3816 long *pHeight) {
3817 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3818 IVideoWindow* pVideoWindow;
3819 HRESULT hr;
3821 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3823 EnterCriticalSection(&This->cs);
3825 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3827 if (hr == S_OK)
3828 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
3830 LeaveCriticalSection(&This->cs);
3832 return hr;
3835 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
3836 long *pWidth,
3837 long *pHeight) {
3838 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3839 IVideoWindow* pVideoWindow;
3840 HRESULT hr;
3842 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3844 EnterCriticalSection(&This->cs);
3846 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3848 if (hr == S_OK)
3849 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
3851 LeaveCriticalSection(&This->cs);
3853 return hr;
3856 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
3857 long *pLeft,
3858 long *pTop,
3859 long *pWidth,
3860 long *pHeight) {
3861 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3862 IVideoWindow* pVideoWindow;
3863 HRESULT hr;
3865 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3867 EnterCriticalSection(&This->cs);
3869 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3871 if (hr == S_OK)
3872 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3874 LeaveCriticalSection(&This->cs);
3876 return hr;
3879 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
3880 long HideCursor) {
3881 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3882 IVideoWindow* pVideoWindow;
3883 HRESULT hr;
3885 TRACE("(%p/%p)->(%ld)\n", This, iface, HideCursor);
3887 EnterCriticalSection(&This->cs);
3889 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3891 if (hr == S_OK)
3892 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
3894 LeaveCriticalSection(&This->cs);
3896 return hr;
3899 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
3900 long *CursorHidden) {
3901 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3902 IVideoWindow* pVideoWindow;
3903 HRESULT hr;
3905 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
3907 EnterCriticalSection(&This->cs);
3909 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3911 if (hr == S_OK)
3912 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
3914 LeaveCriticalSection(&This->cs);
3916 return hr;
3920 static const IVideoWindowVtbl IVideoWindow_VTable =
3922 VideoWindow_QueryInterface,
3923 VideoWindow_AddRef,
3924 VideoWindow_Release,
3925 VideoWindow_GetTypeInfoCount,
3926 VideoWindow_GetTypeInfo,
3927 VideoWindow_GetIDsOfNames,
3928 VideoWindow_Invoke,
3929 VideoWindow_put_Caption,
3930 VideoWindow_get_Caption,
3931 VideoWindow_put_WindowStyle,
3932 VideoWindow_get_WindowStyle,
3933 VideoWindow_put_WindowStyleEx,
3934 VideoWindow_get_WindowStyleEx,
3935 VideoWindow_put_AutoShow,
3936 VideoWindow_get_AutoShow,
3937 VideoWindow_put_WindowState,
3938 VideoWindow_get_WindowState,
3939 VideoWindow_put_BackgroundPalette,
3940 VideoWindow_get_BackgroundPalette,
3941 VideoWindow_put_Visible,
3942 VideoWindow_get_Visible,
3943 VideoWindow_put_Left,
3944 VideoWindow_get_Left,
3945 VideoWindow_put_Width,
3946 VideoWindow_get_Width,
3947 VideoWindow_put_Top,
3948 VideoWindow_get_Top,
3949 VideoWindow_put_Height,
3950 VideoWindow_get_Height,
3951 VideoWindow_put_Owner,
3952 VideoWindow_get_Owner,
3953 VideoWindow_put_MessageDrain,
3954 VideoWindow_get_MessageDrain,
3955 VideoWindow_get_BorderColor,
3956 VideoWindow_put_BorderColor,
3957 VideoWindow_get_FullScreenMode,
3958 VideoWindow_put_FullScreenMode,
3959 VideoWindow_SetWindowForeground,
3960 VideoWindow_NotifyOwnerMessage,
3961 VideoWindow_SetWindowPosition,
3962 VideoWindow_GetWindowPosition,
3963 VideoWindow_GetMinIdealImageSize,
3964 VideoWindow_GetMaxIdealImageSize,
3965 VideoWindow_GetRestorePosition,
3966 VideoWindow_HideCursor,
3967 VideoWindow_IsCursorHidden
3971 /*** IUnknown methods ***/
3972 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
3973 REFIID riid,
3974 LPVOID*ppvObj) {
3975 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3977 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3979 return Filtergraph_QueryInterface(This, riid, ppvObj);
3982 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
3983 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3985 TRACE("(%p/%p)->()\n", This, iface);
3987 return Filtergraph_AddRef(This);
3990 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
3991 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3993 TRACE("(%p/%p)->()\n", This, iface);
3995 return Filtergraph_Release(This);
3998 /*** IDispatch methods ***/
3999 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
4000 UINT*pctinfo) {
4001 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4003 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
4005 return S_OK;
4008 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
4009 UINT iTInfo,
4010 LCID lcid,
4011 ITypeInfo**ppTInfo) {
4012 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4014 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
4016 return S_OK;
4019 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
4020 REFIID riid,
4021 LPOLESTR*rgszNames,
4022 UINT cNames,
4023 LCID lcid,
4024 DISPID*rgDispId) {
4025 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4027 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4029 return S_OK;
4032 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
4033 DISPID dispIdMember,
4034 REFIID riid,
4035 LCID lcid,
4036 WORD wFlags,
4037 DISPPARAMS*pDispParams,
4038 VARIANT*pVarResult,
4039 EXCEPINFO*pExepInfo,
4040 UINT*puArgErr) {
4041 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4043 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);
4045 return S_OK;
4048 /*** IMediaEvent methods ***/
4049 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4050 OAEVENT *hEvent) {
4051 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4053 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4055 *hEvent = (OAEVENT)This->evqueue.msg_event;
4057 return S_OK;
4060 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4061 long *lEventCode,
4062 LONG_PTR *lParam1,
4063 LONG_PTR *lParam2,
4064 long msTimeout) {
4065 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4066 Event evt;
4068 TRACE("(%p/%p)->(%p, %p, %p, %ld)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4070 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4072 *lEventCode = evt.lEventCode;
4073 *lParam1 = evt.lParam1;
4074 *lParam2 = evt.lParam2;
4075 return S_OK;
4078 *lEventCode = 0;
4079 return E_ABORT;
4082 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4083 long msTimeout,
4084 long *pEvCode) {
4085 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4087 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, msTimeout, pEvCode);
4089 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4091 *pEvCode = This->CompletionStatus;
4092 return S_OK;
4095 *pEvCode = 0;
4096 return E_ABORT;
4099 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4100 long lEvCode) {
4101 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4103 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4105 if (lEvCode == EC_COMPLETE)
4106 This->HandleEcComplete = FALSE;
4107 else if (lEvCode == EC_REPAINT)
4108 This->HandleEcRepaint = FALSE;
4109 else
4110 return S_FALSE;
4112 return S_OK;
4115 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4116 long lEvCode) {
4117 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4119 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4121 if (lEvCode == EC_COMPLETE)
4122 This->HandleEcComplete = TRUE;
4123 else if (lEvCode == EC_REPAINT)
4124 This->HandleEcRepaint = TRUE;
4125 else
4126 return S_FALSE;
4128 return S_OK;
4131 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4132 long lEvCode,
4133 LONG_PTR lParam1,
4134 LONG_PTR lParam2) {
4135 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4137 TRACE("(%p/%p)->(%ld, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4139 return S_OK;
4142 /*** IMediaEventEx methods ***/
4143 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4144 OAHWND hwnd,
4145 long lMsg,
4146 LONG_PTR lInstanceData) {
4147 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4149 TRACE("(%p/%p)->(%08x, %ld, %08lx)\n", This, iface, (DWORD) hwnd, lMsg, lInstanceData);
4151 This->notif.hWnd = (HWND)hwnd;
4152 This->notif.msg = lMsg;
4153 This->notif.instance = (long) lInstanceData;
4155 return S_OK;
4158 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4159 long lNoNotifyFlags) {
4160 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4162 TRACE("(%p/%p)->(%ld)\n", This, iface, lNoNotifyFlags);
4164 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4165 return E_INVALIDARG;
4167 This->notif.disabled = lNoNotifyFlags;
4169 return S_OK;
4172 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
4173 long *lplNoNotifyFlags) {
4174 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4176 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
4178 if (!lplNoNotifyFlags)
4179 return E_POINTER;
4181 *lplNoNotifyFlags = This->notif.disabled;
4183 return S_OK;
4187 static const IMediaEventExVtbl IMediaEventEx_VTable =
4189 MediaEvent_QueryInterface,
4190 MediaEvent_AddRef,
4191 MediaEvent_Release,
4192 MediaEvent_GetTypeInfoCount,
4193 MediaEvent_GetTypeInfo,
4194 MediaEvent_GetIDsOfNames,
4195 MediaEvent_Invoke,
4196 MediaEvent_GetEventHandle,
4197 MediaEvent_GetEvent,
4198 MediaEvent_WaitForCompletion,
4199 MediaEvent_CancelDefaultHandling,
4200 MediaEvent_RestoreDefaultHandling,
4201 MediaEvent_FreeEventParams,
4202 MediaEvent_SetNotifyWindow,
4203 MediaEvent_SetNotifyFlags,
4204 MediaEvent_GetNotifyFlags
4208 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
4210 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4212 return Filtergraph_QueryInterface(This, riid, ppv);
4215 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
4217 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4219 return Filtergraph_AddRef(This);
4222 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
4224 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4226 return Filtergraph_Release(This);
4229 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
4231 FIXME("(%p): stub\n", pClassID);
4233 return E_NOTIMPL;
4236 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
4238 FIXME("(): stub\n");
4240 return E_NOTIMPL;
4243 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
4245 FIXME("(): stub\n");
4247 return E_NOTIMPL;
4250 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
4252 FIXME("(0x%s): stub\n", wine_dbgstr_longlong(tStart));
4254 return E_NOTIMPL;
4257 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
4259 FIXME("(%d, %p): stub\n", dwMsTimeout, pState);
4261 return E_NOTIMPL;
4264 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
4266 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4267 HRESULT hr = S_OK;
4268 int i;
4270 TRACE("(%p/%p)->(%p)\n", iface, This, pClock);
4272 EnterCriticalSection(&This->cs);
4274 for (i = 0;i < This->nFilters;i++)
4276 hr = IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], pClock);
4277 if (FAILED(hr))
4278 break;
4281 if (FAILED(hr))
4283 for(;i >= 0;i--)
4284 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], This->refClock);
4286 else
4288 if (This->refClock)
4289 IReferenceClock_Release(This->refClock);
4290 This->refClock = pClock;
4291 if (This->refClock)
4292 IReferenceClock_AddRef(This->refClock);
4295 LeaveCriticalSection(&This->cs);
4297 return hr;
4300 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
4302 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4304 TRACE("(%p/%p)->(%p)\n", iface, This, ppClock);
4306 if (!ppClock)
4307 return E_POINTER;
4309 EnterCriticalSection(&This->cs);
4311 *ppClock = This->refClock;
4312 if (*ppClock)
4313 IReferenceClock_AddRef(*ppClock);
4315 LeaveCriticalSection(&This->cs);
4317 return S_OK;
4320 static const IMediaFilterVtbl IMediaFilter_VTable =
4322 MediaFilter_QueryInterface,
4323 MediaFilter_AddRef,
4324 MediaFilter_Release,
4325 MediaFilter_GetClassID,
4326 MediaFilter_Stop,
4327 MediaFilter_Pause,
4328 MediaFilter_Run,
4329 MediaFilter_GetState,
4330 MediaFilter_SetSyncSource,
4331 MediaFilter_GetSyncSource
4334 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
4336 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4338 return Filtergraph_QueryInterface(This, riid, ppv);
4341 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
4343 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4345 return Filtergraph_AddRef(This);
4348 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
4350 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4352 return Filtergraph_Release(This);
4355 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
4357 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4358 Event evt;
4360 TRACE("(%p/%p)->(%ld, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
4362 /* We need thread safety here, let's use the events queue's one */
4363 EnterCriticalSection(&This->evqueue.msg_crst);
4365 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
4367 TRACE("Process EC_COMPLETE notification\n");
4368 if (++This->EcCompleteCount == This->nRenderers)
4370 evt.lEventCode = EC_COMPLETE;
4371 evt.lParam1 = S_OK;
4372 evt.lParam2 = 0;
4373 TRACE("Send EC_COMPLETE to app\n");
4374 EventsQueue_PutEvent(&This->evqueue, &evt);
4375 if (!This->notif.disabled && This->notif.hWnd)
4377 TRACE("Send Window message\n");
4378 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4380 This->CompletionStatus = EC_COMPLETE;
4381 SetEvent(This->hEventCompletion);
4384 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
4386 /* FIXME: Not handled yet */
4388 else
4390 evt.lEventCode = EventCode;
4391 evt.lParam1 = EventParam1;
4392 evt.lParam2 = EventParam2;
4393 EventsQueue_PutEvent(&This->evqueue, &evt);
4394 if (!This->notif.disabled && This->notif.hWnd)
4395 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4398 LeaveCriticalSection(&This->evqueue.msg_crst);
4399 return S_OK;
4402 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
4404 MediaEventSink_QueryInterface,
4405 MediaEventSink_AddRef,
4406 MediaEventSink_Release,
4407 MediaEventSink_Notify
4410 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
4412 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4414 return Filtergraph_QueryInterface(This, riid, ppv);
4417 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
4419 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4421 return Filtergraph_AddRef(This);
4424 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
4426 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4428 return Filtergraph_Release(This);
4431 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
4432 IPin* pOutputPin,
4433 IPin* pInputPin,
4434 const AM_MEDIA_TYPE* pmtFirstConnection,
4435 IBaseFilter* pUsingFilter,
4436 HANDLE hAbortEvent,
4437 DWORD dwFlags)
4439 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4441 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
4443 return E_NOTIMPL;
4446 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
4447 IGraphConfigCallback* pCallback,
4448 PVOID pvContext,
4449 DWORD dwFlags,
4450 HANDLE hAbortEvent)
4452 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4454 FIXME("(%p)->(%p, %p, %x, %p): stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
4456 return E_NOTIMPL;
4459 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
4460 IBaseFilter* pFilter)
4462 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4464 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4466 return E_NOTIMPL;
4469 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
4470 IEnumFilters** pEnum)
4472 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4474 FIXME("(%p)->(%p): stub!\n", This, pEnum);
4476 return E_NOTIMPL;
4479 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
4480 IBaseFilter* pFilter)
4482 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4484 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4486 return E_NOTIMPL;
4489 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
4490 REFERENCE_TIME* prtStart)
4492 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4494 FIXME("(%p)->(%p): stub!\n", This, prtStart);
4496 return E_NOTIMPL;
4499 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
4500 IPin* pOutputPin,
4501 IPinConnection* pConnection,
4502 HANDLE hEventAbort)
4504 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4506 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
4508 return E_NOTIMPL;
4511 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
4512 IBaseFilter* pFilter,
4513 DWORD dwFlags)
4515 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4517 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4519 return E_NOTIMPL;
4522 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
4523 IBaseFilter* pFilter,
4524 DWORD* dwFlags)
4526 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4528 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
4530 return E_NOTIMPL;
4533 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
4534 IBaseFilter* pFilter,
4535 DWORD dwFlags)
4537 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4539 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4541 return E_NOTIMPL;
4544 static const IGraphConfigVtbl IGraphConfig_VTable =
4546 GraphConfig_QueryInterface,
4547 GraphConfig_AddRef,
4548 GraphConfig_Release,
4549 GraphConfig_Reconnect,
4550 GraphConfig_Reconfigure,
4551 GraphConfig_AddFilterToCache,
4552 GraphConfig_EnumCacheFilter,
4553 GraphConfig_RemoveFilterFromCache,
4554 GraphConfig_GetStartTime,
4555 GraphConfig_PushThroughData,
4556 GraphConfig_SetFilterFlags,
4557 GraphConfig_GetFilterFlags,
4558 GraphConfig_RemoveFilterEx
4561 /* This is the only function that actually creates a FilterGraph class... */
4562 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4564 IFilterGraphImpl *fimpl;
4565 HRESULT hr;
4567 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
4569 if( pUnkOuter )
4570 return CLASS_E_NOAGGREGATION;
4572 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
4573 fimpl->IGraphBuilder_vtbl = &IGraphBuilder_VTable;
4574 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
4575 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
4576 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
4577 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
4578 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
4579 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
4580 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
4581 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
4582 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
4583 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
4584 fimpl->ref = 1;
4585 fimpl->ppFiltersInGraph = NULL;
4586 fimpl->pFilterNames = NULL;
4587 fimpl->nFilters = 0;
4588 fimpl->filterCapacity = 0;
4589 fimpl->nameIndex = 1;
4590 fimpl->refClock = NULL;
4591 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
4592 fimpl->HandleEcComplete = TRUE;
4593 fimpl->HandleEcRepaint = TRUE;
4594 fimpl->notif.hWnd = 0;
4595 fimpl->notif.disabled = FALSE;
4596 fimpl->nRenderers = 0;
4597 fimpl->EcCompleteCount = 0;
4598 fimpl->state = State_Stopped;
4599 EventsQueue_Init(&fimpl->evqueue);
4600 InitializeCriticalSection(&fimpl->cs);
4601 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
4602 fimpl->nItfCacheEntries = 0;
4604 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
4605 if (FAILED(hr)) {
4606 ERR("Unable to create filter mapper (%x)\n", hr);
4607 return hr;
4610 *ppObj = fimpl;
4611 return S_OK;
4614 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4616 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
4617 return FilterGraph_create(pUnkOuter, ppObj);