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
35 #include "wine/debug.h"
36 #include "quartz_private.h"
42 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
48 HWND hWnd; /* Target window */
49 UINT msg; /* User window message */
50 LONG_PTR instance; /* User data */
51 int disabled; /* Disabled messages posting */
55 LONG lEventCode; /* Event code */
56 LONG_PTR lParam1; /* Param1 */
57 LONG_PTR lParam2; /* Param2 */
60 /* messages ring implementation for queuing events (taken from winmm) */
61 #define EVENTS_RING_BUFFER_INCREMENT 64
67 CRITICAL_SECTION msg_crst;
68 HANDLE msg_event; /* Signaled for no empty queue */
71 static int EventsQueue_Init(EventsQueue* omr)
75 omr->msg_event = CreateEventW(NULL, TRUE, FALSE, NULL);
76 omr->ring_buffer_size = EVENTS_RING_BUFFER_INCREMENT;
77 omr->messages = CoTaskMemAlloc(omr->ring_buffer_size * sizeof(Event));
78 ZeroMemory(omr->messages, omr->ring_buffer_size * sizeof(Event));
80 InitializeCriticalSection(&omr->msg_crst);
81 omr->msg_crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": EventsQueue.msg_crst");
85 static int EventsQueue_Destroy(EventsQueue* omr)
87 CloseHandle(omr->msg_event);
88 CoTaskMemFree(omr->messages);
89 omr->msg_crst.DebugInfo->Spare[0] = 0;
90 DeleteCriticalSection(&omr->msg_crst);
94 static int EventsQueue_PutEvent(EventsQueue* omr, const Event* evt)
96 EnterCriticalSection(&omr->msg_crst);
97 if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
99 int old_ring_buffer_size = omr->ring_buffer_size;
100 omr->ring_buffer_size += EVENTS_RING_BUFFER_INCREMENT;
101 TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
102 omr->messages = CoTaskMemRealloc(omr->messages, omr->ring_buffer_size * sizeof(Event));
103 /* Now we need to rearrange the ring buffer so that the new
104 buffers just allocated are in between omr->msg_tosave and
107 if (omr->msg_tosave < omr->msg_toget)
109 memmove(&(omr->messages[omr->msg_toget + EVENTS_RING_BUFFER_INCREMENT]),
110 &(omr->messages[omr->msg_toget]),
111 sizeof(Event)*(old_ring_buffer_size - omr->msg_toget)
113 omr->msg_toget += EVENTS_RING_BUFFER_INCREMENT;
116 omr->messages[omr->msg_tosave] = *evt;
117 SetEvent(omr->msg_event);
118 omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
119 LeaveCriticalSection(&omr->msg_crst);
123 static int EventsQueue_GetEvent(EventsQueue* omr, Event* evt, LONG msTimeOut)
125 if (WaitForSingleObject(omr->msg_event, msTimeOut) != WAIT_OBJECT_0)
128 EnterCriticalSection(&omr->msg_crst);
130 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
132 LeaveCriticalSection(&omr->msg_crst);
136 *evt = omr->messages[omr->msg_toget];
137 omr->msg_toget = (omr->msg_toget + 1) % omr->ring_buffer_size;
139 /* Mark the buffer as empty if needed */
140 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
141 ResetEvent(omr->msg_event);
143 LeaveCriticalSection(&omr->msg_crst);
147 #define MAX_ITF_CACHE_ENTRIES 3
148 typedef struct _ITF_CACHE_ENTRY {
154 typedef struct _IFilterGraphImpl {
155 const IFilterGraph2Vtbl *IFilterGraph2_vtbl;
156 const IMediaControlVtbl *IMediaControl_vtbl;
157 const IMediaSeekingVtbl *IMediaSeeking_vtbl;
158 const IBasicAudioVtbl *IBasicAudio_vtbl;
159 const IBasicVideo2Vtbl *IBasicVideo_vtbl;
160 const IVideoWindowVtbl *IVideoWindow_vtbl;
161 const IMediaEventExVtbl *IMediaEventEx_vtbl;
162 const IMediaFilterVtbl *IMediaFilter_vtbl;
163 const IMediaEventSinkVtbl *IMediaEventSink_vtbl;
164 const IGraphConfigVtbl *IGraphConfig_vtbl;
165 const IMediaPositionVtbl *IMediaPosition_vtbl;
166 const IUnknownVtbl * IInner_vtbl;
167 /* IAMGraphStreams */
173 /* IRegisterServiceProvider */
174 /* IResourceMananger */
175 /* IServiceProvider */
176 /* IVideoFrameStep */
179 IUnknown *punkFilterMapper2;
180 IFilterMapper2 * pFilterMapper2;
181 IBaseFilter ** ppFiltersInGraph;
182 LPWSTR * pFilterNames;
186 IReferenceClock *refClock;
188 HANDLE hEventCompletion;
189 int CompletionStatus;
193 int HandleEcComplete;
195 int HandleEcClockChanged;
198 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
199 int nItfCacheEntries;
200 IUnknown * pUnkOuter;
205 REFERENCE_TIME start_time;
206 REFERENCE_TIME pause_time;
207 LONGLONG stop_position;
211 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
212 REFIID riid, LPVOID * ppv);
213 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This);
214 static ULONG Filtergraph_Release(IFilterGraphImpl *This);
216 static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown * iface,
219 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
220 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
222 if (This->bAggregatable)
223 This->bUnkOuterValid = TRUE;
225 if (IsEqualGUID(&IID_IUnknown, riid)) {
226 *ppvObj = &(This->IInner_vtbl);
227 TRACE(" returning IUnknown interface (%p)\n", *ppvObj);
228 } else if (IsEqualGUID(&IID_IFilterGraph, riid) ||
229 IsEqualGUID(&IID_IFilterGraph2, riid) ||
230 IsEqualGUID(&IID_IGraphBuilder, riid)) {
231 *ppvObj = &(This->IFilterGraph2_vtbl);
232 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
233 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
234 *ppvObj = &(This->IMediaControl_vtbl);
235 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
236 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
237 *ppvObj = &(This->IMediaSeeking_vtbl);
238 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
239 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
240 *ppvObj = &(This->IBasicAudio_vtbl);
241 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
242 } else if (IsEqualGUID(&IID_IBasicVideo, riid) ||
243 IsEqualGUID(&IID_IBasicVideo2, riid)) {
244 *ppvObj = &(This->IBasicVideo_vtbl);
245 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj);
246 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
247 *ppvObj = &(This->IVideoWindow_vtbl);
248 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
249 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
250 IsEqualGUID(&IID_IMediaEventEx, riid)) {
251 *ppvObj = &(This->IMediaEventEx_vtbl);
252 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
253 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
254 IsEqualGUID(&IID_IPersist, riid)) {
255 *ppvObj = &(This->IMediaFilter_vtbl);
256 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
257 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
258 *ppvObj = &(This->IMediaEventSink_vtbl);
259 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
260 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
261 *ppvObj = &(This->IGraphConfig_vtbl);
262 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
263 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
264 *ppvObj = &(This->IMediaPosition_vtbl);
265 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
266 } else if (IsEqualGUID(&IID_IFilterMapper, riid)) {
267 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj);
268 return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
269 } else if (IsEqualGUID(&IID_IFilterMapper2, riid)) {
270 *ppvObj = This->pFilterMapper2;
271 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj);
272 } else if (IsEqualGUID(&IID_IFilterMapper3, riid)) {
273 *ppvObj = This->pFilterMapper2;
274 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
277 FIXME("unknown interface %s\n", debugstr_guid(riid));
278 return E_NOINTERFACE;
281 IUnknown_AddRef((IUnknown *)(*ppvObj));
285 static ULONG WINAPI FilterGraphInner_AddRef(IUnknown * iface) {
286 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
287 ULONG ref = InterlockedIncrement(&This->ref);
289 TRACE("(%p)->(): new ref = %d\n", This, ref);
294 static ULONG WINAPI FilterGraphInner_Release(IUnknown * iface)
296 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
297 ULONG ref = InterlockedDecrement(&This->ref);
299 TRACE("(%p)->(): new ref = %d\n", This, ref);
304 This->ref = 1; /* guard against reentrancy (aggregation). */
306 IMediaControl_Stop((IMediaControl*)&(This->IMediaControl_vtbl));
308 while (This->nFilters)
309 IFilterGraph2_RemoveFilter((IFilterGraph2*)This, This->ppFiltersInGraph[0]);
312 IReferenceClock_Release(This->refClock);
314 for (i = 0; i < This->nItfCacheEntries; i++)
316 if (This->ItfCacheEntries[i].iface)
317 IUnknown_Release(This->ItfCacheEntries[i].iface);
320 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 interface below.
322 * NOTE: Filtergraph_AddRef isn't suitable, because bUnkOuterValid may be FALSE but punkOuter non-NULL
323 * and already passed as punkOuter to filtermapper in FilterGraph_create - this will happen in case of
324 * CoCreateInstance of filtergraph with non-null pUnkOuter and REFIID other than IID_Unknown that is
325 * cleaning up after error. */
326 if (This->pUnkOuter) IUnknown_AddRef(This->pUnkOuter);
327 else IUnknown_AddRef((IUnknown*)&This->IInner_vtbl);
329 IFilterMapper2_Release(This->pFilterMapper2);
330 IUnknown_Release(This->punkFilterMapper2);
332 CloseHandle(This->hEventCompletion);
333 EventsQueue_Destroy(&This->evqueue);
334 This->cs.DebugInfo->Spare[0] = 0;
335 DeleteCriticalSection(&This->cs);
336 CoTaskMemFree(This->ppFiltersInGraph);
337 CoTaskMemFree(This->pFilterNames);
344 /*** IUnknown methods ***/
345 static HRESULT WINAPI FilterGraph2_QueryInterface(IFilterGraph2 *iface,
348 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
350 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
351 return Filtergraph_QueryInterface(This, riid, ppvObj);
354 static ULONG WINAPI FilterGraph2_AddRef(IFilterGraph2 *iface) {
355 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
357 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
359 return Filtergraph_AddRef(This);
362 static ULONG WINAPI FilterGraph2_Release(IFilterGraph2 *iface) {
363 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
365 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
367 return Filtergraph_Release(This);
370 /*** IFilterGraph methods ***/
371 static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface,
372 IBaseFilter *pFilter,
374 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
377 WCHAR* wszFilterName = NULL;
378 int duplicate_name = FALSE;
380 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
385 wszFilterName = CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
389 /* Check if name already exists */
390 for(i = 0; i < This->nFilters; i++)
391 if (!strcmpW(This->pFilterNames[i], pName))
393 duplicate_name = TRUE;
398 /* If no name given or name already existing, generate one */
399 if (!pName || duplicate_name)
401 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
402 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
404 for (j = 0; j < 10000 ; j++)
408 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
410 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
411 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
413 /* Check if the generated name already exists */
414 for(i = 0; i < This->nFilters; i++)
415 if (!strcmpW(This->pFilterNames[i], wszFilterName))
418 /* Compute next index and exit if generated name is suitable */
419 if (This->nameIndex++ == 10000)
421 if (i == This->nFilters)
424 /* Unable to find a suitable name */
427 CoTaskMemFree(wszFilterName);
428 return VFW_E_DUPLICATE_NAME;
432 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
434 if (This->nFilters + 1 > This->filterCapacity)
436 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
437 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
438 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
439 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
440 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
441 if (This->filterCapacity)
443 CoTaskMemFree(This->ppFiltersInGraph);
444 CoTaskMemFree(This->pFilterNames);
446 This->ppFiltersInGraph = ppNewFilters;
447 This->pFilterNames = pNewNames;
448 This->filterCapacity = newCapacity;
451 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
455 IBaseFilter_AddRef(pFilter);
456 This->ppFiltersInGraph[This->nFilters] = pFilter;
457 This->pFilterNames[This->nFilters] = wszFilterName;
459 IBaseFilter_SetSyncSource(pFilter, This->refClock);
462 CoTaskMemFree(wszFilterName);
464 if (SUCCEEDED(hr) && duplicate_name)
465 return VFW_S_DUPLICATE_NAME;
470 static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface, IBaseFilter *pFilter)
472 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
476 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
478 /* FIXME: check graph is stopped */
480 for (i = 0; i < This->nFilters; i++)
482 if (This->ppFiltersInGraph[i] == pFilter)
484 IEnumPins *penumpins = NULL;
487 TRACE("Removing filter %s\n", debugstr_w(This->pFilterNames[i]));
488 IBaseFilter_GetState(pFilter, 0, &state);
489 if (state == State_Running)
490 IBaseFilter_Pause(pFilter);
491 if (state != State_Stopped)
492 IBaseFilter_Stop(pFilter);
494 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
497 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK)
501 IPin_ConnectedTo(ppin, &victim);
504 h = IPin_Disconnect(victim);
505 TRACE("Disconnect other side: %08x\n", h);
506 if (h == VFW_E_NOT_STOPPED)
509 IPin_QueryPinInfo(victim, &pinfo);
511 IBaseFilter_GetState(pinfo.pFilter, 0, &state);
512 if (state == State_Running)
513 IBaseFilter_Pause(pinfo.pFilter);
514 IBaseFilter_Stop(pinfo.pFilter);
515 IBaseFilter_Release(pinfo.pFilter);
516 h = IPin_Disconnect(victim);
517 TRACE("Disconnect retry: %08x\n", h);
519 IPin_Release(victim);
521 h = IPin_Disconnect(ppin);
522 TRACE("Disconnect 2: %08x\n", h);
526 IEnumPins_Release(penumpins);
529 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
532 IBaseFilter_SetSyncSource(pFilter, NULL);
533 IBaseFilter_Release(pFilter);
534 CoTaskMemFree(This->pFilterNames[i]);
535 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
536 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
538 /* Invalidate interfaces in the cache */
539 for (i = 0; i < This->nItfCacheEntries; i++)
540 if (pFilter == This->ItfCacheEntries[i].filter)
542 IUnknown_Release(This->ItfCacheEntries[i].iface);
543 This->ItfCacheEntries[i].iface = NULL;
544 This->ItfCacheEntries[i].filter = NULL;
552 return hr; /* FIXME: check this error code */
555 static HRESULT WINAPI FilterGraph2_EnumFilters(IFilterGraph2 *iface,
556 IEnumFilters **ppEnum) {
557 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
559 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
561 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
564 static HRESULT WINAPI FilterGraph2_FindFilterByName(IFilterGraph2 *iface,
566 IBaseFilter **ppFilter) {
567 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
570 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
575 for (i = 0; i < This->nFilters; i++)
577 if (!strcmpW(pName, This->pFilterNames[i]))
579 *ppFilter = This->ppFiltersInGraph[i];
580 IBaseFilter_AddRef(*ppFilter);
586 return VFW_E_NOT_FOUND;
589 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
590 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
592 static HRESULT CheckCircularConnection(IFilterGraphImpl *This, IPin *out, IPin *in)
596 PIN_INFO info_out, info_in;
598 hr = IPin_QueryPinInfo(out, &info_out);
601 if (info_out.dir != PINDIR_OUTPUT)
603 IBaseFilter_Release(info_out.pFilter);
607 hr = IPin_QueryPinInfo(in, &info_in);
609 IBaseFilter_Release(info_in.pFilter);
612 if (info_in.dir != PINDIR_INPUT)
618 if (info_out.pFilter == info_in.pFilter)
619 hr = VFW_E_CIRCULAR_GRAPH;
625 hr = IBaseFilter_EnumPins(info_out.pFilter, &enumpins);
629 IEnumPins_Reset(enumpins);
630 while ((hr = IEnumPins_Next(enumpins, 1, &test, NULL)) == S_OK)
632 PIN_DIRECTION dir = PINDIR_OUTPUT;
633 IPin_QueryDirection(test, &dir);
634 if (dir == PINDIR_INPUT)
637 IPin_ConnectedTo(test, &victim);
640 hr = CheckCircularConnection(This, victim, in);
641 IPin_Release(victim);
651 IEnumPins_Release(enumpins);
655 IBaseFilter_Release(info_out.pFilter);
657 ERR("Checking filtergraph returned %08x, something's not right!\n", hr);
660 /* Debugging filtergraphs not enabled */
666 /* NOTE: despite the implication, it doesn't matter which
667 * way round you put in the input and output pins */
668 static HRESULT WINAPI FilterGraph2_ConnectDirect(IFilterGraph2 *iface,
671 const AM_MEDIA_TYPE *pmt) {
675 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
677 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
679 /* FIXME: check pins are in graph */
681 if (TRACE_ON(quartz))
685 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
689 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
690 IBaseFilter_Release(PinInfo.pFilter);
692 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
696 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
697 IBaseFilter_Release(PinInfo.pFilter);
700 hr = IPin_QueryDirection(ppinIn, &dir);
703 if (dir == PINDIR_INPUT)
705 hr = CheckCircularConnection(This, ppinOut, ppinIn);
707 hr = IPin_Connect(ppinOut, ppinIn, pmt);
711 hr = CheckCircularConnection(This, ppinIn, ppinOut);
713 hr = IPin_Connect(ppinIn, ppinOut, pmt);
720 static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface,
722 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
723 IPin *pConnectedTo = NULL;
725 PIN_DIRECTION pindir;
727 IPin_QueryDirection(ppin, &pindir);
728 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
730 TRACE("Querying connected to failed: %x\n", hr);
733 IPin_Disconnect(ppin);
734 IPin_Disconnect(pConnectedTo);
735 if (pindir == PINDIR_INPUT)
736 hr = IPin_Connect(pConnectedTo, ppin, NULL);
738 hr = IPin_Connect(ppin, pConnectedTo, NULL);
739 IPin_Release(pConnectedTo);
741 WARN("Reconnecting pins failed, pins are not connected now..\n");
742 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
746 static HRESULT WINAPI FilterGraph2_Disconnect(IFilterGraph2 *iface, IPin *ppin)
748 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
750 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
755 return IPin_Disconnect(ppin);
758 static HRESULT WINAPI FilterGraph2_SetDefaultSyncSource(IFilterGraph2 *iface) {
759 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
760 IReferenceClock *pClock = NULL;
764 TRACE("(%p/%p)->() live sources not handled properly!\n", iface, This);
766 EnterCriticalSection(&This->cs);
768 for (i = 0; i < This->nFilters; ++i)
771 IAMFilterMiscFlags *flags = NULL;
772 IUnknown_QueryInterface(This->ppFiltersInGraph[i], &IID_IAMFilterMiscFlags, (void**)&flags);
775 miscflags = IAMFilterMiscFlags_GetMiscFlags(flags);
776 IUnknown_Release(flags);
777 if (miscflags == AM_FILTER_MISC_FLAGS_IS_RENDERER)
778 IUnknown_QueryInterface(This->ppFiltersInGraph[i], &IID_IReferenceClock, (void**)&pClock);
784 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pClock);
788 hr = IMediaFilter_SetSyncSource((IMediaFilter*)&(This->IMediaFilter_vtbl), pClock);
789 This->defaultclock = TRUE;
790 IReferenceClock_Release(pClock);
792 LeaveCriticalSection(&This->cs);
797 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
799 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
800 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
801 IPropertyBag * pPropBagCat = NULL;
806 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
809 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
812 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
817 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
820 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
823 IPropertyBag_Release(pPropBagCat);
828 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
833 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
834 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
837 } else if (hr == S_FALSE) {
838 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
839 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
841 WARN("Error (%x)\n", hr);
843 } else if (hr == E_NOTIMPL) {
844 /* Input connected to all outputs */
845 IEnumPins* penumpins;
848 TRACE("E_NOTIMPL\n");
849 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
851 WARN("filter Enumpins failed (%x)\n", hr);
855 /* Count output pins */
856 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
857 PIN_DIRECTION pindir;
858 IPin_QueryDirection(ppin, &pindir);
859 if (pindir == PINDIR_OUTPUT)
863 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
864 /* Retrieve output pins */
865 IEnumPins_Reset(penumpins);
867 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
868 PIN_DIRECTION pindir;
869 IPin_QueryDirection(ppin, &pindir);
870 if (pindir == PINDIR_OUTPUT)
871 (*pppins)[i++] = ppin;
875 IEnumPins_Release(penumpins);
878 WARN("Next failed (%x)\n", hr);
881 } else if (FAILED(hr)) {
882 WARN("Cannot get internal connection (%x)\n", hr);
890 /*** IGraphBuilder methods ***/
891 static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, IPin *ppinIn)
893 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
895 AM_MEDIA_TYPE* mt = NULL;
896 IEnumMediaTypes* penummt = NULL;
898 IEnumPins* penumpins;
899 IEnumMoniker* pEnumMoniker;
908 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
910 if (TRACE_ON(quartz))
912 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
916 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
917 IBaseFilter_Release(PinInfo.pFilter);
919 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
923 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
924 IBaseFilter_Release(PinInfo.pFilter);
927 EnterCriticalSection(&This->cs);
928 ++This->recursioncount;
929 if (This->recursioncount >= 5)
931 WARN("Recursion count has reached %d\n", This->recursioncount);
932 hr = VFW_E_CANNOT_CONNECT;
936 hr = IPin_QueryDirection(ppinOut, &dir);
940 if (dir == PINDIR_INPUT)
949 hr = CheckCircularConnection(This, ppinOut, ppinIn);
953 /* Try direct connection first */
954 hr = IPin_Connect(ppinOut, ppinIn, NULL);
958 TRACE("Direct connection failed, trying to render using extra filters\n");
960 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
964 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
965 IBaseFilter_Release(PinInfo.pFilter);
969 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
970 * filter to the minor mediatype of input pin of the renderer */
971 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
974 WARN("EnumMediaTypes (%x)\n", hr);
978 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
980 WARN("IEnumMediaTypes_Next (%x)\n", hr);
986 WARN("No media type found!\n");
987 hr = VFW_E_INVALIDMEDIATYPE;
990 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
991 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
993 /* Try to find a suitable filter that can connect to the pin to render */
994 tab[0] = mt->majortype;
995 tab[1] = mt->subtype;
996 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
998 WARN("Unable to enum filters (%x)\n", hr);
1002 hr = VFW_E_CANNOT_RENDER;
1003 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1008 IPin* ppinfilter = NULL;
1009 IBaseFilter* pfilter = NULL;
1011 hr = GetFilterInfo(pMoniker, &clsid, &var);
1012 IMoniker_Release(pMoniker);
1014 WARN("Unable to retrieve filter info (%x)\n", hr);
1018 if (IsEqualGUID(&clsid, &FilterCLSID)) {
1019 /* Skip filter (same as the one the output pin belongs to) */
1023 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
1025 WARN("Unable to create filter (%x), trying next one\n", hr);
1029 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1031 WARN("Unable to add filter (%x)\n", hr);
1032 IBaseFilter_Release(pfilter);
1039 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1041 WARN("Enumpins (%x)\n", hr);
1045 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
1046 IEnumPins_Release(penumpins);
1049 WARN("Obtaining next pin: (%x)\n", hr);
1053 WARN("Cannot use this filter: no pins\n");
1057 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1059 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1062 TRACE("Successfully connected to filter, follow chain...\n");
1064 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1065 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
1067 if (SUCCEEDED(hr)) {
1070 IPin_Disconnect(ppinfilter);
1071 IPin_Disconnect(ppinOut);
1074 TRACE("pins to consider: %d\n", nb);
1075 for(i = 0; i < nb; i++)
1077 LPWSTR pinname = NULL;
1079 TRACE("Processing pin %u\n", i);
1081 hr = IPin_QueryId(ppins[i], &pinname);
1084 if (pinname[0] == '~')
1086 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname));
1090 hr = IFilterGraph2_Connect(iface, ppins[i], ppinIn);
1091 CoTaskMemFree(pinname);
1095 TRACE("Cannot connect pin %p (%x)\n", ppinfilter, hr);
1097 IPin_Release(ppins[i]);
1098 if (SUCCEEDED(hr)) break;
1100 while (++i < nb) IPin_Release(ppins[i]);
1101 CoTaskMemFree(ppins);
1102 IPin_Release(ppinfilter);
1103 IBaseFilter_Release(pfilter);
1106 IPin_Disconnect(ppinfilter);
1107 IPin_Disconnect(ppinOut);
1108 IFilterGraph2_RemoveFilter(iface, pfilter);
1116 if (ppinfilter) IPin_Release(ppinfilter);
1118 IFilterGraph2_RemoveFilter(iface, pfilter);
1119 IBaseFilter_Release(pfilter);
1125 IEnumMediaTypes_Release(penummt);
1127 DeleteMediaType(mt);
1128 --This->recursioncount;
1129 LeaveCriticalSection(&This->cs);
1130 TRACE("--> %08x\n", hr);
1131 return SUCCEEDED(hr) ? S_OK : hr;
1134 static HRESULT FilterGraph2_RenderRecurse(IFilterGraphImpl *This, IPin *ppinOut)
1136 /* This pin has been connected now, try to call render on all pins that aren't connected */
1139 IEnumPins *enumpins = NULL;
1140 BOOL renderany = FALSE;
1141 BOOL renderall = TRUE;
1143 IPin_QueryPinInfo(ppinOut, &info);
1145 IBaseFilter_EnumPins(info.pFilter, &enumpins);
1146 /* Don't need to hold a reference, IEnumPins does */
1147 IBaseFilter_Release(info.pFilter);
1149 IEnumPins_Reset(enumpins);
1150 while (IEnumPins_Next(enumpins, 1, &to, NULL) == S_OK)
1152 PIN_DIRECTION dir = PINDIR_INPUT;
1154 IPin_QueryDirection(to, &dir);
1156 if (dir == PINDIR_OUTPUT)
1160 IPin_ConnectedTo(to, &out);
1164 hr = IFilterGraph2_Render((IFilterGraph2 *)&This->IFilterGraph2_vtbl, to);
1177 IEnumPins_Release(enumpins);
1183 return VFW_S_PARTIAL_RENDER;
1185 return VFW_E_CANNOT_RENDER;
1188 /* Ogg hates me if I create a direct rendering method
1190 * It can only connect to a pin properly once, so use a recursive method that does
1192 * +----+ --- (PIN 1) (Render is called on this pin)
1194 * +----+ --- (PIN 2)
1196 * Enumerate possible renderers that EXACTLY match the requested type
1198 * If none is available, try to add intermediate filters that can connect to the input pin
1199 * then call Render on that intermediate pin's output pins
1200 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1201 * and another filter that can connect to the input pin is tried
1202 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1203 * It's recursive, but fun!
1206 static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut)
1208 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1209 IEnumMediaTypes* penummt;
1214 IEnumMoniker* pEnumMoniker;
1220 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
1222 if (TRACE_ON(quartz))
1226 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
1230 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
1231 IBaseFilter_Release(PinInfo.pFilter);
1234 /* Try to find out if there is a renderer for the specified subtype already, and use that
1236 EnterCriticalSection(&This->cs);
1237 for (x = 0; x < This->nFilters; ++x)
1239 IEnumPins *enumpins = NULL;
1242 hr = IBaseFilter_EnumPins(This->ppFiltersInGraph[x], &enumpins);
1244 if (FAILED(hr) || !enumpins)
1247 IEnumPins_Reset(enumpins);
1248 while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
1251 PIN_DIRECTION dir = PINDIR_OUTPUT;
1253 IPin_QueryDirection(pin, &dir);
1254 if (dir != PINDIR_INPUT)
1259 IPin_ConnectedTo(pin, &to);
1263 hr = FilterGraph2_ConnectDirect(iface, ppinOut, pin, NULL);
1266 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut, pin, hr);
1269 hr = FilterGraph2_RenderRecurse(This, pin);
1272 IPin_Disconnect(ppinOut);
1273 IPin_Disconnect(pin);
1276 IEnumPins_Release(enumpins);
1277 LeaveCriticalSection(&This->cs);
1280 WARN("Could not connect!\n");
1287 IEnumPins_Release(enumpins);
1290 LeaveCriticalSection(&This->cs);
1292 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
1294 WARN("EnumMediaTypes (%x)\n", hr);
1298 IEnumMediaTypes_Reset(penummt);
1300 /* Looks like no existing renderer of the kind exists
1301 * Try adding new ones
1303 tab[0] = tab[1] = GUID_NULL;
1304 while (SUCCEEDED(hr))
1306 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
1308 WARN("IEnumMediaTypes_Next (%x)\n", hr);
1313 hr = VFW_E_CANNOT_RENDER;
1318 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
1319 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
1321 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1322 if (IsEqualIID(&tab[0], &mt->majortype) && IsEqualIID(&tab[1], &mt->subtype))
1324 DeleteMediaType(mt);
1328 /* Try to find a suitable renderer with the same media type */
1329 tab[0] = mt->majortype;
1330 tab[1] = mt->subtype;
1331 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1334 WARN("Unable to enum filters (%x)\n", hr);
1340 while (IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1345 IBaseFilter* pfilter = NULL;
1346 IEnumPins* penumpins = NULL;
1349 hr = GetFilterInfo(pMoniker, &clsid, &var);
1350 IMoniker_Release(pMoniker);
1352 WARN("Unable to retrieve filter info (%x)\n", hr);
1356 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
1359 WARN("Unable to create filter (%x), trying next one\n", hr);
1363 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1365 WARN("Unable to add filter (%x)\n", hr);
1366 IBaseFilter_Release(pfilter);
1371 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1373 WARN("Splitter Enumpins (%x)\n", hr);
1377 while ((hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin)) == S_OK)
1387 hr = IPin_QueryDirection(ppinfilter, &dir);
1389 IPin_Release(ppinfilter);
1390 WARN("QueryDirection failed (%x)\n", hr);
1393 if (dir != PINDIR_INPUT) {
1394 IPin_Release(ppinfilter);
1395 continue; /* Wrong direction */
1398 /* Connect the pin to the "Renderer" */
1399 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1400 IPin_Release(ppinfilter);
1403 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_UNION(&var, bstrVal)), hr);
1406 TRACE("Connected, recursing %s\n", debugstr_w(V_UNION(&var, bstrVal)));
1410 hr = FilterGraph2_RenderRecurse(This, ppinfilter);
1412 WARN("Unable to connect recursively (%x)\n", hr);
1415 IBaseFilter_Release(pfilter);
1418 if (SUCCEEDED(hr)) {
1419 IEnumPins_Release(penumpins);
1420 break; /* out of IEnumMoniker_Next loop */
1423 /* IEnumPins_Next failed, all other failure case caught by goto error */
1424 WARN("IEnumPins_Next (%x)\n", hr);
1430 IEnumPins_Release(penumpins);
1432 IFilterGraph2_RemoveFilter(iface, pfilter);
1433 IBaseFilter_Release(pfilter);
1435 if (SUCCEEDED(hr)) DebugBreak();
1438 IEnumMoniker_Release(pEnumMoniker);
1440 DeleteMediaType(mt);
1446 IEnumMediaTypes_Release(penummt);
1450 static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface,
1451 LPCWSTR lpcwstrFile,
1452 LPCWSTR lpcwstrPlayList)
1454 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1455 static const WCHAR string[] = {'R','e','a','d','e','r',0};
1456 IBaseFilter* preader = NULL;
1457 IPin* ppinreader = NULL;
1458 IEnumPins* penumpins = NULL;
1460 BOOL partial = FALSE;
1461 HRESULT any = FALSE;
1463 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1465 if (lpcwstrPlayList != NULL)
1466 return E_INVALIDARG;
1468 hr = IFilterGraph2_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1473 hr = IBaseFilter_EnumPins(preader, &penumpins);
1476 while (IEnumPins_Next(penumpins, 1, &ppinreader, NULL) == S_OK)
1480 IPin_QueryDirection(ppinreader, &dir);
1481 if (dir == PINDIR_OUTPUT)
1485 hr = IFilterGraph2_Render(iface, ppinreader);
1486 TRACE("Render %08x\n", hr);
1488 for (i = 0; i < This->nFilters; ++i)
1489 TRACE("Filters in chain: %s\n", debugstr_w(This->pFilterNames[i]));
1496 IPin_Release(ppinreader);
1498 IEnumPins_Release(penumpins);
1501 hr = VFW_E_CANNOT_RENDER;
1503 hr = VFW_S_PARTIAL_RENDER;
1507 IBaseFilter_Release(preader);
1509 TRACE("--> %08x\n", hr);
1513 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1514 static HRESULT GetFileSourceFilter(LPCOLESTR pszFileName, IBaseFilter **filter)
1516 static const WCHAR wszReg[] = {'M','e','d','i','a',' ','T','y','p','e','\\','E','x','t','e','n','s','i','o','n','s',0};
1521 lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszReg, 0, KEY_READ, &extkey);
1522 hr = HRESULT_FROM_WIN32(lRet);
1526 static const WCHAR filtersource[] = {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
1527 WCHAR *ext = PathFindExtensionW(pszFileName);
1528 WCHAR clsid_key[39];
1530 DWORD size = sizeof(clsid_key);
1535 CloseHandle(extkey);
1539 lRet = RegOpenKeyExW(extkey, ext, 0, KEY_READ, &pathkey);
1540 hr = HRESULT_FROM_WIN32(lRet);
1541 CloseHandle(extkey);
1545 lRet = RegQueryValueExW(pathkey, filtersource, NULL, NULL, (LPBYTE)clsid_key, &size);
1546 hr = HRESULT_FROM_WIN32(lRet);
1547 CloseHandle(pathkey);
1551 CLSIDFromString(clsid_key, &clsid);
1553 TRACE("CLSID: %s\n", debugstr_guid(&clsid));
1554 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter);
1557 IFileSourceFilter *source = NULL;
1558 hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID*)&source);
1560 IFileSourceFilter_Release(source);
1562 IBaseFilter_Release(*filter);
1570 static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface,
1571 LPCWSTR lpcwstrFileName,
1572 LPCWSTR lpcwstrFilterName,
1573 IBaseFilter **ppFilter) {
1574 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1576 IBaseFilter* preader;
1577 IFileSourceFilter* pfile = NULL;
1581 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1583 /* Try from file name first, then fall back to default asynchronous reader */
1584 hr = GetFileSourceFilter(lpcwstrFileName, &preader);
1587 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1589 WARN("Unable to create file source filter (%x)\n", hr);
1593 hr = IFilterGraph2_AddFilter(iface, preader, lpcwstrFilterName);
1595 WARN("Unable add filter (%x)\n", hr);
1596 IBaseFilter_Release(preader);
1600 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1602 WARN("Unable to get IFileSourceInterface (%x)\n", hr);
1606 /* Load the file in the file source filter */
1607 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1609 WARN("Load (%x)\n", hr);
1613 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1615 WARN("GetCurFile (%x)\n", hr);
1619 TRACE("File %s\n", debugstr_w(filename));
1620 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1621 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1624 *ppFilter = preader;
1625 IFileSourceFilter_Release(pfile);
1631 IFileSourceFilter_Release(pfile);
1632 IFilterGraph2_RemoveFilter(iface, preader);
1633 IBaseFilter_Release(preader);
1638 static HRESULT WINAPI FilterGraph2_SetLogFile(IFilterGraph2 *iface,
1640 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1642 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1647 static HRESULT WINAPI FilterGraph2_Abort(IFilterGraph2 *iface) {
1648 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1650 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1655 static HRESULT WINAPI FilterGraph2_ShouldOperationContinue(IFilterGraph2 *iface) {
1656 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1658 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1663 /*** IFilterGraph2 methods ***/
1664 static HRESULT WINAPI FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2 *iface,
1667 LPCWSTR lpcwstrFilterName,
1668 IBaseFilter **ppFilter) {
1669 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1671 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This, iface, pMoniker, pCtx, debugstr_w(lpcwstrFilterName), ppFilter);
1676 static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface,
1678 const AM_MEDIA_TYPE *pmt) {
1679 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1681 TRACE("(%p/%p)->(%p %p): stub !!!\n", This, iface, ppin, pmt);
1686 static HRESULT WINAPI FilterGraph2_RenderEx(IFilterGraph2 *iface,
1690 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1692 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This, iface, pPinOut, dwFlags, pvContext);
1698 static const IFilterGraph2Vtbl IFilterGraph2_VTable =
1700 FilterGraph2_QueryInterface,
1701 FilterGraph2_AddRef,
1702 FilterGraph2_Release,
1703 FilterGraph2_AddFilter,
1704 FilterGraph2_RemoveFilter,
1705 FilterGraph2_EnumFilters,
1706 FilterGraph2_FindFilterByName,
1707 FilterGraph2_ConnectDirect,
1708 FilterGraph2_Reconnect,
1709 FilterGraph2_Disconnect,
1710 FilterGraph2_SetDefaultSyncSource,
1711 FilterGraph2_Connect,
1712 FilterGraph2_Render,
1713 FilterGraph2_RenderFile,
1714 FilterGraph2_AddSourceFilter,
1715 FilterGraph2_SetLogFile,
1717 FilterGraph2_ShouldOperationContinue,
1718 FilterGraph2_AddSourceFilterForMoniker,
1719 FilterGraph2_ReconnectEx,
1720 FilterGraph2_RenderEx
1723 /*** IUnknown methods ***/
1724 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1727 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1729 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1731 return Filtergraph_QueryInterface(This, riid, ppvObj);
1734 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1735 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1737 TRACE("(%p/%p)->()\n", This, iface);
1739 return Filtergraph_AddRef(This);
1742 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1743 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1745 TRACE("(%p/%p)->()\n", This, iface);
1747 return Filtergraph_Release(This);
1751 /*** IDispatch methods ***/
1752 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1754 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1756 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1761 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1764 ITypeInfo**ppTInfo) {
1765 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1767 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1772 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1778 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1780 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1785 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1786 DISPID dispIdMember,
1790 DISPPARAMS*pDispParams,
1792 EXCEPINFO*pExepInfo,
1794 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1796 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);
1801 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *, DWORD_PTR data);
1803 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter, DWORD_PTR data)
1812 TRACE("%p %p\n", pGraph, pOutputPin);
1813 PinInfo.pFilter = NULL;
1815 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1819 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1821 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1822 IPin_Release(pInputPin);
1829 TRACE("Reached a renderer\n");
1830 /* Count renderers for end of stream notification */
1831 pGraph->nRenderers++;
1835 for(i = 0; i < nb; i++)
1837 /* Explore the graph downstream from this pin
1838 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1839 * several input pins are connected to the same output (a MUX for instance). */
1840 ExploreGraph(pGraph, ppPins[i], FoundFilter, data);
1841 IPin_Release(ppPins[i]);
1844 CoTaskMemFree(ppPins);
1846 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1848 FoundFilter(PinInfo.pFilter, data);
1851 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1855 static HRESULT WINAPI SendRun(IBaseFilter *pFilter, DWORD_PTR data)
1857 REFERENCE_TIME time = *(REFERENCE_TIME*)data;
1858 return IBaseFilter_Run(pFilter, time);
1861 static HRESULT WINAPI SendPause(IBaseFilter *pFilter, DWORD_PTR data)
1863 return IBaseFilter_Pause(pFilter);
1866 static HRESULT WINAPI SendStop(IBaseFilter *pFilter, DWORD_PTR data)
1868 return IBaseFilter_Stop(pFilter);
1871 static HRESULT WINAPI SendGetState(IBaseFilter *pFilter, DWORD_PTR data)
1874 DWORD time_end = data;
1875 DWORD time_now = GetTickCount();
1878 if (time_end == INFINITE)
1882 else if (time_end > time_now)
1884 wait = time_end - time_now;
1889 return IBaseFilter_GetState(pFilter, wait, &state);
1893 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter, DWORD_PTR data)
1895 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1897 IBaseFilter* pfilter;
1903 TRACE("(%p/%p)->()\n", This, iface);
1905 /* Explorer the graph from source filters to renderers, determine renderers
1906 * number and run filters from renderers to source filters */
1907 This->nRenderers = 0;
1908 ResetEvent(This->hEventCompletion);
1910 for(i = 0; i < This->nFilters; i++)
1913 pfilter = This->ppFiltersInGraph[i];
1914 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1917 WARN("Enum pins failed %x\n", hr);
1920 /* Check if it is a source filter */
1921 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1923 IPin_QueryDirection(pPin, &dir);
1925 if (dir == PINDIR_INPUT)
1933 TRACE("Found a source filter %p\n", pfilter);
1934 IEnumPins_Reset(pEnum);
1935 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1937 /* Explore the graph downstream from this pin */
1938 ExploreGraph(This, pPin, FoundFilter, data);
1941 FoundFilter(pfilter, data);
1943 IEnumPins_Release(pEnum);
1949 /*** IMediaControl methods ***/
1950 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1951 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1952 TRACE("(%p/%p)->()\n", This, iface);
1954 EnterCriticalSection(&This->cs);
1955 if (This->state == State_Running)
1957 This->EcCompleteCount = 0;
1959 if (This->defaultclock && !This->refClock)
1960 IFilterGraph2_SetDefaultSyncSource((IFilterGraph2*)This);
1965 IReferenceClock_GetTime(This->refClock, &now);
1966 if (This->state == State_Stopped)
1967 This->start_time = now + 500000;
1968 else if (This->pause_time >= 0)
1969 This->start_time += now - This->pause_time;
1971 This->start_time = now;
1973 else This->start_time = 0;
1975 SendFilterMessage(iface, SendRun, (DWORD_PTR)&This->start_time);
1976 This->state = State_Running;
1978 LeaveCriticalSection(&This->cs);
1982 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1983 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1984 TRACE("(%p/%p)->()\n", This, iface);
1986 EnterCriticalSection(&This->cs);
1987 if (This->state == State_Paused)
1990 if (This->state == State_Running && This->refClock && This->start_time >= 0)
1991 IReferenceClock_GetTime(This->refClock, &This->pause_time);
1993 This->pause_time = -1;
1995 SendFilterMessage(iface, SendPause, 0);
1996 This->state = State_Paused;
1998 LeaveCriticalSection(&This->cs);
2002 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
2003 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2004 TRACE("(%p/%p)->()\n", This, iface);
2006 if (This->state == State_Stopped) return S_OK;
2008 EnterCriticalSection(&This->cs);
2009 if (This->state == State_Running) SendFilterMessage(iface, SendPause, 0);
2010 SendFilterMessage(iface, SendStop, 0);
2011 This->state = State_Stopped;
2012 LeaveCriticalSection(&This->cs);
2016 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
2018 OAFilterState *pfs) {
2019 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2022 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pfs);
2027 EnterCriticalSection(&This->cs);
2032 end = GetTickCount() + msTimeout;
2034 else if (msTimeout < 0)
2043 SendFilterMessage(iface, SendGetState, end);
2045 LeaveCriticalSection(&This->cs);
2050 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
2052 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2054 FIXME("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
2059 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
2061 IDispatch **ppUnk) {
2062 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2064 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
2069 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
2070 IDispatch **ppUnk) {
2071 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2073 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2078 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
2079 IDispatch **ppUnk) {
2080 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2082 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2087 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
2088 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2090 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
2096 static const IMediaControlVtbl IMediaControl_VTable =
2098 MediaControl_QueryInterface,
2099 MediaControl_AddRef,
2100 MediaControl_Release,
2101 MediaControl_GetTypeInfoCount,
2102 MediaControl_GetTypeInfo,
2103 MediaControl_GetIDsOfNames,
2104 MediaControl_Invoke,
2108 MediaControl_GetState,
2109 MediaControl_RenderFile,
2110 MediaControl_AddSourceFilter,
2111 MediaControl_get_FilterCollection,
2112 MediaControl_get_RegFilterCollection,
2113 MediaControl_StopWhenReady
2117 /*** IUnknown methods ***/
2118 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
2121 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2123 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2125 return Filtergraph_QueryInterface(This, riid, ppvObj);
2128 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
2129 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2131 TRACE("(%p/%p)->()\n", This, iface);
2133 return Filtergraph_AddRef(This);
2136 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
2137 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2139 TRACE("(%p/%p)->()\n", This, iface);
2141 return Filtergraph_Release(This);
2144 typedef HRESULT (WINAPI *fnFoundSeek)(IFilterGraphImpl *This, IMediaSeeking*, DWORD_PTR arg);
2146 static HRESULT all_renderers_seek(IFilterGraphImpl *This, fnFoundSeek FoundSeek, DWORD_PTR arg) {
2147 BOOL allnotimpl = TRUE;
2149 HRESULT hr, hr_return = S_OK;
2151 TRACE("(%p)->(%p %08lx)\n", This, FoundSeek, arg);
2152 /* Send a message to all renderers, they are responsible for broadcasting it further */
2154 for(i = 0; i < This->nFilters; i++)
2156 IMediaSeeking *seek = NULL;
2157 IBaseFilter* pfilter = This->ppFiltersInGraph[i];
2158 IAMFilterMiscFlags *flags = NULL;
2160 IUnknown_QueryInterface(pfilter, &IID_IAMFilterMiscFlags, (void**)&flags);
2163 filterflags = IAMFilterMiscFlags_GetMiscFlags(flags);
2164 IUnknown_Release(flags);
2165 if (filterflags != AM_FILTER_MISC_FLAGS_IS_RENDERER)
2168 IBaseFilter_QueryInterface(pfilter, &IID_IMediaSeeking, (void**)&seek);
2171 hr = FoundSeek(This, seek, arg);
2172 IMediaSeeking_Release(seek);
2173 if (hr_return != E_NOTIMPL)
2175 if (hr_return == S_OK || (FAILED(hr) && hr != E_NOTIMPL && SUCCEEDED(hr_return)))
2184 static HRESULT WINAPI FoundCapabilities(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pcaps)
2189 hr = IMediaSeeking_GetCapabilities(seek, &caps);
2193 /* Only add common capabilities everything supports */
2194 *(DWORD*)pcaps &= caps;
2199 /*** IMediaSeeking methods ***/
2200 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
2201 DWORD *pCapabilities) {
2202 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2204 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2209 EnterCriticalSection(&This->cs);
2210 *pCapabilities = 0xffffffff;
2212 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2213 LeaveCriticalSection(&This->cs);
2218 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
2219 DWORD *pCapabilities) {
2220 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2223 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2228 EnterCriticalSection(&This->cs);
2229 originalcaps = *pCapabilities;
2230 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2231 LeaveCriticalSection(&This->cs);
2236 if (!*pCapabilities)
2238 if (*pCapabilities != originalcaps)
2243 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
2244 const GUID *pFormat) {
2245 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2250 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2252 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2254 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2261 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
2263 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2268 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This, iface, pFormat);
2269 memcpy(pFormat, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
2274 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
2276 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2281 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2282 memcpy(pFormat, &This->timeformatseek, sizeof(GUID));
2287 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
2288 const GUID *pFormat) {
2289 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2291 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2295 if (memcmp(pFormat, &This->timeformatseek, sizeof(GUID)))
2301 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
2302 const GUID *pFormat) {
2303 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2308 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2310 if (This->state != State_Stopped)
2311 return VFW_E_WRONG_STATE;
2313 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2315 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2316 return E_INVALIDARG;
2322 static HRESULT WINAPI FoundDuration(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pduration)
2325 LONGLONG duration = 0, *pdur = (LONGLONG*)pduration;
2327 hr = IMediaSeeking_GetDuration(seek, &duration);
2331 if (*pdur < duration)
2336 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
2337 LONGLONG *pDuration) {
2338 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2341 TRACE("(%p/%p)->(%p)\n", This, iface, pDuration);
2346 EnterCriticalSection(&This->cs);
2348 hr = all_renderers_seek(This, FoundDuration, (DWORD_PTR)pDuration);
2349 LeaveCriticalSection(&This->cs);
2351 TRACE("--->%08x\n", hr);
2355 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
2357 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2360 TRACE("(%p/%p)->(%p)\n", This, iface, pStop);
2365 EnterCriticalSection(&This->cs);
2366 if (This->stop_position < 0)
2367 /* Stop position not set, use duration instead */
2368 hr = IMediaSeeking_GetDuration(iface, pStop);
2370 *pStop = This->stop_position;
2371 LeaveCriticalSection(&This->cs);
2376 static HRESULT WINAPI FoundCurrentPosition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pposition)
2379 LONGLONG pos = 0, *ppos = (LONGLONG*)pposition;
2381 hr = IMediaSeeking_GetCurrentPosition(seek, &pos);
2385 if (*ppos < 0 || pos < *ppos)
2390 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
2391 LONGLONG *pCurrent) {
2392 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2398 EnterCriticalSection(&This->cs);
2400 hr = all_renderers_seek(This, FoundCurrentPosition, (DWORD_PTR)pCurrent);
2401 if (hr == E_NOTIMPL) {
2405 LeaveCriticalSection(&This->cs);
2407 TRACE("Time: %u.%03u\n", (DWORD)(*pCurrent / 10000000), (DWORD)((*pCurrent / 10000)%1000));
2412 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
2414 const GUID *pTargetFormat,
2416 const GUID *pSourceFormat) {
2417 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2419 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
2420 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
2426 LONGLONG* current, *stop;
2427 DWORD curflags, stopflags;
2430 static HRESULT WINAPI found_setposition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pargs)
2432 struct pos_args *args = (void*)pargs;
2434 return IMediaSeeking_SetPositions(seek, args->current, args->curflags, args->stop, args->stopflags);
2437 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
2439 DWORD dwCurrentFlags,
2441 DWORD dwStopFlags) {
2442 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2445 struct pos_args args;
2447 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
2449 EnterCriticalSection(&This->cs);
2450 state = This->state;
2451 TRACE("State: %s\n", state == State_Running ? "Running" : (state == State_Paused ? "Paused" : (state == State_Stopped ? "Stopped" : "UNKNOWN")));
2453 if ((dwCurrentFlags & 0x7) != AM_SEEKING_AbsolutePositioning &&
2454 (dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning)
2455 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags & 0x7);
2457 if ((dwStopFlags & 0x7) == AM_SEEKING_AbsolutePositioning)
2458 This->stop_position = *pStop;
2459 else if ((dwStopFlags & 0x7) != AM_SEEKING_NoPositioning)
2460 FIXME("Stop position not handled yet!\n");
2462 args.current = pCurrent;
2464 args.curflags = dwCurrentFlags;
2465 args.stopflags = dwStopFlags;
2466 hr = all_renderers_seek(This, found_setposition, (DWORD_PTR)&args);
2468 if ((dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning) {
2469 if (This->state == State_Running)
2470 FIXME("Seeking while graph is running is not properly supported!\n");
2471 This->pause_time = This->start_time = -1;
2473 LeaveCriticalSection(&This->cs);
2478 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
2481 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2484 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pCurrent, pStop);
2485 hr = IMediaSeeking_GetCurrentPosition(iface, pCurrent);
2487 hr = IMediaSeeking_GetStopPosition(iface, pStop);
2492 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
2493 LONGLONG *pEarliest,
2494 LONGLONG *pLatest) {
2495 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2497 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
2502 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
2504 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2506 FIXME("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
2511 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
2513 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2515 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
2520 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
2521 LONGLONG *pllPreroll) {
2522 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2524 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
2530 static const IMediaSeekingVtbl IMediaSeeking_VTable =
2532 MediaSeeking_QueryInterface,
2533 MediaSeeking_AddRef,
2534 MediaSeeking_Release,
2535 MediaSeeking_GetCapabilities,
2536 MediaSeeking_CheckCapabilities,
2537 MediaSeeking_IsFormatSupported,
2538 MediaSeeking_QueryPreferredFormat,
2539 MediaSeeking_GetTimeFormat,
2540 MediaSeeking_IsUsingTimeFormat,
2541 MediaSeeking_SetTimeFormat,
2542 MediaSeeking_GetDuration,
2543 MediaSeeking_GetStopPosition,
2544 MediaSeeking_GetCurrentPosition,
2545 MediaSeeking_ConvertTimeFormat,
2546 MediaSeeking_SetPositions,
2547 MediaSeeking_GetPositions,
2548 MediaSeeking_GetAvailable,
2549 MediaSeeking_SetRate,
2550 MediaSeeking_GetRate,
2551 MediaSeeking_GetPreroll
2554 static inline IFilterGraphImpl *impl_from_IMediaPosition( IMediaPosition *iface )
2556 return (IFilterGraphImpl *)((char*)iface - FIELD_OFFSET(IFilterGraphImpl, IMediaPosition_vtbl));
2559 /*** IUnknown methods ***/
2560 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj)
2562 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2564 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2565 return Filtergraph_QueryInterface(This, riid, ppvObj);
2568 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface)
2570 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2572 TRACE("(%p/%p)->()\n", This, iface);
2573 return Filtergraph_AddRef(This);
2576 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface)
2578 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2580 TRACE("(%p/%p)->()\n", This, iface);
2581 return Filtergraph_Release(This);
2584 /*** IDispatch methods ***/
2585 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
2586 FIXME("(%p) stub!\n", iface);
2590 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
2591 FIXME("(%p) stub!\n", iface);
2595 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
2596 FIXME("(%p) stub!\n", iface);
2600 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
2601 FIXME("(%p) stub!\n", iface);
2605 /*** IMediaPosition methods ***/
2606 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength)
2609 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2610 HRESULT hr = IMediaSeeking_GetDuration( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &duration );
2611 if (SUCCEEDED(hr)) *plength = duration;
2615 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime)
2617 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2618 LONGLONG reftime = llTime;
2620 return IMediaSeeking_SetPositions((IMediaSeeking *)&This->IMediaSeeking_vtbl,
2621 &reftime, AM_SEEKING_AbsolutePositioning,
2622 NULL, AM_SEEKING_NoPositioning);
2625 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime)
2627 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2629 HRESULT hr = IMediaSeeking_GetCurrentPosition( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &pos );
2630 if (SUCCEEDED(hr)) *pllTime = pos;
2634 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime)
2636 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2638 HRESULT hr = IMediaSeeking_GetStopPosition( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &pos );
2639 if (SUCCEEDED(hr)) *pllTime = pos;
2643 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime)
2645 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2646 LONGLONG reftime = llTime;
2648 return IMediaSeeking_SetPositions((IMediaSeeking *)&This->IMediaSeeking_vtbl,
2649 NULL, AM_SEEKING_NoPositioning,
2650 &reftime, AM_SEEKING_AbsolutePositioning);
2653 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
2654 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2658 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
2659 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2663 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate)
2665 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2666 return IMediaSeeking_SetRate((IMediaSeeking *)&This->IMediaSeeking_vtbl, dRate);
2669 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate)
2671 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2672 return IMediaSeeking_GetRate((IMediaSeeking *)&This->IMediaSeeking_vtbl, pdRate);
2675 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
2676 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
2680 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
2681 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
2686 static const IMediaPositionVtbl IMediaPosition_VTable =
2688 MediaPosition_QueryInterface,
2689 MediaPosition_AddRef,
2690 MediaPosition_Release,
2691 MediaPosition_GetTypeInfoCount,
2692 MediaPosition_GetTypeInfo,
2693 MediaPosition_GetIDsOfNames,
2694 MediaPosition_Invoke,
2695 MediaPosition_get_Duration,
2696 MediaPosition_put_CurrentPosition,
2697 MediaPosition_get_CurrentPosition,
2698 MediaPosition_get_StopTime,
2699 MediaPosition_put_StopTime,
2700 MediaPosition_get_PrerollTime,
2701 MediaPosition_put_PrerollTime,
2702 MediaPosition_put_Rate,
2703 MediaPosition_get_Rate,
2704 MediaPosition_CanSeekForward,
2705 MediaPosition_CanSeekBackward
2708 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
2710 HRESULT hr = E_NOINTERFACE;
2714 /* Check if the interface type is already registered */
2715 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
2716 if (riid == pGraph->ItfCacheEntries[entry].riid)
2718 if (pGraph->ItfCacheEntries[entry].iface)
2720 /* Return the interface if available */
2721 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
2727 if (entry >= MAX_ITF_CACHE_ENTRIES)
2729 FIXME("Not enough space to store interface in the cache\n");
2730 return E_OUTOFMEMORY;
2733 /* Find a filter supporting the requested interface */
2734 for (i = 0; i < pGraph->nFilters; i++)
2736 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
2739 pGraph->ItfCacheEntries[entry].riid = riid;
2740 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
2741 pGraph->ItfCacheEntries[entry].iface = *ppvObj;
2742 if (entry >= pGraph->nItfCacheEntries)
2743 pGraph->nItfCacheEntries++;
2746 if (hr != E_NOINTERFACE)
2753 /*** IUnknown methods ***/
2754 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
2757 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2759 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2761 return Filtergraph_QueryInterface(This, riid, ppvObj);
2764 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
2765 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2767 TRACE("(%p/%p)->()\n", This, iface);
2769 return Filtergraph_AddRef(This);
2772 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
2773 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2775 TRACE("(%p/%p)->()\n", This, iface);
2777 return Filtergraph_Release(This);
2780 /*** IDispatch methods ***/
2781 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
2783 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2784 IBasicAudio* pBasicAudio;
2787 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2789 EnterCriticalSection(&This->cs);
2791 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2794 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
2796 LeaveCriticalSection(&This->cs);
2801 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
2804 ITypeInfo**ppTInfo) {
2805 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2806 IBasicAudio* pBasicAudio;
2809 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2811 EnterCriticalSection(&This->cs);
2813 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2816 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
2818 LeaveCriticalSection(&This->cs);
2823 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
2829 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2830 IBasicAudio* pBasicAudio;
2833 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2835 EnterCriticalSection(&This->cs);
2837 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2840 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2842 LeaveCriticalSection(&This->cs);
2847 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2848 DISPID dispIdMember,
2852 DISPPARAMS*pDispParams,
2854 EXCEPINFO*pExepInfo,
2856 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2857 IBasicAudio* pBasicAudio;
2860 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);
2862 EnterCriticalSection(&This->cs);
2864 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2867 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2869 LeaveCriticalSection(&This->cs);
2874 /*** IBasicAudio methods ***/
2875 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2877 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2878 IBasicAudio* pBasicAudio;
2881 TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
2883 EnterCriticalSection(&This->cs);
2885 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2888 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2890 LeaveCriticalSection(&This->cs);
2895 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2897 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2898 IBasicAudio* pBasicAudio;
2901 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2903 EnterCriticalSection(&This->cs);
2905 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2908 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2910 LeaveCriticalSection(&This->cs);
2915 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2917 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2918 IBasicAudio* pBasicAudio;
2921 TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
2923 EnterCriticalSection(&This->cs);
2925 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2928 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2930 LeaveCriticalSection(&This->cs);
2935 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2937 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2938 IBasicAudio* pBasicAudio;
2941 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2943 EnterCriticalSection(&This->cs);
2945 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2948 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2950 LeaveCriticalSection(&This->cs);
2955 static const IBasicAudioVtbl IBasicAudio_VTable =
2957 BasicAudio_QueryInterface,
2960 BasicAudio_GetTypeInfoCount,
2961 BasicAudio_GetTypeInfo,
2962 BasicAudio_GetIDsOfNames,
2964 BasicAudio_put_Volume,
2965 BasicAudio_get_Volume,
2966 BasicAudio_put_Balance,
2967 BasicAudio_get_Balance
2970 /*** IUnknown methods ***/
2971 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo2 *iface,
2974 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2976 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2978 return Filtergraph_QueryInterface(This, riid, ppvObj);
2981 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo2 *iface) {
2982 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2984 TRACE("(%p/%p)->()\n", This, iface);
2986 return Filtergraph_AddRef(This);
2989 static ULONG WINAPI BasicVideo_Release(IBasicVideo2 *iface) {
2990 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2992 TRACE("(%p/%p)->()\n", This, iface);
2994 return Filtergraph_Release(This);
2997 /*** IDispatch methods ***/
2998 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo2 *iface,
3000 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3001 IBasicVideo* pBasicVideo;
3004 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3006 EnterCriticalSection(&This->cs);
3008 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3011 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
3013 LeaveCriticalSection(&This->cs);
3018 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo2 *iface,
3021 ITypeInfo**ppTInfo) {
3022 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3023 IBasicVideo* pBasicVideo;
3026 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3028 EnterCriticalSection(&This->cs);
3030 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3033 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
3035 LeaveCriticalSection(&This->cs);
3040 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo2 *iface,
3046 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3047 IBasicVideo* pBasicVideo;
3050 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3052 EnterCriticalSection(&This->cs);
3054 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3057 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
3059 LeaveCriticalSection(&This->cs);
3064 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo2 *iface,
3065 DISPID dispIdMember,
3069 DISPPARAMS*pDispParams,
3071 EXCEPINFO*pExepInfo,
3073 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3074 IBasicVideo* pBasicVideo;
3077 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);
3079 EnterCriticalSection(&This->cs);
3081 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3084 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3086 LeaveCriticalSection(&This->cs);
3091 /*** IBasicVideo methods ***/
3092 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo2 *iface,
3093 REFTIME *pAvgTimePerFrame) {
3094 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3095 IBasicVideo* pBasicVideo;
3098 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
3100 EnterCriticalSection(&This->cs);
3102 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3105 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
3107 LeaveCriticalSection(&This->cs);
3112 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo2 *iface,
3114 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3115 IBasicVideo* pBasicVideo;
3118 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
3120 EnterCriticalSection(&This->cs);
3122 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3125 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
3127 LeaveCriticalSection(&This->cs);
3132 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo2 *iface,
3133 LONG *pBitErrorRate) {
3134 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3135 IBasicVideo* pBasicVideo;
3138 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
3140 EnterCriticalSection(&This->cs);
3142 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3145 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
3147 LeaveCriticalSection(&This->cs);
3152 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo2 *iface,
3153 LONG *pVideoWidth) {
3154 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3155 IBasicVideo* pBasicVideo;
3158 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
3160 EnterCriticalSection(&This->cs);
3162 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3165 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
3167 LeaveCriticalSection(&This->cs);
3172 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo2 *iface,
3173 LONG *pVideoHeight) {
3174 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3175 IBasicVideo* pBasicVideo;
3178 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
3180 EnterCriticalSection(&This->cs);
3182 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3185 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
3187 LeaveCriticalSection(&This->cs);
3192 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo2 *iface,
3194 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3195 IBasicVideo* pBasicVideo;
3198 TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
3200 EnterCriticalSection(&This->cs);
3202 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3205 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
3207 LeaveCriticalSection(&This->cs);
3212 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo2 *iface,
3213 LONG *pSourceLeft) {
3214 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3215 IBasicVideo* pBasicVideo;
3218 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
3220 EnterCriticalSection(&This->cs);
3222 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3225 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
3227 LeaveCriticalSection(&This->cs);
3232 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo2 *iface,
3234 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3235 IBasicVideo* pBasicVideo;
3238 TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
3240 EnterCriticalSection(&This->cs);
3242 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3245 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
3247 LeaveCriticalSection(&This->cs);
3252 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo2 *iface,
3253 LONG *pSourceWidth) {
3254 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3255 IBasicVideo* pBasicVideo;
3258 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
3260 EnterCriticalSection(&This->cs);
3262 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3265 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
3267 LeaveCriticalSection(&This->cs);
3272 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo2 *iface,
3274 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3275 IBasicVideo* pBasicVideo;
3278 TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
3280 EnterCriticalSection(&This->cs);
3282 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3285 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
3287 LeaveCriticalSection(&This->cs);
3292 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo2 *iface,
3294 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3295 IBasicVideo* pBasicVideo;
3298 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
3300 EnterCriticalSection(&This->cs);
3302 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3305 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
3307 LeaveCriticalSection(&This->cs);
3312 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo2 *iface,
3313 LONG SourceHeight) {
3314 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3315 IBasicVideo* pBasicVideo;
3318 TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
3320 EnterCriticalSection(&This->cs);
3322 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3325 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
3327 LeaveCriticalSection(&This->cs);
3332 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo2 *iface,
3333 LONG *pSourceHeight) {
3334 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3335 IBasicVideo* pBasicVideo;
3338 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
3340 EnterCriticalSection(&This->cs);
3342 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3345 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
3347 LeaveCriticalSection(&This->cs);
3352 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo2 *iface,
3353 LONG DestinationLeft) {
3354 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3355 IBasicVideo* pBasicVideo;
3358 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
3360 EnterCriticalSection(&This->cs);
3362 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3365 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
3367 LeaveCriticalSection(&This->cs);
3372 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo2 *iface,
3373 LONG *pDestinationLeft) {
3374 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3375 IBasicVideo* pBasicVideo;
3378 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
3380 EnterCriticalSection(&This->cs);
3382 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3385 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
3387 LeaveCriticalSection(&This->cs);
3392 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo2 *iface,
3393 LONG DestinationWidth) {
3394 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3395 IBasicVideo* pBasicVideo;
3398 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
3400 EnterCriticalSection(&This->cs);
3402 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3405 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
3407 LeaveCriticalSection(&This->cs);
3412 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo2 *iface,
3413 LONG *pDestinationWidth) {
3414 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3415 IBasicVideo* pBasicVideo;
3418 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
3420 EnterCriticalSection(&This->cs);
3422 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3425 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
3427 LeaveCriticalSection(&This->cs);
3432 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo2 *iface,
3433 LONG DestinationTop) {
3434 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3435 IBasicVideo* pBasicVideo;
3438 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
3440 EnterCriticalSection(&This->cs);
3442 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3445 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
3447 LeaveCriticalSection(&This->cs);
3452 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo2 *iface,
3453 LONG *pDestinationTop) {
3454 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3455 IBasicVideo* pBasicVideo;
3458 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
3460 EnterCriticalSection(&This->cs);
3462 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3465 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
3467 LeaveCriticalSection(&This->cs);
3472 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo2 *iface,
3473 LONG DestinationHeight) {
3474 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3475 IBasicVideo* pBasicVideo;
3478 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
3480 EnterCriticalSection(&This->cs);
3482 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3485 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
3487 LeaveCriticalSection(&This->cs);
3492 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo2 *iface,
3493 LONG *pDestinationHeight) {
3494 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3495 IBasicVideo* pBasicVideo;
3498 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
3500 EnterCriticalSection(&This->cs);
3502 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3505 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
3507 LeaveCriticalSection(&This->cs);
3512 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo2 *iface,
3517 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3518 IBasicVideo* pBasicVideo;
3521 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3523 EnterCriticalSection(&This->cs);
3525 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3528 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
3530 LeaveCriticalSection(&This->cs);
3535 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo2 *iface,
3540 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3541 IBasicVideo* pBasicVideo;
3544 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3546 EnterCriticalSection(&This->cs);
3548 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3551 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3553 LeaveCriticalSection(&This->cs);
3558 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo2 *iface) {
3559 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3560 IBasicVideo* pBasicVideo;
3563 TRACE("(%p/%p)->()\n", This, iface);
3565 EnterCriticalSection(&This->cs);
3567 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3570 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
3572 LeaveCriticalSection(&This->cs);
3577 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo2 *iface,
3582 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3583 IBasicVideo* pBasicVideo;
3586 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3588 EnterCriticalSection(&This->cs);
3590 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3593 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
3595 LeaveCriticalSection(&This->cs);
3600 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo2 *iface,
3605 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3606 IBasicVideo* pBasicVideo;
3609 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3611 EnterCriticalSection(&This->cs);
3613 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3616 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3618 LeaveCriticalSection(&This->cs);
3623 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo2 *iface) {
3624 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3625 IBasicVideo* pBasicVideo;
3628 TRACE("(%p/%p)->()\n", This, iface);
3630 EnterCriticalSection(&This->cs);
3632 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3635 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
3637 LeaveCriticalSection(&This->cs);
3642 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo2 *iface,
3645 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3646 IBasicVideo* pBasicVideo;
3649 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3651 EnterCriticalSection(&This->cs);
3653 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3656 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
3658 LeaveCriticalSection(&This->cs);
3663 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo2 *iface,
3668 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3669 IBasicVideo* pBasicVideo;
3672 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
3674 EnterCriticalSection(&This->cs);
3676 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3679 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
3681 LeaveCriticalSection(&This->cs);
3686 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo2 *iface,
3689 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3690 IBasicVideo* pBasicVideo;
3693 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
3695 EnterCriticalSection(&This->cs);
3697 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3700 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
3702 LeaveCriticalSection(&This->cs);
3707 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo2 *iface) {
3708 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3709 IBasicVideo* pBasicVideo;
3712 TRACE("(%p/%p)->()\n", This, iface);
3714 EnterCriticalSection(&This->cs);
3716 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3719 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
3721 LeaveCriticalSection(&This->cs);
3726 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo2 *iface) {
3727 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3728 IBasicVideo* pBasicVideo;
3731 TRACE("(%p/%p)->()\n", This, iface);
3733 EnterCriticalSection(&This->cs);
3735 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3738 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
3740 LeaveCriticalSection(&This->cs);
3745 static HRESULT WINAPI BasicVideo2_GetPreferredAspectRatio(IBasicVideo2 *iface, LONG *plAspectX, LONG *plAspectY) {
3746 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3747 IBasicVideo2 *pBasicVideo2;
3750 TRACE("(%p/%p)->()\n", This, iface);
3752 EnterCriticalSection(&This->cs);
3754 hr = GetTargetInterface(This, &IID_IBasicVideo2, (LPVOID*)&pBasicVideo2);
3757 hr = BasicVideo2_GetPreferredAspectRatio(iface, plAspectX, plAspectY);
3759 LeaveCriticalSection(&This->cs);
3764 static const IBasicVideo2Vtbl IBasicVideo_VTable =
3766 BasicVideo_QueryInterface,
3769 BasicVideo_GetTypeInfoCount,
3770 BasicVideo_GetTypeInfo,
3771 BasicVideo_GetIDsOfNames,
3773 BasicVideo_get_AvgTimePerFrame,
3774 BasicVideo_get_BitRate,
3775 BasicVideo_get_BitErrorRate,
3776 BasicVideo_get_VideoWidth,
3777 BasicVideo_get_VideoHeight,
3778 BasicVideo_put_SourceLeft,
3779 BasicVideo_get_SourceLeft,
3780 BasicVideo_put_SourceWidth,
3781 BasicVideo_get_SourceWidth,
3782 BasicVideo_put_SourceTop,
3783 BasicVideo_get_SourceTop,
3784 BasicVideo_put_SourceHeight,
3785 BasicVideo_get_SourceHeight,
3786 BasicVideo_put_DestinationLeft,
3787 BasicVideo_get_DestinationLeft,
3788 BasicVideo_put_DestinationWidth,
3789 BasicVideo_get_DestinationWidth,
3790 BasicVideo_put_DestinationTop,
3791 BasicVideo_get_DestinationTop,
3792 BasicVideo_put_DestinationHeight,
3793 BasicVideo_get_DestinationHeight,
3794 BasicVideo_SetSourcePosition,
3795 BasicVideo_GetSourcePosition,
3796 BasicVideo_SetDefaultSourcePosition,
3797 BasicVideo_SetDestinationPosition,
3798 BasicVideo_GetDestinationPosition,
3799 BasicVideo_SetDefaultDestinationPosition,
3800 BasicVideo_GetVideoSize,
3801 BasicVideo_GetVideoPaletteEntries,
3802 BasicVideo_GetCurrentImage,
3803 BasicVideo_IsUsingDefaultSource,
3804 BasicVideo_IsUsingDefaultDestination,
3805 BasicVideo2_GetPreferredAspectRatio
3809 /*** IUnknown methods ***/
3810 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
3813 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3815 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3817 return Filtergraph_QueryInterface(This, riid, ppvObj);
3820 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
3821 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3823 TRACE("(%p/%p)->()\n", This, iface);
3825 return Filtergraph_AddRef(This);
3828 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
3829 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3831 TRACE("(%p/%p)->()\n", This, iface);
3833 return Filtergraph_Release(This);
3836 /*** IDispatch methods ***/
3837 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
3839 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3840 IVideoWindow* pVideoWindow;
3843 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3845 EnterCriticalSection(&This->cs);
3847 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3850 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
3852 LeaveCriticalSection(&This->cs);
3857 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3860 ITypeInfo**ppTInfo) {
3861 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3862 IVideoWindow* pVideoWindow;
3865 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3867 EnterCriticalSection(&This->cs);
3869 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3872 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3874 LeaveCriticalSection(&This->cs);
3879 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3885 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3886 IVideoWindow* pVideoWindow;
3889 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3891 EnterCriticalSection(&This->cs);
3893 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3896 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3898 LeaveCriticalSection(&This->cs);
3903 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3904 DISPID dispIdMember,
3908 DISPPARAMS*pDispParams,
3910 EXCEPINFO*pExepInfo,
3912 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3913 IVideoWindow* pVideoWindow;
3916 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);
3918 EnterCriticalSection(&This->cs);
3920 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3923 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3925 LeaveCriticalSection(&This->cs);
3931 /*** IVideoWindow methods ***/
3932 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3934 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3935 IVideoWindow* pVideoWindow;
3938 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3940 EnterCriticalSection(&This->cs);
3942 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3945 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3947 LeaveCriticalSection(&This->cs);
3952 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3954 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3955 IVideoWindow* pVideoWindow;
3958 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3960 EnterCriticalSection(&This->cs);
3962 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3965 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3967 LeaveCriticalSection(&This->cs);
3972 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3974 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3975 IVideoWindow* pVideoWindow;
3978 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyle);
3980 EnterCriticalSection(&This->cs);
3982 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3985 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
3987 LeaveCriticalSection(&This->cs);
3992 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
3993 LONG *WindowStyle) {
3994 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3995 IVideoWindow* pVideoWindow;
3998 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
4000 EnterCriticalSection(&This->cs);
4002 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4005 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
4007 LeaveCriticalSection(&This->cs);
4012 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
4013 LONG WindowStyleEx) {
4014 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4015 IVideoWindow* pVideoWindow;
4018 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyleEx);
4020 EnterCriticalSection(&This->cs);
4022 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4025 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
4027 LeaveCriticalSection(&This->cs);
4032 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
4033 LONG *WindowStyleEx) {
4034 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4035 IVideoWindow* pVideoWindow;
4038 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
4040 EnterCriticalSection(&This->cs);
4042 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4045 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
4047 LeaveCriticalSection(&This->cs);
4052 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
4054 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4055 IVideoWindow* pVideoWindow;
4058 TRACE("(%p/%p)->(%d)\n", This, iface, AutoShow);
4060 EnterCriticalSection(&This->cs);
4062 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4065 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
4067 LeaveCriticalSection(&This->cs);
4072 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
4074 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4075 IVideoWindow* pVideoWindow;
4078 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
4080 EnterCriticalSection(&This->cs);
4082 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4085 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
4087 LeaveCriticalSection(&This->cs);
4092 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
4094 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4095 IVideoWindow* pVideoWindow;
4098 TRACE("(%p/%p)->(%d)\n", This, iface, WindowState);
4100 EnterCriticalSection(&This->cs);
4102 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4105 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
4107 LeaveCriticalSection(&This->cs);
4112 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
4113 LONG *WindowState) {
4114 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4115 IVideoWindow* pVideoWindow;
4118 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
4120 EnterCriticalSection(&This->cs);
4122 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4125 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
4127 LeaveCriticalSection(&This->cs);
4132 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
4133 LONG BackgroundPalette) {
4134 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4135 IVideoWindow* pVideoWindow;
4138 TRACE("(%p/%p)->(%d)\n", This, iface, BackgroundPalette);
4140 EnterCriticalSection(&This->cs);
4142 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4145 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
4147 LeaveCriticalSection(&This->cs);
4152 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
4153 LONG *pBackgroundPalette) {
4154 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4155 IVideoWindow* pVideoWindow;
4158 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
4160 EnterCriticalSection(&This->cs);
4162 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4165 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
4167 LeaveCriticalSection(&This->cs);
4172 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
4174 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4175 IVideoWindow* pVideoWindow;
4178 TRACE("(%p/%p)->(%d)\n", This, iface, Visible);
4180 EnterCriticalSection(&This->cs);
4182 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4185 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
4187 LeaveCriticalSection(&This->cs);
4192 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
4194 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4195 IVideoWindow* pVideoWindow;
4198 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
4200 EnterCriticalSection(&This->cs);
4202 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4205 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
4207 LeaveCriticalSection(&This->cs);
4212 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
4214 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4215 IVideoWindow* pVideoWindow;
4218 TRACE("(%p/%p)->(%d)\n", This, iface, Left);
4220 EnterCriticalSection(&This->cs);
4222 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4225 hr = IVideoWindow_put_Left(pVideoWindow, Left);
4227 LeaveCriticalSection(&This->cs);
4232 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
4234 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4235 IVideoWindow* pVideoWindow;
4238 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
4240 EnterCriticalSection(&This->cs);
4242 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4245 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
4247 LeaveCriticalSection(&This->cs);
4252 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
4254 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4255 IVideoWindow* pVideoWindow;
4258 TRACE("(%p/%p)->(%d)\n", This, iface, Width);
4260 EnterCriticalSection(&This->cs);
4262 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4265 hr = IVideoWindow_put_Width(pVideoWindow, Width);
4267 LeaveCriticalSection(&This->cs);
4272 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
4274 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4275 IVideoWindow* pVideoWindow;
4278 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
4280 EnterCriticalSection(&This->cs);
4282 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4285 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
4287 LeaveCriticalSection(&This->cs);
4292 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
4294 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4295 IVideoWindow* pVideoWindow;
4298 TRACE("(%p/%p)->(%d)\n", This, iface, Top);
4300 EnterCriticalSection(&This->cs);
4302 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4305 hr = IVideoWindow_put_Top(pVideoWindow, Top);
4307 LeaveCriticalSection(&This->cs);
4312 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
4314 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4315 IVideoWindow* pVideoWindow;
4318 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
4320 EnterCriticalSection(&This->cs);
4322 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4325 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
4327 LeaveCriticalSection(&This->cs);
4332 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
4334 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4335 IVideoWindow* pVideoWindow;
4338 TRACE("(%p/%p)->(%d)\n", This, iface, Height);
4340 EnterCriticalSection(&This->cs);
4342 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4345 hr = IVideoWindow_put_Height(pVideoWindow, Height);
4347 LeaveCriticalSection(&This->cs);
4352 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
4354 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4355 IVideoWindow* pVideoWindow;
4358 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
4360 EnterCriticalSection(&This->cs);
4362 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4365 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
4367 LeaveCriticalSection(&This->cs);
4372 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
4374 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4375 IVideoWindow* pVideoWindow;
4378 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
4380 EnterCriticalSection(&This->cs);
4382 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4385 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
4387 LeaveCriticalSection(&This->cs);
4392 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
4394 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4395 IVideoWindow* pVideoWindow;
4398 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
4400 EnterCriticalSection(&This->cs);
4402 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4405 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
4407 LeaveCriticalSection(&This->cs);
4412 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
4414 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4415 IVideoWindow* pVideoWindow;
4418 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
4420 EnterCriticalSection(&This->cs);
4422 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4425 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
4427 LeaveCriticalSection(&This->cs);
4432 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
4434 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4435 IVideoWindow* pVideoWindow;
4438 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
4440 EnterCriticalSection(&This->cs);
4442 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4445 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
4447 LeaveCriticalSection(&This->cs);
4452 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
4454 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4455 IVideoWindow* pVideoWindow;
4458 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
4460 EnterCriticalSection(&This->cs);
4462 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4465 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
4467 LeaveCriticalSection(&This->cs);
4472 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
4474 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4475 IVideoWindow* pVideoWindow;
4478 TRACE("(%p/%p)->(%d)\n", This, iface, Color);
4480 EnterCriticalSection(&This->cs);
4482 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4485 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
4487 LeaveCriticalSection(&This->cs);
4492 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
4493 LONG *FullScreenMode) {
4494 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4495 IVideoWindow* pVideoWindow;
4498 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
4500 EnterCriticalSection(&This->cs);
4502 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4505 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
4507 LeaveCriticalSection(&This->cs);
4512 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
4513 LONG FullScreenMode) {
4514 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4515 IVideoWindow* pVideoWindow;
4518 TRACE("(%p/%p)->(%d)\n", This, iface, FullScreenMode);
4520 EnterCriticalSection(&This->cs);
4522 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4525 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
4527 LeaveCriticalSection(&This->cs);
4532 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
4534 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4535 IVideoWindow* pVideoWindow;
4538 TRACE("(%p/%p)->(%d)\n", This, iface, Focus);
4540 EnterCriticalSection(&This->cs);
4542 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4545 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
4547 LeaveCriticalSection(&This->cs);
4552 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
4557 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4558 IVideoWindow* pVideoWindow;
4561 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This, iface, hwnd, uMsg, wParam, lParam);
4563 EnterCriticalSection(&This->cs);
4565 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4568 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
4570 LeaveCriticalSection(&This->cs);
4575 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
4580 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4581 IVideoWindow* pVideoWindow;
4584 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
4586 EnterCriticalSection(&This->cs);
4588 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4591 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
4593 LeaveCriticalSection(&This->cs);
4598 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
4603 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4604 IVideoWindow* pVideoWindow;
4607 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4609 EnterCriticalSection(&This->cs);
4611 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4614 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4616 LeaveCriticalSection(&This->cs);
4621 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
4624 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4625 IVideoWindow* pVideoWindow;
4628 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4630 EnterCriticalSection(&This->cs);
4632 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4635 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
4637 LeaveCriticalSection(&This->cs);
4642 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
4645 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4646 IVideoWindow* pVideoWindow;
4649 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4651 EnterCriticalSection(&This->cs);
4653 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4656 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
4658 LeaveCriticalSection(&This->cs);
4663 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
4668 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4669 IVideoWindow* pVideoWindow;
4672 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4674 EnterCriticalSection(&This->cs);
4676 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4679 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4681 LeaveCriticalSection(&This->cs);
4686 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
4688 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4689 IVideoWindow* pVideoWindow;
4692 TRACE("(%p/%p)->(%d)\n", This, iface, HideCursor);
4694 EnterCriticalSection(&This->cs);
4696 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4699 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
4701 LeaveCriticalSection(&This->cs);
4706 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
4707 LONG *CursorHidden) {
4708 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4709 IVideoWindow* pVideoWindow;
4712 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
4714 EnterCriticalSection(&This->cs);
4716 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4719 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
4721 LeaveCriticalSection(&This->cs);
4727 static const IVideoWindowVtbl IVideoWindow_VTable =
4729 VideoWindow_QueryInterface,
4731 VideoWindow_Release,
4732 VideoWindow_GetTypeInfoCount,
4733 VideoWindow_GetTypeInfo,
4734 VideoWindow_GetIDsOfNames,
4736 VideoWindow_put_Caption,
4737 VideoWindow_get_Caption,
4738 VideoWindow_put_WindowStyle,
4739 VideoWindow_get_WindowStyle,
4740 VideoWindow_put_WindowStyleEx,
4741 VideoWindow_get_WindowStyleEx,
4742 VideoWindow_put_AutoShow,
4743 VideoWindow_get_AutoShow,
4744 VideoWindow_put_WindowState,
4745 VideoWindow_get_WindowState,
4746 VideoWindow_put_BackgroundPalette,
4747 VideoWindow_get_BackgroundPalette,
4748 VideoWindow_put_Visible,
4749 VideoWindow_get_Visible,
4750 VideoWindow_put_Left,
4751 VideoWindow_get_Left,
4752 VideoWindow_put_Width,
4753 VideoWindow_get_Width,
4754 VideoWindow_put_Top,
4755 VideoWindow_get_Top,
4756 VideoWindow_put_Height,
4757 VideoWindow_get_Height,
4758 VideoWindow_put_Owner,
4759 VideoWindow_get_Owner,
4760 VideoWindow_put_MessageDrain,
4761 VideoWindow_get_MessageDrain,
4762 VideoWindow_get_BorderColor,
4763 VideoWindow_put_BorderColor,
4764 VideoWindow_get_FullScreenMode,
4765 VideoWindow_put_FullScreenMode,
4766 VideoWindow_SetWindowForeground,
4767 VideoWindow_NotifyOwnerMessage,
4768 VideoWindow_SetWindowPosition,
4769 VideoWindow_GetWindowPosition,
4770 VideoWindow_GetMinIdealImageSize,
4771 VideoWindow_GetMaxIdealImageSize,
4772 VideoWindow_GetRestorePosition,
4773 VideoWindow_HideCursor,
4774 VideoWindow_IsCursorHidden
4778 /*** IUnknown methods ***/
4779 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
4782 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4784 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
4786 return Filtergraph_QueryInterface(This, riid, ppvObj);
4789 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
4790 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4792 TRACE("(%p/%p)->()\n", This, iface);
4794 return Filtergraph_AddRef(This);
4797 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
4798 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4800 TRACE("(%p/%p)->()\n", This, iface);
4802 return Filtergraph_Release(This);
4805 /*** IDispatch methods ***/
4806 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
4808 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4810 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
4815 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
4818 ITypeInfo**ppTInfo) {
4819 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4821 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
4826 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
4832 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4834 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4839 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
4840 DISPID dispIdMember,
4844 DISPPARAMS*pDispParams,
4846 EXCEPINFO*pExepInfo,
4848 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4850 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);
4855 /*** IMediaEvent methods ***/
4856 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4858 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4860 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4862 *hEvent = (OAEVENT)This->evqueue.msg_event;
4867 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4872 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4875 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4877 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4879 *lEventCode = evt.lEventCode;
4880 *lParam1 = evt.lParam1;
4881 *lParam2 = evt.lParam2;
4889 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4892 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4894 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pEvCode);
4896 if (This->state != State_Running)
4897 return VFW_E_WRONG_STATE;
4899 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4901 *pEvCode = This->CompletionStatus;
4909 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4911 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4913 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
4915 if (lEvCode == EC_COMPLETE)
4916 This->HandleEcComplete = FALSE;
4917 else if (lEvCode == EC_REPAINT)
4918 This->HandleEcRepaint = FALSE;
4919 else if (lEvCode == EC_CLOCK_CHANGED)
4920 This->HandleEcClockChanged = FALSE;
4927 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4929 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4931 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
4933 if (lEvCode == EC_COMPLETE)
4934 This->HandleEcComplete = TRUE;
4935 else if (lEvCode == EC_REPAINT)
4936 This->HandleEcRepaint = TRUE;
4937 else if (lEvCode == EC_CLOCK_CHANGED)
4938 This->HandleEcClockChanged = TRUE;
4945 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4949 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4951 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4956 /*** IMediaEventEx methods ***/
4957 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4960 LONG_PTR lInstanceData) {
4961 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4963 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This, iface, hwnd, lMsg, lInstanceData);
4965 This->notif.hWnd = (HWND)hwnd;
4966 This->notif.msg = lMsg;
4967 This->notif.instance = lInstanceData;
4972 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4973 LONG lNoNotifyFlags) {
4974 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4976 TRACE("(%p/%p)->(%d)\n", This, iface, lNoNotifyFlags);
4978 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4979 return E_INVALIDARG;
4981 This->notif.disabled = lNoNotifyFlags;
4986 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
4987 LONG *lplNoNotifyFlags) {
4988 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4990 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
4992 if (!lplNoNotifyFlags)
4995 *lplNoNotifyFlags = This->notif.disabled;
5001 static const IMediaEventExVtbl IMediaEventEx_VTable =
5003 MediaEvent_QueryInterface,
5006 MediaEvent_GetTypeInfoCount,
5007 MediaEvent_GetTypeInfo,
5008 MediaEvent_GetIDsOfNames,
5010 MediaEvent_GetEventHandle,
5011 MediaEvent_GetEvent,
5012 MediaEvent_WaitForCompletion,
5013 MediaEvent_CancelDefaultHandling,
5014 MediaEvent_RestoreDefaultHandling,
5015 MediaEvent_FreeEventParams,
5016 MediaEvent_SetNotifyWindow,
5017 MediaEvent_SetNotifyFlags,
5018 MediaEvent_GetNotifyFlags
5022 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
5024 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5026 return Filtergraph_QueryInterface(This, riid, ppv);
5029 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
5031 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5033 return Filtergraph_AddRef(This);
5036 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
5038 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5040 return Filtergraph_Release(This);
5043 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
5045 FIXME("(%p): stub\n", pClassID);
5050 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
5052 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5053 return MediaControl_Stop((IMediaControl*)&This->IMediaControl_vtbl);
5056 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
5058 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5059 return MediaControl_Pause((IMediaControl*)&This->IMediaControl_vtbl);
5062 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
5064 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5066 FIXME("Run called with non-null tStart: %x%08x\n",
5067 (int)(tStart>>32), (int)tStart);
5068 return MediaControl_Run((IMediaControl*)&This->IMediaControl_vtbl);
5071 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
5073 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5074 return MediaControl_GetState((IMediaControl*)&This->IMediaControl_vtbl, dwMsTimeout, (OAFilterState*)pState);
5077 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
5079 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5083 TRACE("(%p/%p)->(%p)\n", iface, This, pClock);
5085 EnterCriticalSection(&This->cs);
5087 for (i = 0;i < This->nFilters;i++)
5089 hr = IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], pClock);
5097 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], This->refClock);
5102 IReferenceClock_Release(This->refClock);
5103 This->refClock = pClock;
5105 IReferenceClock_AddRef(This->refClock);
5106 This->defaultclock = FALSE;
5108 if (This->HandleEcClockChanged)
5110 IMediaEventSink *pEventSink;
5113 eshr = IMediaFilter_QueryInterface(iface, &IID_IMediaEventSink, (LPVOID)&pEventSink);
5114 if (SUCCEEDED(eshr))
5116 IMediaEventSink_Notify(pEventSink, EC_CLOCK_CHANGED, 0, 0);
5117 IMediaEventSink_Release(pEventSink);
5122 LeaveCriticalSection(&This->cs);
5127 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
5129 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5131 TRACE("(%p/%p)->(%p)\n", iface, This, ppClock);
5136 EnterCriticalSection(&This->cs);
5138 *ppClock = This->refClock;
5140 IReferenceClock_AddRef(*ppClock);
5142 LeaveCriticalSection(&This->cs);
5147 static const IMediaFilterVtbl IMediaFilter_VTable =
5149 MediaFilter_QueryInterface,
5151 MediaFilter_Release,
5152 MediaFilter_GetClassID,
5156 MediaFilter_GetState,
5157 MediaFilter_SetSyncSource,
5158 MediaFilter_GetSyncSource
5161 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
5163 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5165 return Filtergraph_QueryInterface(This, riid, ppv);
5168 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
5170 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5172 return Filtergraph_AddRef(This);
5175 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
5177 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5179 return Filtergraph_Release(This);
5182 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, LONG EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
5184 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5187 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
5189 /* We need thread safety here, let's use the events queue's one */
5190 EnterCriticalSection(&This->evqueue.msg_crst);
5192 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
5194 TRACE("Process EC_COMPLETE notification\n");
5195 if (++This->EcCompleteCount == This->nRenderers)
5197 evt.lEventCode = EC_COMPLETE;
5200 TRACE("Send EC_COMPLETE to app\n");
5201 EventsQueue_PutEvent(&This->evqueue, &evt);
5202 if (!This->notif.disabled && This->notif.hWnd)
5204 TRACE("Send Window message\n");
5205 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5207 This->CompletionStatus = EC_COMPLETE;
5208 SetEvent(This->hEventCompletion);
5211 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
5213 /* FIXME: Not handled yet */
5217 evt.lEventCode = EventCode;
5218 evt.lParam1 = EventParam1;
5219 evt.lParam2 = EventParam2;
5220 EventsQueue_PutEvent(&This->evqueue, &evt);
5221 if (!This->notif.disabled && This->notif.hWnd)
5222 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5225 LeaveCriticalSection(&This->evqueue.msg_crst);
5229 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
5231 MediaEventSink_QueryInterface,
5232 MediaEventSink_AddRef,
5233 MediaEventSink_Release,
5234 MediaEventSink_Notify
5237 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
5239 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5241 return Filtergraph_QueryInterface(This, riid, ppv);
5244 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
5246 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5248 return Filtergraph_AddRef(This);
5251 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
5253 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5255 return Filtergraph_Release(This);
5258 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
5261 const AM_MEDIA_TYPE* pmtFirstConnection,
5262 IBaseFilter* pUsingFilter,
5266 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5268 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
5273 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
5274 IGraphConfigCallback* pCallback,
5279 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5282 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
5285 FIXME("The parameter hAbortEvent is not handled!\n");
5287 EnterCriticalSection(&This->cs);
5289 hr = IGraphConfigCallback_Reconfigure(pCallback, pvContext, dwFlags);
5291 LeaveCriticalSection(&This->cs);
5296 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
5297 IBaseFilter* pFilter)
5299 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5301 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5306 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
5307 IEnumFilters** pEnum)
5309 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5311 FIXME("(%p)->(%p): stub!\n", This, pEnum);
5316 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
5317 IBaseFilter* pFilter)
5319 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5321 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5326 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
5327 REFERENCE_TIME* prtStart)
5329 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5331 FIXME("(%p)->(%p): stub!\n", This, prtStart);
5336 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
5338 IPinConnection* pConnection,
5341 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5343 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
5348 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
5349 IBaseFilter* pFilter,
5352 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5354 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5359 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
5360 IBaseFilter* pFilter,
5363 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5365 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
5370 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
5371 IBaseFilter* pFilter,
5374 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5376 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5381 static const IGraphConfigVtbl IGraphConfig_VTable =
5383 GraphConfig_QueryInterface,
5385 GraphConfig_Release,
5386 GraphConfig_Reconnect,
5387 GraphConfig_Reconfigure,
5388 GraphConfig_AddFilterToCache,
5389 GraphConfig_EnumCacheFilter,
5390 GraphConfig_RemoveFilterFromCache,
5391 GraphConfig_GetStartTime,
5392 GraphConfig_PushThroughData,
5393 GraphConfig_SetFilterFlags,
5394 GraphConfig_GetFilterFlags,
5395 GraphConfig_RemoveFilterEx
5398 static const IUnknownVtbl IInner_VTable =
5400 FilterGraphInner_QueryInterface,
5401 FilterGraphInner_AddRef,
5402 FilterGraphInner_Release
5405 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
5408 if (This->bAggregatable)
5409 This->bUnkOuterValid = TRUE;
5411 if (This->pUnkOuter)
5413 if (This->bAggregatable)
5414 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
5416 if (IsEqualIID(riid, &IID_IUnknown))
5420 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
5421 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
5422 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
5423 This->bAggregatable = TRUE;
5428 return E_NOINTERFACE;
5431 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
5434 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This) {
5435 if (This->pUnkOuter && This->bUnkOuterValid)
5436 return IUnknown_AddRef(This->pUnkOuter);
5437 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
5440 static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
5441 if (This->pUnkOuter && This->bUnkOuterValid)
5442 return IUnknown_Release(This->pUnkOuter);
5443 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
5446 /* This is the only function that actually creates a FilterGraph class... */
5447 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5449 IFilterGraphImpl *fimpl;
5452 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
5456 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
5457 fimpl->pUnkOuter = pUnkOuter;
5458 fimpl->bUnkOuterValid = FALSE;
5459 fimpl->bAggregatable = FALSE;
5460 fimpl->defaultclock = TRUE;
5461 fimpl->IInner_vtbl = &IInner_VTable;
5462 fimpl->IFilterGraph2_vtbl = &IFilterGraph2_VTable;
5463 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
5464 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
5465 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
5466 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
5467 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
5468 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
5469 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
5470 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
5471 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
5472 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
5474 fimpl->ppFiltersInGraph = NULL;
5475 fimpl->pFilterNames = NULL;
5476 fimpl->nFilters = 0;
5477 fimpl->filterCapacity = 0;
5478 fimpl->nameIndex = 1;
5479 fimpl->refClock = NULL;
5480 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
5481 fimpl->HandleEcComplete = TRUE;
5482 fimpl->HandleEcRepaint = TRUE;
5483 fimpl->HandleEcClockChanged = TRUE;
5484 fimpl->notif.hWnd = 0;
5485 fimpl->notif.disabled = FALSE;
5486 fimpl->nRenderers = 0;
5487 fimpl->EcCompleteCount = 0;
5488 fimpl->state = State_Stopped;
5489 EventsQueue_Init(&fimpl->evqueue);
5490 InitializeCriticalSection(&fimpl->cs);
5491 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
5492 fimpl->nItfCacheEntries = 0;
5493 memcpy(&fimpl->timeformatseek, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
5494 fimpl->start_time = fimpl->pause_time = 0;
5495 fimpl->stop_position = -1;
5496 fimpl->punkFilterMapper2 = NULL;
5497 fimpl->recursioncount = 0;
5499 /* create Filtermapper aggregated. */
5500 hr = CoCreateInstance(&CLSID_FilterMapper2, pUnkOuter ? pUnkOuter : (IUnknown*)&fimpl->IInner_vtbl, CLSCTX_INPROC_SERVER,
5501 &IID_IUnknown, (LPVOID*)&fimpl->punkFilterMapper2);
5503 if (SUCCEEDED(hr)) {
5504 hr = IUnknown_QueryInterface(fimpl->punkFilterMapper2, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
5507 if (SUCCEEDED(hr)) {
5508 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5509 if (pUnkOuter) IUnknown_Release(pUnkOuter);
5510 else IUnknown_Release((IUnknown*)&fimpl->IInner_vtbl);
5514 ERR("Unable to create filter mapper (%x)\n", hr);
5515 if (fimpl->punkFilterMapper2) IUnknown_Release(fimpl->punkFilterMapper2);
5516 CloseHandle(fimpl->hEventCompletion);
5517 EventsQueue_Destroy(&fimpl->evqueue);
5518 fimpl->cs.DebugInfo->Spare[0] = 0;
5519 DeleteCriticalSection(&fimpl->cs);
5520 CoTaskMemFree(fimpl);
5528 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5530 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5531 return FilterGraph_create(pUnkOuter, ppObj);