quartz: Add filters using their names.
[wine.git] / dlls / quartz / filtergraph.c
blob5964502f9c02e86dab50cfb5dea12cb2279452e1
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 EventsQueue evqueue;
185 HANDLE hEventCompletion;
186 int CompletionStatus;
187 WndNotify notif;
188 int nRenderers;
189 int EcCompleteCount;
190 int HandleEcComplete;
191 int HandleEcRepaint;
192 OAFilterState state;
193 CRITICAL_SECTION cs;
194 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
195 int nItfCacheEntries;
196 } IFilterGraphImpl;
199 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
200 REFIID riid,
201 LPVOID *ppvObj) {
202 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
204 if (IsEqualGUID(&IID_IUnknown, riid) ||
205 IsEqualGUID(&IID_IFilterGraph, riid) ||
206 IsEqualGUID(&IID_IGraphBuilder, riid)) {
207 *ppvObj = &(This->IGraphBuilder_vtbl);
208 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
209 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
210 *ppvObj = &(This->IMediaControl_vtbl);
211 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
212 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
213 *ppvObj = &(This->IMediaSeeking_vtbl);
214 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
215 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
216 *ppvObj = &(This->IBasicAudio_vtbl);
217 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
218 } else if (IsEqualGUID(&IID_IBasicVideo, riid)) {
219 *ppvObj = &(This->IBasicVideo_vtbl);
220 TRACE(" returning IBasicVideo interface (%p)\n", *ppvObj);
221 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
222 *ppvObj = &(This->IVideoWindow_vtbl);
223 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
224 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
225 IsEqualGUID(&IID_IMediaEventEx, riid)) {
226 *ppvObj = &(This->IMediaEventEx_vtbl);
227 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
228 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
229 IsEqualGUID(&IID_IPersist, riid)) {
230 *ppvObj = &(This->IMediaFilter_vtbl);
231 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
232 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
233 *ppvObj = &(This->IMediaEventSink_vtbl);
234 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
235 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
236 *ppvObj = &(This->IGraphConfig_vtbl);
237 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
238 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
239 *ppvObj = &(This->IMediaPosition_vtbl);
240 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
241 } else {
242 *ppvObj = NULL;
243 FIXME("unknown interface %s\n", debugstr_guid(riid));
244 return E_NOINTERFACE;
247 InterlockedIncrement(&This->ref);
248 return S_OK;
251 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This) {
252 ULONG ref = InterlockedIncrement(&This->ref);
254 TRACE("(%p)->(): new ref = %d\n", This, ref);
256 return ref;
259 static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
260 ULONG ref = InterlockedDecrement(&This->ref);
262 TRACE("(%p)->(): new ref = %d\n", This, ref);
264 if (ref == 0) {
265 int i;
266 for (i = 0; i < This->nFilters; i++)
267 IBaseFilter_Release(This->ppFiltersInGraph[i]);
268 for (i = 0; i < This->nItfCacheEntries; i++)
269 IUnknown_Release(This->ItfCacheEntries[i].iface);
270 IFilterMapper2_Release(This->pFilterMapper2);
271 CloseHandle(This->hEventCompletion);
272 EventsQueue_Destroy(&This->evqueue);
273 This->cs.DebugInfo->Spare[0] = 0;
274 DeleteCriticalSection(&This->cs);
275 CoTaskMemFree(This->ppFiltersInGraph);
276 CoTaskMemFree(This->pFilterNames);
277 CoTaskMemFree(This);
279 return ref;
283 /*** IUnknown methods ***/
284 static HRESULT WINAPI GraphBuilder_QueryInterface(IGraphBuilder *iface,
285 REFIID riid,
286 LPVOID*ppvObj) {
287 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
289 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
290 return Filtergraph_QueryInterface(This, riid, ppvObj);
293 static ULONG WINAPI GraphBuilder_AddRef(IGraphBuilder *iface) {
294 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
296 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
298 return Filtergraph_AddRef(This);
301 static ULONG WINAPI GraphBuilder_Release(IGraphBuilder *iface) {
302 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
304 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
306 return Filtergraph_Release(This);
309 /*** IFilterGraph methods ***/
310 static HRESULT WINAPI GraphBuilder_AddFilter(IGraphBuilder *iface,
311 IBaseFilter *pFilter,
312 LPCWSTR pName) {
313 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
314 HRESULT hr;
315 int i,j;
316 WCHAR* wszFilterName = NULL;
317 int duplicate_name = FALSE;
319 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
321 wszFilterName = (WCHAR*) CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
323 if (pName)
325 /* Check if name already exists */
326 for(i = 0; i < This->nFilters; i++)
327 if (!strcmpW(This->pFilterNames[i], pName))
329 duplicate_name = TRUE;
330 break;
334 /* If no name given or name already existing, generate one */
335 if (!pName || duplicate_name)
337 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
338 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
340 for (j = 0; j < 10000 ; j++)
342 /* Create name */
343 if (pName)
344 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
345 else
346 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
347 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
349 /* Check if the generated name already exists */
350 for(i = 0; i < This->nFilters; i++)
351 if (!strcmpW(This->pFilterNames[i], wszFilterName))
352 break;
354 /* Compute next index and exit if generated name is suitable */
355 if (This->nameIndex++ == 10000)
356 This->nameIndex = 1;
357 if (i == This->nFilters)
358 break;
360 /* Unable to find a suitable name */
361 if (j == 10000)
363 CoTaskMemFree(wszFilterName);
364 return VFW_E_DUPLICATE_NAME;
367 else
368 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
370 if (This->nFilters + 1 > This->filterCapacity)
372 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
373 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
374 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
375 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
376 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
377 if (!This->filterCapacity)
379 CoTaskMemFree(This->ppFiltersInGraph);
380 CoTaskMemFree(This->pFilterNames);
382 This->ppFiltersInGraph = ppNewFilters;
383 This->pFilterNames = pNewNames;
384 This->filterCapacity = newCapacity;
387 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
389 if (SUCCEEDED(hr))
391 IBaseFilter_AddRef(pFilter);
392 This->ppFiltersInGraph[This->nFilters] = pFilter;
393 This->pFilterNames[This->nFilters] = wszFilterName;
394 This->nFilters++;
396 else
397 CoTaskMemFree(wszFilterName);
399 if (SUCCEEDED(hr) && duplicate_name)
400 return VFW_S_DUPLICATE_NAME;
402 return hr;
405 static HRESULT WINAPI GraphBuilder_RemoveFilter(IGraphBuilder *iface,
406 IBaseFilter *pFilter) {
407 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
408 int i;
409 HRESULT hr = E_FAIL;
411 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
413 /* FIXME: check graph is stopped */
415 for (i = 0; i < This->nFilters; i++)
417 if (This->ppFiltersInGraph[i] == pFilter)
419 IEnumPins *penumpins;
420 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
421 if (SUCCEEDED(hr)) {
422 IPin *ppin;
423 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK) {
424 IPin_Disconnect(ppin);
425 IPin_Release(ppin);
427 IEnumPins_Release(penumpins);
430 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
431 if (SUCCEEDED(hr))
433 IBaseFilter_Release(pFilter);
434 CoTaskMemFree(This->pFilterNames[i]);
435 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
436 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
437 This->nFilters--;
438 /* Invalidate interfaces in the cache */
439 for (i = 0; i < This->nItfCacheEntries; i++)
440 if (pFilter == This->ItfCacheEntries[i].filter)
442 IUnknown_Release(This->ItfCacheEntries[i].iface);
443 This->ItfCacheEntries[i].iface = NULL;
444 This->ItfCacheEntries[i].filter = NULL;
446 return S_OK;
448 break;
452 return hr; /* FIXME: check this error code */
455 static HRESULT WINAPI GraphBuilder_EnumFilters(IGraphBuilder *iface,
456 IEnumFilters **ppEnum) {
457 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
459 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
461 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
464 static HRESULT WINAPI GraphBuilder_FindFilterByName(IGraphBuilder *iface,
465 LPCWSTR pName,
466 IBaseFilter **ppFilter) {
467 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
468 int i;
470 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
472 *ppFilter = NULL;
474 for (i = 0; i < This->nFilters; i++)
476 if (!strcmpW(pName, This->pFilterNames[i]))
478 *ppFilter = This->ppFiltersInGraph[i];
479 IBaseFilter_AddRef(*ppFilter);
480 return S_OK;
484 return E_FAIL; /* FIXME: check this error code */
487 /* NOTE: despite the implication, it doesn't matter which
488 * way round you put in the input and output pins */
489 static HRESULT WINAPI GraphBuilder_ConnectDirect(IGraphBuilder *iface,
490 IPin *ppinIn,
491 IPin *ppinOut,
492 const AM_MEDIA_TYPE *pmt) {
493 PIN_DIRECTION dir;
494 HRESULT hr;
496 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
498 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
500 /* FIXME: check pins are in graph */
502 if (TRACE_ON(quartz))
504 PIN_INFO PinInfo;
506 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
507 if (FAILED(hr))
508 return hr;
510 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
511 IBaseFilter_Release(PinInfo.pFilter);
513 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
514 if (FAILED(hr))
515 return hr;
517 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
518 IBaseFilter_Release(PinInfo.pFilter);
521 hr = IPin_QueryDirection(ppinIn, &dir);
522 if (SUCCEEDED(hr))
524 if (dir == PINDIR_INPUT)
525 hr = IPin_Connect(ppinOut, ppinIn, pmt);
526 else
527 hr = IPin_Connect(ppinIn, ppinOut, pmt);
530 return hr;
533 static HRESULT WINAPI GraphBuilder_Reconnect(IGraphBuilder *iface,
534 IPin *ppin) {
535 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
536 IPin *pConnectedTo = NULL;
537 HRESULT hr;
538 PIN_DIRECTION pindir;
540 IPin_QueryDirection(ppin, &pindir);
541 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
542 if (FAILED(hr)) {
543 TRACE("Querying connected to failed: %x\n", hr);
544 return hr;
546 IPin_Disconnect(ppin);
547 IPin_Disconnect(pConnectedTo);
548 if (pindir == PINDIR_INPUT)
549 hr = IPin_Connect(pConnectedTo, ppin, NULL);
550 else
551 hr = IPin_Connect(ppin, pConnectedTo, NULL);
552 IPin_Release(pConnectedTo);
553 if (FAILED(hr))
554 ERR("Reconnecting pins failed, pins are not connected now..\n");
555 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
556 return hr;
559 static HRESULT WINAPI GraphBuilder_Disconnect(IGraphBuilder *iface,
560 IPin *ppin) {
561 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
563 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
565 return IPin_Disconnect(ppin);
568 static HRESULT WINAPI GraphBuilder_SetDefaultSyncSource(IGraphBuilder *iface) {
569 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
571 TRACE("(%p/%p)->(): stub !!!\n", iface, This);
573 return S_OK;
576 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
578 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
579 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
580 IPropertyBag * pPropBagCat = NULL;
581 HRESULT hr;
583 VariantInit(pvar);
584 V_VT(pvar) = VT_BSTR;
586 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
588 if (SUCCEEDED(hr))
589 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
591 if (SUCCEEDED(hr))
592 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
594 if (SUCCEEDED(hr))
595 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
597 if (SUCCEEDED(hr))
598 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
600 if (pPropBagCat)
601 IPropertyBag_Release(pPropBagCat);
603 return hr;
606 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
608 HRESULT hr;
609 ULONG nb = 0;
611 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
612 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
613 if (hr == S_OK) {
614 /* Rendered input */
615 } else if (hr == S_FALSE) {
616 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
617 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
618 if (hr != S_OK) {
619 ERR("Error (%x)\n", hr);
621 } else if (hr == E_NOTIMPL) {
622 /* Input connected to all outputs */
623 IEnumPins* penumpins;
624 IPin* ppin;
625 int i = 0;
626 TRACE("E_NOTIMPL\n");
627 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
628 if (FAILED(hr)) {
629 ERR("filter Enumpins failed (%x)\n", hr);
630 return hr;
632 i = 0;
633 /* Count output pins */
634 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
635 PIN_DIRECTION pindir;
636 IPin_QueryDirection(ppin, &pindir);
637 if (pindir == PINDIR_OUTPUT)
638 i++;
639 IPin_Release(ppin);
641 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
642 /* Retrieve output pins */
643 IEnumPins_Reset(penumpins);
644 i = 0;
645 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
646 PIN_DIRECTION pindir;
647 IPin_QueryDirection(ppin, &pindir);
648 if (pindir == PINDIR_OUTPUT)
649 (*pppins)[i++] = ppin;
650 else
651 IPin_Release(ppin);
653 IEnumPins_Release(penumpins);
654 nb = i;
655 if (FAILED(hr)) {
656 ERR("Next failed (%x)\n", hr);
657 return hr;
659 } else if (FAILED(hr)) {
660 ERR("Cannot get internal connection (%x)\n", hr);
661 return hr;
664 *pnb = nb;
665 return S_OK;
668 /*** IGraphBuilder methods ***/
669 static HRESULT WINAPI GraphBuilder_Connect(IGraphBuilder *iface,
670 IPin *ppinOut,
671 IPin *ppinIn) {
672 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
673 HRESULT hr;
674 AM_MEDIA_TYPE* mt;
675 IEnumMediaTypes* penummt;
676 ULONG nbmt;
677 IEnumPins* penumpins;
678 IEnumMoniker* pEnumMoniker;
679 GUID tab[2];
680 ULONG nb;
681 IMoniker* pMoniker;
682 ULONG pin;
683 PIN_INFO PinInfo;
684 CLSID FilterCLSID;
686 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
688 if (TRACE_ON(quartz))
690 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
691 if (FAILED(hr))
692 return hr;
694 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
695 IBaseFilter_Release(PinInfo.pFilter);
697 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
698 if (FAILED(hr))
699 return hr;
701 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
702 IBaseFilter_Release(PinInfo.pFilter);
705 /* Try direct connection first */
706 hr = IPin_Connect(ppinOut, ppinIn, NULL);
707 if (SUCCEEDED(hr)) {
708 return S_OK;
710 TRACE("Direct connection failed, trying to insert other filters\n");
712 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
713 if (FAILED(hr))
714 return hr;
716 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
717 IBaseFilter_Release(PinInfo.pFilter);
718 if (FAILED(hr))
719 return hr;
721 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
722 * filter to the minor mediatype of input pin of the renderer */
723 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
724 if (FAILED(hr)) {
725 ERR("EnumMediaTypes (%x)\n", hr);
726 return hr;
729 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
730 if (FAILED(hr)) {
731 ERR("IEnumMediaTypes_Next (%x)\n", hr);
732 return hr;
735 if (!nbmt) {
736 ERR("No media type found!\n");
737 return S_OK;
739 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
740 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
742 /* Try to find a suitable filter that can connect to the pin to render */
743 tab[0] = mt->majortype;
744 tab[1] = mt->subtype;
745 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
746 if (FAILED(hr)) {
747 ERR("Unable to enum filters (%x)\n", hr);
748 return hr;
751 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
753 VARIANT var;
754 GUID clsid;
755 IPin** ppins;
756 IPin* ppinfilter = NULL;
757 IBaseFilter* pfilter = NULL;
759 hr = GetFilterInfo(pMoniker, &clsid, &var);
760 IMoniker_Release(pMoniker);
761 if (FAILED(hr)) {
762 ERR("Unable to retrieve filter info (%x)\n", hr);
763 goto error;
766 if (IsEqualGUID(&clsid, &FilterCLSID)) {
767 /* Skip filter (same as the one the output pin belongs to) */
768 goto error;
771 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
772 if (FAILED(hr)) {
773 ERR("Unable to create filter (%x), trying next one\n", hr);
774 goto error;
777 hr = IGraphBuilder_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
778 if (FAILED(hr)) {
779 ERR("Unable to add filter (%x)\n", hr);
780 IBaseFilter_Release(pfilter);
781 pfilter = NULL;
782 goto error;
785 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
786 if (FAILED(hr)) {
787 ERR("Enumpins (%x)\n", hr);
788 goto error;
791 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
792 IEnumPins_Release(penumpins);
794 if (FAILED(hr)) {
795 ERR("Next (%x)\n", hr);
796 goto error;
798 if (pin == 0) {
799 ERR("No Pin\n");
800 goto error;
803 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
804 if (FAILED(hr)) {
805 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
806 goto error;
808 TRACE("Successfully connected to filter, follow chain...\n");
810 /* Render all output pins of the filter by calling IGraphBuilder_Render on each of them */
811 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
813 if (SUCCEEDED(hr)) {
814 int i;
815 if (nb == 0) {
816 IPin_Disconnect(ppinOut);
817 goto error;
819 TRACE("pins to consider: %d\n", nb);
820 for(i = 0; i < nb; i++) {
821 TRACE("Processing pin %d\n", i);
822 hr = IGraphBuilder_Connect(iface, ppins[i], ppinIn);
823 if (FAILED(hr)) {
824 TRACE("Cannot render pin %p (%x)\n", ppinfilter, hr);
826 IPin_Release(ppins[i]);
827 if (SUCCEEDED(hr)) break;
829 while (++i < nb) IPin_Release(ppins[i]);
830 CoTaskMemFree(ppins);
831 IPin_Release(ppinfilter);
832 IBaseFilter_Release(pfilter);
833 break;
836 error:
837 if (ppinfilter) IPin_Release(ppinfilter);
838 if (pfilter) {
839 IGraphBuilder_RemoveFilter(iface, pfilter);
840 IBaseFilter_Release(pfilter);
844 IEnumMediaTypes_Release(penummt);
845 DeleteMediaType(mt);
847 return S_OK;
850 static HRESULT WINAPI GraphBuilder_Render(IGraphBuilder *iface,
851 IPin *ppinOut) {
852 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
853 IEnumMediaTypes* penummt;
854 AM_MEDIA_TYPE* mt;
855 ULONG nbmt;
856 HRESULT hr;
858 IEnumMoniker* pEnumMoniker;
859 GUID tab[2];
860 ULONG nb;
861 IMoniker* pMoniker;
863 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
865 if (TRACE_ON(quartz))
867 PIN_INFO PinInfo;
869 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
870 if (FAILED(hr))
871 return hr;
873 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
874 IBaseFilter_Release(PinInfo.pFilter);
877 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
878 if (FAILED(hr)) {
879 ERR("EnumMediaTypes (%x)\n", hr);
880 return hr;
883 while(1)
885 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
886 if (FAILED(hr)) {
887 ERR("IEnumMediaTypes_Next (%x)\n", hr);
888 return hr;
890 if (!nbmt)
891 break;
892 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
893 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
895 /* Try to find a suitable renderer with the same media type */
896 tab[0] = mt->majortype;
897 tab[1] = GUID_NULL;
898 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL);
899 if (FAILED(hr)) {
900 ERR("Unable to enum filters (%x)\n", hr);
901 return hr;
904 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
906 VARIANT var;
907 GUID clsid;
908 IPin* ppinfilter;
909 IBaseFilter* pfilter = NULL;
910 IEnumPins* penumpins;
911 ULONG pin;
913 hr = GetFilterInfo(pMoniker, &clsid, &var);
914 IMoniker_Release(pMoniker);
915 if (FAILED(hr)) {
916 ERR("Unable to retrieve filter info (%x)\n", hr);
917 goto error;
920 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
921 if (FAILED(hr)) {
922 ERR("Unable to create filter (%x), trying next one\n", hr);
923 goto error;
926 hr = IGraphBuilder_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
927 if (FAILED(hr)) {
928 ERR("Unable to add filter (%x)\n", hr);
929 IBaseFilter_Release(pfilter);
930 pfilter = NULL;
931 goto error;
934 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
935 if (FAILED(hr)) {
936 ERR("Splitter Enumpins (%x)\n", hr);
937 goto error;
939 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
940 IEnumPins_Release(penumpins);
941 if (FAILED(hr)) {
942 ERR("Next (%x)\n", hr);
943 goto error;
945 if (pin == 0) {
946 ERR("No Pin\n");
947 goto error;
950 /* Connect the pin to render to the renderer */
951 hr = IGraphBuilder_Connect(iface, ppinOut, ppinfilter);
952 if (FAILED(hr)) {
953 TRACE("Unable to connect to renderer (%x)\n", hr);
954 IPin_Release(ppinfilter);
955 goto error;
957 IPin_Release(ppinfilter);
958 IBaseFilter_Release(pfilter);
959 pfilter = NULL;
960 break;
962 error:
963 if (pfilter) {
964 IGraphBuilder_RemoveFilter(iface, pfilter);
965 IBaseFilter_Release(pfilter);
969 DeleteMediaType(mt);
970 break;
973 IEnumMediaTypes_Release(penummt);
975 return S_OK;
978 static HRESULT WINAPI GraphBuilder_RenderFile(IGraphBuilder *iface,
979 LPCWSTR lpcwstrFile,
980 LPCWSTR lpcwstrPlayList) {
981 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
982 static const WCHAR string[] = {'R','e','a','d','e','r',0};
983 IBaseFilter* preader = NULL;
984 IBaseFilter* psplitter = NULL;
985 IPin* ppinreader = NULL;
986 IPin* ppinsplitter;
987 IEnumPins* penumpins;
988 ULONG pin;
989 HRESULT hr;
990 IEnumMoniker* pEnumMoniker = NULL;
991 GUID tab[2];
992 IPin** ppins = NULL;
993 ULONG nb;
994 IMoniker* pMoniker;
995 IFileSourceFilter* pfile = NULL;
996 AM_MEDIA_TYPE mt;
997 WCHAR* filename;
999 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1001 if (lpcwstrPlayList != NULL)
1002 return E_INVALIDARG;
1004 hr = IGraphBuilder_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1006 /* Retrieve file media type */
1007 if (SUCCEEDED(hr))
1008 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1009 if (SUCCEEDED(hr)) {
1010 hr = IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1011 IFileSourceFilter_Release(pfile);
1014 if (SUCCEEDED(hr))
1015 hr = IBaseFilter_EnumPins(preader, &penumpins);
1016 if (SUCCEEDED(hr)) {
1017 hr = IEnumPins_Next(penumpins, 1, &ppinreader, &pin);
1018 IEnumPins_Release(penumpins);
1021 if (SUCCEEDED(hr)) {
1022 tab[0] = mt.majortype;
1023 tab[1] = mt.subtype;
1024 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, 0, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1027 if (FAILED(hr))
1029 if (ppinreader)
1030 IPin_Release(ppinreader);
1031 if (pEnumMoniker)
1032 IEnumMoniker_Release(pEnumMoniker);
1033 if (preader) {
1034 IGraphBuilder_RemoveFilter(iface, preader);
1035 IBaseFilter_Release(preader);
1037 return hr;
1040 hr = VFW_E_CANNOT_RENDER;
1041 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1043 VARIANT var;
1044 GUID clsid;
1046 hr = GetFilterInfo(pMoniker, &clsid, &var);
1047 IMoniker_Release(pMoniker);
1048 if (FAILED(hr)) {
1049 ERR("Unable to retrieve filter info (%x)\n", hr);
1050 continue;
1053 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&psplitter);
1054 if (FAILED(hr)) {
1055 ERR("Unable to create filter (%x), trying next one\n", hr);
1056 continue;
1059 hr = IGraphBuilder_AddFilter(iface, psplitter, V_UNION(&var, bstrVal));
1060 if (FAILED(hr)) {
1061 ERR("Unable add filter (%x)\n", hr);
1062 IBaseFilter_Release(psplitter);
1063 continue;
1066 /* Connect file source and splitter filters together */
1067 /* Make the splitter analyze incoming data */
1069 hr = IBaseFilter_EnumPins(psplitter, &penumpins);
1070 if (SUCCEEDED(hr)) {
1071 hr = IEnumPins_Next(penumpins, 1, &ppinsplitter, &pin);
1072 IEnumPins_Release(penumpins);
1075 if (SUCCEEDED(hr))
1076 hr = IPin_Connect(ppinreader, ppinsplitter, NULL);
1078 /* Make sure there's some output pins in the filter */
1079 if (SUCCEEDED(hr))
1080 hr = GetInternalConnections(psplitter, ppinsplitter, &ppins, &nb);
1081 if (SUCCEEDED(hr)) {
1082 if(nb == 0) {
1083 IPin_Disconnect(ppinreader);
1084 TRACE("No output pins found in filter\n");
1085 hr = VFW_E_CANNOT_RENDER;
1089 if (ppinsplitter)
1090 IPin_Release(ppinsplitter);
1091 ppinsplitter = NULL;
1093 if (SUCCEEDED(hr)) {
1094 TRACE("Successfully connected to filter\n");
1095 break;
1098 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1100 if (ppins) {
1101 CoTaskMemFree(ppins);
1102 ppins = NULL;
1104 IGraphBuilder_RemoveFilter(iface, psplitter);
1105 IBaseFilter_Release(psplitter);
1106 psplitter = NULL;
1109 /* Render all output pin of the splitter by calling IGraphBuilder_Render on each of them */
1110 if (SUCCEEDED(hr)) {
1111 int partial = 0;
1112 int i;
1113 TRACE("pins to consider: %d\n", nb);
1114 for(i = 0; i < nb; i++) {
1115 TRACE("Processing pin %d\n", i);
1116 hr = IGraphBuilder_Render(iface, ppins[i]);
1117 if (FAILED(hr)) {
1118 ERR("Cannot render pin %p (%x)\n", ppins[i], hr);
1119 partial = 1;
1121 IPin_Release(ppins[i]);
1123 CoTaskMemFree(ppins);
1125 hr = (partial ? VFW_S_PARTIAL_RENDER : S_OK);
1128 IPin_Release(ppinreader);
1129 IBaseFilter_Release(preader);
1130 if (psplitter)
1131 IBaseFilter_Release(psplitter);
1133 return hr;
1136 static HRESULT WINAPI GraphBuilder_AddSourceFilter(IGraphBuilder *iface,
1137 LPCWSTR lpcwstrFileName,
1138 LPCWSTR lpcwstrFilterName,
1139 IBaseFilter **ppFilter) {
1140 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1141 HRESULT hr;
1142 IBaseFilter* preader;
1143 IFileSourceFilter* pfile = NULL;
1144 AM_MEDIA_TYPE mt;
1145 WCHAR* filename;
1147 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1149 /* Instantiate a file source filter */
1150 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1151 if (FAILED(hr)) {
1152 ERR("Unable to create file source filter (%x)\n", hr);
1153 return hr;
1156 hr = IGraphBuilder_AddFilter(iface, preader, lpcwstrFilterName);
1157 if (FAILED(hr)) {
1158 ERR("Unable add filter (%x)\n", hr);
1159 IBaseFilter_Release(preader);
1160 return hr;
1163 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1164 if (FAILED(hr)) {
1165 ERR("Unable to get IFileSourceInterface (%x)\n", hr);
1166 goto error;
1169 /* Load the file in the file source filter */
1170 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1171 if (FAILED(hr)) {
1172 ERR("Load (%x)\n", hr);
1173 goto error;
1176 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1177 if (FAILED(hr)) {
1178 ERR("GetCurFile (%x)\n", hr);
1179 goto error;
1181 TRACE("File %s\n", debugstr_w(filename));
1182 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1183 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1185 if (ppFilter)
1186 *ppFilter = preader;
1187 IFileSourceFilter_Release(pfile);
1189 return S_OK;
1191 error:
1192 if (pfile)
1193 IFileSourceFilter_Release(pfile);
1194 IGraphBuilder_RemoveFilter(iface, preader);
1195 IBaseFilter_Release(preader);
1197 return hr;
1200 static HRESULT WINAPI GraphBuilder_SetLogFile(IGraphBuilder *iface,
1201 DWORD_PTR hFile) {
1202 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1204 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1206 return S_OK;
1209 static HRESULT WINAPI GraphBuilder_Abort(IGraphBuilder *iface) {
1210 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1212 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1214 return S_OK;
1217 static HRESULT WINAPI GraphBuilder_ShouldOperationContinue(IGraphBuilder *iface) {
1218 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphBuilder_vtbl, iface);
1220 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1222 return S_OK;
1226 static const IGraphBuilderVtbl IGraphBuilder_VTable =
1228 GraphBuilder_QueryInterface,
1229 GraphBuilder_AddRef,
1230 GraphBuilder_Release,
1231 GraphBuilder_AddFilter,
1232 GraphBuilder_RemoveFilter,
1233 GraphBuilder_EnumFilters,
1234 GraphBuilder_FindFilterByName,
1235 GraphBuilder_ConnectDirect,
1236 GraphBuilder_Reconnect,
1237 GraphBuilder_Disconnect,
1238 GraphBuilder_SetDefaultSyncSource,
1239 GraphBuilder_Connect,
1240 GraphBuilder_Render,
1241 GraphBuilder_RenderFile,
1242 GraphBuilder_AddSourceFilter,
1243 GraphBuilder_SetLogFile,
1244 GraphBuilder_Abort,
1245 GraphBuilder_ShouldOperationContinue
1248 /*** IUnknown methods ***/
1249 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1250 REFIID riid,
1251 LPVOID*ppvObj) {
1252 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1254 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1256 return Filtergraph_QueryInterface(This, riid, ppvObj);
1259 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1260 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1262 TRACE("(%p/%p)->()\n", This, iface);
1264 return Filtergraph_AddRef(This);
1267 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1268 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1270 TRACE("(%p/%p)->()\n", This, iface);
1272 return Filtergraph_Release(This);
1276 /*** IDispatch methods ***/
1277 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1278 UINT*pctinfo) {
1279 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1281 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1283 return S_OK;
1286 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1287 UINT iTInfo,
1288 LCID lcid,
1289 ITypeInfo**ppTInfo) {
1290 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1292 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1294 return S_OK;
1297 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1298 REFIID riid,
1299 LPOLESTR*rgszNames,
1300 UINT cNames,
1301 LCID lcid,
1302 DISPID*rgDispId) {
1303 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1305 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1307 return S_OK;
1310 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1311 DISPID dispIdMember,
1312 REFIID riid,
1313 LCID lcid,
1314 WORD wFlags,
1315 DISPPARAMS*pDispParams,
1316 VARIANT*pVarResult,
1317 EXCEPINFO*pExepInfo,
1318 UINT*puArgErr) {
1319 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1321 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);
1323 return S_OK;
1326 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *);
1328 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter)
1330 HRESULT hr;
1331 IPin* pInputPin;
1332 IPin** ppPins;
1333 ULONG nb;
1334 ULONG i;
1335 PIN_INFO PinInfo;
1337 TRACE("%p %p\n", pGraph, pOutputPin);
1338 PinInfo.pFilter = NULL;
1340 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1342 if (SUCCEEDED(hr))
1344 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1345 if (SUCCEEDED(hr))
1346 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1347 IPin_Release(pInputPin);
1350 if (SUCCEEDED(hr))
1352 if (nb == 0)
1354 TRACE("Reached a renderer\n");
1355 /* Count renderers for end of stream notification */
1356 pGraph->nRenderers++;
1358 else
1360 for(i = 0; i < nb; i++)
1362 /* Explore the graph downstream from this pin
1363 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1364 * several input pins are connected to the same output (a MUX for instance). */
1365 ExploreGraph(pGraph, ppPins[i], FoundFilter);
1366 IPin_Release(ppPins[i]);
1369 CoTaskMemFree(ppPins);
1371 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1372 FoundFilter(PinInfo.pFilter);
1375 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1376 return hr;
1379 static HRESULT WINAPI SendRun(IBaseFilter *pFilter) {
1380 return IBaseFilter_Run(pFilter, 0);
1383 static HRESULT WINAPI SendPause(IBaseFilter *pFilter) {
1384 return IBaseFilter_Pause(pFilter);
1387 static HRESULT WINAPI SendStop(IBaseFilter *pFilter) {
1388 return IBaseFilter_Stop(pFilter);
1391 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter) {
1392 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1393 int i;
1394 IBaseFilter* pfilter;
1395 IEnumPins* pEnum;
1396 HRESULT hr;
1397 IPin* pPin;
1398 DWORD dummy;
1399 PIN_DIRECTION dir;
1400 TRACE("(%p/%p)->()\n", This, iface);
1402 /* Explorer the graph from source filters to renderers, determine renderers
1403 * number and run filters from renderers to source filters */
1404 This->nRenderers = 0;
1405 ResetEvent(This->hEventCompletion);
1407 for(i = 0; i < This->nFilters; i++)
1409 BOOL source = TRUE;
1410 pfilter = This->ppFiltersInGraph[i];
1411 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1412 if (hr != S_OK)
1414 ERR("Enum pins failed %x\n", hr);
1415 continue;
1417 /* Check if it is a source filter */
1418 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1420 IPin_QueryDirection(pPin, &dir);
1421 IPin_Release(pPin);
1422 if (dir == PINDIR_INPUT)
1424 source = FALSE;
1425 break;
1428 if (source)
1430 TRACE("Found a source filter %p\n", pfilter);
1431 IEnumPins_Reset(pEnum);
1432 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1434 /* Explore the graph downstream from this pin */
1435 ExploreGraph(This, pPin, FoundFilter);
1436 IPin_Release(pPin);
1438 FoundFilter(pfilter);
1440 IEnumPins_Release(pEnum);
1443 return S_FALSE;
1446 /*** IMediaControl methods ***/
1447 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1448 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1449 TRACE("(%p/%p)->()\n", This, iface);
1451 if (This->state == State_Running) return S_OK;
1453 EnterCriticalSection(&This->cs);
1454 SendFilterMessage(iface, SendRun);
1455 This->state = State_Running;
1456 LeaveCriticalSection(&This->cs);
1457 return S_FALSE;
1460 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1461 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1462 TRACE("(%p/%p)->()\n", This, iface);
1464 if (This->state == State_Paused) return S_OK;
1466 EnterCriticalSection(&This->cs);
1467 SendFilterMessage(iface, SendPause);
1468 This->state = State_Paused;
1469 LeaveCriticalSection(&This->cs);
1470 return S_FALSE;
1473 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
1474 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1475 TRACE("(%p/%p)->()\n", This, iface);
1477 if (This->state == State_Stopped) return S_OK;
1479 EnterCriticalSection(&This->cs);
1480 if (This->state == State_Running) SendFilterMessage(iface, SendPause);
1481 SendFilterMessage(iface, SendStop);
1482 This->state = State_Stopped;
1483 LeaveCriticalSection(&This->cs);
1484 return S_FALSE;
1487 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
1488 LONG msTimeout,
1489 OAFilterState *pfs) {
1490 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1492 TRACE("(%p/%p)->(%d, %p): semi-stub !!!\n", This, iface, msTimeout, pfs);
1494 EnterCriticalSection(&This->cs);
1496 *pfs = This->state;
1498 LeaveCriticalSection(&This->cs);
1500 return S_OK;
1503 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
1504 BSTR strFilename) {
1505 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1507 TRACE("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
1509 return S_OK;
1512 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
1513 BSTR strFilename,
1514 IDispatch **ppUnk) {
1515 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1517 TRACE("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
1519 return S_OK;
1522 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
1523 IDispatch **ppUnk) {
1524 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1526 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1528 return S_OK;
1531 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
1532 IDispatch **ppUnk) {
1533 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1535 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
1537 return S_OK;
1540 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
1541 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1543 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1545 return S_OK;
1549 static const IMediaControlVtbl IMediaControl_VTable =
1551 MediaControl_QueryInterface,
1552 MediaControl_AddRef,
1553 MediaControl_Release,
1554 MediaControl_GetTypeInfoCount,
1555 MediaControl_GetTypeInfo,
1556 MediaControl_GetIDsOfNames,
1557 MediaControl_Invoke,
1558 MediaControl_Run,
1559 MediaControl_Pause,
1560 MediaControl_Stop,
1561 MediaControl_GetState,
1562 MediaControl_RenderFile,
1563 MediaControl_AddSourceFilter,
1564 MediaControl_get_FilterCollection,
1565 MediaControl_get_RegFilterCollection,
1566 MediaControl_StopWhenReady
1570 /*** IUnknown methods ***/
1571 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
1572 REFIID riid,
1573 LPVOID*ppvObj) {
1574 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1576 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1578 return Filtergraph_QueryInterface(This, riid, ppvObj);
1581 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
1582 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1584 TRACE("(%p/%p)->()\n", This, iface);
1586 return Filtergraph_AddRef(This);
1589 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
1590 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1592 TRACE("(%p/%p)->()\n", This, iface);
1594 return Filtergraph_Release(This);
1597 /*** IMediaSeeking methods ***/
1598 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
1599 DWORD *pCapabilities) {
1600 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1602 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1604 return S_OK;
1607 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
1608 DWORD *pCapabilities) {
1609 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1611 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCapabilities);
1613 return S_OK;
1616 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
1617 const GUID *pFormat) {
1618 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1620 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1622 return S_OK;
1625 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
1626 GUID *pFormat) {
1627 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1629 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1631 return S_OK;
1634 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
1635 GUID *pFormat) {
1636 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1638 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1640 return S_OK;
1643 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
1644 const GUID *pFormat) {
1645 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1647 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1649 return S_OK;
1652 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
1653 const GUID *pFormat) {
1654 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1656 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pFormat);
1658 return S_OK;
1661 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
1662 LONGLONG *pDuration) {
1663 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1665 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pDuration);
1667 return S_OK;
1670 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
1671 LONGLONG *pStop) {
1672 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1674 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pStop);
1676 return S_OK;
1679 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
1680 LONGLONG *pCurrent) {
1681 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1683 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pCurrent);
1685 return S_OK;
1688 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
1689 LONGLONG *pTarget,
1690 const GUID *pTargetFormat,
1691 LONGLONG Source,
1692 const GUID *pSourceFormat) {
1693 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1695 TRACE("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
1696 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
1698 return S_OK;
1701 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
1702 LONGLONG *pCurrent,
1703 DWORD dwCurrentFlags,
1704 LONGLONG *pStop,
1705 DWORD dwStopFlags) {
1706 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1708 TRACE("(%p/%p)->(%p, %08x, %p, %08x): stub !!!\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
1710 return S_OK;
1713 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
1714 LONGLONG *pCurrent,
1715 LONGLONG *pStop) {
1716 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1718 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pCurrent, pStop);
1720 return S_OK;
1723 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
1724 LONGLONG *pEarliest,
1725 LONGLONG *pLatest) {
1726 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1728 TRACE("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
1730 return S_OK;
1733 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
1734 double dRate) {
1735 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1737 TRACE("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
1739 return S_OK;
1742 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
1743 double *pdRate) {
1744 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1746 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
1748 return S_OK;
1751 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
1752 LONGLONG *pllPreroll) {
1753 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
1755 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
1757 return S_OK;
1761 static const IMediaSeekingVtbl IMediaSeeking_VTable =
1763 MediaSeeking_QueryInterface,
1764 MediaSeeking_AddRef,
1765 MediaSeeking_Release,
1766 MediaSeeking_GetCapabilities,
1767 MediaSeeking_CheckCapabilities,
1768 MediaSeeking_IsFormatSupported,
1769 MediaSeeking_QueryPreferredFormat,
1770 MediaSeeking_GetTimeFormat,
1771 MediaSeeking_IsUsingTimeFormat,
1772 MediaSeeking_SetTimeFormat,
1773 MediaSeeking_GetDuration,
1774 MediaSeeking_GetStopPosition,
1775 MediaSeeking_GetCurrentPosition,
1776 MediaSeeking_ConvertTimeFormat,
1777 MediaSeeking_SetPositions,
1778 MediaSeeking_GetPositions,
1779 MediaSeeking_GetAvailable,
1780 MediaSeeking_SetRate,
1781 MediaSeeking_GetRate,
1782 MediaSeeking_GetPreroll
1785 /*** IUnknown methods ***/
1786 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj){
1787 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1789 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1791 return Filtergraph_QueryInterface(This, riid, ppvObj);
1794 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface){
1795 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1797 TRACE("(%p/%p)->()\n", This, iface);
1799 return Filtergraph_AddRef(This);
1802 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface){
1803 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaPosition_vtbl, iface);
1805 TRACE("(%p/%p)->()\n", This, iface);
1807 return Filtergraph_Release(This);
1810 /*** IDispatch methods ***/
1811 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
1812 FIXME("(%p) stub!\n", iface);
1813 return E_NOTIMPL;
1816 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
1817 FIXME("(%p) stub!\n", iface);
1818 return E_NOTIMPL;
1821 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
1822 FIXME("(%p) stub!\n", iface);
1823 return E_NOTIMPL;
1826 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
1827 FIXME("(%p) stub!\n", iface);
1828 return E_NOTIMPL;
1831 /*** IMediaPosition methods ***/
1832 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength){
1833 FIXME("(%p)->(%p) stub!\n", iface, plength);
1834 return E_NOTIMPL;
1837 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime){
1838 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1839 return E_NOTIMPL;
1842 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime){
1843 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime){
1848 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1849 return E_NOTIMPL;
1852 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime){
1853 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
1858 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
1859 return E_NOTIMPL;
1862 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
1863 FIXME("(%p)->(%f) stub!\n", iface, llTime);
1864 return E_NOTIMPL;
1867 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate){
1868 FIXME("(%p)->(%f) stub!\n", iface, dRate);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate){
1873 FIXME("(%p)->(%p) stub!\n", iface, pdRate);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
1878 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
1879 return E_NOTIMPL;
1882 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
1883 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
1884 return E_NOTIMPL;
1888 static const IMediaPositionVtbl IMediaPosition_VTable =
1890 MediaPosition_QueryInterface,
1891 MediaPosition_AddRef,
1892 MediaPosition_Release,
1893 MediaPosition_GetTypeInfoCount,
1894 MediaPosition_GetTypeInfo,
1895 MediaPosition_GetIDsOfNames,
1896 MediaPosition_Invoke,
1897 MediaPosition_get_Duration,
1898 MediaPosition_put_CurrentPosition,
1899 MediaPosition_get_CurrentPosition,
1900 MediaPosition_get_StopTime,
1901 MediaPosition_put_StopTime,
1902 MediaPosition_get_PrerollTime,
1903 MediaPosition_put_PrerollTime,
1904 MediaPosition_put_Rate,
1905 MediaPosition_get_Rate,
1906 MediaPosition_CanSeekForward,
1907 MediaPosition_CanSeekBackward
1910 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
1912 HRESULT hr = E_NOINTERFACE;
1913 int i;
1914 int entry;
1916 /* Check if the interface type is already registered */
1917 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
1918 if (riid == pGraph->ItfCacheEntries[entry].riid)
1920 if (pGraph->ItfCacheEntries[entry].iface)
1922 /* Return the interface if available */
1923 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
1924 return S_OK;
1926 break;
1929 if (entry >= MAX_ITF_CACHE_ENTRIES)
1931 FIXME("Not enough space to store interface in the cache\n");
1932 return E_OUTOFMEMORY;
1935 /* Find a filter supporting the requested interface */
1936 for (i = 0; i < pGraph->nFilters; i++)
1938 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
1939 if (hr == S_OK)
1941 pGraph->ItfCacheEntries[entry].riid = riid;
1942 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
1943 pGraph->ItfCacheEntries[entry].iface = (IUnknown*)*ppvObj;
1944 if (entry >= pGraph->nItfCacheEntries)
1945 pGraph->nItfCacheEntries++;
1946 return S_OK;
1948 if (hr != E_NOINTERFACE)
1949 return hr;
1952 return hr;
1955 /*** IUnknown methods ***/
1956 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
1957 REFIID riid,
1958 LPVOID*ppvObj) {
1959 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1961 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1963 return Filtergraph_QueryInterface(This, riid, ppvObj);
1966 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
1967 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1969 TRACE("(%p/%p)->()\n", This, iface);
1971 return Filtergraph_AddRef(This);
1974 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
1975 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1977 TRACE("(%p/%p)->()\n", This, iface);
1979 return Filtergraph_Release(This);
1982 /*** IDispatch methods ***/
1983 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
1984 UINT*pctinfo) {
1985 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
1986 IBasicAudio* pBasicAudio;
1987 HRESULT hr;
1989 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
1991 EnterCriticalSection(&This->cs);
1993 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
1995 if (hr == S_OK)
1996 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
1998 LeaveCriticalSection(&This->cs);
2000 return hr;
2003 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
2004 UINT iTInfo,
2005 LCID lcid,
2006 ITypeInfo**ppTInfo) {
2007 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2008 IBasicAudio* pBasicAudio;
2009 HRESULT hr;
2011 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2013 EnterCriticalSection(&This->cs);
2015 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2017 if (hr == S_OK)
2018 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
2020 LeaveCriticalSection(&This->cs);
2022 return hr;
2025 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
2026 REFIID riid,
2027 LPOLESTR*rgszNames,
2028 UINT cNames,
2029 LCID lcid,
2030 DISPID*rgDispId) {
2031 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2032 IBasicAudio* pBasicAudio;
2033 HRESULT hr;
2035 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2037 EnterCriticalSection(&This->cs);
2039 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2041 if (hr == S_OK)
2042 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2044 LeaveCriticalSection(&This->cs);
2046 return hr;
2049 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2050 DISPID dispIdMember,
2051 REFIID riid,
2052 LCID lcid,
2053 WORD wFlags,
2054 DISPPARAMS*pDispParams,
2055 VARIANT*pVarResult,
2056 EXCEPINFO*pExepInfo,
2057 UINT*puArgErr) {
2058 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2059 IBasicAudio* pBasicAudio;
2060 HRESULT hr;
2062 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);
2064 EnterCriticalSection(&This->cs);
2066 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2068 if (hr == S_OK)
2069 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2071 LeaveCriticalSection(&This->cs);
2073 return hr;
2076 /*** IBasicAudio methods ***/
2077 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2078 long lVolume) {
2079 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2080 IBasicAudio* pBasicAudio;
2081 HRESULT hr;
2083 TRACE("(%p/%p)->(%ld)\n", This, iface, lVolume);
2085 EnterCriticalSection(&This->cs);
2087 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2089 if (hr == S_OK)
2090 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2092 LeaveCriticalSection(&This->cs);
2094 return hr;
2097 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2098 long *plVolume) {
2099 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2100 IBasicAudio* pBasicAudio;
2101 HRESULT hr;
2103 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2105 EnterCriticalSection(&This->cs);
2107 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2109 if (hr == S_OK)
2110 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2112 LeaveCriticalSection(&This->cs);
2114 return hr;
2117 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2118 long lBalance) {
2119 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2120 IBasicAudio* pBasicAudio;
2121 HRESULT hr;
2123 TRACE("(%p/%p)->(%ld)\n", This, iface, lBalance);
2125 EnterCriticalSection(&This->cs);
2127 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2129 if (hr == S_OK)
2130 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2132 LeaveCriticalSection(&This->cs);
2134 return hr;
2137 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2138 long *plBalance) {
2139 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2140 IBasicAudio* pBasicAudio;
2141 HRESULT hr;
2143 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2145 EnterCriticalSection(&This->cs);
2147 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2149 if (hr == S_OK)
2150 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2152 LeaveCriticalSection(&This->cs);
2154 return hr;
2157 static const IBasicAudioVtbl IBasicAudio_VTable =
2159 BasicAudio_QueryInterface,
2160 BasicAudio_AddRef,
2161 BasicAudio_Release,
2162 BasicAudio_GetTypeInfoCount,
2163 BasicAudio_GetTypeInfo,
2164 BasicAudio_GetIDsOfNames,
2165 BasicAudio_Invoke,
2166 BasicAudio_put_Volume,
2167 BasicAudio_get_Volume,
2168 BasicAudio_put_Balance,
2169 BasicAudio_get_Balance
2172 /*** IUnknown methods ***/
2173 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo *iface,
2174 REFIID riid,
2175 LPVOID*ppvObj) {
2176 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2178 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2180 return Filtergraph_QueryInterface(This, riid, ppvObj);
2183 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo *iface) {
2184 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2186 TRACE("(%p/%p)->()\n", This, iface);
2188 return Filtergraph_AddRef(This);
2191 static ULONG WINAPI BasicVideo_Release(IBasicVideo *iface) {
2192 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2194 TRACE("(%p/%p)->()\n", This, iface);
2196 return Filtergraph_Release(This);
2199 /*** IDispatch methods ***/
2200 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo *iface,
2201 UINT*pctinfo) {
2202 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2203 IBasicVideo* pBasicVideo;
2204 HRESULT hr;
2206 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2208 EnterCriticalSection(&This->cs);
2210 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2212 if (hr == S_OK)
2213 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
2215 LeaveCriticalSection(&This->cs);
2217 return hr;
2220 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo *iface,
2221 UINT iTInfo,
2222 LCID lcid,
2223 ITypeInfo**ppTInfo) {
2224 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2225 IBasicVideo* pBasicVideo;
2226 HRESULT hr;
2228 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2230 EnterCriticalSection(&This->cs);
2232 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2234 if (hr == S_OK)
2235 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
2237 LeaveCriticalSection(&This->cs);
2239 return hr;
2242 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo *iface,
2243 REFIID riid,
2244 LPOLESTR*rgszNames,
2245 UINT cNames,
2246 LCID lcid,
2247 DISPID*rgDispId) {
2248 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2249 IBasicVideo* pBasicVideo;
2250 HRESULT hr;
2252 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2254 EnterCriticalSection(&This->cs);
2256 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2258 if (hr == S_OK)
2259 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
2261 LeaveCriticalSection(&This->cs);
2263 return hr;
2266 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo *iface,
2267 DISPID dispIdMember,
2268 REFIID riid,
2269 LCID lcid,
2270 WORD wFlags,
2271 DISPPARAMS*pDispParams,
2272 VARIANT*pVarResult,
2273 EXCEPINFO*pExepInfo,
2274 UINT*puArgErr) {
2275 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2276 IBasicVideo* pBasicVideo;
2277 HRESULT hr;
2279 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);
2281 EnterCriticalSection(&This->cs);
2283 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2285 if (hr == S_OK)
2286 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2288 LeaveCriticalSection(&This->cs);
2290 return hr;
2293 /*** IBasicVideo methods ***/
2294 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo *iface,
2295 REFTIME *pAvgTimePerFrame) {
2296 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2297 IBasicVideo* pBasicVideo;
2298 HRESULT hr;
2300 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
2302 EnterCriticalSection(&This->cs);
2304 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2306 if (hr == S_OK)
2307 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
2309 LeaveCriticalSection(&This->cs);
2311 return hr;
2314 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo *iface,
2315 long *pBitRate) {
2316 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2317 IBasicVideo* pBasicVideo;
2318 HRESULT hr;
2320 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
2322 EnterCriticalSection(&This->cs);
2324 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2326 if (hr == S_OK)
2327 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
2329 LeaveCriticalSection(&This->cs);
2331 return hr;
2334 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo *iface,
2335 long *pBitErrorRate) {
2336 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2337 IBasicVideo* pBasicVideo;
2338 HRESULT hr;
2340 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
2342 EnterCriticalSection(&This->cs);
2344 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2346 if (hr == S_OK)
2347 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
2349 LeaveCriticalSection(&This->cs);
2351 return hr;
2354 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo *iface,
2355 long *pVideoWidth) {
2356 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2357 IBasicVideo* pBasicVideo;
2358 HRESULT hr;
2360 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
2362 EnterCriticalSection(&This->cs);
2364 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2366 if (hr == S_OK)
2367 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
2369 LeaveCriticalSection(&This->cs);
2371 return hr;
2374 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo *iface,
2375 long *pVideoHeight) {
2376 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2377 IBasicVideo* pBasicVideo;
2378 HRESULT hr;
2380 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
2382 EnterCriticalSection(&This->cs);
2384 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2386 if (hr == S_OK)
2387 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
2389 LeaveCriticalSection(&This->cs);
2391 return hr;
2394 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo *iface,
2395 long SourceLeft) {
2396 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2397 IBasicVideo* pBasicVideo;
2398 HRESULT hr;
2400 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
2402 EnterCriticalSection(&This->cs);
2404 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2406 if (hr == S_OK)
2407 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
2409 LeaveCriticalSection(&This->cs);
2411 return hr;
2414 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo *iface,
2415 long *pSourceLeft) {
2416 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2417 IBasicVideo* pBasicVideo;
2418 HRESULT hr;
2420 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
2422 EnterCriticalSection(&This->cs);
2424 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2426 if (hr == S_OK)
2427 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
2429 LeaveCriticalSection(&This->cs);
2431 return hr;
2434 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo *iface,
2435 long SourceWidth) {
2436 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2437 IBasicVideo* pBasicVideo;
2438 HRESULT hr;
2440 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
2442 EnterCriticalSection(&This->cs);
2444 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2446 if (hr == S_OK)
2447 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
2449 LeaveCriticalSection(&This->cs);
2451 return hr;
2454 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo *iface,
2455 long *pSourceWidth) {
2456 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2457 IBasicVideo* pBasicVideo;
2458 HRESULT hr;
2460 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
2462 EnterCriticalSection(&This->cs);
2464 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2466 if (hr == S_OK)
2467 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
2469 LeaveCriticalSection(&This->cs);
2471 return hr;
2474 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo *iface,
2475 long SourceTop) {
2476 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2477 IBasicVideo* pBasicVideo;
2478 HRESULT hr;
2480 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
2482 EnterCriticalSection(&This->cs);
2484 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2486 if (hr == S_OK)
2487 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
2489 LeaveCriticalSection(&This->cs);
2491 return hr;
2494 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo *iface,
2495 long *pSourceTop) {
2496 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2497 IBasicVideo* pBasicVideo;
2498 HRESULT hr;
2500 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
2502 EnterCriticalSection(&This->cs);
2504 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2506 if (hr == S_OK)
2507 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
2509 LeaveCriticalSection(&This->cs);
2511 return hr;
2514 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo *iface,
2515 long SourceHeight) {
2516 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2517 IBasicVideo* pBasicVideo;
2518 HRESULT hr;
2520 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
2522 EnterCriticalSection(&This->cs);
2524 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2526 if (hr == S_OK)
2527 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
2529 LeaveCriticalSection(&This->cs);
2531 return hr;
2534 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo *iface,
2535 long *pSourceHeight) {
2536 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2537 IBasicVideo* pBasicVideo;
2538 HRESULT hr;
2540 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
2542 EnterCriticalSection(&This->cs);
2544 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2546 if (hr == S_OK)
2547 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
2549 LeaveCriticalSection(&This->cs);
2551 return hr;
2554 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo *iface,
2555 long DestinationLeft) {
2556 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2557 IBasicVideo* pBasicVideo;
2558 HRESULT hr;
2560 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
2562 EnterCriticalSection(&This->cs);
2564 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2566 if (hr == S_OK)
2567 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
2569 LeaveCriticalSection(&This->cs);
2571 return hr;
2574 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo *iface,
2575 long *pDestinationLeft) {
2576 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2577 IBasicVideo* pBasicVideo;
2578 HRESULT hr;
2580 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
2582 EnterCriticalSection(&This->cs);
2584 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2586 if (hr == S_OK)
2587 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
2589 LeaveCriticalSection(&This->cs);
2591 return hr;
2594 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo *iface,
2595 long DestinationWidth) {
2596 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2597 IBasicVideo* pBasicVideo;
2598 HRESULT hr;
2600 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
2602 EnterCriticalSection(&This->cs);
2604 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2606 if (hr == S_OK)
2607 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
2609 LeaveCriticalSection(&This->cs);
2611 return hr;
2614 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo *iface,
2615 long *pDestinationWidth) {
2616 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2617 IBasicVideo* pBasicVideo;
2618 HRESULT hr;
2620 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
2622 EnterCriticalSection(&This->cs);
2624 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2626 if (hr == S_OK)
2627 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
2629 LeaveCriticalSection(&This->cs);
2631 return hr;
2634 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo *iface,
2635 long DestinationTop) {
2636 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2637 IBasicVideo* pBasicVideo;
2638 HRESULT hr;
2640 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
2642 EnterCriticalSection(&This->cs);
2644 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2646 if (hr == S_OK)
2647 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
2649 LeaveCriticalSection(&This->cs);
2651 return hr;
2654 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo *iface,
2655 long *pDestinationTop) {
2656 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2657 IBasicVideo* pBasicVideo;
2658 HRESULT hr;
2660 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
2662 EnterCriticalSection(&This->cs);
2664 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2666 if (hr == S_OK)
2667 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
2669 LeaveCriticalSection(&This->cs);
2671 return hr;
2674 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo *iface,
2675 long DestinationHeight) {
2676 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2677 IBasicVideo* pBasicVideo;
2678 HRESULT hr;
2680 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
2682 EnterCriticalSection(&This->cs);
2684 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2686 if (hr == S_OK)
2687 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
2689 LeaveCriticalSection(&This->cs);
2691 return hr;
2694 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo *iface,
2695 long *pDestinationHeight) {
2696 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2697 IBasicVideo* pBasicVideo;
2698 HRESULT hr;
2700 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
2702 EnterCriticalSection(&This->cs);
2704 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2706 if (hr == S_OK)
2707 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
2709 LeaveCriticalSection(&This->cs);
2711 return hr;
2714 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo *iface,
2715 long Left,
2716 long Top,
2717 long Width,
2718 long Height) {
2719 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2720 IBasicVideo* pBasicVideo;
2721 HRESULT hr;
2723 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2725 EnterCriticalSection(&This->cs);
2727 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2729 if (hr == S_OK)
2730 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
2732 LeaveCriticalSection(&This->cs);
2734 return hr;
2737 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo *iface,
2738 long *pLeft,
2739 long *pTop,
2740 long *pWidth,
2741 long *pHeight) {
2742 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2743 IBasicVideo* pBasicVideo;
2744 HRESULT hr;
2746 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2748 EnterCriticalSection(&This->cs);
2750 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2752 if (hr == S_OK)
2753 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2755 LeaveCriticalSection(&This->cs);
2757 return hr;
2760 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo *iface) {
2761 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2762 IBasicVideo* pBasicVideo;
2763 HRESULT hr;
2765 TRACE("(%p/%p)->()\n", This, iface);
2767 EnterCriticalSection(&This->cs);
2769 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2771 if (hr == S_OK)
2772 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
2774 LeaveCriticalSection(&This->cs);
2776 return hr;
2779 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo *iface,
2780 long Left,
2781 long Top,
2782 long Width,
2783 long Height) {
2784 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2785 IBasicVideo* pBasicVideo;
2786 HRESULT hr;
2788 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2790 EnterCriticalSection(&This->cs);
2792 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2794 if (hr == S_OK)
2795 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
2797 LeaveCriticalSection(&This->cs);
2799 return hr;
2802 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo *iface,
2803 long *pLeft,
2804 long *pTop,
2805 long *pWidth,
2806 long *pHeight) {
2807 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2808 IBasicVideo* pBasicVideo;
2809 HRESULT hr;
2811 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2813 EnterCriticalSection(&This->cs);
2815 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2817 if (hr == S_OK)
2818 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
2820 LeaveCriticalSection(&This->cs);
2822 return hr;
2825 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
2826 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2827 IBasicVideo* pBasicVideo;
2828 HRESULT hr;
2830 TRACE("(%p/%p)->()\n", This, iface);
2832 EnterCriticalSection(&This->cs);
2834 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2836 if (hr == S_OK)
2837 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
2839 LeaveCriticalSection(&This->cs);
2841 return hr;
2844 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo *iface,
2845 long *pWidth,
2846 long *pHeight) {
2847 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2848 IBasicVideo* pBasicVideo;
2849 HRESULT hr;
2851 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
2853 EnterCriticalSection(&This->cs);
2855 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2857 if (hr == S_OK)
2858 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
2860 LeaveCriticalSection(&This->cs);
2862 return hr;
2865 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo *iface,
2866 long StartIndex,
2867 long Entries,
2868 long *pRetrieved,
2869 long *pPalette) {
2870 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2871 IBasicVideo* pBasicVideo;
2872 HRESULT hr;
2874 TRACE("(%p/%p)->(%ld, %ld, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
2876 EnterCriticalSection(&This->cs);
2878 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2880 if (hr == S_OK)
2881 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
2883 LeaveCriticalSection(&This->cs);
2885 return hr;
2888 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo *iface,
2889 long *pBufferSize,
2890 long *pDIBImage) {
2891 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2892 IBasicVideo* pBasicVideo;
2893 HRESULT hr;
2895 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
2897 EnterCriticalSection(&This->cs);
2899 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2901 if (hr == S_OK)
2902 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
2904 LeaveCriticalSection(&This->cs);
2906 return hr;
2909 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo *iface) {
2910 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2911 IBasicVideo* pBasicVideo;
2912 HRESULT hr;
2914 TRACE("(%p/%p)->()\n", This, iface);
2916 EnterCriticalSection(&This->cs);
2918 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2920 if (hr == S_OK)
2921 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
2923 LeaveCriticalSection(&This->cs);
2925 return hr;
2928 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo *iface) {
2929 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2930 IBasicVideo* pBasicVideo;
2931 HRESULT hr;
2933 TRACE("(%p/%p)->()\n", This, iface);
2935 EnterCriticalSection(&This->cs);
2937 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
2939 if (hr == S_OK)
2940 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
2942 LeaveCriticalSection(&This->cs);
2944 return hr;
2948 static const IBasicVideoVtbl IBasicVideo_VTable =
2950 BasicVideo_QueryInterface,
2951 BasicVideo_AddRef,
2952 BasicVideo_Release,
2953 BasicVideo_GetTypeInfoCount,
2954 BasicVideo_GetTypeInfo,
2955 BasicVideo_GetIDsOfNames,
2956 BasicVideo_Invoke,
2957 BasicVideo_get_AvgTimePerFrame,
2958 BasicVideo_get_BitRate,
2959 BasicVideo_get_BitErrorRate,
2960 BasicVideo_get_VideoWidth,
2961 BasicVideo_get_VideoHeight,
2962 BasicVideo_put_SourceLeft,
2963 BasicVideo_get_SourceLeft,
2964 BasicVideo_put_SourceWidth,
2965 BasicVideo_get_SourceWidth,
2966 BasicVideo_put_SourceTop,
2967 BasicVideo_get_SourceTop,
2968 BasicVideo_put_SourceHeight,
2969 BasicVideo_get_SourceHeight,
2970 BasicVideo_put_DestinationLeft,
2971 BasicVideo_get_DestinationLeft,
2972 BasicVideo_put_DestinationWidth,
2973 BasicVideo_get_DestinationWidth,
2974 BasicVideo_put_DestinationTop,
2975 BasicVideo_get_DestinationTop,
2976 BasicVideo_put_DestinationHeight,
2977 BasicVideo_get_DestinationHeight,
2978 BasicVideo_SetSourcePosition,
2979 BasicVideo_GetSourcePosition,
2980 BasicVideo_SetDefaultSourcePosition,
2981 BasicVideo_SetDestinationPosition,
2982 BasicVideo_GetDestinationPosition,
2983 BasicVideo_SetDefaultDestinationPosition,
2984 BasicVideo_GetVideoSize,
2985 BasicVideo_GetVideoPaletteEntries,
2986 BasicVideo_GetCurrentImage,
2987 BasicVideo_IsUsingDefaultSource,
2988 BasicVideo_IsUsingDefaultDestination
2992 /*** IUnknown methods ***/
2993 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
2994 REFIID riid,
2995 LPVOID*ppvObj) {
2996 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
2998 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3000 return Filtergraph_QueryInterface(This, riid, ppvObj);
3003 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
3004 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3006 TRACE("(%p/%p)->()\n", This, iface);
3008 return Filtergraph_AddRef(This);
3011 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
3012 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3014 TRACE("(%p/%p)->()\n", This, iface);
3016 return Filtergraph_Release(This);
3019 /*** IDispatch methods ***/
3020 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
3021 UINT*pctinfo) {
3022 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3023 IVideoWindow* pVideoWindow;
3024 HRESULT hr;
3026 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3028 EnterCriticalSection(&This->cs);
3030 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3032 if (hr == S_OK)
3033 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
3035 LeaveCriticalSection(&This->cs);
3037 return hr;
3040 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3041 UINT iTInfo,
3042 LCID lcid,
3043 ITypeInfo**ppTInfo) {
3044 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3045 IVideoWindow* pVideoWindow;
3046 HRESULT hr;
3048 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3050 EnterCriticalSection(&This->cs);
3052 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3054 if (hr == S_OK)
3055 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3057 LeaveCriticalSection(&This->cs);
3059 return hr;
3062 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3063 REFIID riid,
3064 LPOLESTR*rgszNames,
3065 UINT cNames,
3066 LCID lcid,
3067 DISPID*rgDispId) {
3068 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3069 IVideoWindow* pVideoWindow;
3070 HRESULT hr;
3072 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3074 EnterCriticalSection(&This->cs);
3076 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3078 if (hr == S_OK)
3079 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3081 LeaveCriticalSection(&This->cs);
3083 return hr;
3086 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3087 DISPID dispIdMember,
3088 REFIID riid,
3089 LCID lcid,
3090 WORD wFlags,
3091 DISPPARAMS*pDispParams,
3092 VARIANT*pVarResult,
3093 EXCEPINFO*pExepInfo,
3094 UINT*puArgErr) {
3095 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3096 IVideoWindow* pVideoWindow;
3097 HRESULT hr;
3099 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);
3101 EnterCriticalSection(&This->cs);
3103 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3105 if (hr == S_OK)
3106 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3108 LeaveCriticalSection(&This->cs);
3110 return hr;
3114 /*** IVideoWindow methods ***/
3115 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3116 BSTR strCaption) {
3117 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3118 IVideoWindow* pVideoWindow;
3119 HRESULT hr;
3121 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3123 EnterCriticalSection(&This->cs);
3125 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3127 if (hr == S_OK)
3128 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3130 LeaveCriticalSection(&This->cs);
3132 return hr;
3135 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3136 BSTR *strCaption) {
3137 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3138 IVideoWindow* pVideoWindow;
3139 HRESULT hr;
3141 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3143 EnterCriticalSection(&This->cs);
3145 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3147 if (hr == S_OK)
3148 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3150 LeaveCriticalSection(&This->cs);
3152 return hr;
3155 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3156 long WindowStyle) {
3157 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3158 IVideoWindow* pVideoWindow;
3159 HRESULT hr;
3161 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyle);
3163 EnterCriticalSection(&This->cs);
3165 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3167 if (hr == S_OK)
3168 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
3170 LeaveCriticalSection(&This->cs);
3172 return hr;
3175 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
3176 long *WindowStyle) {
3177 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3178 IVideoWindow* pVideoWindow;
3179 HRESULT hr;
3181 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
3183 EnterCriticalSection(&This->cs);
3185 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3187 if (hr == S_OK)
3188 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
3190 LeaveCriticalSection(&This->cs);
3192 return hr;
3195 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
3196 long WindowStyleEx) {
3197 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3198 IVideoWindow* pVideoWindow;
3199 HRESULT hr;
3201 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
3203 EnterCriticalSection(&This->cs);
3205 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3207 if (hr == S_OK)
3208 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
3210 LeaveCriticalSection(&This->cs);
3212 return hr;
3215 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
3216 long *WindowStyleEx) {
3217 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3218 IVideoWindow* pVideoWindow;
3219 HRESULT hr;
3221 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
3223 EnterCriticalSection(&This->cs);
3225 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3227 if (hr == S_OK)
3228 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
3230 LeaveCriticalSection(&This->cs);
3232 return hr;
3235 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
3236 long AutoShow) {
3237 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3238 IVideoWindow* pVideoWindow;
3239 HRESULT hr;
3241 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
3243 EnterCriticalSection(&This->cs);
3245 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3247 if (hr == S_OK)
3248 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
3250 LeaveCriticalSection(&This->cs);
3252 return hr;
3255 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
3256 long *AutoShow) {
3257 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3258 IVideoWindow* pVideoWindow;
3259 HRESULT hr;
3261 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
3263 EnterCriticalSection(&This->cs);
3265 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3267 if (hr == S_OK)
3268 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
3270 LeaveCriticalSection(&This->cs);
3272 return hr;
3275 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
3276 long WindowState) {
3277 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3278 IVideoWindow* pVideoWindow;
3279 HRESULT hr;
3281 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowState);
3283 EnterCriticalSection(&This->cs);
3285 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3287 if (hr == S_OK)
3288 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
3290 LeaveCriticalSection(&This->cs);
3292 return hr;
3295 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
3296 long *WindowState) {
3297 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3298 IVideoWindow* pVideoWindow;
3299 HRESULT hr;
3301 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
3303 EnterCriticalSection(&This->cs);
3305 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3307 if (hr == S_OK)
3308 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
3310 LeaveCriticalSection(&This->cs);
3312 return hr;
3315 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
3316 long BackgroundPalette) {
3317 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3318 IVideoWindow* pVideoWindow;
3319 HRESULT hr;
3321 TRACE("(%p/%p)->(%ld)\n", This, iface, BackgroundPalette);
3323 EnterCriticalSection(&This->cs);
3325 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3327 if (hr == S_OK)
3328 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
3330 LeaveCriticalSection(&This->cs);
3332 return hr;
3335 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
3336 long *pBackgroundPalette) {
3337 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3338 IVideoWindow* pVideoWindow;
3339 HRESULT hr;
3341 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
3343 EnterCriticalSection(&This->cs);
3345 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3347 if (hr == S_OK)
3348 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
3350 LeaveCriticalSection(&This->cs);
3352 return hr;
3355 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
3356 long Visible) {
3357 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3358 IVideoWindow* pVideoWindow;
3359 HRESULT hr;
3361 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
3363 EnterCriticalSection(&This->cs);
3365 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3367 if (hr == S_OK)
3368 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
3370 LeaveCriticalSection(&This->cs);
3372 return hr;
3375 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
3376 long *pVisible) {
3377 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3378 IVideoWindow* pVideoWindow;
3379 HRESULT hr;
3381 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
3383 EnterCriticalSection(&This->cs);
3385 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3387 if (hr == S_OK)
3388 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
3390 LeaveCriticalSection(&This->cs);
3392 return hr;
3395 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
3396 long Left) {
3397 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3398 IVideoWindow* pVideoWindow;
3399 HRESULT hr;
3401 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
3403 EnterCriticalSection(&This->cs);
3405 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3407 if (hr == S_OK)
3408 hr = IVideoWindow_put_Left(pVideoWindow, Left);
3410 LeaveCriticalSection(&This->cs);
3412 return hr;
3415 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
3416 long *pLeft) {
3417 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3418 IVideoWindow* pVideoWindow;
3419 HRESULT hr;
3421 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
3423 EnterCriticalSection(&This->cs);
3425 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3427 if (hr == S_OK)
3428 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
3430 LeaveCriticalSection(&This->cs);
3432 return hr;
3435 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
3436 long Width) {
3437 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3438 IVideoWindow* pVideoWindow;
3439 HRESULT hr;
3441 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
3443 EnterCriticalSection(&This->cs);
3445 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3447 if (hr == S_OK)
3448 hr = IVideoWindow_put_Width(pVideoWindow, Width);
3450 LeaveCriticalSection(&This->cs);
3452 return hr;
3455 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
3456 long *pWidth) {
3457 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3458 IVideoWindow* pVideoWindow;
3459 HRESULT hr;
3461 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
3463 EnterCriticalSection(&This->cs);
3465 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3467 if (hr == S_OK)
3468 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
3470 LeaveCriticalSection(&This->cs);
3472 return hr;
3475 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
3476 long Top) {
3477 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3478 IVideoWindow* pVideoWindow;
3479 HRESULT hr;
3481 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
3483 EnterCriticalSection(&This->cs);
3485 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3487 if (hr == S_OK)
3488 hr = IVideoWindow_put_Top(pVideoWindow, Top);
3490 LeaveCriticalSection(&This->cs);
3492 return hr;
3495 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
3496 long *pTop) {
3497 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3498 IVideoWindow* pVideoWindow;
3499 HRESULT hr;
3501 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
3503 EnterCriticalSection(&This->cs);
3505 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3507 if (hr == S_OK)
3508 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
3510 LeaveCriticalSection(&This->cs);
3512 return hr;
3515 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
3516 long Height) {
3517 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3518 IVideoWindow* pVideoWindow;
3519 HRESULT hr;
3521 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
3523 EnterCriticalSection(&This->cs);
3525 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3527 if (hr == S_OK)
3528 hr = IVideoWindow_put_Height(pVideoWindow, Height);
3530 LeaveCriticalSection(&This->cs);
3532 return hr;
3535 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
3536 long *pHeight) {
3537 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3538 IVideoWindow* pVideoWindow;
3539 HRESULT hr;
3541 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
3543 EnterCriticalSection(&This->cs);
3545 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3547 if (hr == S_OK)
3548 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
3550 LeaveCriticalSection(&This->cs);
3552 return hr;
3555 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
3556 OAHWND Owner) {
3557 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3558 IVideoWindow* pVideoWindow;
3559 HRESULT hr;
3561 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
3563 EnterCriticalSection(&This->cs);
3565 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3567 if (hr == S_OK)
3568 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
3570 LeaveCriticalSection(&This->cs);
3572 return hr;
3575 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
3576 OAHWND *Owner) {
3577 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3578 IVideoWindow* pVideoWindow;
3579 HRESULT hr;
3581 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
3583 EnterCriticalSection(&This->cs);
3585 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3587 if (hr == S_OK)
3588 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
3590 LeaveCriticalSection(&This->cs);
3592 return hr;
3595 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
3596 OAHWND Drain) {
3597 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3598 IVideoWindow* pVideoWindow;
3599 HRESULT hr;
3601 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
3603 EnterCriticalSection(&This->cs);
3605 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3607 if (hr == S_OK)
3608 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
3610 LeaveCriticalSection(&This->cs);
3612 return hr;
3615 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
3616 OAHWND *Drain) {
3617 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3618 IVideoWindow* pVideoWindow;
3619 HRESULT hr;
3621 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
3623 EnterCriticalSection(&This->cs);
3625 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3627 if (hr == S_OK)
3628 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
3630 LeaveCriticalSection(&This->cs);
3632 return hr;
3635 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
3636 long *Color) {
3637 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3638 IVideoWindow* pVideoWindow;
3639 HRESULT hr;
3641 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
3643 EnterCriticalSection(&This->cs);
3645 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3647 if (hr == S_OK)
3648 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
3650 LeaveCriticalSection(&This->cs);
3652 return hr;
3655 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
3656 long Color) {
3657 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3658 IVideoWindow* pVideoWindow;
3659 HRESULT hr;
3661 TRACE("(%p/%p)->(%ld)\n", This, iface, Color);
3663 EnterCriticalSection(&This->cs);
3665 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3667 if (hr == S_OK)
3668 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
3670 LeaveCriticalSection(&This->cs);
3672 return hr;
3675 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
3676 long *FullScreenMode) {
3677 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3678 IVideoWindow* pVideoWindow;
3679 HRESULT hr;
3681 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
3683 EnterCriticalSection(&This->cs);
3685 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3687 if (hr == S_OK)
3688 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
3690 LeaveCriticalSection(&This->cs);
3692 return hr;
3695 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
3696 long FullScreenMode) {
3697 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3698 IVideoWindow* pVideoWindow;
3699 HRESULT hr;
3701 TRACE("(%p/%p)->(%ld)\n", This, iface, FullScreenMode);
3703 EnterCriticalSection(&This->cs);
3705 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3707 if (hr == S_OK)
3708 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
3710 LeaveCriticalSection(&This->cs);
3712 return hr;
3715 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
3716 long Focus) {
3717 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3718 IVideoWindow* pVideoWindow;
3719 HRESULT hr;
3721 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
3723 EnterCriticalSection(&This->cs);
3725 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3727 if (hr == S_OK)
3728 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
3730 LeaveCriticalSection(&This->cs);
3732 return hr;
3735 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
3736 OAHWND hwnd,
3737 long uMsg,
3738 LONG_PTR wParam,
3739 LONG_PTR lParam) {
3740 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3741 IVideoWindow* pVideoWindow;
3742 HRESULT hr;
3744 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
3746 EnterCriticalSection(&This->cs);
3748 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3750 if (hr == S_OK)
3751 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
3753 LeaveCriticalSection(&This->cs);
3755 return hr;
3758 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
3759 long Left,
3760 long Top,
3761 long Width,
3762 long Height) {
3763 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3764 IVideoWindow* pVideoWindow;
3765 HRESULT hr;
3767 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
3769 EnterCriticalSection(&This->cs);
3771 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3773 if (hr == S_OK)
3774 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
3776 LeaveCriticalSection(&This->cs);
3778 return hr;
3781 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
3782 long *pLeft,
3783 long *pTop,
3784 long *pWidth,
3785 long *pHeight) {
3786 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3787 IVideoWindow* pVideoWindow;
3788 HRESULT hr;
3790 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3792 EnterCriticalSection(&This->cs);
3794 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3796 if (hr == S_OK)
3797 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3799 LeaveCriticalSection(&This->cs);
3801 return hr;
3804 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
3805 long *pWidth,
3806 long *pHeight) {
3807 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3808 IVideoWindow* pVideoWindow;
3809 HRESULT hr;
3811 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3813 EnterCriticalSection(&This->cs);
3815 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3817 if (hr == S_OK)
3818 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
3820 LeaveCriticalSection(&This->cs);
3822 return hr;
3825 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
3826 long *pWidth,
3827 long *pHeight) {
3828 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3829 IVideoWindow* pVideoWindow;
3830 HRESULT hr;
3832 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3834 EnterCriticalSection(&This->cs);
3836 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3838 if (hr == S_OK)
3839 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
3841 LeaveCriticalSection(&This->cs);
3843 return hr;
3846 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
3847 long *pLeft,
3848 long *pTop,
3849 long *pWidth,
3850 long *pHeight) {
3851 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3852 IVideoWindow* pVideoWindow;
3853 HRESULT hr;
3855 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3857 EnterCriticalSection(&This->cs);
3859 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3861 if (hr == S_OK)
3862 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
3864 LeaveCriticalSection(&This->cs);
3866 return hr;
3869 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
3870 long HideCursor) {
3871 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3872 IVideoWindow* pVideoWindow;
3873 HRESULT hr;
3875 TRACE("(%p/%p)->(%ld)\n", This, iface, HideCursor);
3877 EnterCriticalSection(&This->cs);
3879 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3881 if (hr == S_OK)
3882 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
3884 LeaveCriticalSection(&This->cs);
3886 return hr;
3889 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
3890 long *CursorHidden) {
3891 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3892 IVideoWindow* pVideoWindow;
3893 HRESULT hr;
3895 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
3897 EnterCriticalSection(&This->cs);
3899 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3901 if (hr == S_OK)
3902 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
3904 LeaveCriticalSection(&This->cs);
3906 return hr;
3910 static const IVideoWindowVtbl IVideoWindow_VTable =
3912 VideoWindow_QueryInterface,
3913 VideoWindow_AddRef,
3914 VideoWindow_Release,
3915 VideoWindow_GetTypeInfoCount,
3916 VideoWindow_GetTypeInfo,
3917 VideoWindow_GetIDsOfNames,
3918 VideoWindow_Invoke,
3919 VideoWindow_put_Caption,
3920 VideoWindow_get_Caption,
3921 VideoWindow_put_WindowStyle,
3922 VideoWindow_get_WindowStyle,
3923 VideoWindow_put_WindowStyleEx,
3924 VideoWindow_get_WindowStyleEx,
3925 VideoWindow_put_AutoShow,
3926 VideoWindow_get_AutoShow,
3927 VideoWindow_put_WindowState,
3928 VideoWindow_get_WindowState,
3929 VideoWindow_put_BackgroundPalette,
3930 VideoWindow_get_BackgroundPalette,
3931 VideoWindow_put_Visible,
3932 VideoWindow_get_Visible,
3933 VideoWindow_put_Left,
3934 VideoWindow_get_Left,
3935 VideoWindow_put_Width,
3936 VideoWindow_get_Width,
3937 VideoWindow_put_Top,
3938 VideoWindow_get_Top,
3939 VideoWindow_put_Height,
3940 VideoWindow_get_Height,
3941 VideoWindow_put_Owner,
3942 VideoWindow_get_Owner,
3943 VideoWindow_put_MessageDrain,
3944 VideoWindow_get_MessageDrain,
3945 VideoWindow_get_BorderColor,
3946 VideoWindow_put_BorderColor,
3947 VideoWindow_get_FullScreenMode,
3948 VideoWindow_put_FullScreenMode,
3949 VideoWindow_SetWindowForeground,
3950 VideoWindow_NotifyOwnerMessage,
3951 VideoWindow_SetWindowPosition,
3952 VideoWindow_GetWindowPosition,
3953 VideoWindow_GetMinIdealImageSize,
3954 VideoWindow_GetMaxIdealImageSize,
3955 VideoWindow_GetRestorePosition,
3956 VideoWindow_HideCursor,
3957 VideoWindow_IsCursorHidden
3961 /*** IUnknown methods ***/
3962 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
3963 REFIID riid,
3964 LPVOID*ppvObj) {
3965 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3967 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3969 return Filtergraph_QueryInterface(This, riid, ppvObj);
3972 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
3973 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3975 TRACE("(%p/%p)->()\n", This, iface);
3977 return Filtergraph_AddRef(This);
3980 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
3981 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3983 TRACE("(%p/%p)->()\n", This, iface);
3985 return Filtergraph_Release(This);
3988 /*** IDispatch methods ***/
3989 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
3990 UINT*pctinfo) {
3991 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
3993 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
3995 return S_OK;
3998 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
3999 UINT iTInfo,
4000 LCID lcid,
4001 ITypeInfo**ppTInfo) {
4002 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4004 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
4006 return S_OK;
4009 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
4010 REFIID riid,
4011 LPOLESTR*rgszNames,
4012 UINT cNames,
4013 LCID lcid,
4014 DISPID*rgDispId) {
4015 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4017 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4019 return S_OK;
4022 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
4023 DISPID dispIdMember,
4024 REFIID riid,
4025 LCID lcid,
4026 WORD wFlags,
4027 DISPPARAMS*pDispParams,
4028 VARIANT*pVarResult,
4029 EXCEPINFO*pExepInfo,
4030 UINT*puArgErr) {
4031 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4033 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);
4035 return S_OK;
4038 /*** IMediaEvent methods ***/
4039 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4040 OAEVENT *hEvent) {
4041 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4043 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4045 *hEvent = (OAEVENT)This->evqueue.msg_event;
4047 return S_OK;
4050 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4051 long *lEventCode,
4052 LONG_PTR *lParam1,
4053 LONG_PTR *lParam2,
4054 long msTimeout) {
4055 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4056 Event evt;
4058 TRACE("(%p/%p)->(%p, %p, %p, %ld)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4060 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4062 *lEventCode = evt.lEventCode;
4063 *lParam1 = evt.lParam1;
4064 *lParam2 = evt.lParam2;
4065 return S_OK;
4068 *lEventCode = 0;
4069 return E_ABORT;
4072 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4073 long msTimeout,
4074 long *pEvCode) {
4075 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4077 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, msTimeout, pEvCode);
4079 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4081 *pEvCode = This->CompletionStatus;
4082 return S_OK;
4085 *pEvCode = 0;
4086 return E_ABORT;
4089 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4090 long lEvCode) {
4091 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4093 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4095 if (lEvCode == EC_COMPLETE)
4096 This->HandleEcComplete = FALSE;
4097 else if (lEvCode == EC_REPAINT)
4098 This->HandleEcRepaint = FALSE;
4099 else
4100 return S_FALSE;
4102 return S_OK;
4105 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4106 long lEvCode) {
4107 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4109 TRACE("(%p/%p)->(%ld)\n", This, iface, lEvCode);
4111 if (lEvCode == EC_COMPLETE)
4112 This->HandleEcComplete = TRUE;
4113 else if (lEvCode == EC_REPAINT)
4114 This->HandleEcRepaint = TRUE;
4115 else
4116 return S_FALSE;
4118 return S_OK;
4121 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4122 long lEvCode,
4123 LONG_PTR lParam1,
4124 LONG_PTR lParam2) {
4125 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4127 TRACE("(%p/%p)->(%ld, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4129 return S_OK;
4132 /*** IMediaEventEx methods ***/
4133 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4134 OAHWND hwnd,
4135 long lMsg,
4136 LONG_PTR lInstanceData) {
4137 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4139 TRACE("(%p/%p)->(%08x, %ld, %08lx)\n", This, iface, (DWORD) hwnd, lMsg, lInstanceData);
4141 This->notif.hWnd = (HWND)hwnd;
4142 This->notif.msg = lMsg;
4143 This->notif.instance = (long) lInstanceData;
4145 return S_OK;
4148 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4149 long lNoNotifyFlags) {
4150 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4152 TRACE("(%p/%p)->(%ld)\n", This, iface, lNoNotifyFlags);
4154 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4155 return E_INVALIDARG;
4157 This->notif.disabled = lNoNotifyFlags;
4159 return S_OK;
4162 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
4163 long *lplNoNotifyFlags) {
4164 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4166 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
4168 if (!lplNoNotifyFlags)
4169 return E_POINTER;
4171 *lplNoNotifyFlags = This->notif.disabled;
4173 return S_OK;
4177 static const IMediaEventExVtbl IMediaEventEx_VTable =
4179 MediaEvent_QueryInterface,
4180 MediaEvent_AddRef,
4181 MediaEvent_Release,
4182 MediaEvent_GetTypeInfoCount,
4183 MediaEvent_GetTypeInfo,
4184 MediaEvent_GetIDsOfNames,
4185 MediaEvent_Invoke,
4186 MediaEvent_GetEventHandle,
4187 MediaEvent_GetEvent,
4188 MediaEvent_WaitForCompletion,
4189 MediaEvent_CancelDefaultHandling,
4190 MediaEvent_RestoreDefaultHandling,
4191 MediaEvent_FreeEventParams,
4192 MediaEvent_SetNotifyWindow,
4193 MediaEvent_SetNotifyFlags,
4194 MediaEvent_GetNotifyFlags
4198 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
4200 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4202 return Filtergraph_QueryInterface(This, riid, ppv);
4205 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
4207 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4209 return Filtergraph_AddRef(This);
4212 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
4214 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
4216 return Filtergraph_Release(This);
4219 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
4221 FIXME("(%p): stub\n", pClassID);
4223 return E_NOTIMPL;
4226 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
4228 FIXME("(): stub\n");
4230 return E_NOTIMPL;
4233 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
4235 FIXME("(): stub\n");
4237 return E_NOTIMPL;
4240 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
4242 FIXME("(0x%s): stub\n", wine_dbgstr_longlong(tStart));
4244 return E_NOTIMPL;
4247 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
4249 FIXME("(%d, %p): stub\n", dwMsTimeout, pState);
4251 return E_NOTIMPL;
4254 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
4256 FIXME("(%p): stub\n", pClock);
4258 return E_NOTIMPL;
4261 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
4263 FIXME("(%p): stub\n", ppClock);
4265 return E_NOTIMPL;
4268 static const IMediaFilterVtbl IMediaFilter_VTable =
4270 MediaFilter_QueryInterface,
4271 MediaFilter_AddRef,
4272 MediaFilter_Release,
4273 MediaFilter_GetClassID,
4274 MediaFilter_Stop,
4275 MediaFilter_Pause,
4276 MediaFilter_Run,
4277 MediaFilter_GetState,
4278 MediaFilter_SetSyncSource,
4279 MediaFilter_GetSyncSource
4282 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
4284 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4286 return Filtergraph_QueryInterface(This, riid, ppv);
4289 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
4291 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4293 return Filtergraph_AddRef(This);
4296 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
4298 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4300 return Filtergraph_Release(This);
4303 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
4305 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4306 Event evt;
4308 TRACE("(%p/%p)->(%ld, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
4310 /* We need thread safety here, let's use the events queue's one */
4311 EnterCriticalSection(&This->evqueue.msg_crst);
4313 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
4315 TRACE("Process EC_COMPLETE notification\n");
4316 if (++This->EcCompleteCount == This->nRenderers)
4318 evt.lEventCode = EC_COMPLETE;
4319 evt.lParam1 = S_OK;
4320 evt.lParam2 = 0;
4321 TRACE("Send EC_COMPLETE to app\n");
4322 EventsQueue_PutEvent(&This->evqueue, &evt);
4323 if (!This->notif.disabled && This->notif.hWnd)
4325 TRACE("Send Window message\n");
4326 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4328 This->CompletionStatus = EC_COMPLETE;
4329 SetEvent(This->hEventCompletion);
4332 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
4334 /* FIXME: Not handled yet */
4336 else
4338 evt.lEventCode = EventCode;
4339 evt.lParam1 = EventParam1;
4340 evt.lParam2 = EventParam2;
4341 EventsQueue_PutEvent(&This->evqueue, &evt);
4342 if (!This->notif.disabled && This->notif.hWnd)
4343 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
4346 LeaveCriticalSection(&This->evqueue.msg_crst);
4347 return S_OK;
4350 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
4352 MediaEventSink_QueryInterface,
4353 MediaEventSink_AddRef,
4354 MediaEventSink_Release,
4355 MediaEventSink_Notify
4358 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
4360 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4362 return Filtergraph_QueryInterface(This, riid, ppv);
4365 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
4367 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
4369 return Filtergraph_AddRef(This);
4372 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
4374 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4376 return Filtergraph_Release(This);
4379 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
4380 IPin* pOutputPin,
4381 IPin* pInputPin,
4382 const AM_MEDIA_TYPE* pmtFirstConnection,
4383 IBaseFilter* pUsingFilter,
4384 HANDLE hAbortEvent,
4385 DWORD dwFlags)
4387 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4389 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
4391 return E_NOTIMPL;
4394 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
4395 IGraphConfigCallback* pCallback,
4396 PVOID pvContext,
4397 DWORD dwFlags,
4398 HANDLE hAbortEvent)
4400 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4402 FIXME("(%p)->(%p, %p, %x, %p): stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
4404 return E_NOTIMPL;
4407 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
4408 IBaseFilter* pFilter)
4410 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4412 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4414 return E_NOTIMPL;
4417 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
4418 IEnumFilters** pEnum)
4420 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4422 FIXME("(%p)->(%p): stub!\n", This, pEnum);
4424 return E_NOTIMPL;
4427 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
4428 IBaseFilter* pFilter)
4430 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4432 FIXME("(%p)->(%p): stub!\n", This, pFilter);
4434 return E_NOTIMPL;
4437 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
4438 REFERENCE_TIME* prtStart)
4440 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4442 FIXME("(%p)->(%p): stub!\n", This, prtStart);
4444 return E_NOTIMPL;
4447 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
4448 IPin* pOutputPin,
4449 IPinConnection* pConnection,
4450 HANDLE hEventAbort)
4452 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4454 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
4456 return E_NOTIMPL;
4459 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
4460 IBaseFilter* pFilter,
4461 DWORD dwFlags)
4463 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4465 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4467 return E_NOTIMPL;
4470 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
4471 IBaseFilter* pFilter,
4472 DWORD* dwFlags)
4474 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4476 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
4478 return E_NOTIMPL;
4481 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
4482 IBaseFilter* pFilter,
4483 DWORD dwFlags)
4485 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
4487 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
4489 return E_NOTIMPL;
4492 static const IGraphConfigVtbl IGraphConfig_VTable =
4494 GraphConfig_QueryInterface,
4495 GraphConfig_AddRef,
4496 GraphConfig_Release,
4497 GraphConfig_Reconnect,
4498 GraphConfig_Reconfigure,
4499 GraphConfig_AddFilterToCache,
4500 GraphConfig_EnumCacheFilter,
4501 GraphConfig_RemoveFilterFromCache,
4502 GraphConfig_GetStartTime,
4503 GraphConfig_PushThroughData,
4504 GraphConfig_SetFilterFlags,
4505 GraphConfig_GetFilterFlags,
4506 GraphConfig_RemoveFilterEx
4509 /* This is the only function that actually creates a FilterGraph class... */
4510 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4512 IFilterGraphImpl *fimpl;
4513 HRESULT hr;
4515 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
4517 if( pUnkOuter )
4518 return CLASS_E_NOAGGREGATION;
4520 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
4521 fimpl->IGraphBuilder_vtbl = &IGraphBuilder_VTable;
4522 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
4523 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
4524 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
4525 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
4526 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
4527 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
4528 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
4529 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
4530 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
4531 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
4532 fimpl->ref = 1;
4533 fimpl->ppFiltersInGraph = NULL;
4534 fimpl->pFilterNames = NULL;
4535 fimpl->nFilters = 0;
4536 fimpl->filterCapacity = 0;
4537 fimpl->nameIndex = 1;
4538 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
4539 fimpl->HandleEcComplete = TRUE;
4540 fimpl->HandleEcRepaint = TRUE;
4541 fimpl->notif.hWnd = 0;
4542 fimpl->notif.disabled = FALSE;
4543 fimpl->nRenderers = 0;
4544 fimpl->EcCompleteCount = 0;
4545 fimpl->state = State_Stopped;
4546 EventsQueue_Init(&fimpl->evqueue);
4547 InitializeCriticalSection(&fimpl->cs);
4548 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
4549 fimpl->nItfCacheEntries = 0;
4551 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
4552 if (FAILED(hr)) {
4553 ERR("Unable to create filter mapper (%x)\n", hr);
4554 return hr;
4557 *ppObj = fimpl;
4558 return S_OK;
4561 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
4563 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
4564 return FilterGraph_create(pUnkOuter, ppObj);