1 /* DirectShow FilterGraph object (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
33 #include "quartz_private.h"
39 #include "wine/unicode.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
45 HWND hWnd; /* Target window */
46 UINT msg; /* User window message */
47 LONG_PTR instance; /* User data */
48 int disabled; /* Disabled messages posting */
52 LONG lEventCode; /* Event code */
53 LONG_PTR lParam1; /* Param1 */
54 LONG_PTR lParam2; /* Param2 */
57 /* messages ring implementation for queuing events (taken from winmm) */
58 #define EVENTS_RING_BUFFER_INCREMENT 64
64 CRITICAL_SECTION msg_crst;
65 HANDLE msg_event; /* Signaled for no empty queue */
68 static int EventsQueue_Init(EventsQueue* omr)
72 omr->msg_event = CreateEventW(NULL, TRUE, FALSE, NULL);
73 omr->ring_buffer_size = EVENTS_RING_BUFFER_INCREMENT;
74 omr->messages = CoTaskMemAlloc(omr->ring_buffer_size * sizeof(Event));
75 ZeroMemory(omr->messages, omr->ring_buffer_size * sizeof(Event));
77 InitializeCriticalSection(&omr->msg_crst);
78 omr->msg_crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": EventsQueue.msg_crst");
82 static int EventsQueue_Destroy(EventsQueue* omr)
84 CloseHandle(omr->msg_event);
85 CoTaskMemFree(omr->messages);
86 omr->msg_crst.DebugInfo->Spare[0] = 0;
87 DeleteCriticalSection(&omr->msg_crst);
91 static int EventsQueue_PutEvent(EventsQueue* omr, const Event* evt)
93 EnterCriticalSection(&omr->msg_crst);
94 if (omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size))
96 int old_ring_buffer_size = omr->ring_buffer_size;
97 omr->ring_buffer_size += EVENTS_RING_BUFFER_INCREMENT;
98 TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
99 omr->messages = CoTaskMemRealloc(omr->messages, omr->ring_buffer_size * sizeof(Event));
100 /* Now we need to rearrange the ring buffer so that the new
101 buffers just allocated are in between omr->msg_tosave and
104 if (omr->msg_tosave < omr->msg_toget)
106 memmove(&(omr->messages[omr->msg_toget + EVENTS_RING_BUFFER_INCREMENT]),
107 &(omr->messages[omr->msg_toget]),
108 sizeof(Event)*(old_ring_buffer_size - omr->msg_toget)
110 omr->msg_toget += EVENTS_RING_BUFFER_INCREMENT;
113 omr->messages[omr->msg_tosave] = *evt;
114 SetEvent(omr->msg_event);
115 omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
116 LeaveCriticalSection(&omr->msg_crst);
120 static int EventsQueue_GetEvent(EventsQueue* omr, Event* evt, LONG msTimeOut)
122 if (WaitForSingleObject(omr->msg_event, msTimeOut) != WAIT_OBJECT_0)
125 EnterCriticalSection(&omr->msg_crst);
127 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
129 LeaveCriticalSection(&omr->msg_crst);
133 *evt = omr->messages[omr->msg_toget];
134 omr->msg_toget = (omr->msg_toget + 1) % omr->ring_buffer_size;
136 /* Mark the buffer as empty if needed */
137 if (omr->msg_toget == omr->msg_tosave) /* buffer empty ? */
138 ResetEvent(omr->msg_event);
140 LeaveCriticalSection(&omr->msg_crst);
144 #define MAX_ITF_CACHE_ENTRIES 3
145 typedef struct _ITF_CACHE_ENTRY {
151 typedef struct _IFilterGraphImpl {
152 IUnknown IUnknown_inner;
153 IFilterGraph2 IFilterGraph2_iface;
154 IMediaControl IMediaControl_iface;
155 IMediaSeeking IMediaSeeking_iface;
156 IBasicAudio IBasicAudio_iface;
157 IBasicVideo2 IBasicVideo2_iface;
158 IVideoWindow IVideoWindow_iface;
159 IMediaEventEx IMediaEventEx_iface;
160 IMediaFilter IMediaFilter_iface;
161 IMediaEventSink IMediaEventSink_iface;
162 IGraphConfig IGraphConfig_iface;
163 IMediaPosition IMediaPosition_iface;
164 IObjectWithSite IObjectWithSite_iface;
165 IGraphVersion IGraphVersion_iface;
166 /* IAMGraphStreams */
171 /* IRegisterServiceProvider */
172 /* IResourceMananger */
173 /* IServiceProvider */
174 /* IVideoFrameStep */
178 IUnknown *punkFilterMapper2;
179 IFilterMapper2 * pFilterMapper2;
180 IBaseFilter ** ppFiltersInGraph;
181 LPWSTR * pFilterNames;
185 IReferenceClock *refClock;
186 IBaseFilter *refClockProvider;
188 HANDLE hEventCompletion;
189 int CompletionStatus;
193 int HandleEcComplete;
195 int HandleEcClockChanged;
198 ITF_CACHE_ENTRY ItfCacheEntries[MAX_ITF_CACHE_ENTRIES];
199 int nItfCacheEntries;
202 REFERENCE_TIME start_time;
203 REFERENCE_TIME pause_time;
204 LONGLONG stop_position;
210 static inline IFilterGraphImpl *impl_from_IUnknown(IUnknown *iface)
212 return CONTAINING_RECORD(iface, IFilterGraphImpl, IUnknown_inner);
215 static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObj)
217 IFilterGraphImpl *This = impl_from_IUnknown(iface);
218 TRACE("(%p)->(%s (%p), %p)\n", This, debugstr_guid(riid), riid, ppvObj);
220 if (IsEqualGUID(&IID_IUnknown, riid)) {
221 *ppvObj = &This->IUnknown_inner;
222 TRACE(" returning IUnknown interface (%p)\n", *ppvObj);
223 } else if (IsEqualGUID(&IID_IFilterGraph, riid) ||
224 IsEqualGUID(&IID_IFilterGraph2, riid) ||
225 IsEqualGUID(&IID_IGraphBuilder, riid)) {
226 *ppvObj = &This->IFilterGraph2_iface;
227 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj);
228 } else if (IsEqualGUID(&IID_IMediaControl, riid)) {
229 *ppvObj = &This->IMediaControl_iface;
230 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj);
231 } else if (IsEqualGUID(&IID_IMediaSeeking, riid)) {
232 *ppvObj = &This->IMediaSeeking_iface;
233 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj);
234 } else if (IsEqualGUID(&IID_IBasicAudio, riid)) {
235 *ppvObj = &This->IBasicAudio_iface;
236 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj);
237 } else if (IsEqualGUID(&IID_IBasicVideo, riid) ||
238 IsEqualGUID(&IID_IBasicVideo2, riid)) {
239 *ppvObj = &This->IBasicVideo2_iface;
240 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj);
241 } else if (IsEqualGUID(&IID_IVideoWindow, riid)) {
242 *ppvObj = &This->IVideoWindow_iface;
243 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj);
244 } else if (IsEqualGUID(&IID_IMediaEvent, riid) ||
245 IsEqualGUID(&IID_IMediaEventEx, riid)) {
246 *ppvObj = &This->IMediaEventEx_iface;
247 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj);
248 } else if (IsEqualGUID(&IID_IMediaFilter, riid) ||
249 IsEqualGUID(&IID_IPersist, riid)) {
250 *ppvObj = &This->IMediaFilter_iface;
251 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj);
252 } else if (IsEqualGUID(&IID_IMediaEventSink, riid)) {
253 *ppvObj = &This->IMediaEventSink_iface;
254 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj);
255 } else if (IsEqualGUID(&IID_IGraphConfig, riid)) {
256 *ppvObj = &This->IGraphConfig_iface;
257 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
258 } else if (IsEqualGUID(&IID_IMediaPosition, riid)) {
259 *ppvObj = &This->IMediaPosition_iface;
260 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj);
261 } else if (IsEqualGUID(&IID_IObjectWithSite, riid)) {
262 *ppvObj = &This->IObjectWithSite_iface;
263 TRACE(" returning IObjectWithSite interface (%p)\n", *ppvObj);
264 } else if (IsEqualGUID(&IID_IFilterMapper, riid)) {
265 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj);
266 return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
267 } else if (IsEqualGUID(&IID_IFilterMapper2, riid)) {
268 *ppvObj = This->pFilterMapper2;
269 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj);
270 } else if (IsEqualGUID(&IID_IFilterMapper3, riid)) {
271 *ppvObj = This->pFilterMapper2;
272 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
273 } else if (IsEqualGUID(&IID_IGraphVersion, riid)) {
274 *ppvObj = &This->IGraphConfig_iface;
275 TRACE(" returning IGraphConfig interface (%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)
288 IFilterGraphImpl *This = impl_from_IUnknown(iface);
289 ULONG ref = InterlockedIncrement(&This->ref);
291 TRACE("(%p)->(): new ref = %d\n", This, ref);
296 static ULONG WINAPI FilterGraphInner_Release(IUnknown *iface)
298 IFilterGraphImpl *This = impl_from_IUnknown(iface);
299 ULONG ref = InterlockedDecrement(&This->ref);
301 TRACE("(%p)->(): new ref = %d\n", This, ref);
306 This->ref = 1; /* guard against reentrancy (aggregation). */
308 IMediaControl_Stop(&This->IMediaControl_iface);
310 while (This->nFilters)
311 IFilterGraph2_RemoveFilter(&This->IFilterGraph2_iface, This->ppFiltersInGraph[0]);
314 IReferenceClock_Release(This->refClock);
316 for (i = 0; i < This->nItfCacheEntries; i++)
318 if (This->ItfCacheEntries[i].iface)
319 IUnknown_Release(This->ItfCacheEntries[i].iface);
322 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 */
323 IUnknown_AddRef(This->outer_unk);
324 IFilterMapper2_Release(This->pFilterMapper2);
325 IUnknown_Release(This->punkFilterMapper2);
327 if (This->pSite) IUnknown_Release(This->pSite);
329 CloseHandle(This->hEventCompletion);
330 EventsQueue_Destroy(&This->evqueue);
331 This->cs.DebugInfo->Spare[0] = 0;
332 DeleteCriticalSection(&This->cs);
333 CoTaskMemFree(This->ppFiltersInGraph);
334 CoTaskMemFree(This->pFilterNames);
340 static inline IFilterGraphImpl *impl_from_IFilterGraph2(IFilterGraph2 *iface)
342 return CONTAINING_RECORD(iface, IFilterGraphImpl, IFilterGraph2_iface);
345 static HRESULT WINAPI FilterGraph2_QueryInterface(IFilterGraph2 *iface, REFIID riid, void **ppvObj)
347 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
349 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
351 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
354 static ULONG WINAPI FilterGraph2_AddRef(IFilterGraph2 *iface)
356 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
358 TRACE("(%p/%p)->()\n", This, iface);
360 return IUnknown_AddRef(This->outer_unk);
363 static ULONG WINAPI FilterGraph2_Release(IFilterGraph2 *iface)
365 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
367 TRACE("(%p/%p)->()\n", This, iface);
369 return IUnknown_Release(This->outer_unk);
372 /*** IFilterGraph methods ***/
373 static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface, IBaseFilter *pFilter,
376 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
379 WCHAR* wszFilterName = NULL;
380 int duplicate_name = FALSE;
382 TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName);
387 wszFilterName = CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) );
391 /* Check if name already exists */
392 for(i = 0; i < This->nFilters; i++)
393 if (!strcmpW(This->pFilterNames[i], pName))
395 duplicate_name = TRUE;
400 /* If no name given or name already existing, generate one */
401 if (!pName || duplicate_name)
403 static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0};
404 static const WCHAR wszFmt2[] = {'%','0','4','d',0};
406 for (j = 0; j < 10000 ; j++)
410 sprintfW(wszFilterName, wszFmt1, pName, This->nameIndex);
412 sprintfW(wszFilterName, wszFmt2, This->nameIndex);
413 TRACE("Generated name %s\n", debugstr_w(wszFilterName));
415 /* Check if the generated name already exists */
416 for(i = 0; i < This->nFilters; i++)
417 if (!strcmpW(This->pFilterNames[i], wszFilterName))
420 /* Compute next index and exit if generated name is suitable */
421 if (This->nameIndex++ == 10000)
423 if (i == This->nFilters)
426 /* Unable to find a suitable name */
429 CoTaskMemFree(wszFilterName);
430 return VFW_E_DUPLICATE_NAME;
434 memcpy(wszFilterName, pName, (strlenW(pName) + 1) * sizeof(WCHAR));
436 if (This->nFilters + 1 > This->filterCapacity)
438 int newCapacity = This->filterCapacity ? 2 * This->filterCapacity : 1;
439 IBaseFilter ** ppNewFilters = CoTaskMemAlloc(newCapacity * sizeof(IBaseFilter*));
440 LPWSTR * pNewNames = CoTaskMemAlloc(newCapacity * sizeof(LPWSTR));
441 memcpy(ppNewFilters, This->ppFiltersInGraph, This->nFilters * sizeof(IBaseFilter*));
442 memcpy(pNewNames, This->pFilterNames, This->nFilters * sizeof(LPWSTR));
443 if (This->filterCapacity)
445 CoTaskMemFree(This->ppFiltersInGraph);
446 CoTaskMemFree(This->pFilterNames);
448 This->ppFiltersInGraph = ppNewFilters;
449 This->pFilterNames = pNewNames;
450 This->filterCapacity = newCapacity;
453 hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)This, wszFilterName);
457 IBaseFilter_AddRef(pFilter);
458 This->ppFiltersInGraph[This->nFilters] = pFilter;
459 This->pFilterNames[This->nFilters] = wszFilterName;
462 IBaseFilter_SetSyncSource(pFilter, This->refClock);
465 CoTaskMemFree(wszFilterName);
467 if (SUCCEEDED(hr) && duplicate_name)
468 return VFW_S_DUPLICATE_NAME;
473 static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface, IBaseFilter *pFilter)
475 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
479 TRACE("(%p/%p)->(%p)\n", This, iface, pFilter);
481 /* FIXME: check graph is stopped */
483 for (i = 0; i < This->nFilters; i++)
485 if (This->ppFiltersInGraph[i] == pFilter)
487 IEnumPins *penumpins = NULL;
490 if (This->defaultclock && This->refClockProvider == pFilter)
492 IMediaFilter_SetSyncSource(&This->IMediaFilter_iface, NULL);
493 This->defaultclock = 1;
496 TRACE("Removing filter %s\n", debugstr_w(This->pFilterNames[i]));
497 IBaseFilter_GetState(pFilter, 0, &state);
498 if (state == State_Running)
499 IBaseFilter_Pause(pFilter);
500 if (state != State_Stopped)
501 IBaseFilter_Stop(pFilter);
503 hr = IBaseFilter_EnumPins(pFilter, &penumpins);
506 while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK)
510 IPin_ConnectedTo(ppin, &victim);
513 h = IPin_Disconnect(victim);
514 TRACE("Disconnect other side: %08x\n", h);
515 if (h == VFW_E_NOT_STOPPED)
518 IPin_QueryPinInfo(victim, &pinfo);
520 IBaseFilter_GetState(pinfo.pFilter, 0, &state);
521 if (state == State_Running)
522 IBaseFilter_Pause(pinfo.pFilter);
523 IBaseFilter_Stop(pinfo.pFilter);
524 IBaseFilter_Release(pinfo.pFilter);
525 h = IPin_Disconnect(victim);
526 TRACE("Disconnect retry: %08x\n", h);
528 IPin_Release(victim);
530 h = IPin_Disconnect(ppin);
531 TRACE("Disconnect 2: %08x\n", h);
535 IEnumPins_Release(penumpins);
538 hr = IBaseFilter_JoinFilterGraph(pFilter, NULL, This->pFilterNames[i]);
541 IBaseFilter_SetSyncSource(pFilter, NULL);
542 IBaseFilter_Release(pFilter);
543 CoTaskMemFree(This->pFilterNames[i]);
544 memmove(This->ppFiltersInGraph+i, This->ppFiltersInGraph+i+1, sizeof(IBaseFilter*)*(This->nFilters - 1 - i));
545 memmove(This->pFilterNames+i, This->pFilterNames+i+1, sizeof(LPWSTR)*(This->nFilters - 1 - i));
548 /* Invalidate interfaces in the cache */
549 for (i = 0; i < This->nItfCacheEntries; i++)
550 if (pFilter == This->ItfCacheEntries[i].filter)
552 IUnknown_Release(This->ItfCacheEntries[i].iface);
553 This->ItfCacheEntries[i].iface = NULL;
554 This->ItfCacheEntries[i].filter = NULL;
562 return hr; /* FIXME: check this error code */
565 static HRESULT WINAPI FilterGraph2_EnumFilters(IFilterGraph2 *iface, IEnumFilters **ppEnum)
567 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
569 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
571 return IEnumFiltersImpl_Construct(&This->IGraphVersion_iface, &This->ppFiltersInGraph, &This->nFilters, ppEnum);
574 static HRESULT WINAPI FilterGraph2_FindFilterByName(IFilterGraph2 *iface, LPCWSTR pName,
575 IBaseFilter **ppFilter)
577 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
580 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_w(pName), pName, ppFilter);
585 for (i = 0; i < This->nFilters; i++)
587 if (!strcmpW(pName, This->pFilterNames[i]))
589 *ppFilter = This->ppFiltersInGraph[i];
590 IBaseFilter_AddRef(*ppFilter);
596 return VFW_E_NOT_FOUND;
599 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
600 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
602 static HRESULT CheckCircularConnection(IFilterGraphImpl *This, IPin *out, IPin *in)
606 PIN_INFO info_out, info_in;
608 hr = IPin_QueryPinInfo(out, &info_out);
611 if (info_out.dir != PINDIR_OUTPUT)
613 IBaseFilter_Release(info_out.pFilter);
617 hr = IPin_QueryPinInfo(in, &info_in);
619 IBaseFilter_Release(info_in.pFilter);
622 if (info_in.dir != PINDIR_INPUT)
628 if (info_out.pFilter == info_in.pFilter)
629 hr = VFW_E_CIRCULAR_GRAPH;
635 hr = IBaseFilter_EnumPins(info_out.pFilter, &enumpins);
639 IEnumPins_Reset(enumpins);
640 while ((hr = IEnumPins_Next(enumpins, 1, &test, NULL)) == S_OK)
642 PIN_DIRECTION dir = PINDIR_OUTPUT;
643 IPin_QueryDirection(test, &dir);
644 if (dir == PINDIR_INPUT)
647 IPin_ConnectedTo(test, &victim);
650 hr = CheckCircularConnection(This, victim, in);
651 IPin_Release(victim);
661 IEnumPins_Release(enumpins);
665 IBaseFilter_Release(info_out.pFilter);
667 ERR("Checking filtergraph returned %08x, something's not right!\n", hr);
670 /* Debugging filtergraphs not enabled */
676 /* NOTE: despite the implication, it doesn't matter which
677 * way round you put in the input and output pins */
678 static HRESULT WINAPI FilterGraph2_ConnectDirect(IFilterGraph2 *iface, IPin *ppinIn, IPin *ppinOut,
679 const AM_MEDIA_TYPE *pmt)
681 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
685 TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, ppinIn, ppinOut, pmt);
687 /* FIXME: check pins are in graph */
689 if (TRACE_ON(quartz))
693 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
697 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
698 IBaseFilter_Release(PinInfo.pFilter);
700 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
704 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
705 IBaseFilter_Release(PinInfo.pFilter);
708 hr = IPin_QueryDirection(ppinIn, &dir);
711 if (dir == PINDIR_INPUT)
713 hr = CheckCircularConnection(This, ppinOut, ppinIn);
715 hr = IPin_Connect(ppinOut, ppinIn, pmt);
719 hr = CheckCircularConnection(This, ppinIn, ppinOut);
721 hr = IPin_Connect(ppinIn, ppinOut, pmt);
728 static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface, IPin *ppin)
730 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
731 IPin *pConnectedTo = NULL;
733 PIN_DIRECTION pindir;
735 IPin_QueryDirection(ppin, &pindir);
736 hr = IPin_ConnectedTo(ppin, &pConnectedTo);
738 TRACE("Querying connected to failed: %x\n", hr);
741 IPin_Disconnect(ppin);
742 IPin_Disconnect(pConnectedTo);
743 if (pindir == PINDIR_INPUT)
744 hr = IPin_Connect(pConnectedTo, ppin, NULL);
746 hr = IPin_Connect(ppin, pConnectedTo, NULL);
747 IPin_Release(pConnectedTo);
749 WARN("Reconnecting pins failed, pins are not connected now..\n");
750 TRACE("(%p->%p) -- %p %p -> %x\n", iface, This, ppin, pConnectedTo, hr);
754 static HRESULT WINAPI FilterGraph2_Disconnect(IFilterGraph2 *iface, IPin *ppin)
756 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
758 TRACE("(%p/%p)->(%p)\n", This, iface, ppin);
763 return IPin_Disconnect(ppin);
766 static HRESULT WINAPI FilterGraph2_SetDefaultSyncSource(IFilterGraph2 *iface)
768 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
769 IReferenceClock *pClock = NULL;
773 TRACE("(%p/%p)->() live sources not handled properly!\n", iface, This);
775 EnterCriticalSection(&This->cs);
777 for (i = 0; i < This->nFilters; ++i)
780 IAMFilterMiscFlags *flags = NULL;
781 IBaseFilter_QueryInterface(This->ppFiltersInGraph[i], &IID_IAMFilterMiscFlags, (void**)&flags);
784 miscflags = IAMFilterMiscFlags_GetMiscFlags(flags);
785 IAMFilterMiscFlags_Release(flags);
786 if (miscflags == AM_FILTER_MISC_FLAGS_IS_RENDERER)
787 IBaseFilter_QueryInterface(This->ppFiltersInGraph[i], &IID_IReferenceClock, (void**)&pClock);
794 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pClock);
795 This->refClockProvider = NULL;
798 This->refClockProvider = This->ppFiltersInGraph[i];
802 hr = IMediaFilter_SetSyncSource(&This->IMediaFilter_iface, pClock);
803 This->defaultclock = TRUE;
804 IReferenceClock_Release(pClock);
806 LeaveCriticalSection(&This->cs);
811 static HRESULT GetFilterInfo(IMoniker* pMoniker, GUID* pclsid, VARIANT* pvar)
813 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
814 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
815 IPropertyBag * pPropBagCat = NULL;
820 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
823 hr = IPropertyBag_Read(pPropBagCat, wszClsidName, pvar, NULL);
826 hr = CLSIDFromString(V_UNION(pvar, bstrVal), pclsid);
831 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, pvar, NULL);
834 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid), debugstr_w(V_UNION(pvar, bstrVal)));
837 IPropertyBag_Release(pPropBagCat);
842 static HRESULT GetInternalConnections(IBaseFilter* pfilter, IPin* pinputpin, IPin*** pppins, ULONG* pnb)
847 TRACE("(%p, %p, %p, %p)\n", pfilter, pinputpin, pppins, pnb);
848 hr = IPin_QueryInternalConnections(pinputpin, NULL, &nb);
851 } else if (hr == S_FALSE) {
852 *pppins = CoTaskMemAlloc(sizeof(IPin*)*nb);
853 hr = IPin_QueryInternalConnections(pinputpin, *pppins, &nb);
855 WARN("Error (%x)\n", hr);
857 } else if (hr == E_NOTIMPL) {
858 /* Input connected to all outputs */
859 IEnumPins* penumpins;
862 TRACE("E_NOTIMPL\n");
863 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
865 WARN("filter Enumpins failed (%x)\n", hr);
869 /* Count output pins */
870 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
871 PIN_DIRECTION pindir;
872 IPin_QueryDirection(ppin, &pindir);
873 if (pindir == PINDIR_OUTPUT)
877 *pppins = CoTaskMemAlloc(sizeof(IPin*)*i);
878 /* Retrieve output pins */
879 IEnumPins_Reset(penumpins);
881 while(IEnumPins_Next(penumpins, 1, &ppin, &nb) == S_OK) {
882 PIN_DIRECTION pindir;
883 IPin_QueryDirection(ppin, &pindir);
884 if (pindir == PINDIR_OUTPUT)
885 (*pppins)[i++] = ppin;
889 IEnumPins_Release(penumpins);
892 WARN("Next failed (%x)\n", hr);
895 } else if (FAILED(hr)) {
896 WARN("Cannot get internal connection (%x)\n", hr);
904 /*** IGraphBuilder methods ***/
905 static HRESULT WINAPI FilterGraph2_Connect(IFilterGraph2 *iface, IPin *ppinOut, IPin *ppinIn)
907 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
909 AM_MEDIA_TYPE* mt = NULL;
910 IEnumMediaTypes* penummt = NULL;
912 IEnumPins* penumpins;
913 IEnumMoniker* pEnumMoniker;
923 TRACE("(%p/%p)->(%p, %p)\n", This, iface, ppinOut, ppinIn);
925 if (TRACE_ON(quartz))
927 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
931 TRACE("Filter owning first pin => %p\n", PinInfo.pFilter);
932 IBaseFilter_Release(PinInfo.pFilter);
934 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
938 TRACE("Filter owning second pin => %p\n", PinInfo.pFilter);
939 IBaseFilter_Release(PinInfo.pFilter);
942 EnterCriticalSection(&This->cs);
943 ++This->recursioncount;
944 if (This->recursioncount >= 5)
946 WARN("Recursion count has reached %d\n", This->recursioncount);
947 hr = VFW_E_CANNOT_CONNECT;
951 hr = IPin_QueryDirection(ppinOut, &dir);
955 if (dir == PINDIR_INPUT)
964 hr = CheckCircularConnection(This, ppinOut, ppinIn);
968 /* Try direct connection first */
969 hr = IPin_Connect(ppinOut, ppinIn, NULL);
973 TRACE("Direct connection failed, trying to render using extra filters\n");
975 hr = IPin_QueryPinInfo(ppinIn, &PinInfo);
979 hr = IBaseFilter_GetClassID(PinInfo.pFilter, &FilterCLSID);
980 IBaseFilter_Release(PinInfo.pFilter);
984 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
985 * filter to the minor mediatype of input pin of the renderer */
986 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
989 WARN("EnumMediaTypes (%x)\n", hr);
993 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
995 WARN("IEnumMediaTypes_Next (%x)\n", hr);
1001 WARN("No media type found!\n");
1002 hr = VFW_E_INVALIDMEDIATYPE;
1005 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
1006 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
1008 /* Try to find a suitable filter that can connect to the pin to render */
1009 tab[0] = mt->majortype;
1010 tab[1] = mt->subtype;
1011 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1013 WARN("Unable to enum filters (%x)\n", hr);
1017 hr = VFW_E_CANNOT_RENDER;
1018 while(IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1022 IPin** ppins = NULL;
1023 IPin* ppinfilter = NULL;
1024 IBaseFilter* pfilter = NULL;
1025 IAMGraphBuilderCallback *callback = NULL;
1027 hr = GetFilterInfo(pMoniker, &clsid, &var);
1029 WARN("Unable to retrieve filter info (%x)\n", hr);
1033 hr = IMoniker_BindToObject(pMoniker, NULL, NULL, &IID_IBaseFilter, (LPVOID*)&pfilter);
1034 IMoniker_Release(pMoniker);
1036 WARN("Unable to create filter (%x), trying next one\n", hr);
1040 hr = IBaseFilter_GetClassID(pfilter, &clsid);
1043 IBaseFilter_Release(pfilter);
1047 if (IsEqualGUID(&clsid, &FilterCLSID)) {
1048 /* Skip filter (same as the one the output pin belongs to) */
1049 IBaseFilter_Release(pfilter);
1055 IUnknown_QueryInterface(This->pSite, &IID_IAMGraphBuilderCallback, (LPVOID*)&callback);
1059 rc = IAMGraphBuilderCallback_SelectedFilter(callback, pMoniker);
1062 TRACE("Filter rejected by IAMGraphBuilderCallback_SelectedFilter\n");
1063 IAMGraphBuilderCallback_Release(callback);
1072 rc = IAMGraphBuilderCallback_CreatedFilter(callback, pfilter);
1073 IAMGraphBuilderCallback_Release(callback);
1076 IBaseFilter_Release(pfilter);
1078 TRACE("Filter rejected by IAMGraphBuilderCallback_CreatedFilter\n");
1083 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1085 WARN("Unable to add filter (%x)\n", hr);
1086 IBaseFilter_Release(pfilter);
1093 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1095 WARN("Enumpins (%x)\n", hr);
1099 hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin);
1100 IEnumPins_Release(penumpins);
1103 WARN("Obtaining next pin: (%x)\n", hr);
1107 WARN("Cannot use this filter: no pins\n");
1111 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1113 TRACE("Cannot connect to filter (%x), trying next one\n", hr);
1116 TRACE("Successfully connected to filter, follow chain...\n");
1118 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1119 hr = GetInternalConnections(pfilter, ppinfilter, &ppins, &nb);
1121 if (SUCCEEDED(hr)) {
1123 IPin_Disconnect(ppinfilter);
1124 IPin_Disconnect(ppinOut);
1127 TRACE("pins to consider: %d\n", nb);
1128 for(i = 0; i < nb; i++)
1130 LPWSTR pinname = NULL;
1132 TRACE("Processing pin %u\n", i);
1134 hr = IPin_QueryId(ppins[i], &pinname);
1137 if (pinname[0] == '~')
1139 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname));
1143 hr = IFilterGraph2_Connect(iface, ppins[i], ppinIn);
1144 CoTaskMemFree(pinname);
1148 TRACE("Cannot connect pin %p (%x)\n", ppinfilter, hr);
1150 IPin_Release(ppins[i]);
1151 if (SUCCEEDED(hr)) break;
1153 while (++i < nb) IPin_Release(ppins[i]);
1154 CoTaskMemFree(ppins);
1155 IPin_Release(ppinfilter);
1156 IBaseFilter_Release(pfilter);
1159 IPin_Disconnect(ppinfilter);
1160 IPin_Disconnect(ppinOut);
1161 IFilterGraph2_RemoveFilter(iface, pfilter);
1169 if (ppinfilter) IPin_Release(ppinfilter);
1171 IFilterGraph2_RemoveFilter(iface, pfilter);
1172 IBaseFilter_Release(pfilter);
1174 while (++i < nb) IPin_Release(ppins[i]);
1175 CoTaskMemFree(ppins);
1180 IEnumMediaTypes_Release(penummt);
1182 DeleteMediaType(mt);
1183 --This->recursioncount;
1184 LeaveCriticalSection(&This->cs);
1185 TRACE("--> %08x\n", hr);
1186 return SUCCEEDED(hr) ? S_OK : hr;
1189 static HRESULT FilterGraph2_RenderRecurse(IFilterGraphImpl *This, IPin *ppinOut)
1191 /* This pin has been connected now, try to call render on all pins that aren't connected */
1194 IEnumPins *enumpins = NULL;
1195 BOOL renderany = FALSE;
1196 BOOL renderall = TRUE;
1198 IPin_QueryPinInfo(ppinOut, &info);
1200 IBaseFilter_EnumPins(info.pFilter, &enumpins);
1201 /* Don't need to hold a reference, IEnumPins does */
1202 IBaseFilter_Release(info.pFilter);
1204 IEnumPins_Reset(enumpins);
1205 while (IEnumPins_Next(enumpins, 1, &to, NULL) == S_OK)
1207 PIN_DIRECTION dir = PINDIR_INPUT;
1209 IPin_QueryDirection(to, &dir);
1211 if (dir == PINDIR_OUTPUT)
1215 IPin_ConnectedTo(to, &out);
1219 hr = IFilterGraph2_Render(&This->IFilterGraph2_iface, to);
1232 IEnumPins_Release(enumpins);
1238 return VFW_S_PARTIAL_RENDER;
1240 return VFW_E_CANNOT_RENDER;
1243 /* Ogg hates me if I create a direct rendering method
1245 * It can only connect to a pin properly once, so use a recursive method that does
1247 * +----+ --- (PIN 1) (Render is called on this pin)
1249 * +----+ --- (PIN 2)
1251 * Enumerate possible renderers that EXACTLY match the requested type
1253 * If none is available, try to add intermediate filters that can connect to the input pin
1254 * then call Render on that intermediate pin's output pins
1255 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1256 * and another filter that can connect to the input pin is tried
1257 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1258 * It's recursive, but fun!
1261 static HRESULT WINAPI FilterGraph2_Render(IFilterGraph2 *iface, IPin *ppinOut)
1263 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1264 IEnumMediaTypes* penummt;
1269 IEnumMoniker* pEnumMoniker;
1275 TRACE("(%p/%p)->(%p)\n", This, iface, ppinOut);
1277 if (TRACE_ON(quartz))
1281 hr = IPin_QueryPinInfo(ppinOut, &PinInfo);
1285 TRACE("Filter owning pin => %p\n", PinInfo.pFilter);
1286 IBaseFilter_Release(PinInfo.pFilter);
1289 /* Try to find out if there is a renderer for the specified subtype already, and use that
1291 EnterCriticalSection(&This->cs);
1292 for (x = 0; x < This->nFilters; ++x)
1294 IEnumPins *enumpins = NULL;
1297 hr = IBaseFilter_EnumPins(This->ppFiltersInGraph[x], &enumpins);
1299 if (FAILED(hr) || !enumpins)
1302 IEnumPins_Reset(enumpins);
1303 while (IEnumPins_Next(enumpins, 1, &pin, NULL) == S_OK)
1306 PIN_DIRECTION dir = PINDIR_OUTPUT;
1308 IPin_QueryDirection(pin, &dir);
1309 if (dir != PINDIR_INPUT)
1314 IPin_ConnectedTo(pin, &to);
1318 hr = FilterGraph2_ConnectDirect(iface, ppinOut, pin, NULL);
1321 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut, pin, hr);
1324 hr = FilterGraph2_RenderRecurse(This, pin);
1327 IPin_Disconnect(ppinOut);
1328 IPin_Disconnect(pin);
1331 IEnumPins_Release(enumpins);
1332 LeaveCriticalSection(&This->cs);
1335 WARN("Could not connect!\n");
1342 IEnumPins_Release(enumpins);
1345 LeaveCriticalSection(&This->cs);
1347 hr = IPin_EnumMediaTypes(ppinOut, &penummt);
1349 WARN("EnumMediaTypes (%x)\n", hr);
1353 IEnumMediaTypes_Reset(penummt);
1355 /* Looks like no existing renderer of the kind exists
1356 * Try adding new ones
1358 tab[0] = tab[1] = GUID_NULL;
1359 while (SUCCEEDED(hr))
1361 hr = IEnumMediaTypes_Next(penummt, 1, &mt, &nbmt);
1363 WARN("IEnumMediaTypes_Next (%x)\n", hr);
1368 hr = VFW_E_CANNOT_RENDER;
1373 TRACE("MajorType %s\n", debugstr_guid(&mt->majortype));
1374 TRACE("SubType %s\n", debugstr_guid(&mt->subtype));
1376 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1377 if (IsEqualIID(&tab[0], &mt->majortype) && IsEqualIID(&tab[1], &mt->subtype))
1379 DeleteMediaType(mt);
1383 /* Try to find a suitable renderer with the same media type */
1384 tab[0] = mt->majortype;
1385 tab[1] = mt->subtype;
1386 hr = IFilterMapper2_EnumMatchingFilters(This->pFilterMapper2, &pEnumMoniker, 0, FALSE, MERIT_UNLIKELY, TRUE, 1, tab, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
1389 WARN("Unable to enum filters (%x)\n", hr);
1395 while (IEnumMoniker_Next(pEnumMoniker, 1, &pMoniker, &nb) == S_OK)
1400 IBaseFilter* pfilter = NULL;
1401 IEnumPins* penumpins = NULL;
1404 hr = GetFilterInfo(pMoniker, &clsid, &var);
1406 WARN("Unable to retrieve filter info (%x)\n", hr);
1410 hr = IMoniker_BindToObject(pMoniker, NULL, NULL, &IID_IBaseFilter, (LPVOID*)&pfilter);
1411 IMoniker_Release(pMoniker);
1414 WARN("Unable to create filter (%x), trying next one\n", hr);
1418 hr = IFilterGraph2_AddFilter(iface, pfilter, V_UNION(&var, bstrVal));
1420 WARN("Unable to add filter (%x)\n", hr);
1421 IBaseFilter_Release(pfilter);
1426 hr = IBaseFilter_EnumPins(pfilter, &penumpins);
1428 WARN("Splitter Enumpins (%x)\n", hr);
1432 while ((hr = IEnumPins_Next(penumpins, 1, &ppinfilter, &pin)) == S_OK)
1442 hr = IPin_QueryDirection(ppinfilter, &dir);
1444 IPin_Release(ppinfilter);
1445 WARN("QueryDirection failed (%x)\n", hr);
1448 if (dir != PINDIR_INPUT) {
1449 IPin_Release(ppinfilter);
1450 continue; /* Wrong direction */
1453 /* Connect the pin to the "Renderer" */
1454 hr = IPin_Connect(ppinOut, ppinfilter, NULL);
1455 IPin_Release(ppinfilter);
1458 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_UNION(&var, bstrVal)), hr);
1461 TRACE("Connected, recursing %s\n", debugstr_w(V_UNION(&var, bstrVal)));
1465 hr = FilterGraph2_RenderRecurse(This, ppinfilter);
1467 WARN("Unable to connect recursively (%x)\n", hr);
1470 IBaseFilter_Release(pfilter);
1473 if (SUCCEEDED(hr)) {
1474 IEnumPins_Release(penumpins);
1475 break; /* out of IEnumMoniker_Next loop */
1478 /* IEnumPins_Next failed, all other failure case caught by goto error */
1479 WARN("IEnumPins_Next (%x)\n", hr);
1485 IEnumPins_Release(penumpins);
1487 IFilterGraph2_RemoveFilter(iface, pfilter);
1488 IBaseFilter_Release(pfilter);
1490 if (SUCCEEDED(hr)) DebugBreak();
1493 IEnumMoniker_Release(pEnumMoniker);
1495 DeleteMediaType(mt);
1501 IEnumMediaTypes_Release(penummt);
1505 static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface, LPCWSTR lpcwstrFile,
1506 LPCWSTR lpcwstrPlayList)
1508 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1509 static const WCHAR string[] = {'R','e','a','d','e','r',0};
1510 IBaseFilter* preader = NULL;
1511 IPin* ppinreader = NULL;
1512 IEnumPins* penumpins = NULL;
1514 BOOL partial = FALSE;
1515 HRESULT any = FALSE;
1517 TRACE("(%p/%p)->(%s, %s)\n", This, iface, debugstr_w(lpcwstrFile), debugstr_w(lpcwstrPlayList));
1519 if (lpcwstrPlayList != NULL)
1520 return E_INVALIDARG;
1522 hr = IFilterGraph2_AddSourceFilter(iface, lpcwstrFile, string, &preader);
1527 hr = IBaseFilter_EnumPins(preader, &penumpins);
1530 while (IEnumPins_Next(penumpins, 1, &ppinreader, NULL) == S_OK)
1534 IPin_QueryDirection(ppinreader, &dir);
1535 if (dir == PINDIR_OUTPUT)
1539 hr = IFilterGraph2_Render(iface, ppinreader);
1540 TRACE("Render %08x\n", hr);
1542 for (i = 0; i < This->nFilters; ++i)
1543 TRACE("Filters in chain: %s\n", debugstr_w(This->pFilterNames[i]));
1550 IPin_Release(ppinreader);
1552 IEnumPins_Release(penumpins);
1555 hr = VFW_E_CANNOT_RENDER;
1557 hr = VFW_S_PARTIAL_RENDER;
1561 IBaseFilter_Release(preader);
1563 TRACE("--> %08x\n", hr);
1567 static HRESULT CreateFilterInstanceAndLoadFile(GUID* clsid, LPCOLESTR pszFileName, IBaseFilter **filter)
1569 IFileSourceFilter *source = NULL;
1570 HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter);
1571 TRACE("CLSID: %s\n", debugstr_guid(clsid));
1575 hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID*)&source);
1578 IBaseFilter_Release(*filter);
1582 /* Load the file in the file source filter */
1583 hr = IFileSourceFilter_Load(source, pszFileName, NULL);
1584 IFileSourceFilter_Release(source);
1586 WARN("Load (%x)\n", hr);
1587 IBaseFilter_Release(*filter);
1594 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1595 static HRESULT GetFileSourceFilter(LPCOLESTR pszFileName, IBaseFilter **filter)
1599 IAsyncReader * pReader = NULL;
1600 IFileSourceFilter* pSource = NULL;
1601 IPin * pOutputPin = NULL;
1602 static const WCHAR wszOutputPinName[] = { 'O','u','t','p','u','t',0 };
1604 /* Try to find a match without reading the file first */
1605 hr = GetClassMediaFile(NULL, pszFileName, NULL, NULL, &clsid);
1608 return CreateFilterInstanceAndLoadFile(&clsid, pszFileName, filter);
1610 /* Now create a AyncReader instance, to check for signature bytes in the file */
1611 hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter);
1615 hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID *)&pSource);
1618 IBaseFilter_Release(*filter);
1622 hr = IFileSourceFilter_Load(pSource, pszFileName, NULL);
1623 IFileSourceFilter_Release(pSource);
1626 IBaseFilter_Release(*filter);
1630 hr = IBaseFilter_FindPin(*filter, wszOutputPinName, &pOutputPin);
1633 IBaseFilter_Release(*filter);
1637 hr = IPin_QueryInterface(pOutputPin, &IID_IAsyncReader, (LPVOID *)&pReader);
1638 IPin_Release(pOutputPin);
1641 IBaseFilter_Release(*filter);
1645 /* Try again find a match */
1646 hr = GetClassMediaFile(pReader, pszFileName, NULL, NULL, &clsid);
1647 IAsyncReader_Release(pReader);
1651 /* Release the AsyncReader filter and create the matching one */
1652 IBaseFilter_Release(*filter);
1653 return CreateFilterInstanceAndLoadFile(&clsid, pszFileName, filter);
1656 /* Return the AsyncReader filter */
1660 static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface, LPCWSTR lpcwstrFileName,
1661 LPCWSTR lpcwstrFilterName, IBaseFilter **ppFilter)
1663 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1665 IBaseFilter* preader;
1666 IFileSourceFilter* pfile = NULL;
1670 TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
1672 /* Try from file name first, then fall back to default asynchronous reader */
1673 hr = GetFileSourceFilter(lpcwstrFileName, &preader);
1675 WARN("Unable to create file source filter (%x)\n", hr);
1679 hr = IFilterGraph2_AddFilter(iface, preader, lpcwstrFilterName);
1681 WARN("Unable add filter (%x)\n", hr);
1682 IBaseFilter_Release(preader);
1686 hr = IBaseFilter_QueryInterface(preader, &IID_IFileSourceFilter, (LPVOID*)&pfile);
1688 WARN("Unable to get IFileSourceInterface (%x)\n", hr);
1692 /* The file has been already loaded */
1693 IFileSourceFilter_GetCurFile(pfile, &filename, &mt);
1695 WARN("GetCurFile (%x)\n", hr);
1699 TRACE("File %s\n", debugstr_w(filename));
1700 TRACE("MajorType %s\n", debugstr_guid(&mt.majortype));
1701 TRACE("SubType %s\n", debugstr_guid(&mt.subtype));
1704 *ppFilter = preader;
1705 IFileSourceFilter_Release(pfile);
1711 IFileSourceFilter_Release(pfile);
1712 IFilterGraph2_RemoveFilter(iface, preader);
1713 IBaseFilter_Release(preader);
1718 static HRESULT WINAPI FilterGraph2_SetLogFile(IFilterGraph2 *iface, DWORD_PTR hFile)
1720 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1722 TRACE("(%p/%p)->(%08x): stub !!!\n", This, iface, (DWORD) hFile);
1727 static HRESULT WINAPI FilterGraph2_Abort(IFilterGraph2 *iface)
1729 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1731 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1736 static HRESULT WINAPI FilterGraph2_ShouldOperationContinue(IFilterGraph2 *iface)
1738 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1740 TRACE("(%p/%p)->(): stub !!!\n", This, iface);
1745 /*** IFilterGraph2 methods ***/
1746 static HRESULT WINAPI FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2 *iface,
1747 IMoniker *pMoniker, IBindCtx *pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter **ppFilter)
1749 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1751 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This, iface, pMoniker, pCtx, debugstr_w(lpcwstrFilterName), ppFilter);
1756 static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface, IPin *ppin,
1757 const AM_MEDIA_TYPE *pmt)
1759 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1761 TRACE("(%p/%p)->(%p %p): stub !!!\n", This, iface, ppin, pmt);
1766 static HRESULT WINAPI FilterGraph2_RenderEx(IFilterGraph2 *iface, IPin *pPinOut, DWORD dwFlags,
1769 IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
1771 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This, iface, pPinOut, dwFlags, pvContext);
1777 static const IFilterGraph2Vtbl IFilterGraph2_VTable =
1779 FilterGraph2_QueryInterface,
1780 FilterGraph2_AddRef,
1781 FilterGraph2_Release,
1782 FilterGraph2_AddFilter,
1783 FilterGraph2_RemoveFilter,
1784 FilterGraph2_EnumFilters,
1785 FilterGraph2_FindFilterByName,
1786 FilterGraph2_ConnectDirect,
1787 FilterGraph2_Reconnect,
1788 FilterGraph2_Disconnect,
1789 FilterGraph2_SetDefaultSyncSource,
1790 FilterGraph2_Connect,
1791 FilterGraph2_Render,
1792 FilterGraph2_RenderFile,
1793 FilterGraph2_AddSourceFilter,
1794 FilterGraph2_SetLogFile,
1796 FilterGraph2_ShouldOperationContinue,
1797 FilterGraph2_AddSourceFilterForMoniker,
1798 FilterGraph2_ReconnectEx,
1799 FilterGraph2_RenderEx
1802 static inline IFilterGraphImpl *impl_from_IMediaControl(IMediaControl *iface)
1804 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaControl_iface);
1807 static HRESULT WINAPI MediaControl_QueryInterface(IMediaControl *iface, REFIID riid, void **ppvObj)
1809 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1811 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1813 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
1816 static ULONG WINAPI MediaControl_AddRef(IMediaControl *iface)
1818 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1820 TRACE("(%p/%p)->()\n", This, iface);
1822 return IUnknown_AddRef(This->outer_unk);
1825 static ULONG WINAPI MediaControl_Release(IMediaControl *iface)
1827 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1829 TRACE("(%p/%p)->()\n", This, iface);
1831 return IUnknown_Release(This->outer_unk);
1835 /*** IDispatch methods ***/
1836 static HRESULT WINAPI MediaControl_GetTypeInfoCount(IMediaControl *iface, UINT *pctinfo)
1838 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1840 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1845 static HRESULT WINAPI MediaControl_GetTypeInfo(IMediaControl *iface, UINT iTInfo, LCID lcid,
1846 ITypeInfo **ppTInfo)
1848 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1850 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1855 static HRESULT WINAPI MediaControl_GetIDsOfNames(IMediaControl *iface, REFIID riid,
1856 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1858 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1860 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1865 static HRESULT WINAPI MediaControl_Invoke(IMediaControl *iface, DISPID dispIdMember, REFIID riid,
1866 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo,
1869 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
1871 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);
1876 typedef HRESULT(WINAPI *fnFoundFilter)(IBaseFilter *, DWORD_PTR data);
1878 static HRESULT ExploreGraph(IFilterGraphImpl* pGraph, IPin* pOutputPin, fnFoundFilter FoundFilter, DWORD_PTR data)
1887 TRACE("%p %p\n", pGraph, pOutputPin);
1888 PinInfo.pFilter = NULL;
1890 hr = IPin_ConnectedTo(pOutputPin, &pInputPin);
1894 hr = IPin_QueryPinInfo(pInputPin, &PinInfo);
1896 hr = GetInternalConnections(PinInfo.pFilter, pInputPin, &ppPins, &nb);
1897 IPin_Release(pInputPin);
1904 TRACE("Reached a renderer\n");
1905 /* Count renderers for end of stream notification */
1906 pGraph->nRenderers++;
1910 for(i = 0; i < nb; i++)
1912 /* Explore the graph downstream from this pin
1913 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1914 * several input pins are connected to the same output (a MUX for instance). */
1915 ExploreGraph(pGraph, ppPins[i], FoundFilter, data);
1916 IPin_Release(ppPins[i]);
1919 CoTaskMemFree(ppPins);
1921 TRACE("Doing stuff with filter %p\n", PinInfo.pFilter);
1923 FoundFilter(PinInfo.pFilter, data);
1926 if (PinInfo.pFilter) IBaseFilter_Release(PinInfo.pFilter);
1930 static HRESULT WINAPI SendRun(IBaseFilter *pFilter, DWORD_PTR data)
1932 REFERENCE_TIME time = *(REFERENCE_TIME*)data;
1933 return IBaseFilter_Run(pFilter, time);
1936 static HRESULT WINAPI SendPause(IBaseFilter *pFilter, DWORD_PTR data)
1938 return IBaseFilter_Pause(pFilter);
1941 static HRESULT WINAPI SendStop(IBaseFilter *pFilter, DWORD_PTR data)
1943 return IBaseFilter_Stop(pFilter);
1946 static HRESULT WINAPI SendGetState(IBaseFilter *pFilter, DWORD_PTR data)
1949 DWORD time_end = data;
1950 DWORD time_now = GetTickCount();
1953 if (time_end == INFINITE)
1957 else if (time_end > time_now)
1959 wait = time_end - time_now;
1964 return IBaseFilter_GetState(pFilter, wait, &state);
1968 static HRESULT SendFilterMessage(IFilterGraphImpl *This, fnFoundFilter FoundFilter, DWORD_PTR data)
1971 IBaseFilter* pfilter;
1978 TRACE("(%p)->()\n", This);
1980 /* Explorer the graph from source filters to renderers, determine renderers
1981 * number and run filters from renderers to source filters */
1982 This->nRenderers = 0;
1983 ResetEvent(This->hEventCompletion);
1985 for(i = 0; i < This->nFilters; i++)
1988 pfilter = This->ppFiltersInGraph[i];
1989 hr = IBaseFilter_EnumPins(pfilter, &pEnum);
1992 WARN("Enum pins failed %x\n", hr);
1995 /* Check if it is a source filter */
1996 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
1998 IPin_QueryDirection(pPin, &dir);
2000 if (dir == PINDIR_INPUT)
2008 TRACE("Found a source filter %p\n", pfilter);
2009 IEnumPins_Reset(pEnum);
2010 while(IEnumPins_Next(pEnum, 1, &pPin, &dummy) == S_OK)
2012 /* Explore the graph downstream from this pin */
2013 ExploreGraph(This, pPin, FoundFilter, data);
2016 FoundFilter(pfilter, data);
2018 IEnumPins_Release(pEnum);
2024 /*** IMediaControl methods ***/
2025 static HRESULT WINAPI MediaControl_Run(IMediaControl *iface)
2027 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2029 TRACE("(%p/%p)->()\n", This, iface);
2031 EnterCriticalSection(&This->cs);
2032 if (This->state == State_Running)
2034 This->EcCompleteCount = 0;
2036 if (This->defaultclock && !This->refClock)
2037 IFilterGraph2_SetDefaultSyncSource(&This->IFilterGraph2_iface);
2042 IReferenceClock_GetTime(This->refClock, &now);
2043 if (This->state == State_Stopped)
2044 This->start_time = now + 500000;
2045 else if (This->pause_time >= 0)
2046 This->start_time += now - This->pause_time;
2048 This->start_time = now;
2050 else This->start_time = 0;
2052 SendFilterMessage(This, SendRun, (DWORD_PTR)&This->start_time);
2053 This->state = State_Running;
2055 LeaveCriticalSection(&This->cs);
2059 static HRESULT WINAPI MediaControl_Pause(IMediaControl *iface)
2061 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2063 TRACE("(%p/%p)->()\n", This, iface);
2065 EnterCriticalSection(&This->cs);
2066 if (This->state == State_Paused)
2069 if (This->state == State_Running && This->refClock && This->start_time >= 0)
2070 IReferenceClock_GetTime(This->refClock, &This->pause_time);
2072 This->pause_time = -1;
2074 SendFilterMessage(This, SendPause, 0);
2075 This->state = State_Paused;
2077 LeaveCriticalSection(&This->cs);
2081 static HRESULT WINAPI MediaControl_Stop(IMediaControl *iface)
2083 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2085 TRACE("(%p/%p)->()\n", This, iface);
2087 if (This->state == State_Stopped) return S_OK;
2089 EnterCriticalSection(&This->cs);
2090 if (This->state == State_Running) SendFilterMessage(This, SendPause, 0);
2091 SendFilterMessage(This, SendStop, 0);
2092 This->state = State_Stopped;
2093 LeaveCriticalSection(&This->cs);
2097 static HRESULT WINAPI MediaControl_GetState(IMediaControl *iface, LONG msTimeout,
2100 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2103 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pfs);
2108 EnterCriticalSection(&This->cs);
2113 end = GetTickCount() + msTimeout;
2115 else if (msTimeout < 0)
2124 SendFilterMessage(This, SendGetState, end);
2126 LeaveCriticalSection(&This->cs);
2131 static HRESULT WINAPI MediaControl_RenderFile(IMediaControl *iface, BSTR strFilename)
2133 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2135 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strFilename), strFilename);
2137 return IFilterGraph2_RenderFile(&This->IFilterGraph2_iface, strFilename, NULL);
2140 static HRESULT WINAPI MediaControl_AddSourceFilter(IMediaControl *iface, BSTR strFilename,
2143 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2145 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This, iface, debugstr_w(strFilename), strFilename, ppUnk);
2150 static HRESULT WINAPI MediaControl_get_FilterCollection(IMediaControl *iface, IDispatch **ppUnk)
2152 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2154 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2159 static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface, IDispatch **ppUnk)
2161 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2163 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, ppUnk);
2168 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface)
2170 IFilterGraphImpl *This = impl_from_IMediaControl(iface);
2172 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
2178 static const IMediaControlVtbl IMediaControl_VTable =
2180 MediaControl_QueryInterface,
2181 MediaControl_AddRef,
2182 MediaControl_Release,
2183 MediaControl_GetTypeInfoCount,
2184 MediaControl_GetTypeInfo,
2185 MediaControl_GetIDsOfNames,
2186 MediaControl_Invoke,
2190 MediaControl_GetState,
2191 MediaControl_RenderFile,
2192 MediaControl_AddSourceFilter,
2193 MediaControl_get_FilterCollection,
2194 MediaControl_get_RegFilterCollection,
2195 MediaControl_StopWhenReady
2198 static inline IFilterGraphImpl *impl_from_IMediaSeeking(IMediaSeeking *iface)
2200 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaSeeking_iface);
2203 static HRESULT WINAPI MediaSeeking_QueryInterface(IMediaSeeking *iface, REFIID riid, void **ppvObj)
2205 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2207 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2209 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
2212 static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface)
2214 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2216 TRACE("(%p/%p)->()\n", This, iface);
2218 return IUnknown_AddRef(This->outer_unk);
2221 static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface)
2223 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2225 TRACE("(%p/%p)->()\n", This, iface);
2227 return IUnknown_Release(This->outer_unk);
2230 typedef HRESULT (WINAPI *fnFoundSeek)(IFilterGraphImpl *This, IMediaSeeking*, DWORD_PTR arg);
2232 static HRESULT all_renderers_seek(IFilterGraphImpl *This, fnFoundSeek FoundSeek, DWORD_PTR arg) {
2233 BOOL allnotimpl = TRUE;
2235 HRESULT hr, hr_return = S_OK;
2237 TRACE("(%p)->(%p %08lx)\n", This, FoundSeek, arg);
2238 /* Send a message to all renderers, they are responsible for broadcasting it further */
2240 for(i = 0; i < This->nFilters; i++)
2242 IMediaSeeking *seek = NULL;
2243 IBaseFilter* pfilter = This->ppFiltersInGraph[i];
2244 IAMFilterMiscFlags *flags = NULL;
2246 IBaseFilter_QueryInterface(pfilter, &IID_IAMFilterMiscFlags, (void**)&flags);
2249 filterflags = IAMFilterMiscFlags_GetMiscFlags(flags);
2250 IAMFilterMiscFlags_Release(flags);
2251 if (filterflags != AM_FILTER_MISC_FLAGS_IS_RENDERER)
2254 IBaseFilter_QueryInterface(pfilter, &IID_IMediaSeeking, (void**)&seek);
2257 hr = FoundSeek(This, seek, arg);
2258 IMediaSeeking_Release(seek);
2259 if (hr_return != E_NOTIMPL)
2261 if (hr_return == S_OK || (FAILED(hr) && hr != E_NOTIMPL && SUCCEEDED(hr_return)))
2270 static HRESULT WINAPI FoundCapabilities(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pcaps)
2275 hr = IMediaSeeking_GetCapabilities(seek, &caps);
2279 /* Only add common capabilities everything supports */
2280 *(DWORD*)pcaps &= caps;
2285 /*** IMediaSeeking methods ***/
2286 static HRESULT WINAPI MediaSeeking_GetCapabilities(IMediaSeeking *iface, DWORD *pCapabilities)
2288 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2291 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2296 EnterCriticalSection(&This->cs);
2297 *pCapabilities = 0xffffffff;
2299 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2300 LeaveCriticalSection(&This->cs);
2305 static HRESULT WINAPI MediaSeeking_CheckCapabilities(IMediaSeeking *iface, DWORD *pCapabilities)
2307 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2311 TRACE("(%p/%p)->(%p)\n", This, iface, pCapabilities);
2316 EnterCriticalSection(&This->cs);
2317 originalcaps = *pCapabilities;
2318 hr = all_renderers_seek(This, FoundCapabilities, (DWORD_PTR)pCapabilities);
2319 LeaveCriticalSection(&This->cs);
2324 if (!*pCapabilities)
2326 if (*pCapabilities != originalcaps)
2331 static HRESULT WINAPI MediaSeeking_IsFormatSupported(IMediaSeeking *iface, const GUID *pFormat)
2333 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2338 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2340 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2342 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2349 static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *pFormat)
2351 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2356 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This, iface, pFormat);
2357 memcpy(pFormat, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
2362 static HRESULT WINAPI MediaSeeking_GetTimeFormat(IMediaSeeking *iface, GUID *pFormat)
2364 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2369 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2370 memcpy(pFormat, &This->timeformatseek, sizeof(GUID));
2375 static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(IMediaSeeking *iface, const GUID *pFormat)
2377 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2379 TRACE("(%p/%p)->(%p)\n", This, iface, pFormat);
2383 if (memcmp(pFormat, &This->timeformatseek, sizeof(GUID)))
2389 static HRESULT WINAPI MediaSeeking_SetTimeFormat(IMediaSeeking *iface, const GUID *pFormat)
2391 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2396 TRACE("(%p/%p)->(%s)\n", This, iface, debugstr_guid(pFormat));
2398 if (This->state != State_Stopped)
2399 return VFW_E_WRONG_STATE;
2401 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, pFormat))
2403 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat));
2404 return E_INVALIDARG;
2410 static HRESULT WINAPI FoundDuration(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pduration)
2413 LONGLONG duration = 0, *pdur = (LONGLONG*)pduration;
2415 hr = IMediaSeeking_GetDuration(seek, &duration);
2419 if (*pdur < duration)
2424 static HRESULT WINAPI MediaSeeking_GetDuration(IMediaSeeking *iface, LONGLONG *pDuration)
2426 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2429 TRACE("(%p/%p)->(%p)\n", This, iface, pDuration);
2434 EnterCriticalSection(&This->cs);
2436 hr = all_renderers_seek(This, FoundDuration, (DWORD_PTR)pDuration);
2437 LeaveCriticalSection(&This->cs);
2439 TRACE("--->%08x\n", hr);
2443 static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface, LONGLONG *pStop)
2445 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2448 TRACE("(%p/%p)->(%p)\n", This, iface, pStop);
2453 EnterCriticalSection(&This->cs);
2454 if (This->stop_position < 0)
2455 /* Stop position not set, use duration instead */
2456 hr = IMediaSeeking_GetDuration(iface, pStop);
2458 *pStop = This->stop_position;
2459 LeaveCriticalSection(&This->cs);
2464 static HRESULT WINAPI FoundCurrentPosition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pposition)
2467 LONGLONG pos = 0, *ppos = (LONGLONG*)pposition;
2469 hr = IMediaSeeking_GetCurrentPosition(seek, &pos);
2473 if (*ppos < 0 || pos < *ppos)
2478 static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *pCurrent)
2480 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2486 EnterCriticalSection(&This->cs);
2488 hr = all_renderers_seek(This, FoundCurrentPosition, (DWORD_PTR)pCurrent);
2489 if (hr == E_NOTIMPL) {
2491 if (This->state == State_Running && This->refClock && This->start_time >= 0)
2493 IReferenceClock_GetTime(This->refClock, &time);
2495 time -= This->start_time;
2497 if (This->pause_time > 0)
2498 time += This->pause_time;
2502 LeaveCriticalSection(&This->cs);
2504 TRACE("Time: %u.%03u\n", (DWORD)(*pCurrent / 10000000), (DWORD)((*pCurrent / 10000)%1000));
2509 static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *pTarget,
2510 const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat)
2512 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2514 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This, iface, pTarget,
2515 pTargetFormat, wine_dbgstr_longlong(Source), pSourceFormat);
2521 LONGLONG* current, *stop;
2522 DWORD curflags, stopflags;
2525 static HRESULT WINAPI found_setposition(IFilterGraphImpl *This, IMediaSeeking *seek, DWORD_PTR pargs)
2527 struct pos_args *args = (void*)pargs;
2529 return IMediaSeeking_SetPositions(seek, args->current, args->curflags, args->stop, args->stopflags);
2532 static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface, LONGLONG *pCurrent,
2533 DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)
2535 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2538 struct pos_args args;
2540 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This, iface, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
2542 EnterCriticalSection(&This->cs);
2543 state = This->state;
2544 TRACE("State: %s\n", state == State_Running ? "Running" : (state == State_Paused ? "Paused" : (state == State_Stopped ? "Stopped" : "UNKNOWN")));
2546 if ((dwCurrentFlags & 0x7) != AM_SEEKING_AbsolutePositioning &&
2547 (dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning)
2548 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags & 0x7);
2550 if ((dwStopFlags & 0x7) == AM_SEEKING_AbsolutePositioning)
2551 This->stop_position = *pStop;
2552 else if ((dwStopFlags & 0x7) != AM_SEEKING_NoPositioning)
2553 FIXME("Stop position not handled yet!\n");
2555 if (state == State_Running && !(dwCurrentFlags & AM_SEEKING_NoFlush))
2556 IMediaControl_Pause(&This->IMediaControl_iface);
2557 args.current = pCurrent;
2559 args.curflags = dwCurrentFlags;
2560 args.stopflags = dwStopFlags;
2561 hr = all_renderers_seek(This, found_setposition, (DWORD_PTR)&args);
2563 if ((dwCurrentFlags & 0x7) != AM_SEEKING_NoPositioning)
2564 This->pause_time = This->start_time = -1;
2565 if (state == State_Running && !(dwCurrentFlags & AM_SEEKING_NoFlush))
2566 IMediaControl_Run(&This->IMediaControl_iface);
2567 LeaveCriticalSection(&This->cs);
2572 static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface, LONGLONG *pCurrent,
2575 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2578 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pCurrent, pStop);
2579 hr = IMediaSeeking_GetCurrentPosition(iface, pCurrent);
2581 hr = IMediaSeeking_GetStopPosition(iface, pStop);
2586 static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface, LONGLONG *pEarliest,
2589 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2591 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pEarliest, pLatest);
2596 static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface, double dRate)
2598 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2600 FIXME("(%p/%p)->(%f): stub !!!\n", This, iface, dRate);
2605 static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface, double *pdRate)
2607 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2609 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pdRate);
2614 static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface, LONGLONG *pllPreroll)
2616 IFilterGraphImpl *This = impl_from_IMediaSeeking(iface);
2618 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pllPreroll);
2624 static const IMediaSeekingVtbl IMediaSeeking_VTable =
2626 MediaSeeking_QueryInterface,
2627 MediaSeeking_AddRef,
2628 MediaSeeking_Release,
2629 MediaSeeking_GetCapabilities,
2630 MediaSeeking_CheckCapabilities,
2631 MediaSeeking_IsFormatSupported,
2632 MediaSeeking_QueryPreferredFormat,
2633 MediaSeeking_GetTimeFormat,
2634 MediaSeeking_IsUsingTimeFormat,
2635 MediaSeeking_SetTimeFormat,
2636 MediaSeeking_GetDuration,
2637 MediaSeeking_GetStopPosition,
2638 MediaSeeking_GetCurrentPosition,
2639 MediaSeeking_ConvertTimeFormat,
2640 MediaSeeking_SetPositions,
2641 MediaSeeking_GetPositions,
2642 MediaSeeking_GetAvailable,
2643 MediaSeeking_SetRate,
2644 MediaSeeking_GetRate,
2645 MediaSeeking_GetPreroll
2648 static inline IFilterGraphImpl *impl_from_IMediaPosition(IMediaPosition *iface)
2650 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaPosition_iface);
2653 /*** IUnknown methods ***/
2654 static HRESULT WINAPI MediaPosition_QueryInterface(IMediaPosition* iface, REFIID riid, void** ppvObj)
2656 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2658 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2660 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
2663 static ULONG WINAPI MediaPosition_AddRef(IMediaPosition *iface)
2665 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2667 TRACE("(%p/%p)->()\n", This, iface);
2669 return IUnknown_AddRef(This->outer_unk);
2672 static ULONG WINAPI MediaPosition_Release(IMediaPosition *iface)
2674 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2676 TRACE("(%p/%p)->()\n", This, iface);
2678 return IUnknown_Release(This->outer_unk);
2681 /*** IDispatch methods ***/
2682 static HRESULT WINAPI MediaPosition_GetTypeInfoCount(IMediaPosition *iface, UINT* pctinfo)
2684 FIXME("(%p) stub!\n", iface);
2688 static HRESULT WINAPI MediaPosition_GetTypeInfo(IMediaPosition *iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
2690 FIXME("(%p) stub!\n", iface);
2694 static HRESULT WINAPI MediaPosition_GetIDsOfNames(IMediaPosition* iface, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
2696 FIXME("(%p) stub!\n", iface);
2700 static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2702 FIXME("(%p) stub!\n", iface);
2706 static HRESULT ConvertFromREFTIME(IMediaSeeking *seek, REFTIME time_in, LONGLONG *time_out)
2711 hr = MediaSeeking_GetTimeFormat(seek, &time_format);
2714 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, &time_format))
2716 FIXME("Unsupported time format.\n");
2720 *time_out = (LONGLONG) (time_in * 10000000); /* convert from 1 second intervals to 100 ns intervals */
2724 static HRESULT ConvertToREFTIME(IMediaSeeking *seek, LONGLONG time_in, REFTIME *time_out)
2729 hr = MediaSeeking_GetTimeFormat(seek, &time_format);
2732 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, &time_format))
2734 FIXME("Unsupported time format.\n");
2738 *time_out = (REFTIME)time_in / 10000000; /* convert from 100 ns intervals to 1 second intervals */
2742 /*** IMediaPosition methods ***/
2743 static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength)
2746 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2747 HRESULT hr = IMediaSeeking_GetDuration(&This->IMediaSeeking_iface, &duration);
2750 return ConvertToREFTIME(&This->IMediaSeeking_iface, duration, plength);
2753 static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime)
2755 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2759 hr = ConvertFromREFTIME(&This->IMediaSeeking_iface, llTime, &reftime);
2762 return IMediaSeeking_SetPositions(&This->IMediaSeeking_iface, &reftime,
2763 AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
2766 static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface, REFTIME *pllTime)
2768 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2772 hr = IMediaSeeking_GetCurrentPosition(&This->IMediaSeeking_iface, &pos);
2775 return ConvertToREFTIME(&This->IMediaSeeking_iface, pos, pllTime);
2778 static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime)
2780 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2782 HRESULT hr = IMediaSeeking_GetStopPosition(&This->IMediaSeeking_iface, &pos);
2785 return ConvertToREFTIME(&This->IMediaSeeking_iface, pos, pllTime);
2788 static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime)
2790 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2794 hr = ConvertFromREFTIME(&This->IMediaSeeking_iface, llTime, &reftime);
2797 return IMediaSeeking_SetPositions(&This->IMediaSeeking_iface, NULL, AM_SEEKING_NoPositioning,
2798 &reftime, AM_SEEKING_AbsolutePositioning);
2801 static HRESULT WINAPI MediaPosition_get_PrerollTime(IMediaPosition * iface, REFTIME *pllTime)
2803 FIXME("(%p)->(%p) stub!\n", iface, pllTime);
2807 static HRESULT WINAPI MediaPosition_put_PrerollTime(IMediaPosition * iface, REFTIME llTime)
2809 FIXME("(%p)->(%f) stub!\n", iface, llTime);
2813 static HRESULT WINAPI MediaPosition_put_Rate(IMediaPosition * iface, double dRate)
2815 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2816 return IMediaSeeking_SetRate(&This->IMediaSeeking_iface, dRate);
2819 static HRESULT WINAPI MediaPosition_get_Rate(IMediaPosition * iface, double *pdRate)
2821 IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
2822 return IMediaSeeking_GetRate(&This->IMediaSeeking_iface, pdRate);
2825 static HRESULT WINAPI MediaPosition_CanSeekForward(IMediaPosition * iface, LONG *pCanSeekForward)
2827 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekForward);
2831 static HRESULT WINAPI MediaPosition_CanSeekBackward(IMediaPosition * iface, LONG *pCanSeekBackward)
2833 FIXME("(%p)->(%p) stub!\n", iface, pCanSeekBackward);
2838 static const IMediaPositionVtbl IMediaPosition_VTable =
2840 MediaPosition_QueryInterface,
2841 MediaPosition_AddRef,
2842 MediaPosition_Release,
2843 MediaPosition_GetTypeInfoCount,
2844 MediaPosition_GetTypeInfo,
2845 MediaPosition_GetIDsOfNames,
2846 MediaPosition_Invoke,
2847 MediaPosition_get_Duration,
2848 MediaPosition_put_CurrentPosition,
2849 MediaPosition_get_CurrentPosition,
2850 MediaPosition_get_StopTime,
2851 MediaPosition_put_StopTime,
2852 MediaPosition_get_PrerollTime,
2853 MediaPosition_put_PrerollTime,
2854 MediaPosition_put_Rate,
2855 MediaPosition_get_Rate,
2856 MediaPosition_CanSeekForward,
2857 MediaPosition_CanSeekBackward
2860 static inline IFilterGraphImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
2862 return CONTAINING_RECORD(iface, IFilterGraphImpl, IObjectWithSite_iface);
2865 /*** IUnknown methods ***/
2866 static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite* iface, REFIID riid, void** ppvObj)
2868 IFilterGraphImpl *This = impl_from_IObjectWithSite( iface );
2870 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2872 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
2875 static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
2877 IFilterGraphImpl *This = impl_from_IObjectWithSite( iface );
2879 TRACE("(%p/%p)->()\n", This, iface);
2881 return IUnknown_AddRef(This->outer_unk);
2884 static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
2886 IFilterGraphImpl *This = impl_from_IObjectWithSite( iface );
2888 TRACE("(%p/%p)->()\n", This, iface);
2890 return IUnknown_Release(This->outer_unk);
2893 /*** IObjectWithSite methods ***/
2895 static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
2897 IFilterGraphImpl *This = impl_from_IObjectWithSite( iface );
2899 TRACE("(%p/%p)->()\n", This, iface);
2900 if (This->pSite) IUnknown_Release(This->pSite);
2901 This->pSite = pUnkSite;
2902 IUnknown_AddRef(This->pSite);
2906 static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite *iface, REFIID riid, PVOID *ppvSite)
2908 IFilterGraphImpl *This = impl_from_IObjectWithSite( iface );
2910 TRACE("(%p/%p)->(%s)\n", This, iface,debugstr_guid(riid));
2916 return IUnknown_QueryInterface(This->pSite, riid, ppvSite);
2919 static const IObjectWithSiteVtbl IObjectWithSite_VTable =
2921 ObjectWithSite_QueryInterface,
2922 ObjectWithSite_AddRef,
2923 ObjectWithSite_Release,
2924 ObjectWithSite_SetSite,
2925 ObjectWithSite_GetSite,
2928 static HRESULT GetTargetInterface(IFilterGraphImpl* pGraph, REFIID riid, LPVOID* ppvObj)
2930 HRESULT hr = E_NOINTERFACE;
2934 /* Check if the interface type is already registered */
2935 for (entry = 0; entry < pGraph->nItfCacheEntries; entry++)
2936 if (riid == pGraph->ItfCacheEntries[entry].riid)
2938 if (pGraph->ItfCacheEntries[entry].iface)
2940 /* Return the interface if available */
2941 *ppvObj = pGraph->ItfCacheEntries[entry].iface;
2947 if (entry >= MAX_ITF_CACHE_ENTRIES)
2949 FIXME("Not enough space to store interface in the cache\n");
2950 return E_OUTOFMEMORY;
2953 /* Find a filter supporting the requested interface */
2954 for (i = 0; i < pGraph->nFilters; i++)
2956 hr = IBaseFilter_QueryInterface(pGraph->ppFiltersInGraph[i], riid, ppvObj);
2959 pGraph->ItfCacheEntries[entry].riid = riid;
2960 pGraph->ItfCacheEntries[entry].filter = pGraph->ppFiltersInGraph[i];
2961 pGraph->ItfCacheEntries[entry].iface = *ppvObj;
2962 if (entry >= pGraph->nItfCacheEntries)
2963 pGraph->nItfCacheEntries++;
2966 if (hr != E_NOINTERFACE)
2973 static inline IFilterGraphImpl *impl_from_IBasicAudio(IBasicAudio *iface)
2975 return CONTAINING_RECORD(iface, IFilterGraphImpl, IBasicAudio_iface);
2978 static HRESULT WINAPI BasicAudio_QueryInterface(IBasicAudio *iface, REFIID riid, void **ppvObj)
2980 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
2982 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
2984 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
2987 static ULONG WINAPI BasicAudio_AddRef(IBasicAudio *iface)
2989 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
2991 TRACE("(%p/%p)->()\n", This, iface);
2993 return IUnknown_AddRef(This->outer_unk);
2996 static ULONG WINAPI BasicAudio_Release(IBasicAudio *iface)
2998 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3000 TRACE("(%p/%p)->()\n", This, iface);
3002 return IUnknown_Release(This->outer_unk);
3005 /*** IDispatch methods ***/
3006 static HRESULT WINAPI BasicAudio_GetTypeInfoCount(IBasicAudio *iface, UINT *pctinfo)
3008 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3009 IBasicAudio* pBasicAudio;
3012 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3014 EnterCriticalSection(&This->cs);
3016 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3019 hr = IBasicAudio_GetTypeInfoCount(pBasicAudio, pctinfo);
3021 LeaveCriticalSection(&This->cs);
3026 static HRESULT WINAPI BasicAudio_GetTypeInfo(IBasicAudio *iface, UINT iTInfo, LCID lcid,
3027 ITypeInfo **ppTInfo)
3029 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3030 IBasicAudio* pBasicAudio;
3033 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3035 EnterCriticalSection(&This->cs);
3037 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3040 hr = IBasicAudio_GetTypeInfo(pBasicAudio, iTInfo, lcid, ppTInfo);
3042 LeaveCriticalSection(&This->cs);
3047 static HRESULT WINAPI BasicAudio_GetIDsOfNames(IBasicAudio *iface, REFIID riid, LPOLESTR *rgszNames,
3048 UINT cNames, LCID lcid, DISPID *rgDispId)
3050 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3051 IBasicAudio* pBasicAudio;
3054 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3056 EnterCriticalSection(&This->cs);
3058 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3061 hr = IBasicAudio_GetIDsOfNames(pBasicAudio, riid, rgszNames, cNames, lcid, rgDispId);
3063 LeaveCriticalSection(&This->cs);
3068 static HRESULT WINAPI BasicAudio_Invoke(IBasicAudio *iface, DISPID dispIdMember, REFIID riid,
3069 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo,
3072 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3073 IBasicAudio* pBasicAudio;
3076 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);
3078 EnterCriticalSection(&This->cs);
3080 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3083 hr = IBasicAudio_Invoke(pBasicAudio, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3085 LeaveCriticalSection(&This->cs);
3090 /*** IBasicAudio methods ***/
3091 static HRESULT WINAPI BasicAudio_put_Volume(IBasicAudio *iface, LONG lVolume)
3093 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3094 IBasicAudio* pBasicAudio;
3097 TRACE("(%p/%p)->(%d)\n", This, iface, lVolume);
3099 EnterCriticalSection(&This->cs);
3101 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3104 hr = IBasicAudio_put_Volume(pBasicAudio, lVolume);
3106 LeaveCriticalSection(&This->cs);
3111 static HRESULT WINAPI BasicAudio_get_Volume(IBasicAudio *iface, LONG *plVolume)
3113 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3114 IBasicAudio* pBasicAudio;
3117 TRACE("(%p/%p)->(%p)\n", This, iface, plVolume);
3119 EnterCriticalSection(&This->cs);
3121 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3124 hr = IBasicAudio_get_Volume(pBasicAudio, plVolume);
3126 LeaveCriticalSection(&This->cs);
3131 static HRESULT WINAPI BasicAudio_put_Balance(IBasicAudio *iface, LONG lBalance)
3133 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3134 IBasicAudio* pBasicAudio;
3137 TRACE("(%p/%p)->(%d)\n", This, iface, lBalance);
3139 EnterCriticalSection(&This->cs);
3141 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3144 hr = IBasicAudio_put_Balance(pBasicAudio, lBalance);
3146 LeaveCriticalSection(&This->cs);
3151 static HRESULT WINAPI BasicAudio_get_Balance(IBasicAudio *iface, LONG *plBalance)
3153 IFilterGraphImpl *This = impl_from_IBasicAudio(iface);
3154 IBasicAudio* pBasicAudio;
3157 TRACE("(%p/%p)->(%p)\n", This, iface, plBalance);
3159 EnterCriticalSection(&This->cs);
3161 hr = GetTargetInterface(This, &IID_IBasicAudio, (LPVOID*)&pBasicAudio);
3164 hr = IBasicAudio_get_Balance(pBasicAudio, plBalance);
3166 LeaveCriticalSection(&This->cs);
3171 static const IBasicAudioVtbl IBasicAudio_VTable =
3173 BasicAudio_QueryInterface,
3176 BasicAudio_GetTypeInfoCount,
3177 BasicAudio_GetTypeInfo,
3178 BasicAudio_GetIDsOfNames,
3180 BasicAudio_put_Volume,
3181 BasicAudio_get_Volume,
3182 BasicAudio_put_Balance,
3183 BasicAudio_get_Balance
3186 static inline IFilterGraphImpl *impl_from_IBasicVideo2(IBasicVideo2 *iface)
3188 return CONTAINING_RECORD(iface, IFilterGraphImpl, IBasicVideo2_iface);
3191 static HRESULT WINAPI BasicVideo_QueryInterface(IBasicVideo2 *iface, REFIID riid, void **ppvObj)
3193 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3195 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
3197 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
3200 static ULONG WINAPI BasicVideo_AddRef(IBasicVideo2 *iface)
3202 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3204 TRACE("(%p/%p)->()\n", This, iface);
3206 return IUnknown_AddRef(This->outer_unk);
3209 static ULONG WINAPI BasicVideo_Release(IBasicVideo2 *iface)
3211 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3213 TRACE("(%p/%p)->()\n", This, iface);
3215 return IUnknown_Release(This->outer_unk);
3218 /*** IDispatch methods ***/
3219 static HRESULT WINAPI BasicVideo_GetTypeInfoCount(IBasicVideo2 *iface, UINT *pctinfo)
3221 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3222 IBasicVideo *pBasicVideo;
3225 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
3227 EnterCriticalSection(&This->cs);
3229 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3232 hr = IBasicVideo_GetTypeInfoCount(pBasicVideo, pctinfo);
3234 LeaveCriticalSection(&This->cs);
3239 static HRESULT WINAPI BasicVideo_GetTypeInfo(IBasicVideo2 *iface, UINT iTInfo, LCID lcid,
3240 ITypeInfo **ppTInfo)
3242 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3243 IBasicVideo *pBasicVideo;
3246 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
3248 EnterCriticalSection(&This->cs);
3250 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3253 hr = IBasicVideo_GetTypeInfo(pBasicVideo, iTInfo, lcid, ppTInfo);
3255 LeaveCriticalSection(&This->cs);
3260 static HRESULT WINAPI BasicVideo_GetIDsOfNames(IBasicVideo2 *iface, REFIID riid,
3261 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3263 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3264 IBasicVideo *pBasicVideo;
3267 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
3269 EnterCriticalSection(&This->cs);
3271 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3274 hr = IBasicVideo_GetIDsOfNames(pBasicVideo, riid, rgszNames, cNames, lcid, rgDispId);
3276 LeaveCriticalSection(&This->cs);
3281 static HRESULT WINAPI BasicVideo_Invoke(IBasicVideo2 *iface, DISPID dispIdMember, REFIID riid,
3282 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo,
3285 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3286 IBasicVideo *pBasicVideo;
3289 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);
3291 EnterCriticalSection(&This->cs);
3293 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3296 hr = IBasicVideo_Invoke(pBasicVideo, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
3298 LeaveCriticalSection(&This->cs);
3303 /*** IBasicVideo methods ***/
3304 static HRESULT WINAPI BasicVideo_get_AvgTimePerFrame(IBasicVideo2 *iface, REFTIME *pAvgTimePerFrame)
3306 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3307 IBasicVideo *pBasicVideo;
3310 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
3312 EnterCriticalSection(&This->cs);
3314 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3317 hr = IBasicVideo_get_AvgTimePerFrame(pBasicVideo, pAvgTimePerFrame);
3319 LeaveCriticalSection(&This->cs);
3324 static HRESULT WINAPI BasicVideo_get_BitRate(IBasicVideo2 *iface, LONG *pBitRate)
3326 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3327 IBasicVideo *pBasicVideo;
3330 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
3332 EnterCriticalSection(&This->cs);
3334 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3337 hr = IBasicVideo_get_BitRate(pBasicVideo, pBitRate);
3339 LeaveCriticalSection(&This->cs);
3344 static HRESULT WINAPI BasicVideo_get_BitErrorRate(IBasicVideo2 *iface, LONG *pBitErrorRate)
3346 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3347 IBasicVideo *pBasicVideo;
3350 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
3352 EnterCriticalSection(&This->cs);
3354 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3357 hr = IBasicVideo_get_BitErrorRate(pBasicVideo, pBitErrorRate);
3359 LeaveCriticalSection(&This->cs);
3364 static HRESULT WINAPI BasicVideo_get_VideoWidth(IBasicVideo2 *iface, LONG *pVideoWidth)
3366 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3367 IBasicVideo *pBasicVideo;
3370 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
3372 EnterCriticalSection(&This->cs);
3374 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3377 hr = IBasicVideo_get_VideoWidth(pBasicVideo, pVideoWidth);
3379 LeaveCriticalSection(&This->cs);
3384 static HRESULT WINAPI BasicVideo_get_VideoHeight(IBasicVideo2 *iface, LONG *pVideoHeight)
3386 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3387 IBasicVideo *pBasicVideo;
3390 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
3392 EnterCriticalSection(&This->cs);
3394 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3397 hr = IBasicVideo_get_VideoHeight(pBasicVideo, pVideoHeight);
3399 LeaveCriticalSection(&This->cs);
3404 static HRESULT WINAPI BasicVideo_put_SourceLeft(IBasicVideo2 *iface, LONG SourceLeft)
3406 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3407 IBasicVideo *pBasicVideo;
3410 TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
3412 EnterCriticalSection(&This->cs);
3414 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3417 hr = IBasicVideo_put_SourceLeft(pBasicVideo, SourceLeft);
3419 LeaveCriticalSection(&This->cs);
3424 static HRESULT WINAPI BasicVideo_get_SourceLeft(IBasicVideo2 *iface, LONG *pSourceLeft)
3426 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3427 IBasicVideo *pBasicVideo;
3430 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
3432 EnterCriticalSection(&This->cs);
3434 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3437 hr = IBasicVideo_get_SourceLeft(pBasicVideo, pSourceLeft);
3439 LeaveCriticalSection(&This->cs);
3444 static HRESULT WINAPI BasicVideo_put_SourceWidth(IBasicVideo2 *iface, LONG SourceWidth)
3446 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3447 IBasicVideo *pBasicVideo;
3450 TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
3452 EnterCriticalSection(&This->cs);
3454 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3457 hr = IBasicVideo_put_SourceWidth(pBasicVideo, SourceWidth);
3459 LeaveCriticalSection(&This->cs);
3464 static HRESULT WINAPI BasicVideo_get_SourceWidth(IBasicVideo2 *iface, LONG *pSourceWidth)
3466 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3467 IBasicVideo *pBasicVideo;
3470 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
3472 EnterCriticalSection(&This->cs);
3474 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3477 hr = IBasicVideo_get_SourceWidth(pBasicVideo, pSourceWidth);
3479 LeaveCriticalSection(&This->cs);
3484 static HRESULT WINAPI BasicVideo_put_SourceTop(IBasicVideo2 *iface, LONG SourceTop)
3486 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3487 IBasicVideo *pBasicVideo;
3490 TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
3492 EnterCriticalSection(&This->cs);
3494 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3497 hr = IBasicVideo_put_SourceTop(pBasicVideo, SourceTop);
3499 LeaveCriticalSection(&This->cs);
3504 static HRESULT WINAPI BasicVideo_get_SourceTop(IBasicVideo2 *iface, LONG *pSourceTop)
3506 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3507 IBasicVideo *pBasicVideo;
3510 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
3512 EnterCriticalSection(&This->cs);
3514 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3517 hr = IBasicVideo_get_SourceTop(pBasicVideo, pSourceTop);
3519 LeaveCriticalSection(&This->cs);
3524 static HRESULT WINAPI BasicVideo_put_SourceHeight(IBasicVideo2 *iface, LONG SourceHeight)
3526 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3527 IBasicVideo *pBasicVideo;
3530 TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
3532 EnterCriticalSection(&This->cs);
3534 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3537 hr = IBasicVideo_put_SourceHeight(pBasicVideo, SourceHeight);
3539 LeaveCriticalSection(&This->cs);
3544 static HRESULT WINAPI BasicVideo_get_SourceHeight(IBasicVideo2 *iface, LONG *pSourceHeight)
3546 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3547 IBasicVideo *pBasicVideo;
3550 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
3552 EnterCriticalSection(&This->cs);
3554 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3557 hr = IBasicVideo_get_SourceHeight(pBasicVideo, pSourceHeight);
3559 LeaveCriticalSection(&This->cs);
3564 static HRESULT WINAPI BasicVideo_put_DestinationLeft(IBasicVideo2 *iface, LONG DestinationLeft)
3566 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3567 IBasicVideo *pBasicVideo;
3570 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
3572 EnterCriticalSection(&This->cs);
3574 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3577 hr = IBasicVideo_put_DestinationLeft(pBasicVideo, DestinationLeft);
3579 LeaveCriticalSection(&This->cs);
3584 static HRESULT WINAPI BasicVideo_get_DestinationLeft(IBasicVideo2 *iface, LONG *pDestinationLeft)
3586 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3587 IBasicVideo *pBasicVideo;
3590 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
3592 EnterCriticalSection(&This->cs);
3594 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3597 hr = IBasicVideo_get_DestinationLeft(pBasicVideo, pDestinationLeft);
3599 LeaveCriticalSection(&This->cs);
3604 static HRESULT WINAPI BasicVideo_put_DestinationWidth(IBasicVideo2 *iface, LONG DestinationWidth)
3606 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3607 IBasicVideo *pBasicVideo;
3610 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
3612 EnterCriticalSection(&This->cs);
3614 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3617 hr = IBasicVideo_put_DestinationWidth(pBasicVideo, DestinationWidth);
3619 LeaveCriticalSection(&This->cs);
3624 static HRESULT WINAPI BasicVideo_get_DestinationWidth(IBasicVideo2 *iface, LONG *pDestinationWidth)
3626 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3627 IBasicVideo *pBasicVideo;
3630 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
3632 EnterCriticalSection(&This->cs);
3634 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3637 hr = IBasicVideo_get_DestinationWidth(pBasicVideo, pDestinationWidth);
3639 LeaveCriticalSection(&This->cs);
3644 static HRESULT WINAPI BasicVideo_put_DestinationTop(IBasicVideo2 *iface, LONG DestinationTop)
3646 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3647 IBasicVideo *pBasicVideo;
3650 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
3652 EnterCriticalSection(&This->cs);
3654 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3657 hr = IBasicVideo_put_DestinationTop(pBasicVideo, DestinationTop);
3659 LeaveCriticalSection(&This->cs);
3664 static HRESULT WINAPI BasicVideo_get_DestinationTop(IBasicVideo2 *iface, LONG *pDestinationTop)
3666 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3667 IBasicVideo *pBasicVideo;
3670 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
3672 EnterCriticalSection(&This->cs);
3674 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3677 hr = IBasicVideo_get_DestinationTop(pBasicVideo, pDestinationTop);
3679 LeaveCriticalSection(&This->cs);
3684 static HRESULT WINAPI BasicVideo_put_DestinationHeight(IBasicVideo2 *iface, LONG DestinationHeight)
3686 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3687 IBasicVideo *pBasicVideo;
3690 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
3692 EnterCriticalSection(&This->cs);
3694 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3697 hr = IBasicVideo_put_DestinationHeight(pBasicVideo, DestinationHeight);
3699 LeaveCriticalSection(&This->cs);
3704 static HRESULT WINAPI BasicVideo_get_DestinationHeight(IBasicVideo2 *iface,
3705 LONG *pDestinationHeight)
3707 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3708 IBasicVideo *pBasicVideo;
3711 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
3713 EnterCriticalSection(&This->cs);
3715 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3718 hr = IBasicVideo_get_DestinationHeight(pBasicVideo, pDestinationHeight);
3720 LeaveCriticalSection(&This->cs);
3725 static HRESULT WINAPI BasicVideo_SetSourcePosition(IBasicVideo2 *iface, LONG Left, LONG Top,
3726 LONG Width, LONG Height)
3728 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3729 IBasicVideo *pBasicVideo;
3732 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3734 EnterCriticalSection(&This->cs);
3736 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3739 hr = IBasicVideo_SetSourcePosition(pBasicVideo, Left, Top, Width, Height);
3741 LeaveCriticalSection(&This->cs);
3746 static HRESULT WINAPI BasicVideo_GetSourcePosition(IBasicVideo2 *iface, LONG *pLeft, LONG *pTop,
3747 LONG *pWidth, LONG *pHeight)
3749 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3750 IBasicVideo *pBasicVideo;
3753 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3755 EnterCriticalSection(&This->cs);
3757 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3760 hr = IBasicVideo_GetSourcePosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3762 LeaveCriticalSection(&This->cs);
3767 static HRESULT WINAPI BasicVideo_SetDefaultSourcePosition(IBasicVideo2 *iface)
3769 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3770 IBasicVideo *pBasicVideo;
3773 TRACE("(%p/%p)->()\n", This, iface);
3775 EnterCriticalSection(&This->cs);
3777 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3780 hr = IBasicVideo_SetDefaultSourcePosition(pBasicVideo);
3782 LeaveCriticalSection(&This->cs);
3787 static HRESULT WINAPI BasicVideo_SetDestinationPosition(IBasicVideo2 *iface, LONG Left, LONG Top,
3788 LONG Width, LONG Height)
3790 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3791 IBasicVideo *pBasicVideo;
3794 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
3796 EnterCriticalSection(&This->cs);
3798 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3801 hr = IBasicVideo_SetDestinationPosition(pBasicVideo, Left, Top, Width, Height);
3803 LeaveCriticalSection(&This->cs);
3808 static HRESULT WINAPI BasicVideo_GetDestinationPosition(IBasicVideo2 *iface, LONG *pLeft,
3809 LONG *pTop, LONG *pWidth, LONG *pHeight)
3811 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3812 IBasicVideo *pBasicVideo;
3815 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
3817 EnterCriticalSection(&This->cs);
3819 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3822 hr = IBasicVideo_GetDestinationPosition(pBasicVideo, pLeft, pTop, pWidth, pHeight);
3824 LeaveCriticalSection(&This->cs);
3829 static HRESULT WINAPI BasicVideo_SetDefaultDestinationPosition(IBasicVideo2 *iface)
3831 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3832 IBasicVideo *pBasicVideo;
3835 TRACE("(%p/%p)->()\n", This, iface);
3837 EnterCriticalSection(&This->cs);
3839 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3842 hr = IBasicVideo_SetDefaultDestinationPosition(pBasicVideo);
3844 LeaveCriticalSection(&This->cs);
3849 static HRESULT WINAPI BasicVideo_GetVideoSize(IBasicVideo2 *iface, LONG *pWidth, LONG *pHeight)
3851 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3852 IBasicVideo *pBasicVideo;
3855 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
3857 EnterCriticalSection(&This->cs);
3859 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3862 hr = IBasicVideo_GetVideoSize(pBasicVideo, pWidth, pHeight);
3864 LeaveCriticalSection(&This->cs);
3869 static HRESULT WINAPI BasicVideo_GetVideoPaletteEntries(IBasicVideo2 *iface, LONG StartIndex,
3870 LONG Entries, LONG *pRetrieved, LONG *pPalette)
3872 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3873 IBasicVideo *pBasicVideo;
3876 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
3878 EnterCriticalSection(&This->cs);
3880 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3883 hr = IBasicVideo_GetVideoPaletteEntries(pBasicVideo, StartIndex, Entries, pRetrieved, pPalette);
3885 LeaveCriticalSection(&This->cs);
3890 static HRESULT WINAPI BasicVideo_GetCurrentImage(IBasicVideo2 *iface, LONG *pBufferSize,
3893 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3894 IBasicVideo *pBasicVideo;
3897 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pBufferSize, pDIBImage);
3899 EnterCriticalSection(&This->cs);
3901 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3904 hr = IBasicVideo_GetCurrentImage(pBasicVideo, pBufferSize, pDIBImage);
3906 LeaveCriticalSection(&This->cs);
3911 static HRESULT WINAPI BasicVideo_IsUsingDefaultSource(IBasicVideo2 *iface)
3913 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3914 IBasicVideo *pBasicVideo;
3917 TRACE("(%p/%p)->()\n", This, iface);
3919 EnterCriticalSection(&This->cs);
3921 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3924 hr = IBasicVideo_IsUsingDefaultSource(pBasicVideo);
3926 LeaveCriticalSection(&This->cs);
3931 static HRESULT WINAPI BasicVideo_IsUsingDefaultDestination(IBasicVideo2 *iface)
3933 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3934 IBasicVideo *pBasicVideo;
3937 TRACE("(%p/%p)->()\n", This, iface);
3939 EnterCriticalSection(&This->cs);
3941 hr = GetTargetInterface(This, &IID_IBasicVideo, (LPVOID*)&pBasicVideo);
3944 hr = IBasicVideo_IsUsingDefaultDestination(pBasicVideo);
3946 LeaveCriticalSection(&This->cs);
3951 static HRESULT WINAPI BasicVideo2_GetPreferredAspectRatio(IBasicVideo2 *iface, LONG *plAspectX,
3954 IFilterGraphImpl *This = impl_from_IBasicVideo2(iface);
3955 IBasicVideo2 *pBasicVideo2;
3958 TRACE("(%p/%p)->()\n", This, iface);
3960 EnterCriticalSection(&This->cs);
3962 hr = GetTargetInterface(This, &IID_IBasicVideo2, (LPVOID*)&pBasicVideo2);
3965 hr = BasicVideo2_GetPreferredAspectRatio(iface, plAspectX, plAspectY);
3967 LeaveCriticalSection(&This->cs);
3972 static const IBasicVideo2Vtbl IBasicVideo_VTable =
3974 BasicVideo_QueryInterface,
3977 BasicVideo_GetTypeInfoCount,
3978 BasicVideo_GetTypeInfo,
3979 BasicVideo_GetIDsOfNames,
3981 BasicVideo_get_AvgTimePerFrame,
3982 BasicVideo_get_BitRate,
3983 BasicVideo_get_BitErrorRate,
3984 BasicVideo_get_VideoWidth,
3985 BasicVideo_get_VideoHeight,
3986 BasicVideo_put_SourceLeft,
3987 BasicVideo_get_SourceLeft,
3988 BasicVideo_put_SourceWidth,
3989 BasicVideo_get_SourceWidth,
3990 BasicVideo_put_SourceTop,
3991 BasicVideo_get_SourceTop,
3992 BasicVideo_put_SourceHeight,
3993 BasicVideo_get_SourceHeight,
3994 BasicVideo_put_DestinationLeft,
3995 BasicVideo_get_DestinationLeft,
3996 BasicVideo_put_DestinationWidth,
3997 BasicVideo_get_DestinationWidth,
3998 BasicVideo_put_DestinationTop,
3999 BasicVideo_get_DestinationTop,
4000 BasicVideo_put_DestinationHeight,
4001 BasicVideo_get_DestinationHeight,
4002 BasicVideo_SetSourcePosition,
4003 BasicVideo_GetSourcePosition,
4004 BasicVideo_SetDefaultSourcePosition,
4005 BasicVideo_SetDestinationPosition,
4006 BasicVideo_GetDestinationPosition,
4007 BasicVideo_SetDefaultDestinationPosition,
4008 BasicVideo_GetVideoSize,
4009 BasicVideo_GetVideoPaletteEntries,
4010 BasicVideo_GetCurrentImage,
4011 BasicVideo_IsUsingDefaultSource,
4012 BasicVideo_IsUsingDefaultDestination,
4013 BasicVideo2_GetPreferredAspectRatio
4016 static inline IFilterGraphImpl *impl_from_IVideoWindow(IVideoWindow *iface)
4018 return CONTAINING_RECORD(iface, IFilterGraphImpl, IVideoWindow_iface);
4021 static HRESULT WINAPI VideoWindow_QueryInterface(IVideoWindow *iface, REFIID riid, void **ppvObj)
4023 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4025 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
4027 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
4030 static ULONG WINAPI VideoWindow_AddRef(IVideoWindow *iface)
4032 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4034 TRACE("(%p/%p)->()\n", This, iface);
4036 return IUnknown_AddRef(This->outer_unk);
4039 static ULONG WINAPI VideoWindow_Release(IVideoWindow *iface)
4041 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4043 TRACE("(%p/%p)->()\n", This, iface);
4045 return IUnknown_Release(This->outer_unk);
4048 /*** IDispatch methods ***/
4049 static HRESULT WINAPI VideoWindow_GetTypeInfoCount(IVideoWindow *iface, UINT *pctinfo)
4051 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4052 IVideoWindow *pVideoWindow;
4055 TRACE("(%p/%p)->(%p)\n", This, iface, pctinfo);
4057 EnterCriticalSection(&This->cs);
4059 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4062 hr = IVideoWindow_GetTypeInfoCount(pVideoWindow, pctinfo);
4064 LeaveCriticalSection(&This->cs);
4069 static HRESULT WINAPI VideoWindow_GetTypeInfo(IVideoWindow *iface, UINT iTInfo, LCID lcid,
4070 ITypeInfo **ppTInfo)
4072 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4073 IVideoWindow *pVideoWindow;
4076 TRACE("(%p/%p)->(%d, %d, %p)\n", This, iface, iTInfo, lcid, ppTInfo);
4078 EnterCriticalSection(&This->cs);
4080 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4083 hr = IVideoWindow_GetTypeInfo(pVideoWindow, iTInfo, lcid, ppTInfo);
4085 LeaveCriticalSection(&This->cs);
4090 static HRESULT WINAPI VideoWindow_GetIDsOfNames(IVideoWindow *iface, REFIID riid,
4091 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4093 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4094 IVideoWindow *pVideoWindow;
4097 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
4099 EnterCriticalSection(&This->cs);
4101 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4104 hr = IVideoWindow_GetIDsOfNames(pVideoWindow, riid, rgszNames, cNames, lcid, rgDispId);
4106 LeaveCriticalSection(&This->cs);
4111 static HRESULT WINAPI VideoWindow_Invoke(IVideoWindow *iface, DISPID dispIdMember, REFIID riid,
4112 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo,
4115 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4116 IVideoWindow *pVideoWindow;
4119 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);
4121 EnterCriticalSection(&This->cs);
4123 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4126 hr = IVideoWindow_Invoke(pVideoWindow, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
4128 LeaveCriticalSection(&This->cs);
4134 /*** IVideoWindow methods ***/
4135 static HRESULT WINAPI VideoWindow_put_Caption(IVideoWindow *iface, BSTR strCaption)
4137 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4138 IVideoWindow *pVideoWindow;
4141 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
4143 EnterCriticalSection(&This->cs);
4145 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4148 hr = IVideoWindow_put_Caption(pVideoWindow, strCaption);
4150 LeaveCriticalSection(&This->cs);
4155 static HRESULT WINAPI VideoWindow_get_Caption(IVideoWindow *iface, BSTR *strCaption)
4157 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4158 IVideoWindow *pVideoWindow;
4161 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
4163 EnterCriticalSection(&This->cs);
4165 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4168 hr = IVideoWindow_get_Caption(pVideoWindow, strCaption);
4170 LeaveCriticalSection(&This->cs);
4175 static HRESULT WINAPI VideoWindow_put_WindowStyle(IVideoWindow *iface, LONG WindowStyle)
4177 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4178 IVideoWindow *pVideoWindow;
4181 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyle);
4183 EnterCriticalSection(&This->cs);
4185 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4188 hr = IVideoWindow_put_WindowStyle(pVideoWindow, WindowStyle);
4190 LeaveCriticalSection(&This->cs);
4195 static HRESULT WINAPI VideoWindow_get_WindowStyle(IVideoWindow *iface, LONG *WindowStyle)
4197 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4198 IVideoWindow *pVideoWindow;
4201 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
4203 EnterCriticalSection(&This->cs);
4205 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4208 hr = IVideoWindow_get_WindowStyle(pVideoWindow, WindowStyle);
4210 LeaveCriticalSection(&This->cs);
4215 static HRESULT WINAPI VideoWindow_put_WindowStyleEx(IVideoWindow *iface, LONG WindowStyleEx)
4217 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4218 IVideoWindow *pVideoWindow;
4221 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyleEx);
4223 EnterCriticalSection(&This->cs);
4225 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4228 hr = IVideoWindow_put_WindowStyleEx(pVideoWindow, WindowStyleEx);
4230 LeaveCriticalSection(&This->cs);
4235 static HRESULT WINAPI VideoWindow_get_WindowStyleEx(IVideoWindow *iface, LONG *WindowStyleEx)
4237 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4238 IVideoWindow *pVideoWindow;
4241 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
4243 EnterCriticalSection(&This->cs);
4245 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4248 hr = IVideoWindow_get_WindowStyleEx(pVideoWindow, WindowStyleEx);
4250 LeaveCriticalSection(&This->cs);
4255 static HRESULT WINAPI VideoWindow_put_AutoShow(IVideoWindow *iface, LONG AutoShow)
4257 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4258 IVideoWindow *pVideoWindow;
4261 TRACE("(%p/%p)->(%d)\n", This, iface, AutoShow);
4263 EnterCriticalSection(&This->cs);
4265 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4268 hr = IVideoWindow_put_AutoShow(pVideoWindow, AutoShow);
4270 LeaveCriticalSection(&This->cs);
4275 static HRESULT WINAPI VideoWindow_get_AutoShow(IVideoWindow *iface, LONG *AutoShow)
4277 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4278 IVideoWindow *pVideoWindow;
4281 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
4283 EnterCriticalSection(&This->cs);
4285 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4288 hr = IVideoWindow_get_AutoShow(pVideoWindow, AutoShow);
4290 LeaveCriticalSection(&This->cs);
4295 static HRESULT WINAPI VideoWindow_put_WindowState(IVideoWindow *iface, LONG WindowState)
4297 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4298 IVideoWindow *pVideoWindow;
4301 TRACE("(%p/%p)->(%d)\n", This, iface, WindowState);
4303 EnterCriticalSection(&This->cs);
4305 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4308 hr = IVideoWindow_put_WindowState(pVideoWindow, WindowState);
4310 LeaveCriticalSection(&This->cs);
4315 static HRESULT WINAPI VideoWindow_get_WindowState(IVideoWindow *iface, LONG *WindowState)
4317 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4318 IVideoWindow *pVideoWindow;
4321 TRACE("(%p/%p)->(%p)\n", This, iface, WindowState);
4323 EnterCriticalSection(&This->cs);
4325 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4328 hr = IVideoWindow_get_WindowState(pVideoWindow, WindowState);
4330 LeaveCriticalSection(&This->cs);
4335 static HRESULT WINAPI VideoWindow_put_BackgroundPalette(IVideoWindow *iface, LONG BackgroundPalette)
4337 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4338 IVideoWindow *pVideoWindow;
4341 TRACE("(%p/%p)->(%d)\n", This, iface, BackgroundPalette);
4343 EnterCriticalSection(&This->cs);
4345 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4348 hr = IVideoWindow_put_BackgroundPalette(pVideoWindow, BackgroundPalette);
4350 LeaveCriticalSection(&This->cs);
4355 static HRESULT WINAPI VideoWindow_get_BackgroundPalette(IVideoWindow *iface,
4356 LONG *pBackgroundPalette)
4358 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4359 IVideoWindow *pVideoWindow;
4362 TRACE("(%p/%p)->(%p)\n", This, iface, pBackgroundPalette);
4364 EnterCriticalSection(&This->cs);
4366 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4369 hr = IVideoWindow_get_BackgroundPalette(pVideoWindow, pBackgroundPalette);
4371 LeaveCriticalSection(&This->cs);
4376 static HRESULT WINAPI VideoWindow_put_Visible(IVideoWindow *iface, LONG Visible)
4378 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4379 IVideoWindow *pVideoWindow;
4382 TRACE("(%p/%p)->(%d)\n", This, iface, Visible);
4384 EnterCriticalSection(&This->cs);
4386 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4389 hr = IVideoWindow_put_Visible(pVideoWindow, Visible);
4391 LeaveCriticalSection(&This->cs);
4396 static HRESULT WINAPI VideoWindow_get_Visible(IVideoWindow *iface, LONG *pVisible)
4398 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4399 IVideoWindow *pVideoWindow;
4402 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
4404 EnterCriticalSection(&This->cs);
4406 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4409 hr = IVideoWindow_get_Visible(pVideoWindow, pVisible);
4411 LeaveCriticalSection(&This->cs);
4416 static HRESULT WINAPI VideoWindow_put_Left(IVideoWindow *iface, LONG Left)
4418 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4419 IVideoWindow *pVideoWindow;
4422 TRACE("(%p/%p)->(%d)\n", This, iface, Left);
4424 EnterCriticalSection(&This->cs);
4426 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4429 hr = IVideoWindow_put_Left(pVideoWindow, Left);
4431 LeaveCriticalSection(&This->cs);
4436 static HRESULT WINAPI VideoWindow_get_Left(IVideoWindow *iface, LONG *pLeft)
4438 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4439 IVideoWindow *pVideoWindow;
4442 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
4444 EnterCriticalSection(&This->cs);
4446 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4449 hr = IVideoWindow_get_Left(pVideoWindow, pLeft);
4451 LeaveCriticalSection(&This->cs);
4456 static HRESULT WINAPI VideoWindow_put_Width(IVideoWindow *iface, LONG Width)
4458 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4459 IVideoWindow *pVideoWindow;
4462 TRACE("(%p/%p)->(%d)\n", This, iface, Width);
4464 EnterCriticalSection(&This->cs);
4466 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4469 hr = IVideoWindow_put_Width(pVideoWindow, Width);
4471 LeaveCriticalSection(&This->cs);
4476 static HRESULT WINAPI VideoWindow_get_Width(IVideoWindow *iface, LONG *pWidth)
4478 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4479 IVideoWindow *pVideoWindow;
4482 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
4484 EnterCriticalSection(&This->cs);
4486 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4489 hr = IVideoWindow_get_Width(pVideoWindow, pWidth);
4491 LeaveCriticalSection(&This->cs);
4496 static HRESULT WINAPI VideoWindow_put_Top(IVideoWindow *iface, LONG Top)
4498 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4499 IVideoWindow *pVideoWindow;
4502 TRACE("(%p/%p)->(%d)\n", This, iface, Top);
4504 EnterCriticalSection(&This->cs);
4506 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4509 hr = IVideoWindow_put_Top(pVideoWindow, Top);
4511 LeaveCriticalSection(&This->cs);
4516 static HRESULT WINAPI VideoWindow_get_Top(IVideoWindow *iface, LONG *pTop)
4518 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4519 IVideoWindow *pVideoWindow;
4522 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
4524 EnterCriticalSection(&This->cs);
4526 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4529 hr = IVideoWindow_get_Top(pVideoWindow, pTop);
4531 LeaveCriticalSection(&This->cs);
4536 static HRESULT WINAPI VideoWindow_put_Height(IVideoWindow *iface, LONG Height)
4538 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4539 IVideoWindow *pVideoWindow;
4542 TRACE("(%p/%p)->(%d)\n", This, iface, Height);
4544 EnterCriticalSection(&This->cs);
4546 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4549 hr = IVideoWindow_put_Height(pVideoWindow, Height);
4551 LeaveCriticalSection(&This->cs);
4556 static HRESULT WINAPI VideoWindow_get_Height(IVideoWindow *iface, LONG *pHeight)
4558 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4559 IVideoWindow *pVideoWindow;
4562 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
4564 EnterCriticalSection(&This->cs);
4566 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4569 hr = IVideoWindow_get_Height(pVideoWindow, pHeight);
4571 LeaveCriticalSection(&This->cs);
4576 static HRESULT WINAPI VideoWindow_put_Owner(IVideoWindow *iface, OAHWND Owner)
4578 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4579 IVideoWindow *pVideoWindow;
4582 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
4584 EnterCriticalSection(&This->cs);
4586 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4589 hr = IVideoWindow_put_Owner(pVideoWindow, Owner);
4591 LeaveCriticalSection(&This->cs);
4596 static HRESULT WINAPI VideoWindow_get_Owner(IVideoWindow *iface, OAHWND *Owner)
4598 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4599 IVideoWindow *pVideoWindow;
4602 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
4604 EnterCriticalSection(&This->cs);
4606 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4609 hr = IVideoWindow_get_Owner(pVideoWindow, Owner);
4611 LeaveCriticalSection(&This->cs);
4616 static HRESULT WINAPI VideoWindow_put_MessageDrain(IVideoWindow *iface, OAHWND Drain)
4618 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4619 IVideoWindow *pVideoWindow;
4622 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
4624 EnterCriticalSection(&This->cs);
4626 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4629 hr = IVideoWindow_put_MessageDrain(pVideoWindow, Drain);
4631 LeaveCriticalSection(&This->cs);
4636 static HRESULT WINAPI VideoWindow_get_MessageDrain(IVideoWindow *iface, OAHWND *Drain)
4638 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4639 IVideoWindow *pVideoWindow;
4642 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
4644 EnterCriticalSection(&This->cs);
4646 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4649 hr = IVideoWindow_get_MessageDrain(pVideoWindow, Drain);
4651 LeaveCriticalSection(&This->cs);
4656 static HRESULT WINAPI VideoWindow_get_BorderColor(IVideoWindow *iface, LONG *Color)
4658 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4659 IVideoWindow *pVideoWindow;
4662 TRACE("(%p/%p)->(%p)\n", This, iface, Color);
4664 EnterCriticalSection(&This->cs);
4666 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4669 hr = IVideoWindow_get_BorderColor(pVideoWindow, Color);
4671 LeaveCriticalSection(&This->cs);
4676 static HRESULT WINAPI VideoWindow_put_BorderColor(IVideoWindow *iface, LONG Color)
4678 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4679 IVideoWindow *pVideoWindow;
4682 TRACE("(%p/%p)->(%d)\n", This, iface, Color);
4684 EnterCriticalSection(&This->cs);
4686 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4689 hr = IVideoWindow_put_BorderColor(pVideoWindow, Color);
4691 LeaveCriticalSection(&This->cs);
4696 static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface, LONG *FullScreenMode)
4698 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4699 IVideoWindow *pVideoWindow;
4702 TRACE("(%p/%p)->(%p)\n", This, iface, FullScreenMode);
4704 EnterCriticalSection(&This->cs);
4706 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4709 hr = IVideoWindow_get_FullScreenMode(pVideoWindow, FullScreenMode);
4711 LeaveCriticalSection(&This->cs);
4716 static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG FullScreenMode)
4718 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4719 IVideoWindow *pVideoWindow;
4722 TRACE("(%p/%p)->(%d)\n", This, iface, FullScreenMode);
4724 EnterCriticalSection(&This->cs);
4726 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4729 hr = IVideoWindow_put_FullScreenMode(pVideoWindow, FullScreenMode);
4731 LeaveCriticalSection(&This->cs);
4736 static HRESULT WINAPI VideoWindow_SetWindowForeground(IVideoWindow *iface, LONG Focus)
4738 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4739 IVideoWindow *pVideoWindow;
4742 TRACE("(%p/%p)->(%d)\n", This, iface, Focus);
4744 EnterCriticalSection(&This->cs);
4746 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4749 hr = IVideoWindow_SetWindowForeground(pVideoWindow, Focus);
4751 LeaveCriticalSection(&This->cs);
4756 static HRESULT WINAPI VideoWindow_NotifyOwnerMessage(IVideoWindow *iface, OAHWND hwnd, LONG uMsg,
4757 LONG_PTR wParam, LONG_PTR lParam)
4759 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4760 IVideoWindow *pVideoWindow;
4763 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This, iface, hwnd, uMsg, wParam, lParam);
4765 EnterCriticalSection(&This->cs);
4767 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4770 hr = IVideoWindow_NotifyOwnerMessage(pVideoWindow, hwnd, uMsg, wParam, lParam);
4772 LeaveCriticalSection(&This->cs);
4777 static HRESULT WINAPI VideoWindow_SetWindowPosition(IVideoWindow *iface, LONG Left, LONG Top,
4778 LONG Width, LONG Height)
4780 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4781 IVideoWindow *pVideoWindow;
4784 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
4786 EnterCriticalSection(&This->cs);
4788 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4791 hr = IVideoWindow_SetWindowPosition(pVideoWindow, Left, Top, Width, Height);
4793 LeaveCriticalSection(&This->cs);
4798 static HRESULT WINAPI VideoWindow_GetWindowPosition(IVideoWindow *iface, LONG *pLeft, LONG *pTop,
4799 LONG *pWidth, LONG *pHeight)
4801 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4802 IVideoWindow *pVideoWindow;
4805 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4807 EnterCriticalSection(&This->cs);
4809 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4812 hr = IVideoWindow_GetWindowPosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4814 LeaveCriticalSection(&This->cs);
4819 static HRESULT WINAPI VideoWindow_GetMinIdealImageSize(IVideoWindow *iface, LONG *pWidth,
4822 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4823 IVideoWindow *pVideoWindow;
4826 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4828 EnterCriticalSection(&This->cs);
4830 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4833 hr = IVideoWindow_GetMinIdealImageSize(pVideoWindow, pWidth, pHeight);
4835 LeaveCriticalSection(&This->cs);
4840 static HRESULT WINAPI VideoWindow_GetMaxIdealImageSize(IVideoWindow *iface, LONG *pWidth,
4843 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4844 IVideoWindow *pVideoWindow;
4847 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
4849 EnterCriticalSection(&This->cs);
4851 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4854 hr = IVideoWindow_GetMaxIdealImageSize(pVideoWindow, pWidth, pHeight);
4856 LeaveCriticalSection(&This->cs);
4861 static HRESULT WINAPI VideoWindow_GetRestorePosition(IVideoWindow *iface, LONG *pLeft, LONG *pTop,
4862 LONG *pWidth, LONG *pHeight)
4864 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4865 IVideoWindow *pVideoWindow;
4868 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
4870 EnterCriticalSection(&This->cs);
4872 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4875 hr = IVideoWindow_GetRestorePosition(pVideoWindow, pLeft, pTop, pWidth, pHeight);
4877 LeaveCriticalSection(&This->cs);
4882 static HRESULT WINAPI VideoWindow_HideCursor(IVideoWindow *iface, LONG HideCursor)
4884 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4885 IVideoWindow *pVideoWindow;
4888 TRACE("(%p/%p)->(%d)\n", This, iface, HideCursor);
4890 EnterCriticalSection(&This->cs);
4892 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4895 hr = IVideoWindow_HideCursor(pVideoWindow, HideCursor);
4897 LeaveCriticalSection(&This->cs);
4902 static HRESULT WINAPI VideoWindow_IsCursorHidden(IVideoWindow *iface, LONG *CursorHidden)
4904 IFilterGraphImpl *This = impl_from_IVideoWindow(iface);
4905 IVideoWindow *pVideoWindow;
4908 TRACE("(%p/%p)->(%p)\n", This, iface, CursorHidden);
4910 EnterCriticalSection(&This->cs);
4912 hr = GetTargetInterface(This, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
4915 hr = IVideoWindow_IsCursorHidden(pVideoWindow, CursorHidden);
4917 LeaveCriticalSection(&This->cs);
4923 static const IVideoWindowVtbl IVideoWindow_VTable =
4925 VideoWindow_QueryInterface,
4927 VideoWindow_Release,
4928 VideoWindow_GetTypeInfoCount,
4929 VideoWindow_GetTypeInfo,
4930 VideoWindow_GetIDsOfNames,
4932 VideoWindow_put_Caption,
4933 VideoWindow_get_Caption,
4934 VideoWindow_put_WindowStyle,
4935 VideoWindow_get_WindowStyle,
4936 VideoWindow_put_WindowStyleEx,
4937 VideoWindow_get_WindowStyleEx,
4938 VideoWindow_put_AutoShow,
4939 VideoWindow_get_AutoShow,
4940 VideoWindow_put_WindowState,
4941 VideoWindow_get_WindowState,
4942 VideoWindow_put_BackgroundPalette,
4943 VideoWindow_get_BackgroundPalette,
4944 VideoWindow_put_Visible,
4945 VideoWindow_get_Visible,
4946 VideoWindow_put_Left,
4947 VideoWindow_get_Left,
4948 VideoWindow_put_Width,
4949 VideoWindow_get_Width,
4950 VideoWindow_put_Top,
4951 VideoWindow_get_Top,
4952 VideoWindow_put_Height,
4953 VideoWindow_get_Height,
4954 VideoWindow_put_Owner,
4955 VideoWindow_get_Owner,
4956 VideoWindow_put_MessageDrain,
4957 VideoWindow_get_MessageDrain,
4958 VideoWindow_get_BorderColor,
4959 VideoWindow_put_BorderColor,
4960 VideoWindow_get_FullScreenMode,
4961 VideoWindow_put_FullScreenMode,
4962 VideoWindow_SetWindowForeground,
4963 VideoWindow_NotifyOwnerMessage,
4964 VideoWindow_SetWindowPosition,
4965 VideoWindow_GetWindowPosition,
4966 VideoWindow_GetMinIdealImageSize,
4967 VideoWindow_GetMaxIdealImageSize,
4968 VideoWindow_GetRestorePosition,
4969 VideoWindow_HideCursor,
4970 VideoWindow_IsCursorHidden
4973 static inline IFilterGraphImpl *impl_from_IMediaEventEx(IMediaEventEx *iface)
4975 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaEventEx_iface);
4978 static HRESULT WINAPI MediaEvent_QueryInterface(IMediaEventEx *iface, REFIID riid, void **ppvObj)
4980 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
4982 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
4984 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
4987 static ULONG WINAPI MediaEvent_AddRef(IMediaEventEx *iface)
4989 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
4991 TRACE("(%p/%p)->()\n", This, iface);
4993 return IUnknown_AddRef(This->outer_unk);
4996 static ULONG WINAPI MediaEvent_Release(IMediaEventEx *iface)
4998 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5000 TRACE("(%p/%p)->()\n", This, iface);
5002 return IUnknown_Release(This->outer_unk);
5005 /*** IDispatch methods ***/
5006 static HRESULT WINAPI MediaEvent_GetTypeInfoCount(IMediaEventEx *iface, UINT *pctinfo)
5008 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5010 TRACE("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
5015 static HRESULT WINAPI MediaEvent_GetTypeInfo(IMediaEventEx *iface, UINT iTInfo, LCID lcid,
5016 ITypeInfo **ppTInfo)
5018 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5020 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
5025 static HRESULT WINAPI MediaEvent_GetIDsOfNames(IMediaEventEx *iface, REFIID riid,
5026 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
5028 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5030 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
5035 static HRESULT WINAPI MediaEvent_Invoke(IMediaEventEx *iface, DISPID dispIdMember, REFIID riid,
5036 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExepInfo,
5039 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5041 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);
5046 /*** IMediaEvent methods ***/
5047 static HRESULT WINAPI MediaEvent_GetEventHandle(IMediaEventEx *iface, OAEVENT *hEvent)
5049 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5051 TRACE("(%p/%p)->(%p)\n", This, iface, hEvent);
5053 *hEvent = (OAEVENT)This->evqueue.msg_event;
5058 static HRESULT WINAPI MediaEvent_GetEvent(IMediaEventEx *iface, LONG *lEventCode, LONG_PTR *lParam1,
5059 LONG_PTR *lParam2, LONG msTimeout)
5061 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5064 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This, iface, lEventCode, lParam1, lParam2, msTimeout);
5066 if (EventsQueue_GetEvent(&This->evqueue, &evt, msTimeout))
5068 *lEventCode = evt.lEventCode;
5069 *lParam1 = evt.lParam1;
5070 *lParam2 = evt.lParam2;
5078 static HRESULT WINAPI MediaEvent_WaitForCompletion(IMediaEventEx *iface, LONG msTimeout,
5081 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5083 TRACE("(%p/%p)->(%d, %p)\n", This, iface, msTimeout, pEvCode);
5085 if (This->state != State_Running)
5086 return VFW_E_WRONG_STATE;
5088 if (WaitForSingleObject(This->hEventCompletion, msTimeout) == WAIT_OBJECT_0)
5090 *pEvCode = This->CompletionStatus;
5098 static HRESULT WINAPI MediaEvent_CancelDefaultHandling(IMediaEventEx *iface, LONG lEvCode)
5100 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5102 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
5104 if (lEvCode == EC_COMPLETE)
5105 This->HandleEcComplete = FALSE;
5106 else if (lEvCode == EC_REPAINT)
5107 This->HandleEcRepaint = FALSE;
5108 else if (lEvCode == EC_CLOCK_CHANGED)
5109 This->HandleEcClockChanged = FALSE;
5116 static HRESULT WINAPI MediaEvent_RestoreDefaultHandling(IMediaEventEx *iface, LONG lEvCode)
5118 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5120 TRACE("(%p/%p)->(%d)\n", This, iface, lEvCode);
5122 if (lEvCode == EC_COMPLETE)
5123 This->HandleEcComplete = TRUE;
5124 else if (lEvCode == EC_REPAINT)
5125 This->HandleEcRepaint = TRUE;
5126 else if (lEvCode == EC_CLOCK_CHANGED)
5127 This->HandleEcClockChanged = TRUE;
5134 static HRESULT WINAPI MediaEvent_FreeEventParams(IMediaEventEx *iface, LONG lEvCode,
5135 LONG_PTR lParam1, LONG_PTR lParam2)
5137 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5139 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This, iface, lEvCode, lParam1, lParam2);
5144 /*** IMediaEventEx methods ***/
5145 static HRESULT WINAPI MediaEvent_SetNotifyWindow(IMediaEventEx *iface, OAHWND hwnd, LONG lMsg,
5146 LONG_PTR lInstanceData)
5148 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5150 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This, iface, hwnd, lMsg, lInstanceData);
5152 This->notif.hWnd = (HWND)hwnd;
5153 This->notif.msg = lMsg;
5154 This->notif.instance = lInstanceData;
5159 static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface, LONG lNoNotifyFlags)
5161 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5163 TRACE("(%p/%p)->(%d)\n", This, iface, lNoNotifyFlags);
5165 if ((lNoNotifyFlags != 0) && (lNoNotifyFlags != 1))
5166 return E_INVALIDARG;
5168 This->notif.disabled = lNoNotifyFlags;
5173 static HRESULT WINAPI MediaEvent_GetNotifyFlags(IMediaEventEx *iface, LONG *lplNoNotifyFlags)
5175 IFilterGraphImpl *This = impl_from_IMediaEventEx(iface);
5177 TRACE("(%p/%p)->(%p)\n", This, iface, lplNoNotifyFlags);
5179 if (!lplNoNotifyFlags)
5182 *lplNoNotifyFlags = This->notif.disabled;
5188 static const IMediaEventExVtbl IMediaEventEx_VTable =
5190 MediaEvent_QueryInterface,
5193 MediaEvent_GetTypeInfoCount,
5194 MediaEvent_GetTypeInfo,
5195 MediaEvent_GetIDsOfNames,
5197 MediaEvent_GetEventHandle,
5198 MediaEvent_GetEvent,
5199 MediaEvent_WaitForCompletion,
5200 MediaEvent_CancelDefaultHandling,
5201 MediaEvent_RestoreDefaultHandling,
5202 MediaEvent_FreeEventParams,
5203 MediaEvent_SetNotifyWindow,
5204 MediaEvent_SetNotifyFlags,
5205 MediaEvent_GetNotifyFlags
5209 static inline IFilterGraphImpl *impl_from_IMediaFilter(IMediaFilter *iface)
5211 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaFilter_iface);
5214 static HRESULT WINAPI MediaFilter_QueryInterface(IMediaFilter *iface, REFIID riid, void **ppv)
5216 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5218 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
5221 static ULONG WINAPI MediaFilter_AddRef(IMediaFilter *iface)
5223 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5225 return IUnknown_AddRef(This->outer_unk);
5228 static ULONG WINAPI MediaFilter_Release(IMediaFilter *iface)
5230 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5232 return IUnknown_Release(This->outer_unk);
5235 static HRESULT WINAPI MediaFilter_GetClassID(IMediaFilter *iface, CLSID * pClassID)
5237 FIXME("(%p): stub\n", pClassID);
5242 static HRESULT WINAPI MediaFilter_Stop(IMediaFilter *iface)
5244 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5246 return MediaControl_Stop(&This->IMediaControl_iface);
5249 static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface)
5251 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5253 return MediaControl_Pause(&This->IMediaControl_iface);
5256 static HRESULT WINAPI MediaFilter_Run(IMediaFilter *iface, REFERENCE_TIME tStart)
5258 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5261 FIXME("Run called with non-null tStart: %x%08x\n",
5262 (int)(tStart>>32), (int)tStart);
5264 return MediaControl_Run(&This->IMediaControl_iface);
5267 static HRESULT WINAPI MediaFilter_GetState(IMediaFilter *iface, DWORD dwMsTimeout,
5268 FILTER_STATE *pState)
5270 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5272 return MediaControl_GetState(&This->IMediaControl_iface, dwMsTimeout, (OAFilterState*)pState);
5275 static HRESULT WINAPI MediaFilter_SetSyncSource(IMediaFilter *iface, IReferenceClock *pClock)
5277 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5281 TRACE("(%p/%p)->(%p)\n", iface, This, pClock);
5283 EnterCriticalSection(&This->cs);
5285 for (i = 0;i < This->nFilters;i++)
5287 hr = IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], pClock);
5295 IBaseFilter_SetSyncSource(This->ppFiltersInGraph[i], This->refClock);
5300 IReferenceClock_Release(This->refClock);
5301 This->refClock = pClock;
5303 IReferenceClock_AddRef(This->refClock);
5304 This->defaultclock = FALSE;
5306 if (This->HandleEcClockChanged)
5308 IMediaEventSink *pEventSink;
5311 eshr = IMediaFilter_QueryInterface(iface, &IID_IMediaEventSink, (LPVOID)&pEventSink);
5312 if (SUCCEEDED(eshr))
5314 IMediaEventSink_Notify(pEventSink, EC_CLOCK_CHANGED, 0, 0);
5315 IMediaEventSink_Release(pEventSink);
5320 LeaveCriticalSection(&This->cs);
5325 static HRESULT WINAPI MediaFilter_GetSyncSource(IMediaFilter *iface, IReferenceClock **ppClock)
5327 IFilterGraphImpl *This = impl_from_IMediaFilter(iface);
5329 TRACE("(%p/%p)->(%p)\n", iface, This, ppClock);
5334 EnterCriticalSection(&This->cs);
5336 *ppClock = This->refClock;
5338 IReferenceClock_AddRef(*ppClock);
5340 LeaveCriticalSection(&This->cs);
5345 static const IMediaFilterVtbl IMediaFilter_VTable =
5347 MediaFilter_QueryInterface,
5349 MediaFilter_Release,
5350 MediaFilter_GetClassID,
5354 MediaFilter_GetState,
5355 MediaFilter_SetSyncSource,
5356 MediaFilter_GetSyncSource
5359 static inline IFilterGraphImpl *impl_from_IMediaEventSink(IMediaEventSink *iface)
5361 return CONTAINING_RECORD(iface, IFilterGraphImpl, IMediaEventSink_iface);
5364 static HRESULT WINAPI MediaEventSink_QueryInterface(IMediaEventSink *iface, REFIID riid, void **ppv)
5366 IFilterGraphImpl *This = impl_from_IMediaEventSink(iface);
5368 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
5371 static ULONG WINAPI MediaEventSink_AddRef(IMediaEventSink *iface)
5373 IFilterGraphImpl *This = impl_from_IMediaEventSink(iface);
5375 return IUnknown_AddRef(This->outer_unk);
5378 static ULONG WINAPI MediaEventSink_Release(IMediaEventSink *iface)
5380 IFilterGraphImpl *This = impl_from_IMediaEventSink(iface);
5382 return IUnknown_Release(This->outer_unk);
5385 static HRESULT WINAPI MediaEventSink_Notify(IMediaEventSink *iface, LONG EventCode,
5386 LONG_PTR EventParam1, LONG_PTR EventParam2)
5388 IFilterGraphImpl *This = impl_from_IMediaEventSink(iface);
5391 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This, iface, EventCode, EventParam1, EventParam2);
5393 /* We need thread safety here, let's use the events queue's one */
5394 EnterCriticalSection(&This->evqueue.msg_crst);
5396 if ((EventCode == EC_COMPLETE) && This->HandleEcComplete)
5398 TRACE("Process EC_COMPLETE notification\n");
5399 if (++This->EcCompleteCount == This->nRenderers)
5401 evt.lEventCode = EC_COMPLETE;
5404 TRACE("Send EC_COMPLETE to app\n");
5405 EventsQueue_PutEvent(&This->evqueue, &evt);
5406 if (!This->notif.disabled && This->notif.hWnd)
5408 TRACE("Send Window message\n");
5409 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5411 This->CompletionStatus = EC_COMPLETE;
5412 SetEvent(This->hEventCompletion);
5415 else if ((EventCode == EC_REPAINT) && This->HandleEcRepaint)
5417 /* FIXME: Not handled yet */
5421 evt.lEventCode = EventCode;
5422 evt.lParam1 = EventParam1;
5423 evt.lParam2 = EventParam2;
5424 EventsQueue_PutEvent(&This->evqueue, &evt);
5425 if (!This->notif.disabled && This->notif.hWnd)
5426 PostMessageW(This->notif.hWnd, This->notif.msg, 0, This->notif.instance);
5429 LeaveCriticalSection(&This->evqueue.msg_crst);
5433 static const IMediaEventSinkVtbl IMediaEventSink_VTable =
5435 MediaEventSink_QueryInterface,
5436 MediaEventSink_AddRef,
5437 MediaEventSink_Release,
5438 MediaEventSink_Notify
5441 static inline IFilterGraphImpl *impl_from_IGraphConfig(IGraphConfig *iface)
5443 return CONTAINING_RECORD(iface, IFilterGraphImpl, IGraphConfig_iface);
5446 static HRESULT WINAPI GraphConfig_QueryInterface(IGraphConfig *iface, REFIID riid, void **ppv)
5448 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5450 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
5453 static ULONG WINAPI GraphConfig_AddRef(IGraphConfig *iface)
5455 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5457 return IUnknown_AddRef(This->outer_unk);
5460 static ULONG WINAPI GraphConfig_Release(IGraphConfig *iface)
5462 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5464 return IUnknown_Release(This->outer_unk);
5467 static HRESULT WINAPI GraphConfig_Reconnect(IGraphConfig *iface, IPin *pOutputPin, IPin *pInputPin,
5468 const AM_MEDIA_TYPE *pmtFirstConnection, IBaseFilter *pUsingFilter, HANDLE hAbortEvent,
5471 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5473 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This, pOutputPin, pInputPin, pmtFirstConnection, pUsingFilter, hAbortEvent, dwFlags);
5478 static HRESULT WINAPI GraphConfig_Reconfigure(IGraphConfig *iface, IGraphConfigCallback *pCallback,
5479 void *pvContext, DWORD dwFlags, HANDLE hAbortEvent)
5481 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5484 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This, pCallback, pvContext, dwFlags, hAbortEvent);
5487 FIXME("The parameter hAbortEvent is not handled!\n");
5489 EnterCriticalSection(&This->cs);
5491 hr = IGraphConfigCallback_Reconfigure(pCallback, pvContext, dwFlags);
5493 LeaveCriticalSection(&This->cs);
5498 static HRESULT WINAPI GraphConfig_AddFilterToCache(IGraphConfig *iface, IBaseFilter *pFilter)
5500 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5502 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5507 static HRESULT WINAPI GraphConfig_EnumCacheFilter(IGraphConfig *iface, IEnumFilters **pEnum)
5509 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5511 FIXME("(%p)->(%p): stub!\n", This, pEnum);
5516 static HRESULT WINAPI GraphConfig_RemoveFilterFromCache(IGraphConfig *iface, IBaseFilter *pFilter)
5518 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5520 FIXME("(%p)->(%p): stub!\n", This, pFilter);
5525 static HRESULT WINAPI GraphConfig_GetStartTime(IGraphConfig *iface, REFERENCE_TIME *prtStart)
5527 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5529 FIXME("(%p)->(%p): stub!\n", This, prtStart);
5534 static HRESULT WINAPI GraphConfig_PushThroughData(IGraphConfig *iface, IPin *pOutputPin,
5535 IPinConnection *pConnection, HANDLE hEventAbort)
5537 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5539 FIXME("(%p)->(%p, %p, %p): stub!\n", This, pOutputPin, pConnection, hEventAbort);
5544 static HRESULT WINAPI GraphConfig_SetFilterFlags(IGraphConfig *iface, IBaseFilter *pFilter,
5547 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5549 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5554 static HRESULT WINAPI GraphConfig_GetFilterFlags(IGraphConfig *iface, IBaseFilter *pFilter,
5557 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5559 FIXME("(%p)->(%p, %p): stub!\n", This, pFilter, dwFlags);
5564 static HRESULT WINAPI GraphConfig_RemoveFilterEx(IGraphConfig *iface, IBaseFilter *pFilter,
5567 IFilterGraphImpl *This = impl_from_IGraphConfig(iface);
5569 FIXME("(%p)->(%p, %x): stub!\n", This, pFilter, dwFlags);
5574 static const IGraphConfigVtbl IGraphConfig_VTable =
5576 GraphConfig_QueryInterface,
5578 GraphConfig_Release,
5579 GraphConfig_Reconnect,
5580 GraphConfig_Reconfigure,
5581 GraphConfig_AddFilterToCache,
5582 GraphConfig_EnumCacheFilter,
5583 GraphConfig_RemoveFilterFromCache,
5584 GraphConfig_GetStartTime,
5585 GraphConfig_PushThroughData,
5586 GraphConfig_SetFilterFlags,
5587 GraphConfig_GetFilterFlags,
5588 GraphConfig_RemoveFilterEx
5591 static inline IFilterGraphImpl *impl_from_IGraphVersion(IGraphVersion *iface)
5593 return CONTAINING_RECORD(iface, IFilterGraphImpl, IGraphVersion_iface);
5596 static HRESULT WINAPI GraphVersion_QueryInterface(IGraphVersion *iface, REFIID riid, void **ppv)
5598 IFilterGraphImpl *This = impl_from_IGraphVersion(iface);
5600 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
5603 static ULONG WINAPI GraphVersion_AddRef(IGraphVersion *iface)
5605 IFilterGraphImpl *This = impl_from_IGraphVersion(iface);
5607 return IUnknown_AddRef(This->outer_unk);
5610 static ULONG WINAPI GraphVersion_Release(IGraphVersion *iface)
5612 IFilterGraphImpl *This = impl_from_IGraphVersion(iface);
5614 return IUnknown_Release(This->outer_unk);
5617 static HRESULT WINAPI GraphVersion_QueryVersion(IGraphVersion *iface, LONG *pVersion)
5619 IFilterGraphImpl *This = impl_from_IGraphVersion(iface);
5624 TRACE("(%p)->(%p): current version %i\n", This, pVersion, This->version);
5626 *pVersion = This->version;
5630 static const IGraphVersionVtbl IGraphVersion_VTable =
5632 GraphVersion_QueryInterface,
5633 GraphVersion_AddRef,
5634 GraphVersion_Release,
5635 GraphVersion_QueryVersion,
5638 static const IUnknownVtbl IInner_VTable =
5640 FilterGraphInner_QueryInterface,
5641 FilterGraphInner_AddRef,
5642 FilterGraphInner_Release
5645 /* This is the only function that actually creates a FilterGraph class... */
5646 HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5648 IFilterGraphImpl *fimpl;
5651 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
5655 fimpl = CoTaskMemAlloc(sizeof(*fimpl));
5656 fimpl->defaultclock = TRUE;
5657 fimpl->IUnknown_inner.lpVtbl = &IInner_VTable;
5658 fimpl->IFilterGraph2_iface.lpVtbl = &IFilterGraph2_VTable;
5659 fimpl->IMediaControl_iface.lpVtbl = &IMediaControl_VTable;
5660 fimpl->IMediaSeeking_iface.lpVtbl = &IMediaSeeking_VTable;
5661 fimpl->IBasicAudio_iface.lpVtbl = &IBasicAudio_VTable;
5662 fimpl->IBasicVideo2_iface.lpVtbl = &IBasicVideo_VTable;
5663 fimpl->IVideoWindow_iface.lpVtbl = &IVideoWindow_VTable;
5664 fimpl->IMediaEventEx_iface.lpVtbl = &IMediaEventEx_VTable;
5665 fimpl->IMediaFilter_iface.lpVtbl = &IMediaFilter_VTable;
5666 fimpl->IMediaEventSink_iface.lpVtbl = &IMediaEventSink_VTable;
5667 fimpl->IGraphConfig_iface.lpVtbl = &IGraphConfig_VTable;
5668 fimpl->IMediaPosition_iface.lpVtbl = &IMediaPosition_VTable;
5669 fimpl->IObjectWithSite_iface.lpVtbl = &IObjectWithSite_VTable;
5670 fimpl->IGraphVersion_iface.lpVtbl = &IGraphVersion_VTable;
5672 fimpl->ppFiltersInGraph = NULL;
5673 fimpl->pFilterNames = NULL;
5674 fimpl->nFilters = 0;
5675 fimpl->filterCapacity = 0;
5676 fimpl->nameIndex = 1;
5677 fimpl->refClock = NULL;
5678 fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0);
5679 fimpl->HandleEcComplete = TRUE;
5680 fimpl->HandleEcRepaint = TRUE;
5681 fimpl->HandleEcClockChanged = TRUE;
5682 fimpl->notif.hWnd = 0;
5683 fimpl->notif.disabled = FALSE;
5684 fimpl->nRenderers = 0;
5685 fimpl->EcCompleteCount = 0;
5686 fimpl->refClockProvider = NULL;
5687 fimpl->state = State_Stopped;
5688 fimpl->pSite = NULL;
5689 EventsQueue_Init(&fimpl->evqueue);
5690 InitializeCriticalSection(&fimpl->cs);
5691 fimpl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IFilterGraphImpl.cs");
5692 fimpl->nItfCacheEntries = 0;
5693 memcpy(&fimpl->timeformatseek, &TIME_FORMAT_MEDIA_TIME, sizeof(GUID));
5694 fimpl->start_time = fimpl->pause_time = 0;
5695 fimpl->stop_position = -1;
5696 fimpl->punkFilterMapper2 = NULL;
5697 fimpl->recursioncount = 0;
5701 fimpl->outer_unk = pUnkOuter;
5703 fimpl->outer_unk = &fimpl->IUnknown_inner;
5705 /* create Filtermapper aggregated. */
5706 hr = CoCreateInstance(&CLSID_FilterMapper2, fimpl->outer_unk, CLSCTX_INPROC_SERVER,
5707 &IID_IUnknown, (void**)&fimpl->punkFilterMapper2);
5710 hr = IUnknown_QueryInterface(fimpl->punkFilterMapper2, &IID_IFilterMapper2,
5711 (void**)&fimpl->pFilterMapper2);
5714 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5715 IUnknown_Release(fimpl->outer_unk);
5718 ERR("Unable to create filter mapper (%x)\n", hr);
5719 if (fimpl->punkFilterMapper2) IUnknown_Release(fimpl->punkFilterMapper2);
5720 CloseHandle(fimpl->hEventCompletion);
5721 EventsQueue_Destroy(&fimpl->evqueue);
5722 fimpl->cs.DebugInfo->Spare[0] = 0;
5723 DeleteCriticalSection(&fimpl->cs);
5724 CoTaskMemFree(fimpl);
5728 *ppObj = &fimpl->IUnknown_inner;
5732 HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
5734 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5735 return FilterGraph_create(pUnkOuter, ppObj);