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;
187 IBaseFilter *refClockProvider;
189 HANDLE hEventCompletion;
190 int CompletionStatus;
194 int HandleEcComplete;
196 int HandleEcClockChanged;
199 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
200 int nItfCacheEntries;
201 IUnknown * pUnkOuter;
206 REFERENCE_TIME start_time;
207 REFERENCE_TIME pause_time;
208 LONGLONG stop_position;
212 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
213 REFIID riid, LPVOID * ppv);
214 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This);
215 static ULONG Filtergraph_Release(IFilterGraphImpl *This);
217 static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown * iface,
220 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
221 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
223 if (This->bAggregatable)
224 This->bUnkOuterValid = TRUE;
226 if (IsEqualGUID(&IID_IUnknown, riid)) {
227 *ppvObj = &(This->IInner_vtbl);
228 TRACE(" returning IUnknown interface (%p)\n", *ppvObj);
229 } else if (IsEqualGUID(&IID_IFilterGraph, riid) ||
230 IsEqualGUID(&IID_IFilterGraph2, riid) ||
231 IsEqualGUID(&IID_IGraphBuilder, riid)) {
232 *ppvObj = &(This->IFilterGraph2_vtbl);
233 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
234 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
235 *ppvObj = &(This->IMediaControl_vtbl);
236 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
237 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
238 *ppvObj = &(This->IMediaSeeking_vtbl);
239 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
240 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
241 *ppvObj = &(This->IBasicAudio_vtbl);
242 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
243 } else if (IsEqualGUID(&IID_IBasicVideo, riid) ||
244 IsEqualGUID(&IID_IBasicVideo2, riid)) {
245 *ppvObj = &(This->IBasicVideo_vtbl);
246 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj);
247 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
248 *ppvObj = &(This->IVideoWindow_vtbl);
249 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
250 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
251 IsEqualGUID(&IID_IMediaEventEx, riid)) {
252 *ppvObj = &(This->IMediaEventEx_vtbl);
253 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
254 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
255 IsEqualGUID(&IID_IPersist, riid)) {
256 *ppvObj = &(This->IMediaFilter_vtbl);
257 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
258 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
259 *ppvObj = &(This->IMediaEventSink_vtbl);
260 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
261 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
262 *ppvObj = &(This->IGraphConfig_vtbl);
263 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
264 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
265 *ppvObj = &(This->IMediaPosition_vtbl);
266 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
267 } else if (IsEqualGUID(&IID_IFilterMapper, riid)) {
268 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj);
269 return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
270 } else if (IsEqualGUID(&IID_IFilterMapper2, riid)) {
271 *ppvObj = This->pFilterMapper2;
272 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj);
273 } else if (IsEqualGUID(&IID_IFilterMapper3, riid)) {
274 *ppvObj = This->pFilterMapper2;
275 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
278 FIXME("unknown interface %s\n", debugstr_guid(riid));
279 return E_NOINTERFACE;
282 IUnknown_AddRef((IUnknown *)(*ppvObj));
286 static ULONG WINAPI FilterGraphInner_AddRef(IUnknown * iface) {
287 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
288 ULONG ref = InterlockedIncrement(&This->ref);
290 TRACE("(%p)->(): new ref = %d\n", This, ref);
295 static ULONG WINAPI FilterGraphInner_Release(IUnknown * iface)
297 ICOM_THIS_MULTI(IFilterGraphImpl, IInner_vtbl, iface);
298 ULONG ref = InterlockedDecrement(&This->ref);
300 TRACE("(%p)->(): new ref = %d\n", This, ref);
305 This->ref = 1; /* guard against reentrancy (aggregation). */
307 IMediaControl_Stop((IMediaControl*)&(This->IMediaControl_vtbl));
309 while (This->nFilters)
310 IFilterGraph2_RemoveFilter((IFilterGraph2*)This, This->ppFiltersInGraph[0]);
313 IReferenceClock_Release(This->refClock);
315 for (i = 0; i < This->nItfCacheEntries; i++)
317 if (This->ItfCacheEntries[i].iface)
318 IUnknown_Release(This->ItfCacheEntries[i].iface);
321 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 interface below.
323 * NOTE: Filtergraph_AddRef isn't suitable, because bUnkOuterValid may be FALSE but punkOuter non-NULL
324 * and already passed as punkOuter to filtermapper in FilterGraph_create - this will happen in case of
325 * CoCreateInstance of filtergraph with non-null pUnkOuter and REFIID other than IID_Unknown that is
326 * cleaning up after error. */
327 if (This->pUnkOuter) IUnknown_AddRef(This->pUnkOuter);
328 else IUnknown_AddRef((IUnknown*)&This->IInner_vtbl);
330 IFilterMapper2_Release(This->pFilterMapper2);
331 IUnknown_Release(This->punkFilterMapper2);
333 CloseHandle(This->hEventCompletion);
334 EventsQueue_Destroy(&This->evqueue);
335 This->cs.DebugInfo->Spare[0] = 0;
336 DeleteCriticalSection(&This->cs);
337 CoTaskMemFree(This->ppFiltersInGraph);
338 CoTaskMemFree(This->pFilterNames);
345 /*** IUnknown methods ***/
346 static HRESULT WINAPI FilterGraph2_QueryInterface(IFilterGraph2 *iface,
349 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
351 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
352 return Filtergraph_QueryInterface(This, riid, ppvObj);
355 static ULONG WINAPI FilterGraph2_AddRef(IFilterGraph2 *iface) {
356 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
358 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This, iface);
360 return Filtergraph_AddRef(This);
363 static ULONG WINAPI FilterGraph2_Release(IFilterGraph2 *iface) {
364 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
366 TRACE("(%p/%p)->() calling FilterGraph Release\n", This, iface);
368 return Filtergraph_Release(This);
371 /*** IFilterGraph methods ***/
372 static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface,
373 IBaseFilter *pFilter,
375 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
378 WCHAR* wszFilterName = NULL;
379 int duplicate_name = FALSE;
381 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
386 wszFilterName = CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
390 /* Check if name already exists */
391 for(i = 0; i < This->nFilters; i++)
392 if (!strcmpW(This->pFilterNames[i], pName))
394 duplicate_name = TRUE;
399 /* If no name given or name already existing, generate one */
400 if (!pName || duplicate_name)
402 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
403 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
405 for (j = 0; j < 10000 ; j++)
409 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
411 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
412 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
414 /* Check if the generated name already exists */
415 for(i = 0; i < This->nFilters; i++)
416 if (!strcmpW(This->pFilterNames[i], wszFilterName))
419 /* Compute next index and exit if generated name is suitable */
420 if (This->nameIndex++ == 10000)
422 if (i == This->nFilters)
425 /* Unable to find a suitable name */
428 CoTaskMemFree(wszFilterName);
429 return VFW_E_DUPLICATE_NAME;
433 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
435 if (This->nFilters + 1 > This->filterCapacity)
437 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
438 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
439 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
440 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
441 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
442 if (This->filterCapacity)
444 CoTaskMemFree(This->ppFiltersInGraph);
445 CoTaskMemFree(This->pFilterNames);
447 This->ppFiltersInGraph = ppNewFilters;
448 This->pFilterNames = pNewNames;
449 This->filterCapacity = newCapacity;
452 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
456 IBaseFilter_AddRef(pFilter);
457 This->ppFiltersInGraph[This->nFilters] = pFilter;
458 This->pFilterNames[This->nFilters] = wszFilterName;
460 IBaseFilter_SetSyncSource(pFilter, This->refClock);
463 CoTaskMemFree(wszFilterName);
465 if (SUCCEEDED(hr) && duplicate_name)
466 return VFW_S_DUPLICATE_NAME;
471 static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface, IBaseFilter *pFilter)
473 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
477 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
479 /* FIXME: check graph is stopped */
481 for (i = 0; i < This->nFilters; i++)
483 if (This->ppFiltersInGraph[i] == pFilter)
485 IEnumPins *penumpins = NULL;
488 if (This->defaultclock && This->refClockProvider == pFilter)
490 IMediaFilter_SetSyncSource((IMediaFilter*)&This->IMediaFilter_vtbl, NULL);
491 This->defaultclock = 1;
494 TRACE("Removing filter %s\n", debugstr_w(This->pFilterNames[i]));
495 IBaseFilter_GetState(pFilter, 0, &state);
496 if (state == State_Running)
497 IBaseFilter_Pause(pFilter);
498 if (state != State_Stopped)
499 IBaseFilter_Stop(pFilter);
501 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
504 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK)
508 IPin_ConnectedTo(ppin, &victim);
511 h = IPin_Disconnect(victim);
512 TRACE("Disconnect other side: %08x\n", h);
513 if (h == VFW_E_NOT_STOPPED)
516 IPin_QueryPinInfo(victim, &pinfo);
518 IBaseFilter_GetState(pinfo.pFilter, 0, &state);
519 if (state == State_Running)
520 IBaseFilter_Pause(pinfo.pFilter);
521 IBaseFilter_Stop(pinfo.pFilter);
522 IBaseFilter_Release(pinfo.pFilter);
523 h = IPin_Disconnect(victim);
524 TRACE("Disconnect retry: %08x\n", h);
526 IPin_Release(victim);
528 h = IPin_Disconnect(ppin);
529 TRACE("Disconnect 2: %08x\n", h);
533 IEnumPins_Release(penumpins);
536 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
539 IBaseFilter_SetSyncSource(pFilter, NULL);
540 IBaseFilter_Release(pFilter);
541 CoTaskMemFree(This->pFilterNames[i]);
542 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
543 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
545 /* Invalidate interfaces in the cache */
546 for (i = 0; i < This->nItfCacheEntries; i++)
547 if (pFilter == This->ItfCacheEntries[i].filter)
549 IUnknown_Release(This->ItfCacheEntries[i].iface);
550 This->ItfCacheEntries[i].iface = NULL;
551 This->ItfCacheEntries[i].filter = NULL;
559 return hr; /* FIXME: check this error code */
562 static HRESULT WINAPI FilterGraph2_EnumFilters(IFilterGraph2 *iface,
563 IEnumFilters **ppEnum) {
564 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
566 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
568 return IEnumFiltersImpl_Construct(This->ppFiltersInGraph, This->nFilters, ppEnum);
571 static HRESULT WINAPI FilterGraph2_FindFilterByName(IFilterGraph2 *iface,
573 IBaseFilter **ppFilter) {
574 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
577 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
582 for (i = 0; i < This->nFilters; i++)
584 if (!strcmpW(pName, This->pFilterNames[i]))
586 *ppFilter = This->ppFiltersInGraph[i];
587 IBaseFilter_AddRef(*ppFilter);
593 return VFW_E_NOT_FOUND;
596 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
597 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
599 static HRESULT CheckCircularConnection(IFilterGraphImpl *This, IPin *out, IPin *in)
603 PIN_INFO info_out, info_in;
605 hr = IPin_QueryPinInfo(out, &info_out);
608 if (info_out.dir != PINDIR_OUTPUT)
610 IBaseFilter_Release(info_out.pFilter);
614 hr = IPin_QueryPinInfo(in, &info_in);
616 IBaseFilter_Release(info_in.pFilter);
619 if (info_in.dir != PINDIR_INPUT)
625 if (info_out.pFilter == info_in.pFilter)
626 hr = VFW_E_CIRCULAR_GRAPH;
632 hr = IBaseFilter_EnumPins(info_out.pFilter, &enumpins);
636 IEnumPins_Reset(enumpins);
637 while ((hr = IEnumPins_Next(enumpins, 1, &test, NULL)) == S_OK)
639 PIN_DIRECTION dir = PINDIR_OUTPUT;
640 IPin_QueryDirection(test, &dir);
641 if (dir == PINDIR_INPUT)
644 IPin_ConnectedTo(test, &victim);
647 hr = CheckCircularConnection(This, victim, in);
648 IPin_Release(victim);
658 IEnumPins_Release(enumpins);
662 IBaseFilter_Release(info_out.pFilter);
664 ERR("Checking filtergraph returned %08x, something's not right!\n", hr);
667 /* Debugging filtergraphs not enabled */
673 /* NOTE: despite the implication, it doesn't matter which
674 * way round you put in the input and output pins */
675 static HRESULT WINAPI FilterGraph2_ConnectDirect(IFilterGraph2 *iface,
678 const AM_MEDIA_TYPE *pmt) {
682 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
684 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
686 /* FIXME: check pins are in graph */
688 if (TRACE_ON(quartz))
692 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
696 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
697 IBaseFilter_Release(PinInfo.pFilter);
699 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
703 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
704 IBaseFilter_Release(PinInfo.pFilter);
707 hr = IPin_QueryDirection(ppinIn, &dir);
710 if (dir == PINDIR_INPUT)
712 hr = CheckCircularConnection(This, ppinOut, ppinIn);
714 hr = IPin_Connect(ppinOut, ppinIn, pmt);
718 hr = CheckCircularConnection(This, ppinIn, ppinOut);
720 hr = IPin_Connect(ppinIn, ppinOut, pmt);
727 static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface,
729 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
730 IPin *pConnectedTo = NULL;
732 PIN_DIRECTION pindir;
734 IPin_QueryDirection(ppin, &pindir);
735 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
737 TRACE("Querying connected to failed: %x\n", hr);
740 IPin_Disconnect(ppin);
741 IPin_Disconnect(pConnectedTo);
742 if (pindir == PINDIR_INPUT)
743 hr = IPin_Connect(pConnectedTo, ppin, NULL);
745 hr = IPin_Connect(ppin, pConnectedTo, NULL);
746 IPin_Release(pConnectedTo);
748 WARN("Reconnecting pins failed, pins are not connected now..\n");
749 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
753 static HRESULT WINAPI FilterGraph2_Disconnect(IFilterGraph2 *iface, IPin *ppin)
755 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
757 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
762 return IPin_Disconnect(ppin);
765 static HRESULT WINAPI FilterGraph2_SetDefaultSyncSource(IFilterGraph2 *iface) {
766 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
767 IReferenceClock *pClock = NULL;
771 TRACE("(%p/%p)->() live sources not handled properly!\n", iface, This);
773 EnterCriticalSection(&This->cs);
775 for (i = 0; i < This->nFilters; ++i)
778 IAMFilterMiscFlags *flags = NULL;
779 IUnknown_QueryInterface(This->ppFiltersInGraph[i], &IID_IAMFilterMiscFlags, (void**)&flags);
782 miscflags = IAMFilterMiscFlags_GetMiscFlags(flags);
783 IUnknown_Release(flags);
784 if (miscflags == AM_FILTER_MISC_FLAGS_IS_RENDERER)
785 IUnknown_QueryInterface(This->ppFiltersInGraph[i], &IID_IReferenceClock, (void**)&pClock);
792 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pClock);
793 This->refClockProvider = NULL;
796 This->refClockProvider = This->ppFiltersInGraph[i];
800 hr = IMediaFilter_SetSyncSource((IMediaFilter*)&(This->IMediaFilter_vtbl), pClock);
801 This->defaultclock = TRUE;
802 IReferenceClock_Release(pClock);
804 LeaveCriticalSection(&This->cs);
809 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
811 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
812 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
813 IPropertyBag * pPropBagCat = NULL;
818 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
821 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
824 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
829 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
832 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
835 IPropertyBag_Release(pPropBagCat);
840 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
845 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
846 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
849 } else if (hr == S_FALSE) {
850 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
851 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
853 WARN("Error (%x)\n", hr);
855 } else if (hr == E_NOTIMPL) {
856 /* Input connected to all outputs */
857 IEnumPins* penumpins;
860 TRACE("E_NOTIMPL\n");
861 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
863 WARN("filter Enumpins failed (%x)\n", hr);
867 /* Count output pins */
868 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
869 PIN_DIRECTION pindir;
870 IPin_QueryDirection(ppin, &pindir);
871 if (pindir == PINDIR_OUTPUT)
875 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
876 /* Retrieve output pins */
877 IEnumPins_Reset(penumpins);
879 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
880 PIN_DIRECTION pindir;
881 IPin_QueryDirection(ppin, &pindir);
882 if (pindir == PINDIR_OUTPUT)
883 (*pppins)[i++] = ppin;
887 IEnumPins_Release(penumpins);
890 WARN("Next failed (%x)\n", hr);
893 } else if (FAILED(hr)) {
894 WARN("Cannot get internal connection (%x)\n", hr);
902 /*** IGraphBuilder methods ***/
903 static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, IPin *ppinIn)
905 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
907 AM_MEDIA_TYPE* mt = NULL;
908 IEnumMediaTypes* penummt = NULL;
910 IEnumPins* penumpins;
911 IEnumMoniker* pEnumMoniker;
920 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
922 if (TRACE_ON(quartz))
924 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
928 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
929 IBaseFilter_Release(PinInfo.pFilter);
931 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
935 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
936 IBaseFilter_Release(PinInfo.pFilter);
939 EnterCriticalSection(&This->cs);
940 ++This->recursioncount;
941 if (This->recursioncount >= 5)
943 WARN("Recursion count has reached %d\n", This->recursioncount);
944 hr = VFW_E_CANNOT_CONNECT;
948 hr = IPin_QueryDirection(ppinOut, &dir);
952 if (dir == PINDIR_INPUT)
961 hr = CheckCircularConnection(This, ppinOut, ppinIn);
965 /* Try direct connection first */
966 hr = IPin_Connect(ppinOut, ppinIn, NULL);
970 TRACE("Direct connection failed, trying to render using extra filters\n");
972 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
976 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
977 IBaseFilter_Release(PinInfo.pFilter);
981 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
982 * filter to the minor mediatype of input pin of the renderer */
983 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
986 WARN("EnumMediaTypes (%x)\n", hr);
990 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
992 WARN("IEnumMediaTypes_Next (%x)\n", hr);
998 WARN("No media type found!\n");
999 hr = VFW_E_INVALIDMEDIATYPE;
1002 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
1003 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
1005 /* Try to find a suitable filter that can connect to the pin to render */
1006 tab[0] = mt->majortype;
1007 tab[1] = mt->subtype;
1008 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1010 WARN("Unable to enum filters (%x)\n", hr);
1014 hr = VFW_E_CANNOT_RENDER;
1015 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1020 IPin* ppinfilter = NULL;
1021 IBaseFilter* pfilter = NULL;
1023 hr = GetFilterInfo(pMoniker, &clsid, &var);
1024 IMoniker_Release(pMoniker);
1026 WARN("Unable to retrieve filter info (%x)\n", hr);
1030 if (IsEqualGUID(&clsid, &FilterCLSID)) {
1031 /* Skip filter (same as the one the output pin belongs to) */
1035 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
1037 WARN("Unable to create filter (%x), trying next one\n", hr);
1041 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1043 WARN("Unable to add filter (%x)\n", hr);
1044 IBaseFilter_Release(pfilter);
1051 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1053 WARN("Enumpins (%x)\n", hr);
1057 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
1058 IEnumPins_Release(penumpins);
1061 WARN("Obtaining next pin: (%x)\n", hr);
1065 WARN("Cannot use this filter: no pins\n");
1069 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1071 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1074 TRACE("Successfully connected to filter, follow chain...\n");
1076 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1077 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
1079 if (SUCCEEDED(hr)) {
1082 IPin_Disconnect(ppinfilter);
1083 IPin_Disconnect(ppinOut);
1086 TRACE("pins to consider: %d\n", nb);
1087 for(i = 0; i < nb; i++)
1089 LPWSTR pinname = NULL;
1091 TRACE("Processing pin %u\n", i);
1093 hr = IPin_QueryId(ppins[i], &pinname);
1096 if (pinname[0] == '~')
1098 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname));
1102 hr = IFilterGraph2_Connect(iface, ppins[i], ppinIn);
1103 CoTaskMemFree(pinname);
1107 TRACE("Cannot connect pin %p (%x)\n", ppinfilter, hr);
1109 IPin_Release(ppins[i]);
1110 if (SUCCEEDED(hr)) break;
1112 while (++i < nb) IPin_Release(ppins[i]);
1113 CoTaskMemFree(ppins);
1114 IPin_Release(ppinfilter);
1115 IBaseFilter_Release(pfilter);
1118 IPin_Disconnect(ppinfilter);
1119 IPin_Disconnect(ppinOut);
1120 IFilterGraph2_RemoveFilter(iface, pfilter);
1128 if (ppinfilter) IPin_Release(ppinfilter);
1130 IFilterGraph2_RemoveFilter(iface, pfilter);
1131 IBaseFilter_Release(pfilter);
1137 IEnumMediaTypes_Release(penummt);
1139 DeleteMediaType(mt);
1140 --This->recursioncount;
1141 LeaveCriticalSection(&This->cs);
1142 TRACE("--> %08x\n", hr);
1143 return SUCCEEDED(hr) ? S_OK : hr;
1146 static HRESULT FilterGraph2_RenderRecurse(IFilterGraphImpl *This, IPin *ppinOut)
1148 /* This pin has been connected now, try to call render on all pins that aren't connected */
1151 IEnumPins *enumpins = NULL;
1152 BOOL renderany = FALSE;
1153 BOOL renderall = TRUE;
1155 IPin_QueryPinInfo(ppinOut, &info);
1157 IBaseFilter_EnumPins(info.pFilter, &enumpins);
1158 /* Don't need to hold a reference, IEnumPins does */
1159 IBaseFilter_Release(info.pFilter);
1161 IEnumPins_Reset(enumpins);
1162 while (IEnumPins_Next(enumpins, 1, &to, NULL) == S_OK)
1164 PIN_DIRECTION dir = PINDIR_INPUT;
1166 IPin_QueryDirection(to, &dir);
1168 if (dir == PINDIR_OUTPUT)
1172 IPin_ConnectedTo(to, &out);
1176 hr = IFilterGraph2_Render((IFilterGraph2 *)&This->IFilterGraph2_vtbl, to);
1189 IEnumPins_Release(enumpins);
1195 return VFW_S_PARTIAL_RENDER;
1197 return VFW_E_CANNOT_RENDER;
1200 /* Ogg hates me if I create a direct rendering method
1202 * It can only connect to a pin properly once, so use a recursive method that does
1204 * +----+ --- (PIN 1) (Render is called on this pin)
1206 * +----+ --- (PIN 2)
1208 * Enumerate possible renderers that EXACTLY match the requested type
1210 * If none is available, try to add intermediate filters that can connect to the input pin
1211 * then call Render on that intermediate pin's output pins
1212 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1213 * and another filter that can connect to the input pin is tried
1214 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1215 * It's recursive, but fun!
1218 static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut)
1220 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1221 IEnumMediaTypes* penummt;
1226 IEnumMoniker* pEnumMoniker;
1232 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
1234 if (TRACE_ON(quartz))
1238 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
1242 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
1243 IBaseFilter_Release(PinInfo.pFilter);
1246 /* Try to find out if there is a renderer for the specified subtype already, and use that
1248 EnterCriticalSection(&This->cs);
1249 for (x = 0; x < This->nFilters; ++x)
1251 IEnumPins *enumpins = NULL;
1254 hr = IBaseFilter_EnumPins(This->ppFiltersInGraph[x], &enumpins);
1256 if (FAILED(hr) || !enumpins)
1259 IEnumPins_Reset(enumpins);
1260 while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
1263 PIN_DIRECTION dir = PINDIR_OUTPUT;
1265 IPin_QueryDirection(pin, &dir);
1266 if (dir != PINDIR_INPUT)
1271 IPin_ConnectedTo(pin, &to);
1275 hr = FilterGraph2_ConnectDirect(iface, ppinOut, pin, NULL);
1278 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut, pin, hr);
1281 hr = FilterGraph2_RenderRecurse(This, pin);
1284 IPin_Disconnect(ppinOut);
1285 IPin_Disconnect(pin);
1288 IEnumPins_Release(enumpins);
1289 LeaveCriticalSection(&This->cs);
1292 WARN("Could not connect!\n");
1299 IEnumPins_Release(enumpins);
1302 LeaveCriticalSection(&This->cs);
1304 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
1306 WARN("EnumMediaTypes (%x)\n", hr);
1310 IEnumMediaTypes_Reset(penummt);
1312 /* Looks like no existing renderer of the kind exists
1313 * Try adding new ones
1315 tab[0] = tab[1] = GUID_NULL;
1316 while (SUCCEEDED(hr))
1318 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
1320 WARN("IEnumMediaTypes_Next (%x)\n", hr);
1325 hr = VFW_E_CANNOT_RENDER;
1330 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
1331 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
1333 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1334 if (IsEqualIID(&tab[0], &mt->majortype) && IsEqualIID(&tab[1], &mt->subtype))
1336 DeleteMediaType(mt);
1340 /* Try to find a suitable renderer with the same media type */
1341 tab[0] = mt->majortype;
1342 tab[1] = mt->subtype;
1343 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1346 WARN("Unable to enum filters (%x)\n", hr);
1352 while (IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1357 IBaseFilter* pfilter = NULL;
1358 IEnumPins* penumpins = NULL;
1361 hr = GetFilterInfo(pMoniker, &clsid, &var);
1362 IMoniker_Release(pMoniker);
1364 WARN("Unable to retrieve filter info (%x)\n", hr);
1368 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&pfilter);
1371 WARN("Unable to create filter (%x), trying next one\n", hr);
1375 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1377 WARN("Unable to add filter (%x)\n", hr);
1378 IBaseFilter_Release(pfilter);
1383 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1385 WARN("Splitter Enumpins (%x)\n", hr);
1389 while ((hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin)) == S_OK)
1399 hr = IPin_QueryDirection(ppinfilter, &dir);
1401 IPin_Release(ppinfilter);
1402 WARN("QueryDirection failed (%x)\n", hr);
1405 if (dir != PINDIR_INPUT) {
1406 IPin_Release(ppinfilter);
1407 continue; /* Wrong direction */
1410 /* Connect the pin to the "Renderer" */
1411 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1412 IPin_Release(ppinfilter);
1415 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_UNION(&var, bstrVal)), hr);
1418 TRACE("Connected, recursing %s\n", debugstr_w(V_UNION(&var, bstrVal)));
1422 hr = FilterGraph2_RenderRecurse(This, ppinfilter);
1424 WARN("Unable to connect recursively (%x)\n", hr);
1427 IBaseFilter_Release(pfilter);
1430 if (SUCCEEDED(hr)) {
1431 IEnumPins_Release(penumpins);
1432 break; /* out of IEnumMoniker_Next loop */
1435 /* IEnumPins_Next failed, all other failure case caught by goto error */
1436 WARN("IEnumPins_Next (%x)\n", hr);
1442 IEnumPins_Release(penumpins);
1444 IFilterGraph2_RemoveFilter(iface, pfilter);
1445 IBaseFilter_Release(pfilter);
1447 if (SUCCEEDED(hr)) DebugBreak();
1450 IEnumMoniker_Release(pEnumMoniker);
1452 DeleteMediaType(mt);
1458 IEnumMediaTypes_Release(penummt);
1462 static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface,
1463 LPCWSTR lpcwstrFile,
1464 LPCWSTR lpcwstrPlayList)
1466 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1467 static const WCHAR string[] = {'R','e','a','d','e','r',0};
1468 IBaseFilter* preader = NULL;
1469 IPin* ppinreader = NULL;
1470 IEnumPins* penumpins = NULL;
1472 BOOL partial = FALSE;
1473 HRESULT any = FALSE;
1475 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1477 if (lpcwstrPlayList != NULL)
1478 return E_INVALIDARG;
1480 hr = IFilterGraph2_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1485 hr = IBaseFilter_EnumPins(preader, &penumpins);
1488 while (IEnumPins_Next(penumpins, 1, &ppinreader, NULL) == S_OK)
1492 IPin_QueryDirection(ppinreader, &dir);
1493 if (dir == PINDIR_OUTPUT)
1497 hr = IFilterGraph2_Render(iface, ppinreader);
1498 TRACE("Render %08x\n", hr);
1500 for (i = 0; i < This->nFilters; ++i)
1501 TRACE("Filters in chain: %s\n", debugstr_w(This->pFilterNames[i]));
1508 IPin_Release(ppinreader);
1510 IEnumPins_Release(penumpins);
1513 hr = VFW_E_CANNOT_RENDER;
1515 hr = VFW_S_PARTIAL_RENDER;
1519 IBaseFilter_Release(preader);
1521 TRACE("--> %08x\n", hr);
1525 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1526 static HRESULT GetFileSourceFilter(LPCOLESTR pszFileName, IBaseFilter **filter)
1528 static const WCHAR wszReg[] = {'M','e','d','i','a',' ','T','y','p','e','\\','E','x','t','e','n','s','i','o','n','s',0};
1533 lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszReg, 0, KEY_READ, &extkey);
1534 hr = HRESULT_FROM_WIN32(lRet);
1538 static const WCHAR filtersource[] = {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
1539 WCHAR *ext = PathFindExtensionW(pszFileName);
1540 WCHAR clsid_key[39];
1542 DWORD size = sizeof(clsid_key);
1547 CloseHandle(extkey);
1551 lRet = RegOpenKeyExW(extkey, ext, 0, KEY_READ, &pathkey);
1552 hr = HRESULT_FROM_WIN32(lRet);
1553 CloseHandle(extkey);
1557 lRet = RegQueryValueExW(pathkey, filtersource, NULL, NULL, (LPBYTE)clsid_key, &size);
1558 hr = HRESULT_FROM_WIN32(lRet);
1559 CloseHandle(pathkey);
1563 CLSIDFromString(clsid_key, &clsid);
1565 TRACE("CLSID: %s\n", debugstr_guid(&clsid));
1566 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter);
1569 IFileSourceFilter *source = NULL;
1570 hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID*)&source);
1572 IFileSourceFilter_Release(source);
1574 IBaseFilter_Release(*filter);
1582 static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface,
1583 LPCWSTR lpcwstrFileName,
1584 LPCWSTR lpcwstrFilterName,
1585 IBaseFilter **ppFilter) {
1586 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1588 IBaseFilter* preader;
1589 IFileSourceFilter* pfile = NULL;
1593 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1595 /* Try from file name first, then fall back to default asynchronous reader */
1596 hr = GetFileSourceFilter(lpcwstrFileName, &preader);
1599 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader);
1601 WARN("Unable to create file source filter (%x)\n", hr);
1605 hr = IFilterGraph2_AddFilter(iface, preader, lpcwstrFilterName);
1607 WARN("Unable add filter (%x)\n", hr);
1608 IBaseFilter_Release(preader);
1612 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1614 WARN("Unable to get IFileSourceInterface (%x)\n", hr);
1618 /* Load the file in the file source filter */
1619 hr = IFileSourceFilter_Load(pfile, lpcwstrFileName, NULL);
1621 WARN("Load (%x)\n", hr);
1625 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1627 WARN("GetCurFile (%x)\n", hr);
1631 TRACE("File %s\n", debugstr_w(filename));
1632 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1633 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1636 *ppFilter = preader;
1637 IFileSourceFilter_Release(pfile);
1643 IFileSourceFilter_Release(pfile);
1644 IFilterGraph2_RemoveFilter(iface, preader);
1645 IBaseFilter_Release(preader);
1650 static HRESULT WINAPI FilterGraph2_SetLogFile(IFilterGraph2 *iface,
1652 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1654 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1659 static HRESULT WINAPI FilterGraph2_Abort(IFilterGraph2 *iface) {
1660 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1662 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1667 static HRESULT WINAPI FilterGraph2_ShouldOperationContinue(IFilterGraph2 *iface) {
1668 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1670 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1675 /*** IFilterGraph2 methods ***/
1676 static HRESULT WINAPI FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2 *iface,
1679 LPCWSTR lpcwstrFilterName,
1680 IBaseFilter **ppFilter) {
1681 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1683 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This, iface, pMoniker, pCtx, debugstr_w(lpcwstrFilterName), ppFilter);
1688 static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface,
1690 const AM_MEDIA_TYPE *pmt) {
1691 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1693 TRACE("(%p/%p)->(%p %p): stub !!!\n", This, iface, ppin, pmt);
1698 static HRESULT WINAPI FilterGraph2_RenderEx(IFilterGraph2 *iface,
1702 ICOM_THIS_MULTI(IFilterGraphImpl, IFilterGraph2_vtbl, iface);
1704 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This, iface, pPinOut, dwFlags, pvContext);
1710 static const IFilterGraph2Vtbl IFilterGraph2_VTable =
1712 FilterGraph2_QueryInterface,
1713 FilterGraph2_AddRef,
1714 FilterGraph2_Release,
1715 FilterGraph2_AddFilter,
1716 FilterGraph2_RemoveFilter,
1717 FilterGraph2_EnumFilters,
1718 FilterGraph2_FindFilterByName,
1719 FilterGraph2_ConnectDirect,
1720 FilterGraph2_Reconnect,
1721 FilterGraph2_Disconnect,
1722 FilterGraph2_SetDefaultSyncSource,
1723 FilterGraph2_Connect,
1724 FilterGraph2_Render,
1725 FilterGraph2_RenderFile,
1726 FilterGraph2_AddSourceFilter,
1727 FilterGraph2_SetLogFile,
1729 FilterGraph2_ShouldOperationContinue,
1730 FilterGraph2_AddSourceFilterForMoniker,
1731 FilterGraph2_ReconnectEx,
1732 FilterGraph2_RenderEx
1735 /*** IUnknown methods ***/
1736 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface,
1739 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1741 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1743 return Filtergraph_QueryInterface(This, riid, ppvObj);
1746 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface) {
1747 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1749 TRACE("(%p/%p)->()\n", This, iface);
1751 return Filtergraph_AddRef(This);
1754 static ULONG WINAPI MediaControl_Release(IMediaControl *iface) {
1755 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1757 TRACE("(%p/%p)->()\n", This, iface);
1759 return Filtergraph_Release(This);
1763 /*** IDispatch methods ***/
1764 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface,
1766 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1768 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1773 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface,
1776 ITypeInfo**ppTInfo) {
1777 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1779 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1784 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface,
1790 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1792 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1797 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface,
1798 DISPID dispIdMember,
1802 DISPPARAMS*pDispParams,
1804 EXCEPINFO*pExepInfo,
1806 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1808 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);
1813 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *, DWORD_PTR data);
1815 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter, DWORD_PTR data)
1824 TRACE("%p %p\n", pGraph, pOutputPin);
1825 PinInfo.pFilter = NULL;
1827 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1831 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1833 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1834 IPin_Release(pInputPin);
1841 TRACE("Reached a renderer\n");
1842 /* Count renderers for end of stream notification */
1843 pGraph->nRenderers++;
1847 for(i = 0; i < nb; i++)
1849 /* Explore the graph downstream from this pin
1850 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1851 * several input pins are connected to the same output (a MUX for instance). */
1852 ExploreGraph(pGraph, ppPins[i], FoundFilter, data);
1853 IPin_Release(ppPins[i]);
1856 CoTaskMemFree(ppPins);
1858 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1860 FoundFilter(PinInfo.pFilter, data);
1863 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1867 static HRESULT WINAPI SendRun(IBaseFilter *pFilter, DWORD_PTR data)
1869 REFERENCE_TIME time = *(REFERENCE_TIME*)data;
1870 return IBaseFilter_Run(pFilter, time);
1873 static HRESULT WINAPI SendPause(IBaseFilter *pFilter, DWORD_PTR data)
1875 return IBaseFilter_Pause(pFilter);
1878 static HRESULT WINAPI SendStop(IBaseFilter *pFilter, DWORD_PTR data)
1880 return IBaseFilter_Stop(pFilter);
1883 static HRESULT WINAPI SendGetState(IBaseFilter *pFilter, DWORD_PTR data)
1886 DWORD time_end = data;
1887 DWORD time_now = GetTickCount();
1890 if (time_end == INFINITE)
1894 else if (time_end > time_now)
1896 wait = time_end - time_now;
1901 return IBaseFilter_GetState(pFilter, wait, &state);
1905 static HRESULT SendFilterMessage(IMediaControl *iface, fnFoundFilter FoundFilter, DWORD_PTR data)
1907 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1909 IBaseFilter* pfilter;
1915 TRACE("(%p/%p)->()\n", This, iface);
1917 /* Explorer the graph from source filters to renderers, determine renderers
1918 * number and run filters from renderers to source filters */
1919 This->nRenderers = 0;
1920 ResetEvent(This->hEventCompletion);
1922 for(i = 0; i < This->nFilters; i++)
1925 pfilter = This->ppFiltersInGraph[i];
1926 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1929 WARN("Enum pins failed %x\n", hr);
1932 /* Check if it is a source filter */
1933 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1935 IPin_QueryDirection(pPin, &dir);
1937 if (dir == PINDIR_INPUT)
1945 TRACE("Found a source filter %p\n", pfilter);
1946 IEnumPins_Reset(pEnum);
1947 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1949 /* Explore the graph downstream from this pin */
1950 ExploreGraph(This, pPin, FoundFilter, data);
1953 FoundFilter(pfilter, data);
1955 IEnumPins_Release(pEnum);
1961 /*** IMediaControl methods ***/
1962 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface) {
1963 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1964 TRACE("(%p/%p)->()\n", This, iface);
1966 EnterCriticalSection(&This->cs);
1967 if (This->state == State_Running)
1969 This->EcCompleteCount = 0;
1971 if (This->defaultclock && !This->refClock)
1972 IFilterGraph2_SetDefaultSyncSource((IFilterGraph2*)This);
1977 IReferenceClock_GetTime(This->refClock, &now);
1978 if (This->state == State_Stopped)
1979 This->start_time = now + 500000;
1980 else if (This->pause_time >= 0)
1981 This->start_time += now - This->pause_time;
1983 This->start_time = now;
1985 else This->start_time = 0;
1987 SendFilterMessage(iface, SendRun, (DWORD_PTR)&This->start_time);
1988 This->state = State_Running;
1990 LeaveCriticalSection(&This->cs);
1994 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface) {
1995 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
1996 TRACE("(%p/%p)->()\n", This, iface);
1998 EnterCriticalSection(&This->cs);
1999 if (This->state == State_Paused)
2002 if (This->state == State_Running && This->refClock && This->start_time >= 0)
2003 IReferenceClock_GetTime(This->refClock, &This->pause_time);
2005 This->pause_time = -1;
2007 SendFilterMessage(iface, SendPause, 0);
2008 This->state = State_Paused;
2010 LeaveCriticalSection(&This->cs);
2014 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface) {
2015 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2016 TRACE("(%p/%p)->()\n", This, iface);
2018 if (This->state == State_Stopped) return S_OK;
2020 EnterCriticalSection(&This->cs);
2021 if (This->state == State_Running) SendFilterMessage(iface, SendPause, 0);
2022 SendFilterMessage(iface, SendStop, 0);
2023 This->state = State_Stopped;
2024 LeaveCriticalSection(&This->cs);
2028 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface,
2030 OAFilterState *pfs) {
2031 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2034 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pfs);
2039 EnterCriticalSection(&This->cs);
2044 end = GetTickCount() + msTimeout;
2046 else if (msTimeout < 0)
2055 SendFilterMessage(iface, SendGetState, end);
2057 LeaveCriticalSection(&This->cs);
2062 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface,
2064 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2066 FIXME("(%p/%p)->(%s (%p)): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename);
2071 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface,
2073 IDispatch **ppUnk) {
2074 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2076 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
2081 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface,
2082 IDispatch **ppUnk) {
2083 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2085 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2090 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
2091 IDispatch **ppUnk) {
2092 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2094 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2099 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface) {
2100 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaControl_vtbl, iface);
2102 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
2108 static const IMediaControlVtbl IMediaControl_VTable =
2110 MediaControl_QueryInterface,
2111 MediaControl_AddRef,
2112 MediaControl_Release,
2113 MediaControl_GetTypeInfoCount,
2114 MediaControl_GetTypeInfo,
2115 MediaControl_GetIDsOfNames,
2116 MediaControl_Invoke,
2120 MediaControl_GetState,
2121 MediaControl_RenderFile,
2122 MediaControl_AddSourceFilter,
2123 MediaControl_get_FilterCollection,
2124 MediaControl_get_RegFilterCollection,
2125 MediaControl_StopWhenReady
2129 /*** IUnknown methods ***/
2130 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface,
2133 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2135 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2137 return Filtergraph_QueryInterface(This, riid, ppvObj);
2140 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface) {
2141 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2143 TRACE("(%p/%p)->()\n", This, iface);
2145 return Filtergraph_AddRef(This);
2148 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface) {
2149 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2151 TRACE("(%p/%p)->()\n", This, iface);
2153 return Filtergraph_Release(This);
2156 typedef HRESULT (WINAPI *fnFoundSeek)(IFilterGraphImpl *This, IMediaSeeking*, DWORD_PTR arg);
2158 static HRESULT all_renderers_seek(IFilterGraphImpl *This, fnFoundSeek FoundSeek, DWORD_PTR arg) {
2159 BOOL allnotimpl = TRUE;
2161 HRESULT hr, hr_return = S_OK;
2163 TRACE("(%p)->(%p %08lx)\n", This, FoundSeek, arg);
2164 /* Send a message to all renderers, they are responsible for broadcasting it further */
2166 for(i = 0; i < This->nFilters; i++)
2168 IMediaSeeking *seek = NULL;
2169 IBaseFilter* pfilter = This->ppFiltersInGraph[i];
2170 IAMFilterMiscFlags *flags = NULL;
2172 IUnknown_QueryInterface(pfilter, &IID_IAMFilterMiscFlags, (void**)&flags);
2175 filterflags = IAMFilterMiscFlags_GetMiscFlags(flags);
2176 IUnknown_Release(flags);
2177 if (filterflags != AM_FILTER_MISC_FLAGS_IS_RENDERER)
2180 IBaseFilter_QueryInterface(pfilter, &IID_IMediaSeeking, (void**)&seek);
2183 hr = FoundSeek(This, seek, arg);
2184 IMediaSeeking_Release(seek);
2185 if (hr_return != E_NOTIMPL)
2187 if (hr_return == S_OK || (FAILED(hr) && hr != E_NOTIMPL && SUCCEEDED(hr_return)))
2196 static HRESULT WINAPI FoundCapabilities(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pcaps)
2201 hr = IMediaSeeking_GetCapabilities(seek, &caps);
2205 /* Only add common capabilities everything supports */
2206 *(DWORD*)pcaps &= caps;
2211 /*** IMediaSeeking methods ***/
2212 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface,
2213 DWORD *pCapabilities) {
2214 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2216 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2221 EnterCriticalSection(&This->cs);
2222 *pCapabilities = 0xffffffff;
2224 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2225 LeaveCriticalSection(&This->cs);
2230 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface,
2231 DWORD *pCapabilities) {
2232 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2235 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2240 EnterCriticalSection(&This->cs);
2241 originalcaps = *pCapabilities;
2242 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2243 LeaveCriticalSection(&This->cs);
2248 if (!*pCapabilities)
2250 if (*pCapabilities != originalcaps)
2255 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface,
2256 const GUID *pFormat) {
2257 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2262 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2264 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2266 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2273 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface,
2275 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2280 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This, iface, pFormat);
2281 memcpy(pFormat, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
2286 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface,
2288 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2293 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2294 memcpy(pFormat, &This->timeformatseek, sizeof(GUID));
2299 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface,
2300 const GUID *pFormat) {
2301 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2303 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2307 if (memcmp(pFormat, &This->timeformatseek, sizeof(GUID)))
2313 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface,
2314 const GUID *pFormat) {
2315 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2320 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2322 if (This->state != State_Stopped)
2323 return VFW_E_WRONG_STATE;
2325 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2327 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2328 return E_INVALIDARG;
2334 static HRESULT WINAPI FoundDuration(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pduration)
2337 LONGLONG duration = 0, *pdur = (LONGLONG*)pduration;
2339 hr = IMediaSeeking_GetDuration(seek, &duration);
2343 if (*pdur < duration)
2348 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface,
2349 LONGLONG *pDuration) {
2350 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2353 TRACE("(%p/%p)->(%p)\n", This, iface, pDuration);
2358 EnterCriticalSection(&This->cs);
2360 hr = all_renderers_seek(This, FoundDuration, (DWORD_PTR)pDuration);
2361 LeaveCriticalSection(&This->cs);
2363 TRACE("--->%08x\n", hr);
2367 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface,
2369 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2372 TRACE("(%p/%p)->(%p)\n", This, iface, pStop);
2377 EnterCriticalSection(&This->cs);
2378 if (This->stop_position < 0)
2379 /* Stop position not set, use duration instead */
2380 hr = IMediaSeeking_GetDuration(iface, pStop);
2382 *pStop = This->stop_position;
2383 LeaveCriticalSection(&This->cs);
2388 static HRESULT WINAPI FoundCurrentPosition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pposition)
2391 LONGLONG pos = 0, *ppos = (LONGLONG*)pposition;
2393 hr = IMediaSeeking_GetCurrentPosition(seek, &pos);
2397 if (*ppos < 0 || pos < *ppos)
2402 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface,
2403 LONGLONG *pCurrent) {
2404 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2410 EnterCriticalSection(&This->cs);
2412 hr = all_renderers_seek(This, FoundCurrentPosition, (DWORD_PTR)pCurrent);
2413 if (hr == E_NOTIMPL) {
2417 LeaveCriticalSection(&This->cs);
2419 TRACE("Time: %u.%03u\n", (DWORD)(*pCurrent / 10000000), (DWORD)((*pCurrent / 10000)%1000));
2424 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface,
2426 const GUID *pTargetFormat,
2428 const GUID *pSourceFormat) {
2429 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2431 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
2432 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
2438 LONGLONG* current, *stop;
2439 DWORD curflags, stopflags;
2442 static HRESULT WINAPI found_setposition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pargs)
2444 struct pos_args *args = (void*)pargs;
2446 return IMediaSeeking_SetPositions(seek, args->current, args->curflags, args->stop, args->stopflags);
2449 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface,
2451 DWORD dwCurrentFlags,
2453 DWORD dwStopFlags) {
2454 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2457 struct pos_args args;
2459 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
2461 EnterCriticalSection(&This->cs);
2462 state = This->state;
2463 TRACE("State: %s\n", state == State_Running ? "Running" : (state == State_Paused ? "Paused" : (state == State_Stopped ? "Stopped" : "UNKNOWN")));
2465 if ((dwCurrentFlags & 0x7) != AM_SEEKING_AbsolutePositioning &&
2466 (dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning)
2467 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags & 0x7);
2469 if ((dwStopFlags & 0x7) == AM_SEEKING_AbsolutePositioning)
2470 This->stop_position = *pStop;
2471 else if ((dwStopFlags & 0x7) != AM_SEEKING_NoPositioning)
2472 FIXME("Stop position not handled yet!\n");
2474 if (state == State_Running && !(dwCurrentFlags & AM_SEEKING_NoFlush))
2475 IMediaControl_Pause((IMediaControl*)&This->IMediaControl_vtbl);
2476 args.current = pCurrent;
2478 args.curflags = dwCurrentFlags;
2479 args.stopflags = dwStopFlags;
2480 hr = all_renderers_seek(This, found_setposition, (DWORD_PTR)&args);
2482 if ((dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning)
2483 This->pause_time = This->start_time = -1;
2484 if (state == State_Running && !(dwCurrentFlags & AM_SEEKING_NoFlush))
2485 IMediaControl_Run((IMediaControl*)&This->IMediaControl_vtbl);
2486 LeaveCriticalSection(&This->cs);
2491 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
2494 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2497 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pCurrent, pStop);
2498 hr = IMediaSeeking_GetCurrentPosition(iface, pCurrent);
2500 hr = IMediaSeeking_GetStopPosition(iface, pStop);
2505 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
2506 LONGLONG *pEarliest,
2507 LONGLONG *pLatest) {
2508 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2510 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
2515 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface,
2517 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2519 FIXME("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
2524 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface,
2526 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2528 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
2533 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface,
2534 LONGLONG *pllPreroll) {
2535 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaSeeking_vtbl, iface);
2537 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
2543 static const IMediaSeekingVtbl IMediaSeeking_VTable =
2545 MediaSeeking_QueryInterface,
2546 MediaSeeking_AddRef,
2547 MediaSeeking_Release,
2548 MediaSeeking_GetCapabilities,
2549 MediaSeeking_CheckCapabilities,
2550 MediaSeeking_IsFormatSupported,
2551 MediaSeeking_QueryPreferredFormat,
2552 MediaSeeking_GetTimeFormat,
2553 MediaSeeking_IsUsingTimeFormat,
2554 MediaSeeking_SetTimeFormat,
2555 MediaSeeking_GetDuration,
2556 MediaSeeking_GetStopPosition,
2557 MediaSeeking_GetCurrentPosition,
2558 MediaSeeking_ConvertTimeFormat,
2559 MediaSeeking_SetPositions,
2560 MediaSeeking_GetPositions,
2561 MediaSeeking_GetAvailable,
2562 MediaSeeking_SetRate,
2563 MediaSeeking_GetRate,
2564 MediaSeeking_GetPreroll
2567 static inline IFilterGraphImpl *impl_from_IMediaPosition( IMediaPosition *iface )
2569 return (IFilterGraphImpl *)((char*)iface - FIELD_OFFSET(IFilterGraphImpl, IMediaPosition_vtbl));
2572 /*** IUnknown methods ***/
2573 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj)
2575 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2577 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2578 return Filtergraph_QueryInterface(This, riid, ppvObj);
2581 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface)
2583 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2585 TRACE("(%p/%p)->()\n", This, iface);
2586 return Filtergraph_AddRef(This);
2589 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface)
2591 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2593 TRACE("(%p/%p)->()\n", This, iface);
2594 return Filtergraph_Release(This);
2597 /*** IDispatch methods ***/
2598 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo){
2599 FIXME("(%p) stub!\n", iface);
2603 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo){
2604 FIXME("(%p) stub!\n", iface);
2608 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId){
2609 FIXME("(%p) stub!\n", iface);
2613 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr){
2614 FIXME("(%p) stub!\n", iface);
2618 /*** IMediaPosition methods ***/
2619 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength)
2622 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2623 HRESULT hr = IMediaSeeking_GetDuration( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &duration );
2624 if (SUCCEEDED(hr)) *plength = duration;
2628 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime)
2630 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2631 LONGLONG reftime = llTime;
2633 return IMediaSeeking_SetPositions((IMediaSeeking *)&This->IMediaSeeking_vtbl,
2634 &reftime, AM_SEEKING_AbsolutePositioning,
2635 NULL, AM_SEEKING_NoPositioning);
2638 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime)
2640 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2642 HRESULT hr = IMediaSeeking_GetCurrentPosition( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &pos );
2643 if (SUCCEEDED(hr)) *pllTime = pos;
2647 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime)
2649 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2651 HRESULT hr = IMediaSeeking_GetStopPosition( (IMediaSeeking *)&This->IMediaSeeking_vtbl, &pos );
2652 if (SUCCEEDED(hr)) *pllTime = pos;
2656 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime)
2658 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2659 LONGLONG reftime = llTime;
2661 return IMediaSeeking_SetPositions((IMediaSeeking *)&This->IMediaSeeking_vtbl,
2662 NULL, AM_SEEKING_NoPositioning,
2663 &reftime, AM_SEEKING_AbsolutePositioning);
2666 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime){
2667 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2671 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime){
2672 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2676 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate)
2678 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2679 return IMediaSeeking_SetRate((IMediaSeeking *)&This->IMediaSeeking_vtbl, dRate);
2682 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate)
2684 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2685 return IMediaSeeking_GetRate((IMediaSeeking *)&This->IMediaSeeking_vtbl, pdRate);
2688 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward){
2689 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
2693 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward){
2694 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
2699 static const IMediaPositionVtbl IMediaPosition_VTable =
2701 MediaPosition_QueryInterface,
2702 MediaPosition_AddRef,
2703 MediaPosition_Release,
2704 MediaPosition_GetTypeInfoCount,
2705 MediaPosition_GetTypeInfo,
2706 MediaPosition_GetIDsOfNames,
2707 MediaPosition_Invoke,
2708 MediaPosition_get_Duration,
2709 MediaPosition_put_CurrentPosition,
2710 MediaPosition_get_CurrentPosition,
2711 MediaPosition_get_StopTime,
2712 MediaPosition_put_StopTime,
2713 MediaPosition_get_PrerollTime,
2714 MediaPosition_put_PrerollTime,
2715 MediaPosition_put_Rate,
2716 MediaPosition_get_Rate,
2717 MediaPosition_CanSeekForward,
2718 MediaPosition_CanSeekBackward
2721 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
2723 HRESULT hr = E_NOINTERFACE;
2727 /* Check if the interface type is already registered */
2728 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
2729 if (riid == pGraph->ItfCacheEntries[entry].riid)
2731 if (pGraph->ItfCacheEntries[entry].iface)
2733 /* Return the interface if available */
2734 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
2740 if (entry >= MAX_ITF_CACHE_ENTRIES)
2742 FIXME("Not enough space to store interface in the cache\n");
2743 return E_OUTOFMEMORY;
2746 /* Find a filter supporting the requested interface */
2747 for (i = 0; i < pGraph->nFilters; i++)
2749 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
2752 pGraph->ItfCacheEntries[entry].riid = riid;
2753 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
2754 pGraph->ItfCacheEntries[entry].iface = *ppvObj;
2755 if (entry >= pGraph->nItfCacheEntries)
2756 pGraph->nItfCacheEntries++;
2759 if (hr != E_NOINTERFACE)
2766 /*** IUnknown methods ***/
2767 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface,
2770 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2772 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2774 return Filtergraph_QueryInterface(This, riid, ppvObj);
2777 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface) {
2778 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2780 TRACE("(%p/%p)->()\n", This, iface);
2782 return Filtergraph_AddRef(This);
2785 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface) {
2786 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2788 TRACE("(%p/%p)->()\n", This, iface);
2790 return Filtergraph_Release(This);
2793 /*** IDispatch methods ***/
2794 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface,
2796 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2797 IBasicAudio* pBasicAudio;
2800 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
2802 EnterCriticalSection(&This->cs);
2804 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2807 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
2809 LeaveCriticalSection(&This->cs);
2814 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface,
2817 ITypeInfo**ppTInfo) {
2818 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2819 IBasicAudio* pBasicAudio;
2822 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
2824 EnterCriticalSection(&This->cs);
2826 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2829 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
2831 LeaveCriticalSection(&This->cs);
2836 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface,
2842 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2843 IBasicAudio* pBasicAudio;
2846 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
2848 EnterCriticalSection(&This->cs);
2850 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2853 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
2855 LeaveCriticalSection(&This->cs);
2860 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface,
2861 DISPID dispIdMember,
2865 DISPPARAMS*pDispParams,
2867 EXCEPINFO*pExepInfo,
2869 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2870 IBasicAudio* pBasicAudio;
2873 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);
2875 EnterCriticalSection(&This->cs);
2877 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2880 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
2882 LeaveCriticalSection(&This->cs);
2887 /*** IBasicAudio methods ***/
2888 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface,
2890 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2891 IBasicAudio* pBasicAudio;
2894 TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
2896 EnterCriticalSection(&This->cs);
2898 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2901 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
2903 LeaveCriticalSection(&This->cs);
2908 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface,
2910 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2911 IBasicAudio* pBasicAudio;
2914 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
2916 EnterCriticalSection(&This->cs);
2918 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2921 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
2923 LeaveCriticalSection(&This->cs);
2928 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface,
2930 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2931 IBasicAudio* pBasicAudio;
2934 TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
2936 EnterCriticalSection(&This->cs);
2938 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2941 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
2943 LeaveCriticalSection(&This->cs);
2948 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface,
2950 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicAudio_vtbl, iface);
2951 IBasicAudio* pBasicAudio;
2954 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
2956 EnterCriticalSection(&This->cs);
2958 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
2961 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
2963 LeaveCriticalSection(&This->cs);
2968 static const IBasicAudioVtbl IBasicAudio_VTable =
2970 BasicAudio_QueryInterface,
2973 BasicAudio_GetTypeInfoCount,
2974 BasicAudio_GetTypeInfo,
2975 BasicAudio_GetIDsOfNames,
2977 BasicAudio_put_Volume,
2978 BasicAudio_get_Volume,
2979 BasicAudio_put_Balance,
2980 BasicAudio_get_Balance
2983 /*** IUnknown methods ***/
2984 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo2 *iface,
2987 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2989 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2991 return Filtergraph_QueryInterface(This, riid, ppvObj);
2994 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo2 *iface) {
2995 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
2997 TRACE("(%p/%p)->()\n", This, iface);
2999 return Filtergraph_AddRef(This);
3002 static ULONG WINAPI BasicVideo_Release(IBasicVideo2 *iface) {
3003 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3005 TRACE("(%p/%p)->()\n", This, iface);
3007 return Filtergraph_Release(This);
3010 /*** IDispatch methods ***/
3011 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo2 *iface,
3013 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3014 IBasicVideo* pBasicVideo;
3017 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3019 EnterCriticalSection(&This->cs);
3021 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3024 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
3026 LeaveCriticalSection(&This->cs);
3031 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo2 *iface,
3034 ITypeInfo**ppTInfo) {
3035 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3036 IBasicVideo* pBasicVideo;
3039 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3041 EnterCriticalSection(&This->cs);
3043 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3046 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
3048 LeaveCriticalSection(&This->cs);
3053 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo2 *iface,
3059 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3060 IBasicVideo* pBasicVideo;
3063 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3065 EnterCriticalSection(&This->cs);
3067 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3070 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
3072 LeaveCriticalSection(&This->cs);
3077 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo2 *iface,
3078 DISPID dispIdMember,
3082 DISPPARAMS*pDispParams,
3084 EXCEPINFO*pExepInfo,
3086 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3087 IBasicVideo* pBasicVideo;
3090 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);
3092 EnterCriticalSection(&This->cs);
3094 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3097 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3099 LeaveCriticalSection(&This->cs);
3104 /*** IBasicVideo methods ***/
3105 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo2 *iface,
3106 REFTIME *pAvgTimePerFrame) {
3107 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3108 IBasicVideo* pBasicVideo;
3111 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
3113 EnterCriticalSection(&This->cs);
3115 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3118 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
3120 LeaveCriticalSection(&This->cs);
3125 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo2 *iface,
3127 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3128 IBasicVideo* pBasicVideo;
3131 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
3133 EnterCriticalSection(&This->cs);
3135 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3138 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
3140 LeaveCriticalSection(&This->cs);
3145 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo2 *iface,
3146 LONG *pBitErrorRate) {
3147 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3148 IBasicVideo* pBasicVideo;
3151 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
3153 EnterCriticalSection(&This->cs);
3155 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3158 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
3160 LeaveCriticalSection(&This->cs);
3165 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo2 *iface,
3166 LONG *pVideoWidth) {
3167 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3168 IBasicVideo* pBasicVideo;
3171 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
3173 EnterCriticalSection(&This->cs);
3175 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3178 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
3180 LeaveCriticalSection(&This->cs);
3185 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo2 *iface,
3186 LONG *pVideoHeight) {
3187 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3188 IBasicVideo* pBasicVideo;
3191 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
3193 EnterCriticalSection(&This->cs);
3195 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3198 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
3200 LeaveCriticalSection(&This->cs);
3205 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo2 *iface,
3207 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3208 IBasicVideo* pBasicVideo;
3211 TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
3213 EnterCriticalSection(&This->cs);
3215 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3218 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
3220 LeaveCriticalSection(&This->cs);
3225 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo2 *iface,
3226 LONG *pSourceLeft) {
3227 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3228 IBasicVideo* pBasicVideo;
3231 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
3233 EnterCriticalSection(&This->cs);
3235 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3238 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
3240 LeaveCriticalSection(&This->cs);
3245 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo2 *iface,
3247 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3248 IBasicVideo* pBasicVideo;
3251 TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
3253 EnterCriticalSection(&This->cs);
3255 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3258 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
3260 LeaveCriticalSection(&This->cs);
3265 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo2 *iface,
3266 LONG *pSourceWidth) {
3267 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3268 IBasicVideo* pBasicVideo;
3271 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
3273 EnterCriticalSection(&This->cs);
3275 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3278 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
3280 LeaveCriticalSection(&This->cs);
3285 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo2 *iface,
3287 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3288 IBasicVideo* pBasicVideo;
3291 TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
3293 EnterCriticalSection(&This->cs);
3295 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3298 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
3300 LeaveCriticalSection(&This->cs);
3305 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo2 *iface,
3307 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3308 IBasicVideo* pBasicVideo;
3311 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
3313 EnterCriticalSection(&This->cs);
3315 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3318 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
3320 LeaveCriticalSection(&This->cs);
3325 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo2 *iface,
3326 LONG SourceHeight) {
3327 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3328 IBasicVideo* pBasicVideo;
3331 TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
3333 EnterCriticalSection(&This->cs);
3335 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3338 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
3340 LeaveCriticalSection(&This->cs);
3345 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo2 *iface,
3346 LONG *pSourceHeight) {
3347 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3348 IBasicVideo* pBasicVideo;
3351 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
3353 EnterCriticalSection(&This->cs);
3355 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3358 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
3360 LeaveCriticalSection(&This->cs);
3365 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo2 *iface,
3366 LONG DestinationLeft) {
3367 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3368 IBasicVideo* pBasicVideo;
3371 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
3373 EnterCriticalSection(&This->cs);
3375 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3378 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
3380 LeaveCriticalSection(&This->cs);
3385 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo2 *iface,
3386 LONG *pDestinationLeft) {
3387 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3388 IBasicVideo* pBasicVideo;
3391 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
3393 EnterCriticalSection(&This->cs);
3395 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3398 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
3400 LeaveCriticalSection(&This->cs);
3405 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo2 *iface,
3406 LONG DestinationWidth) {
3407 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3408 IBasicVideo* pBasicVideo;
3411 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
3413 EnterCriticalSection(&This->cs);
3415 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3418 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
3420 LeaveCriticalSection(&This->cs);
3425 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo2 *iface,
3426 LONG *pDestinationWidth) {
3427 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3428 IBasicVideo* pBasicVideo;
3431 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
3433 EnterCriticalSection(&This->cs);
3435 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3438 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
3440 LeaveCriticalSection(&This->cs);
3445 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo2 *iface,
3446 LONG DestinationTop) {
3447 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3448 IBasicVideo* pBasicVideo;
3451 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
3453 EnterCriticalSection(&This->cs);
3455 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3458 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
3460 LeaveCriticalSection(&This->cs);
3465 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo2 *iface,
3466 LONG *pDestinationTop) {
3467 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3468 IBasicVideo* pBasicVideo;
3471 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
3473 EnterCriticalSection(&This->cs);
3475 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3478 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
3480 LeaveCriticalSection(&This->cs);
3485 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo2 *iface,
3486 LONG DestinationHeight) {
3487 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3488 IBasicVideo* pBasicVideo;
3491 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
3493 EnterCriticalSection(&This->cs);
3495 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3498 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
3500 LeaveCriticalSection(&This->cs);
3505 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo2 *iface,
3506 LONG *pDestinationHeight) {
3507 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3508 IBasicVideo* pBasicVideo;
3511 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
3513 EnterCriticalSection(&This->cs);
3515 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3518 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
3520 LeaveCriticalSection(&This->cs);
3525 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo2 *iface,
3530 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3531 IBasicVideo* pBasicVideo;
3534 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3536 EnterCriticalSection(&This->cs);
3538 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3541 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
3543 LeaveCriticalSection(&This->cs);
3548 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo2 *iface,
3553 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3554 IBasicVideo* pBasicVideo;
3557 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3559 EnterCriticalSection(&This->cs);
3561 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3564 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3566 LeaveCriticalSection(&This->cs);
3571 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo2 *iface) {
3572 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3573 IBasicVideo* pBasicVideo;
3576 TRACE("(%p/%p)->()\n", This, iface);
3578 EnterCriticalSection(&This->cs);
3580 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3583 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
3585 LeaveCriticalSection(&This->cs);
3590 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo2 *iface,
3595 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3596 IBasicVideo* pBasicVideo;
3599 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3601 EnterCriticalSection(&This->cs);
3603 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3606 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
3608 LeaveCriticalSection(&This->cs);
3613 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo2 *iface,
3618 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3619 IBasicVideo* pBasicVideo;
3622 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3624 EnterCriticalSection(&This->cs);
3626 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3629 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3631 LeaveCriticalSection(&This->cs);
3636 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo2 *iface) {
3637 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3638 IBasicVideo* pBasicVideo;
3641 TRACE("(%p/%p)->()\n", This, iface);
3643 EnterCriticalSection(&This->cs);
3645 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3648 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
3650 LeaveCriticalSection(&This->cs);
3655 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo2 *iface,
3658 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3659 IBasicVideo* pBasicVideo;
3662 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3664 EnterCriticalSection(&This->cs);
3666 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3669 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
3671 LeaveCriticalSection(&This->cs);
3676 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo2 *iface,
3681 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3682 IBasicVideo* pBasicVideo;
3685 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
3687 EnterCriticalSection(&This->cs);
3689 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3692 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
3694 LeaveCriticalSection(&This->cs);
3699 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo2 *iface,
3702 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3703 IBasicVideo* pBasicVideo;
3706 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
3708 EnterCriticalSection(&This->cs);
3710 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3713 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
3715 LeaveCriticalSection(&This->cs);
3720 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo2 *iface) {
3721 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3722 IBasicVideo* pBasicVideo;
3725 TRACE("(%p/%p)->()\n", This, iface);
3727 EnterCriticalSection(&This->cs);
3729 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3732 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
3734 LeaveCriticalSection(&This->cs);
3739 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo2 *iface) {
3740 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3741 IBasicVideo* pBasicVideo;
3744 TRACE("(%p/%p)->()\n", This, iface);
3746 EnterCriticalSection(&This->cs);
3748 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3751 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
3753 LeaveCriticalSection(&This->cs);
3758 static HRESULT WINAPI BasicVideo2_GetPreferredAspectRatio(IBasicVideo2 *iface, LONG *plAspectX, LONG *plAspectY) {
3759 ICOM_THIS_MULTI(IFilterGraphImpl, IBasicVideo_vtbl, iface);
3760 IBasicVideo2 *pBasicVideo2;
3763 TRACE("(%p/%p)->()\n", This, iface);
3765 EnterCriticalSection(&This->cs);
3767 hr = GetTargetInterface(This, &IID_IBasicVideo2, (LPVOID*)&pBasicVideo2);
3770 hr = BasicVideo2_GetPreferredAspectRatio(iface, plAspectX, plAspectY);
3772 LeaveCriticalSection(&This->cs);
3777 static const IBasicVideo2Vtbl IBasicVideo_VTable =
3779 BasicVideo_QueryInterface,
3782 BasicVideo_GetTypeInfoCount,
3783 BasicVideo_GetTypeInfo,
3784 BasicVideo_GetIDsOfNames,
3786 BasicVideo_get_AvgTimePerFrame,
3787 BasicVideo_get_BitRate,
3788 BasicVideo_get_BitErrorRate,
3789 BasicVideo_get_VideoWidth,
3790 BasicVideo_get_VideoHeight,
3791 BasicVideo_put_SourceLeft,
3792 BasicVideo_get_SourceLeft,
3793 BasicVideo_put_SourceWidth,
3794 BasicVideo_get_SourceWidth,
3795 BasicVideo_put_SourceTop,
3796 BasicVideo_get_SourceTop,
3797 BasicVideo_put_SourceHeight,
3798 BasicVideo_get_SourceHeight,
3799 BasicVideo_put_DestinationLeft,
3800 BasicVideo_get_DestinationLeft,
3801 BasicVideo_put_DestinationWidth,
3802 BasicVideo_get_DestinationWidth,
3803 BasicVideo_put_DestinationTop,
3804 BasicVideo_get_DestinationTop,
3805 BasicVideo_put_DestinationHeight,
3806 BasicVideo_get_DestinationHeight,
3807 BasicVideo_SetSourcePosition,
3808 BasicVideo_GetSourcePosition,
3809 BasicVideo_SetDefaultSourcePosition,
3810 BasicVideo_SetDestinationPosition,
3811 BasicVideo_GetDestinationPosition,
3812 BasicVideo_SetDefaultDestinationPosition,
3813 BasicVideo_GetVideoSize,
3814 BasicVideo_GetVideoPaletteEntries,
3815 BasicVideo_GetCurrentImage,
3816 BasicVideo_IsUsingDefaultSource,
3817 BasicVideo_IsUsingDefaultDestination,
3818 BasicVideo2_GetPreferredAspectRatio
3822 /*** IUnknown methods ***/
3823 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface,
3826 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3828 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3830 return Filtergraph_QueryInterface(This, riid, ppvObj);
3833 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface) {
3834 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3836 TRACE("(%p/%p)->()\n", This, iface);
3838 return Filtergraph_AddRef(This);
3841 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface) {
3842 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3844 TRACE("(%p/%p)->()\n", This, iface);
3846 return Filtergraph_Release(This);
3849 /*** IDispatch methods ***/
3850 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface,
3852 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3853 IVideoWindow* pVideoWindow;
3856 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3858 EnterCriticalSection(&This->cs);
3860 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3863 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
3865 LeaveCriticalSection(&This->cs);
3870 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface,
3873 ITypeInfo**ppTInfo) {
3874 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3875 IVideoWindow* pVideoWindow;
3878 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3880 EnterCriticalSection(&This->cs);
3882 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3885 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
3887 LeaveCriticalSection(&This->cs);
3892 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface,
3898 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3899 IVideoWindow* pVideoWindow;
3902 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3904 EnterCriticalSection(&This->cs);
3906 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3909 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
3911 LeaveCriticalSection(&This->cs);
3916 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface,
3917 DISPID dispIdMember,
3921 DISPPARAMS*pDispParams,
3923 EXCEPINFO*pExepInfo,
3925 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3926 IVideoWindow* pVideoWindow;
3929 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);
3931 EnterCriticalSection(&This->cs);
3933 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3936 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3938 LeaveCriticalSection(&This->cs);
3944 /*** IVideoWindow methods ***/
3945 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface,
3947 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3948 IVideoWindow* pVideoWindow;
3951 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
3953 EnterCriticalSection(&This->cs);
3955 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3958 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
3960 LeaveCriticalSection(&This->cs);
3965 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface,
3967 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3968 IVideoWindow* pVideoWindow;
3971 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
3973 EnterCriticalSection(&This->cs);
3975 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3978 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
3980 LeaveCriticalSection(&This->cs);
3985 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface,
3987 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
3988 IVideoWindow* pVideoWindow;
3991 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyle);
3993 EnterCriticalSection(&This->cs);
3995 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
3998 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
4000 LeaveCriticalSection(&This->cs);
4005 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface,
4006 LONG *WindowStyle) {
4007 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4008 IVideoWindow* pVideoWindow;
4011 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
4013 EnterCriticalSection(&This->cs);
4015 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4018 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
4020 LeaveCriticalSection(&This->cs);
4025 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface,
4026 LONG WindowStyleEx) {
4027 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4028 IVideoWindow* pVideoWindow;
4031 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyleEx);
4033 EnterCriticalSection(&This->cs);
4035 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4038 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
4040 LeaveCriticalSection(&This->cs);
4045 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface,
4046 LONG *WindowStyleEx) {
4047 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4048 IVideoWindow* pVideoWindow;
4051 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
4053 EnterCriticalSection(&This->cs);
4055 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4058 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
4060 LeaveCriticalSection(&This->cs);
4065 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface,
4067 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4068 IVideoWindow* pVideoWindow;
4071 TRACE("(%p/%p)->(%d)\n", This, iface, AutoShow);
4073 EnterCriticalSection(&This->cs);
4075 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4078 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
4080 LeaveCriticalSection(&This->cs);
4085 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface,
4087 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4088 IVideoWindow* pVideoWindow;
4091 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
4093 EnterCriticalSection(&This->cs);
4095 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4098 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
4100 LeaveCriticalSection(&This->cs);
4105 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface,
4107 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4108 IVideoWindow* pVideoWindow;
4111 TRACE("(%p/%p)->(%d)\n", This, iface, WindowState);
4113 EnterCriticalSection(&This->cs);
4115 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4118 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
4120 LeaveCriticalSection(&This->cs);
4125 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface,
4126 LONG *WindowState) {
4127 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4128 IVideoWindow* pVideoWindow;
4131 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
4133 EnterCriticalSection(&This->cs);
4135 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4138 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
4140 LeaveCriticalSection(&This->cs);
4145 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface,
4146 LONG BackgroundPalette) {
4147 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4148 IVideoWindow* pVideoWindow;
4151 TRACE("(%p/%p)->(%d)\n", This, iface, BackgroundPalette);
4153 EnterCriticalSection(&This->cs);
4155 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4158 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
4160 LeaveCriticalSection(&This->cs);
4165 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
4166 LONG *pBackgroundPalette) {
4167 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4168 IVideoWindow* pVideoWindow;
4171 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
4173 EnterCriticalSection(&This->cs);
4175 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4178 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
4180 LeaveCriticalSection(&This->cs);
4185 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface,
4187 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4188 IVideoWindow* pVideoWindow;
4191 TRACE("(%p/%p)->(%d)\n", This, iface, Visible);
4193 EnterCriticalSection(&This->cs);
4195 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4198 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
4200 LeaveCriticalSection(&This->cs);
4205 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface,
4207 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4208 IVideoWindow* pVideoWindow;
4211 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
4213 EnterCriticalSection(&This->cs);
4215 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4218 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
4220 LeaveCriticalSection(&This->cs);
4225 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface,
4227 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4228 IVideoWindow* pVideoWindow;
4231 TRACE("(%p/%p)->(%d)\n", This, iface, Left);
4233 EnterCriticalSection(&This->cs);
4235 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4238 hr = IVideoWindow_put_Left(pVideoWindow, Left);
4240 LeaveCriticalSection(&This->cs);
4245 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface,
4247 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4248 IVideoWindow* pVideoWindow;
4251 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
4253 EnterCriticalSection(&This->cs);
4255 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4258 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
4260 LeaveCriticalSection(&This->cs);
4265 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface,
4267 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4268 IVideoWindow* pVideoWindow;
4271 TRACE("(%p/%p)->(%d)\n", This, iface, Width);
4273 EnterCriticalSection(&This->cs);
4275 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4278 hr = IVideoWindow_put_Width(pVideoWindow, Width);
4280 LeaveCriticalSection(&This->cs);
4285 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface,
4287 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4288 IVideoWindow* pVideoWindow;
4291 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
4293 EnterCriticalSection(&This->cs);
4295 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4298 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
4300 LeaveCriticalSection(&This->cs);
4305 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface,
4307 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4308 IVideoWindow* pVideoWindow;
4311 TRACE("(%p/%p)->(%d)\n", This, iface, Top);
4313 EnterCriticalSection(&This->cs);
4315 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4318 hr = IVideoWindow_put_Top(pVideoWindow, Top);
4320 LeaveCriticalSection(&This->cs);
4325 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface,
4327 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4328 IVideoWindow* pVideoWindow;
4331 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
4333 EnterCriticalSection(&This->cs);
4335 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4338 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
4340 LeaveCriticalSection(&This->cs);
4345 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface,
4347 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4348 IVideoWindow* pVideoWindow;
4351 TRACE("(%p/%p)->(%d)\n", This, iface, Height);
4353 EnterCriticalSection(&This->cs);
4355 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4358 hr = IVideoWindow_put_Height(pVideoWindow, Height);
4360 LeaveCriticalSection(&This->cs);
4365 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface,
4367 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4368 IVideoWindow* pVideoWindow;
4371 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
4373 EnterCriticalSection(&This->cs);
4375 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4378 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
4380 LeaveCriticalSection(&This->cs);
4385 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface,
4387 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4388 IVideoWindow* pVideoWindow;
4391 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
4393 EnterCriticalSection(&This->cs);
4395 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4398 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
4400 LeaveCriticalSection(&This->cs);
4405 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface,
4407 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4408 IVideoWindow* pVideoWindow;
4411 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
4413 EnterCriticalSection(&This->cs);
4415 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4418 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
4420 LeaveCriticalSection(&This->cs);
4425 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface,
4427 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4428 IVideoWindow* pVideoWindow;
4431 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
4433 EnterCriticalSection(&This->cs);
4435 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4438 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
4440 LeaveCriticalSection(&This->cs);
4445 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface,
4447 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4448 IVideoWindow* pVideoWindow;
4451 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
4453 EnterCriticalSection(&This->cs);
4455 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4458 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
4460 LeaveCriticalSection(&This->cs);
4465 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface,
4467 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4468 IVideoWindow* pVideoWindow;
4471 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
4473 EnterCriticalSection(&This->cs);
4475 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4478 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
4480 LeaveCriticalSection(&This->cs);
4485 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface,
4487 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4488 IVideoWindow* pVideoWindow;
4491 TRACE("(%p/%p)->(%d)\n", This, iface, Color);
4493 EnterCriticalSection(&This->cs);
4495 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4498 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
4500 LeaveCriticalSection(&This->cs);
4505 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface,
4506 LONG *FullScreenMode) {
4507 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4508 IVideoWindow* pVideoWindow;
4511 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
4513 EnterCriticalSection(&This->cs);
4515 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4518 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
4520 LeaveCriticalSection(&This->cs);
4525 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface,
4526 LONG FullScreenMode) {
4527 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4528 IVideoWindow* pVideoWindow;
4531 TRACE("(%p/%p)->(%d)\n", This, iface, FullScreenMode);
4533 EnterCriticalSection(&This->cs);
4535 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4538 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
4540 LeaveCriticalSection(&This->cs);
4545 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface,
4547 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4548 IVideoWindow* pVideoWindow;
4551 TRACE("(%p/%p)->(%d)\n", This, iface, Focus);
4553 EnterCriticalSection(&This->cs);
4555 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4558 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
4560 LeaveCriticalSection(&This->cs);
4565 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface,
4570 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4571 IVideoWindow* pVideoWindow;
4574 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This, iface, hwnd, uMsg, wParam, lParam);
4576 EnterCriticalSection(&This->cs);
4578 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4581 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
4583 LeaveCriticalSection(&This->cs);
4588 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface,
4593 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4594 IVideoWindow* pVideoWindow;
4597 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
4599 EnterCriticalSection(&This->cs);
4601 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4604 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
4606 LeaveCriticalSection(&This->cs);
4611 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface,
4616 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4617 IVideoWindow* pVideoWindow;
4620 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4622 EnterCriticalSection(&This->cs);
4624 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4627 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4629 LeaveCriticalSection(&This->cs);
4634 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface,
4637 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4638 IVideoWindow* pVideoWindow;
4641 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4643 EnterCriticalSection(&This->cs);
4645 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4648 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
4650 LeaveCriticalSection(&This->cs);
4655 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface,
4658 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4659 IVideoWindow* pVideoWindow;
4662 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4664 EnterCriticalSection(&This->cs);
4666 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4669 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
4671 LeaveCriticalSection(&This->cs);
4676 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface,
4681 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4682 IVideoWindow* pVideoWindow;
4685 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4687 EnterCriticalSection(&This->cs);
4689 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4692 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4694 LeaveCriticalSection(&This->cs);
4699 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface,
4701 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4702 IVideoWindow* pVideoWindow;
4705 TRACE("(%p/%p)->(%d)\n", This, iface, HideCursor);
4707 EnterCriticalSection(&This->cs);
4709 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4712 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
4714 LeaveCriticalSection(&This->cs);
4719 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface,
4720 LONG *CursorHidden) {
4721 ICOM_THIS_MULTI(IFilterGraphImpl, IVideoWindow_vtbl, iface);
4722 IVideoWindow* pVideoWindow;
4725 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
4727 EnterCriticalSection(&This->cs);
4729 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4732 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
4734 LeaveCriticalSection(&This->cs);
4740 static const IVideoWindowVtbl IVideoWindow_VTable =
4742 VideoWindow_QueryInterface,
4744 VideoWindow_Release,
4745 VideoWindow_GetTypeInfoCount,
4746 VideoWindow_GetTypeInfo,
4747 VideoWindow_GetIDsOfNames,
4749 VideoWindow_put_Caption,
4750 VideoWindow_get_Caption,
4751 VideoWindow_put_WindowStyle,
4752 VideoWindow_get_WindowStyle,
4753 VideoWindow_put_WindowStyleEx,
4754 VideoWindow_get_WindowStyleEx,
4755 VideoWindow_put_AutoShow,
4756 VideoWindow_get_AutoShow,
4757 VideoWindow_put_WindowState,
4758 VideoWindow_get_WindowState,
4759 VideoWindow_put_BackgroundPalette,
4760 VideoWindow_get_BackgroundPalette,
4761 VideoWindow_put_Visible,
4762 VideoWindow_get_Visible,
4763 VideoWindow_put_Left,
4764 VideoWindow_get_Left,
4765 VideoWindow_put_Width,
4766 VideoWindow_get_Width,
4767 VideoWindow_put_Top,
4768 VideoWindow_get_Top,
4769 VideoWindow_put_Height,
4770 VideoWindow_get_Height,
4771 VideoWindow_put_Owner,
4772 VideoWindow_get_Owner,
4773 VideoWindow_put_MessageDrain,
4774 VideoWindow_get_MessageDrain,
4775 VideoWindow_get_BorderColor,
4776 VideoWindow_put_BorderColor,
4777 VideoWindow_get_FullScreenMode,
4778 VideoWindow_put_FullScreenMode,
4779 VideoWindow_SetWindowForeground,
4780 VideoWindow_NotifyOwnerMessage,
4781 VideoWindow_SetWindowPosition,
4782 VideoWindow_GetWindowPosition,
4783 VideoWindow_GetMinIdealImageSize,
4784 VideoWindow_GetMaxIdealImageSize,
4785 VideoWindow_GetRestorePosition,
4786 VideoWindow_HideCursor,
4787 VideoWindow_IsCursorHidden
4791 /*** IUnknown methods ***/
4792 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface,
4795 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4797 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
4799 return Filtergraph_QueryInterface(This, riid, ppvObj);
4802 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface) {
4803 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4805 TRACE("(%p/%p)->()\n", This, iface);
4807 return Filtergraph_AddRef(This);
4810 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface) {
4811 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4813 TRACE("(%p/%p)->()\n", This, iface);
4815 return Filtergraph_Release(This);
4818 /*** IDispatch methods ***/
4819 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface,
4821 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4823 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
4828 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface,
4831 ITypeInfo**ppTInfo) {
4832 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4834 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
4839 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface,
4845 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4847 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4852 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface,
4853 DISPID dispIdMember,
4857 DISPPARAMS*pDispParams,
4859 EXCEPINFO*pExepInfo,
4861 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4863 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);
4868 /*** IMediaEvent methods ***/
4869 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface,
4871 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4873 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
4875 *hEvent = (OAEVENT)This->evqueue.msg_event;
4880 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface,
4885 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4888 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
4890 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
4892 *lEventCode = evt.lEventCode;
4893 *lParam1 = evt.lParam1;
4894 *lParam2 = evt.lParam2;
4902 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface,
4905 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4907 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pEvCode);
4909 if (This->state != State_Running)
4910 return VFW_E_WRONG_STATE;
4912 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
4914 *pEvCode = This->CompletionStatus;
4922 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface,
4924 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4926 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
4928 if (lEvCode == EC_COMPLETE)
4929 This->HandleEcComplete = FALSE;
4930 else if (lEvCode == EC_REPAINT)
4931 This->HandleEcRepaint = FALSE;
4932 else if (lEvCode == EC_CLOCK_CHANGED)
4933 This->HandleEcClockChanged = FALSE;
4940 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface,
4942 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4944 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
4946 if (lEvCode == EC_COMPLETE)
4947 This->HandleEcComplete = TRUE;
4948 else if (lEvCode == EC_REPAINT)
4949 This->HandleEcRepaint = TRUE;
4950 else if (lEvCode == EC_CLOCK_CHANGED)
4951 This->HandleEcClockChanged = TRUE;
4958 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface,
4962 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4964 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
4969 /*** IMediaEventEx methods ***/
4970 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface,
4973 LONG_PTR lInstanceData) {
4974 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4976 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This, iface, hwnd, lMsg, lInstanceData);
4978 This->notif.hWnd = (HWND)hwnd;
4979 This->notif.msg = lMsg;
4980 This->notif.instance = lInstanceData;
4985 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface,
4986 LONG lNoNotifyFlags) {
4987 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
4989 TRACE("(%p/%p)->(%d)\n", This, iface, lNoNotifyFlags);
4991 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
4992 return E_INVALIDARG;
4994 This->notif.disabled = lNoNotifyFlags;
4999 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface,
5000 LONG *lplNoNotifyFlags) {
5001 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventEx_vtbl, iface);
5003 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
5005 if (!lplNoNotifyFlags)
5008 *lplNoNotifyFlags = This->notif.disabled;
5014 static const IMediaEventExVtbl IMediaEventEx_VTable =
5016 MediaEvent_QueryInterface,
5019 MediaEvent_GetTypeInfoCount,
5020 MediaEvent_GetTypeInfo,
5021 MediaEvent_GetIDsOfNames,
5023 MediaEvent_GetEventHandle,
5024 MediaEvent_GetEvent,
5025 MediaEvent_WaitForCompletion,
5026 MediaEvent_CancelDefaultHandling,
5027 MediaEvent_RestoreDefaultHandling,
5028 MediaEvent_FreeEventParams,
5029 MediaEvent_SetNotifyWindow,
5030 MediaEvent_SetNotifyFlags,
5031 MediaEvent_GetNotifyFlags
5035 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, LPVOID *ppv)
5037 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5039 return Filtergraph_QueryInterface(This, riid, ppv);
5042 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
5044 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5046 return Filtergraph_AddRef(This);
5049 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
5051 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5053 return Filtergraph_Release(This);
5056 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
5058 FIXME("(%p): stub\n", pClassID);
5063 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
5065 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5066 return MediaControl_Stop((IMediaControl*)&This->IMediaControl_vtbl);
5069 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
5071 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5072 return MediaControl_Pause((IMediaControl*)&This->IMediaControl_vtbl);
5075 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
5077 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5079 FIXME("Run called with non-null tStart: %x%08x\n",
5080 (int)(tStart>>32), (int)tStart);
5081 return MediaControl_Run((IMediaControl*)&This->IMediaControl_vtbl);
5084 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout, FILTER_STATE * pState)
5086 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5087 return MediaControl_GetState((IMediaControl*)&This->IMediaControl_vtbl, dwMsTimeout, (OAFilterState*)pState);
5090 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
5092 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5096 TRACE("(%p/%p)->(%p)\n", iface, This, pClock);
5098 EnterCriticalSection(&This->cs);
5100 for (i = 0;i < This->nFilters;i++)
5102 hr = IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], pClock);
5110 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], This->refClock);
5115 IReferenceClock_Release(This->refClock);
5116 This->refClock = pClock;
5118 IReferenceClock_AddRef(This->refClock);
5119 This->defaultclock = FALSE;
5121 if (This->HandleEcClockChanged)
5123 IMediaEventSink *pEventSink;
5126 eshr = IMediaFilter_QueryInterface(iface, &IID_IMediaEventSink, (LPVOID)&pEventSink);
5127 if (SUCCEEDED(eshr))
5129 IMediaEventSink_Notify(pEventSink, EC_CLOCK_CHANGED, 0, 0);
5130 IMediaEventSink_Release(pEventSink);
5135 LeaveCriticalSection(&This->cs);
5140 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
5142 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaFilter_vtbl, iface);
5144 TRACE("(%p/%p)->(%p)\n", iface, This, ppClock);
5149 EnterCriticalSection(&This->cs);
5151 *ppClock = This->refClock;
5153 IReferenceClock_AddRef(*ppClock);
5155 LeaveCriticalSection(&This->cs);
5160 static const IMediaFilterVtbl IMediaFilter_VTable =
5162 MediaFilter_QueryInterface,
5164 MediaFilter_Release,
5165 MediaFilter_GetClassID,
5169 MediaFilter_GetState,
5170 MediaFilter_SetSyncSource,
5171 MediaFilter_GetSyncSource
5174 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, LPVOID *ppv)
5176 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5178 return Filtergraph_QueryInterface(This, riid, ppv);
5181 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
5183 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5185 return Filtergraph_AddRef(This);
5188 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
5190 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5192 return Filtergraph_Release(This);
5195 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, LONG EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)
5197 ICOM_THIS_MULTI(IFilterGraphImpl, IMediaEventSink_vtbl, iface);
5200 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
5202 /* We need thread safety here, let's use the events queue's one */
5203 EnterCriticalSection(&This->evqueue.msg_crst);
5205 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
5207 TRACE("Process EC_COMPLETE notification\n");
5208 if (++This->EcCompleteCount == This->nRenderers)
5210 evt.lEventCode = EC_COMPLETE;
5213 TRACE("Send EC_COMPLETE to app\n");
5214 EventsQueue_PutEvent(&This->evqueue, &evt);
5215 if (!This->notif.disabled && This->notif.hWnd)
5217 TRACE("Send Window message\n");
5218 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5220 This->CompletionStatus = EC_COMPLETE;
5221 SetEvent(This->hEventCompletion);
5224 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
5226 /* FIXME: Not handled yet */
5230 evt.lEventCode = EventCode;
5231 evt.lParam1 = EventParam1;
5232 evt.lParam2 = EventParam2;
5233 EventsQueue_PutEvent(&This->evqueue, &evt);
5234 if (!This->notif.disabled && This->notif.hWnd)
5235 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5238 LeaveCriticalSection(&This->evqueue.msg_crst);
5242 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
5244 MediaEventSink_QueryInterface,
5245 MediaEventSink_AddRef,
5246 MediaEventSink_Release,
5247 MediaEventSink_Notify
5250 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, LPVOID *ppv)
5252 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5254 return Filtergraph_QueryInterface(This, riid, ppv);
5257 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
5259 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5261 return Filtergraph_AddRef(This);
5264 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
5266 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5268 return Filtergraph_Release(This);
5271 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface,
5274 const AM_MEDIA_TYPE* pmtFirstConnection,
5275 IBaseFilter* pUsingFilter,
5279 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5281 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
5286 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface,
5287 IGraphConfigCallback* pCallback,
5292 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5295 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
5298 FIXME("The parameter hAbortEvent is not handled!\n");
5300 EnterCriticalSection(&This->cs);
5302 hr = IGraphConfigCallback_Reconfigure(pCallback, pvContext, dwFlags);
5304 LeaveCriticalSection(&This->cs);
5309 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface,
5310 IBaseFilter* pFilter)
5312 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5314 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5319 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface,
5320 IEnumFilters** pEnum)
5322 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5324 FIXME("(%p)->(%p): stub!\n", This, pEnum);
5329 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface,
5330 IBaseFilter* pFilter)
5332 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5334 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5339 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface,
5340 REFERENCE_TIME* prtStart)
5342 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5344 FIXME("(%p)->(%p): stub!\n", This, prtStart);
5349 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface,
5351 IPinConnection* pConnection,
5354 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5356 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
5361 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface,
5362 IBaseFilter* pFilter,
5365 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5367 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5372 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface,
5373 IBaseFilter* pFilter,
5376 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5378 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
5383 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface,
5384 IBaseFilter* pFilter,
5387 ICOM_THIS_MULTI(IFilterGraphImpl, IGraphConfig_vtbl, iface);
5389 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5394 static const IGraphConfigVtbl IGraphConfig_VTable =
5396 GraphConfig_QueryInterface,
5398 GraphConfig_Release,
5399 GraphConfig_Reconnect,
5400 GraphConfig_Reconfigure,
5401 GraphConfig_AddFilterToCache,
5402 GraphConfig_EnumCacheFilter,
5403 GraphConfig_RemoveFilterFromCache,
5404 GraphConfig_GetStartTime,
5405 GraphConfig_PushThroughData,
5406 GraphConfig_SetFilterFlags,
5407 GraphConfig_GetFilterFlags,
5408 GraphConfig_RemoveFilterEx
5411 static const IUnknownVtbl IInner_VTable =
5413 FilterGraphInner_QueryInterface,
5414 FilterGraphInner_AddRef,
5415 FilterGraphInner_Release
5418 static HRESULT Filtergraph_QueryInterface(IFilterGraphImpl *This,
5421 if (This->bAggregatable)
5422 This->bUnkOuterValid = TRUE;
5424 if (This->pUnkOuter)
5426 if (This->bAggregatable)
5427 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
5429 if (IsEqualIID(riid, &IID_IUnknown))
5433 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
5434 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
5435 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
5436 This->bAggregatable = TRUE;
5441 return E_NOINTERFACE;
5444 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
5447 static ULONG Filtergraph_AddRef(IFilterGraphImpl *This) {
5448 if (This->pUnkOuter && This->bUnkOuterValid)
5449 return IUnknown_AddRef(This->pUnkOuter);
5450 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
5453 static ULONG Filtergraph_Release(IFilterGraphImpl *This) {
5454 if (This->pUnkOuter && This->bUnkOuterValid)
5455 return IUnknown_Release(This->pUnkOuter);
5456 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
5459 /* This is the only function that actually creates a FilterGraph class... */
5460 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5462 IFilterGraphImpl *fimpl;
5465 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
5469 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
5470 fimpl->pUnkOuter = pUnkOuter;
5471 fimpl->bUnkOuterValid = FALSE;
5472 fimpl->bAggregatable = FALSE;
5473 fimpl->defaultclock = TRUE;
5474 fimpl->IInner_vtbl = &IInner_VTable;
5475 fimpl->IFilterGraph2_vtbl = &IFilterGraph2_VTable;
5476 fimpl->IMediaControl_vtbl = &IMediaControl_VTable;
5477 fimpl->IMediaSeeking_vtbl = &IMediaSeeking_VTable;
5478 fimpl->IBasicAudio_vtbl = &IBasicAudio_VTable;
5479 fimpl->IBasicVideo_vtbl = &IBasicVideo_VTable;
5480 fimpl->IVideoWindow_vtbl = &IVideoWindow_VTable;
5481 fimpl->IMediaEventEx_vtbl = &IMediaEventEx_VTable;
5482 fimpl->IMediaFilter_vtbl = &IMediaFilter_VTable;
5483 fimpl->IMediaEventSink_vtbl = &IMediaEventSink_VTable;
5484 fimpl->IGraphConfig_vtbl = &IGraphConfig_VTable;
5485 fimpl->IMediaPosition_vtbl = &IMediaPosition_VTable;
5487 fimpl->ppFiltersInGraph = NULL;
5488 fimpl->pFilterNames = NULL;
5489 fimpl->nFilters = 0;
5490 fimpl->filterCapacity = 0;
5491 fimpl->nameIndex = 1;
5492 fimpl->refClock = NULL;
5493 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
5494 fimpl->HandleEcComplete = TRUE;
5495 fimpl->HandleEcRepaint = TRUE;
5496 fimpl->HandleEcClockChanged = TRUE;
5497 fimpl->notif.hWnd = 0;
5498 fimpl->notif.disabled = FALSE;
5499 fimpl->nRenderers = 0;
5500 fimpl->EcCompleteCount = 0;
5501 fimpl->refClockProvider = NULL;
5502 fimpl->state = State_Stopped;
5503 EventsQueue_Init(&fimpl->evqueue);
5504 InitializeCriticalSection(&fimpl->cs);
5505 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
5506 fimpl->nItfCacheEntries = 0;
5507 memcpy(&fimpl->timeformatseek, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
5508 fimpl->start_time = fimpl->pause_time = 0;
5509 fimpl->stop_position = -1;
5510 fimpl->punkFilterMapper2 = NULL;
5511 fimpl->recursioncount = 0;
5513 /* create Filtermapper aggregated. */
5514 hr = CoCreateInstance(&CLSID_FilterMapper2, pUnkOuter ? pUnkOuter : (IUnknown*)&fimpl->IInner_vtbl, CLSCTX_INPROC_SERVER,
5515 &IID_IUnknown, (LPVOID*)&fimpl->punkFilterMapper2);
5517 if (SUCCEEDED(hr)) {
5518 hr = IUnknown_QueryInterface(fimpl->punkFilterMapper2, &IID_IFilterMapper2, (LPVOID*)&fimpl->pFilterMapper2);
5521 if (SUCCEEDED(hr)) {
5522 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5523 if (pUnkOuter) IUnknown_Release(pUnkOuter);
5524 else IUnknown_Release((IUnknown*)&fimpl->IInner_vtbl);
5528 ERR("Unable to create filter mapper (%x)\n", hr);
5529 if (fimpl->punkFilterMapper2) IUnknown_Release(fimpl->punkFilterMapper2);
5530 CloseHandle(fimpl->hEventCompletion);
5531 EventsQueue_Destroy(&fimpl->evqueue);
5532 fimpl->cs.DebugInfo->Spare[0] = 0;
5533 DeleteCriticalSection(&fimpl->cs);
5534 CoTaskMemFree(fimpl);
5542 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5544 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5545 return FilterGraph_create(pUnkOuter, ppObj);