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 BOOL
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 BOOL
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 BOOL 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
->IFilterGraph2_iface
, 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
= TRUE
;
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
, VARIANT
* pvar
)
813 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
814 IPropertyBag
* pPropBagCat
= NULL
;
819 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
822 hr
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, pvar
, NULL
);
825 TRACE("Moniker = %s\n", debugstr_w(V_BSTR(pvar
)));
828 IPropertyBag_Release(pPropBagCat
);
833 static HRESULT
GetInternalConnections(IBaseFilter
* pfilter
, IPin
* pinputpin
, IPin
*** pppins
, ULONG
* pnb
)
838 TRACE("(%p, %p, %p, %p)\n", pfilter
, pinputpin
, pppins
, pnb
);
839 hr
= IPin_QueryInternalConnections(pinputpin
, NULL
, &nb
);
842 } else if (hr
== S_FALSE
) {
843 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*nb
);
844 hr
= IPin_QueryInternalConnections(pinputpin
, *pppins
, &nb
);
846 WARN("Error (%x)\n", hr
);
848 } else if (hr
== E_NOTIMPL
) {
849 /* Input connected to all outputs */
850 IEnumPins
* penumpins
;
853 TRACE("E_NOTIMPL\n");
854 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
856 WARN("filter Enumpins failed (%x)\n", hr
);
860 /* Count output pins */
861 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
862 PIN_DIRECTION pindir
;
863 IPin_QueryDirection(ppin
, &pindir
);
864 if (pindir
== PINDIR_OUTPUT
)
868 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*i
);
869 /* Retrieve output pins */
870 IEnumPins_Reset(penumpins
);
872 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
873 PIN_DIRECTION pindir
;
874 IPin_QueryDirection(ppin
, &pindir
);
875 if (pindir
== PINDIR_OUTPUT
)
876 (*pppins
)[i
++] = ppin
;
880 IEnumPins_Release(penumpins
);
883 WARN("Next failed (%x)\n", hr
);
886 } else if (FAILED(hr
)) {
887 WARN("Cannot get internal connection (%x)\n", hr
);
895 /*** IGraphBuilder methods ***/
896 static HRESULT WINAPI
FilterGraph2_Connect(IFilterGraph2
*iface
, IPin
*ppinOut
, IPin
*ppinIn
)
898 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
900 AM_MEDIA_TYPE
* mt
= NULL
;
901 IEnumMediaTypes
* penummt
= NULL
;
903 IEnumPins
* penumpins
;
904 IEnumMoniker
* pEnumMoniker
;
914 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, ppinOut
, ppinIn
);
916 if (TRACE_ON(quartz
))
918 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
922 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
923 IBaseFilter_Release(PinInfo
.pFilter
);
925 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
929 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
930 IBaseFilter_Release(PinInfo
.pFilter
);
933 EnterCriticalSection(&This
->cs
);
934 ++This
->recursioncount
;
935 if (This
->recursioncount
>= 5)
937 WARN("Recursion count has reached %d\n", This
->recursioncount
);
938 hr
= VFW_E_CANNOT_CONNECT
;
942 hr
= IPin_QueryDirection(ppinOut
, &dir
);
946 if (dir
== PINDIR_INPUT
)
955 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
959 /* Try direct connection first */
960 hr
= IPin_Connect(ppinOut
, ppinIn
, NULL
);
964 TRACE("Direct connection failed, trying to render using extra filters\n");
966 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
970 hr
= IBaseFilter_GetClassID(PinInfo
.pFilter
, &FilterCLSID
);
971 IBaseFilter_Release(PinInfo
.pFilter
);
975 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
976 * filter to the minor mediatype of input pin of the renderer */
977 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
980 WARN("EnumMediaTypes (%x)\n", hr
);
984 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
986 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
992 WARN("No media type found!\n");
993 hr
= VFW_E_INVALIDMEDIATYPE
;
996 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
997 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
999 /* Try to find a suitable filter that can connect to the pin to render */
1000 tab
[0] = mt
->majortype
;
1001 tab
[1] = mt
->subtype
;
1002 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1004 WARN("Unable to enum filters (%x)\n", hr
);
1008 hr
= VFW_E_CANNOT_RENDER
;
1009 while(IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1013 IPin
** ppins
= NULL
;
1014 IPin
* ppinfilter
= NULL
;
1015 IBaseFilter
* pfilter
= NULL
;
1016 IAMGraphBuilderCallback
*callback
= NULL
;
1018 hr
= GetFilterInfo(pMoniker
, &var
);
1020 WARN("Unable to retrieve filter info (%x)\n", hr
);
1024 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1025 IMoniker_Release(pMoniker
);
1027 WARN("Unable to create filter (%x), trying next one\n", hr
);
1031 hr
= IBaseFilter_GetClassID(pfilter
, &clsid
);
1034 IBaseFilter_Release(pfilter
);
1038 if (IsEqualGUID(&clsid
, &FilterCLSID
)) {
1039 /* Skip filter (same as the one the output pin belongs to) */
1040 IBaseFilter_Release(pfilter
);
1046 IUnknown_QueryInterface(This
->pSite
, &IID_IAMGraphBuilderCallback
, (LPVOID
*)&callback
);
1050 rc
= IAMGraphBuilderCallback_SelectedFilter(callback
, pMoniker
);
1053 TRACE("Filter rejected by IAMGraphBuilderCallback_SelectedFilter\n");
1054 IAMGraphBuilderCallback_Release(callback
);
1063 rc
= IAMGraphBuilderCallback_CreatedFilter(callback
, pfilter
);
1064 IAMGraphBuilderCallback_Release(callback
);
1067 IBaseFilter_Release(pfilter
);
1069 TRACE("Filter rejected by IAMGraphBuilderCallback_CreatedFilter\n");
1074 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1076 WARN("Unable to add filter (%x)\n", hr
);
1077 IBaseFilter_Release(pfilter
);
1084 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1086 WARN("Enumpins (%x)\n", hr
);
1090 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1091 IEnumPins_Release(penumpins
);
1094 WARN("Obtaining next pin: (%x)\n", hr
);
1098 WARN("Cannot use this filter: no pins\n");
1102 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1104 TRACE("Cannot connect to filter (%x), trying next one\n", hr
);
1107 TRACE("Successfully connected to filter, follow chain...\n");
1109 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1110 hr
= GetInternalConnections(pfilter
, ppinfilter
, &ppins
, &nb
);
1112 if (SUCCEEDED(hr
)) {
1114 IPin_Disconnect(ppinfilter
);
1115 IPin_Disconnect(ppinOut
);
1118 TRACE("pins to consider: %d\n", nb
);
1119 for(i
= 0; i
< nb
; i
++)
1121 LPWSTR pinname
= NULL
;
1123 TRACE("Processing pin %u\n", i
);
1125 hr
= IPin_QueryId(ppins
[i
], &pinname
);
1128 if (pinname
[0] == '~')
1130 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname
));
1134 hr
= IFilterGraph2_Connect(iface
, ppins
[i
], ppinIn
);
1135 CoTaskMemFree(pinname
);
1139 TRACE("Cannot connect pin %p (%x)\n", ppinfilter
, hr
);
1141 IPin_Release(ppins
[i
]);
1142 if (SUCCEEDED(hr
)) break;
1144 while (++i
< nb
) IPin_Release(ppins
[i
]);
1145 CoTaskMemFree(ppins
);
1146 IPin_Release(ppinfilter
);
1147 IBaseFilter_Release(pfilter
);
1150 IPin_Disconnect(ppinfilter
);
1151 IPin_Disconnect(ppinOut
);
1152 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1160 if (ppinfilter
) IPin_Release(ppinfilter
);
1162 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1163 IBaseFilter_Release(pfilter
);
1165 while (++i
< nb
) IPin_Release(ppins
[i
]);
1166 CoTaskMemFree(ppins
);
1171 IEnumMediaTypes_Release(penummt
);
1173 DeleteMediaType(mt
);
1174 --This
->recursioncount
;
1175 LeaveCriticalSection(&This
->cs
);
1176 TRACE("--> %08x\n", hr
);
1177 return SUCCEEDED(hr
) ? S_OK
: hr
;
1180 static HRESULT
FilterGraph2_RenderRecurse(IFilterGraphImpl
*This
, IPin
*ppinOut
)
1182 /* This pin has been connected now, try to call render on all pins that aren't connected */
1185 IEnumPins
*enumpins
= NULL
;
1186 BOOL renderany
= FALSE
;
1187 BOOL renderall
= TRUE
;
1189 IPin_QueryPinInfo(ppinOut
, &info
);
1191 IBaseFilter_EnumPins(info
.pFilter
, &enumpins
);
1192 /* Don't need to hold a reference, IEnumPins does */
1193 IBaseFilter_Release(info
.pFilter
);
1195 IEnumPins_Reset(enumpins
);
1196 while (IEnumPins_Next(enumpins
, 1, &to
, NULL
) == S_OK
)
1198 PIN_DIRECTION dir
= PINDIR_INPUT
;
1200 IPin_QueryDirection(to
, &dir
);
1202 if (dir
== PINDIR_OUTPUT
)
1206 IPin_ConnectedTo(to
, &out
);
1210 hr
= IFilterGraph2_Render(&This
->IFilterGraph2_iface
, to
);
1223 IEnumPins_Release(enumpins
);
1229 return VFW_S_PARTIAL_RENDER
;
1231 return VFW_E_CANNOT_RENDER
;
1234 /* Ogg hates me if I create a direct rendering method
1236 * It can only connect to a pin properly once, so use a recursive method that does
1238 * +----+ --- (PIN 1) (Render is called on this pin)
1240 * +----+ --- (PIN 2)
1242 * Enumerate possible renderers that EXACTLY match the requested type
1244 * If none is available, try to add intermediate filters that can connect to the input pin
1245 * then call Render on that intermediate pin's output pins
1246 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1247 * and another filter that can connect to the input pin is tried
1248 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1249 * It's recursive, but fun!
1252 static HRESULT WINAPI
FilterGraph2_Render(IFilterGraph2
*iface
, IPin
*ppinOut
)
1254 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1255 IEnumMediaTypes
* penummt
;
1260 IEnumMoniker
* pEnumMoniker
;
1266 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppinOut
);
1268 if (TRACE_ON(quartz
))
1272 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
1276 TRACE("Filter owning pin => %p\n", PinInfo
.pFilter
);
1277 IBaseFilter_Release(PinInfo
.pFilter
);
1280 /* Try to find out if there is a renderer for the specified subtype already, and use that
1282 EnterCriticalSection(&This
->cs
);
1283 for (x
= 0; x
< This
->nFilters
; ++x
)
1285 IEnumPins
*enumpins
= NULL
;
1288 hr
= IBaseFilter_EnumPins(This
->ppFiltersInGraph
[x
], &enumpins
);
1290 if (FAILED(hr
) || !enumpins
)
1293 IEnumPins_Reset(enumpins
);
1294 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
1297 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
1299 IPin_QueryDirection(pin
, &dir
);
1300 if (dir
!= PINDIR_INPUT
)
1305 IPin_ConnectedTo(pin
, &to
);
1309 hr
= FilterGraph2_ConnectDirect(iface
, ppinOut
, pin
, NULL
);
1312 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut
, pin
, hr
);
1315 hr
= FilterGraph2_RenderRecurse(This
, pin
);
1318 IPin_Disconnect(ppinOut
);
1319 IPin_Disconnect(pin
);
1322 IEnumPins_Release(enumpins
);
1323 LeaveCriticalSection(&This
->cs
);
1326 WARN("Could not connect!\n");
1333 IEnumPins_Release(enumpins
);
1336 LeaveCriticalSection(&This
->cs
);
1338 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
1340 WARN("EnumMediaTypes (%x)\n", hr
);
1344 IEnumMediaTypes_Reset(penummt
);
1346 /* Looks like no existing renderer of the kind exists
1347 * Try adding new ones
1349 tab
[0] = tab
[1] = GUID_NULL
;
1350 while (SUCCEEDED(hr
))
1352 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1354 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1359 hr
= VFW_E_CANNOT_RENDER
;
1364 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1365 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1367 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1368 if (IsEqualIID(&tab
[0], &mt
->majortype
) && IsEqualIID(&tab
[1], &mt
->subtype
))
1370 DeleteMediaType(mt
);
1374 /* Try to find a suitable renderer with the same media type */
1375 tab
[0] = mt
->majortype
;
1376 tab
[1] = mt
->subtype
;
1377 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1380 WARN("Unable to enum filters (%x)\n", hr
);
1386 while (IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1390 IBaseFilter
* pfilter
= NULL
;
1391 IEnumPins
* penumpins
= NULL
;
1394 hr
= GetFilterInfo(pMoniker
, &var
);
1396 WARN("Unable to retrieve filter info (%x)\n", hr
);
1400 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1401 IMoniker_Release(pMoniker
);
1404 WARN("Unable to create filter (%x), trying next one\n", hr
);
1408 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1410 WARN("Unable to add filter (%x)\n", hr
);
1411 IBaseFilter_Release(pfilter
);
1416 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1418 WARN("Splitter Enumpins (%x)\n", hr
);
1422 while ((hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
)) == S_OK
)
1432 hr
= IPin_QueryDirection(ppinfilter
, &dir
);
1434 IPin_Release(ppinfilter
);
1435 WARN("QueryDirection failed (%x)\n", hr
);
1438 if (dir
!= PINDIR_INPUT
) {
1439 IPin_Release(ppinfilter
);
1440 continue; /* Wrong direction */
1443 /* Connect the pin to the "Renderer" */
1444 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1445 IPin_Release(ppinfilter
);
1448 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_BSTR(&var
)), hr
);
1451 TRACE("Connected, recursing %s\n", debugstr_w(V_BSTR(&var
)));
1455 hr
= FilterGraph2_RenderRecurse(This
, ppinfilter
);
1457 WARN("Unable to connect recursively (%x)\n", hr
);
1460 IBaseFilter_Release(pfilter
);
1463 if (SUCCEEDED(hr
)) {
1464 IEnumPins_Release(penumpins
);
1465 break; /* out of IEnumMoniker_Next loop */
1468 /* IEnumPins_Next failed, all other failure case caught by goto error */
1469 WARN("IEnumPins_Next (%x)\n", hr
);
1475 IEnumPins_Release(penumpins
);
1477 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1478 IBaseFilter_Release(pfilter
);
1480 if (SUCCEEDED(hr
)) DebugBreak();
1483 IEnumMoniker_Release(pEnumMoniker
);
1485 DeleteMediaType(mt
);
1491 IEnumMediaTypes_Release(penummt
);
1495 static HRESULT WINAPI
FilterGraph2_RenderFile(IFilterGraph2
*iface
, LPCWSTR lpcwstrFile
,
1496 LPCWSTR lpcwstrPlayList
)
1498 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1499 static const WCHAR string
[] = {'R','e','a','d','e','r',0};
1500 IBaseFilter
* preader
= NULL
;
1501 IPin
* ppinreader
= NULL
;
1502 IEnumPins
* penumpins
= NULL
;
1504 BOOL partial
= FALSE
;
1507 TRACE("(%p/%p)->(%s, %s)\n", This
, iface
, debugstr_w(lpcwstrFile
), debugstr_w(lpcwstrPlayList
));
1509 if (lpcwstrPlayList
!= NULL
)
1510 return E_INVALIDARG
;
1512 hr
= IFilterGraph2_AddSourceFilter(iface
, lpcwstrFile
, string
, &preader
);
1517 hr
= IBaseFilter_EnumPins(preader
, &penumpins
);
1520 while (IEnumPins_Next(penumpins
, 1, &ppinreader
, NULL
) == S_OK
)
1524 IPin_QueryDirection(ppinreader
, &dir
);
1525 if (dir
== PINDIR_OUTPUT
)
1529 hr
= IFilterGraph2_Render(iface
, ppinreader
);
1530 TRACE("Render %08x\n", hr
);
1532 for (i
= 0; i
< This
->nFilters
; ++i
)
1533 TRACE("Filters in chain: %s\n", debugstr_w(This
->pFilterNames
[i
]));
1540 IPin_Release(ppinreader
);
1542 IEnumPins_Release(penumpins
);
1545 hr
= VFW_E_CANNOT_RENDER
;
1547 hr
= VFW_S_PARTIAL_RENDER
;
1551 IBaseFilter_Release(preader
);
1553 TRACE("--> %08x\n", hr
);
1557 static HRESULT
CreateFilterInstanceAndLoadFile(GUID
* clsid
, LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1559 IFileSourceFilter
*source
= NULL
;
1560 HRESULT hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1561 TRACE("CLSID: %s\n", debugstr_guid(clsid
));
1565 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&source
);
1568 IBaseFilter_Release(*filter
);
1572 /* Load the file in the file source filter */
1573 hr
= IFileSourceFilter_Load(source
, pszFileName
, NULL
);
1574 IFileSourceFilter_Release(source
);
1576 WARN("Load (%x)\n", hr
);
1577 IBaseFilter_Release(*filter
);
1584 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1585 static HRESULT
GetFileSourceFilter(LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1589 IAsyncReader
* pReader
= NULL
;
1590 IFileSourceFilter
* pSource
= NULL
;
1591 IPin
* pOutputPin
= NULL
;
1592 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
1594 /* Try to find a match without reading the file first */
1595 hr
= GetClassMediaFile(NULL
, pszFileName
, NULL
, NULL
, &clsid
);
1598 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1600 /* Now create a AyncReader instance, to check for signature bytes in the file */
1601 hr
= CoCreateInstance(&CLSID_AsyncReader
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1605 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&pSource
);
1608 IBaseFilter_Release(*filter
);
1612 hr
= IFileSourceFilter_Load(pSource
, pszFileName
, NULL
);
1613 IFileSourceFilter_Release(pSource
);
1616 IBaseFilter_Release(*filter
);
1620 hr
= IBaseFilter_FindPin(*filter
, wszOutputPinName
, &pOutputPin
);
1623 IBaseFilter_Release(*filter
);
1627 hr
= IPin_QueryInterface(pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
1628 IPin_Release(pOutputPin
);
1631 IBaseFilter_Release(*filter
);
1635 /* Try again find a match */
1636 hr
= GetClassMediaFile(pReader
, pszFileName
, NULL
, NULL
, &clsid
);
1637 IAsyncReader_Release(pReader
);
1641 /* Release the AsyncReader filter and create the matching one */
1642 IBaseFilter_Release(*filter
);
1643 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1646 /* Return the AsyncReader filter */
1650 static HRESULT WINAPI
FilterGraph2_AddSourceFilter(IFilterGraph2
*iface
, LPCWSTR lpcwstrFileName
,
1651 LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1653 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1655 IBaseFilter
* preader
;
1656 IFileSourceFilter
* pfile
= NULL
;
1660 TRACE("(%p/%p)->(%s, %s, %p)\n", This
, iface
, debugstr_w(lpcwstrFileName
), debugstr_w(lpcwstrFilterName
), ppFilter
);
1662 /* Try from file name first, then fall back to default asynchronous reader */
1663 hr
= GetFileSourceFilter(lpcwstrFileName
, &preader
);
1665 WARN("Unable to create file source filter (%x)\n", hr
);
1669 hr
= IFilterGraph2_AddFilter(iface
, preader
, lpcwstrFilterName
);
1671 WARN("Unable add filter (%x)\n", hr
);
1672 IBaseFilter_Release(preader
);
1676 hr
= IBaseFilter_QueryInterface(preader
, &IID_IFileSourceFilter
, (LPVOID
*)&pfile
);
1678 WARN("Unable to get IFileSourceInterface (%x)\n", hr
);
1682 /* The file has been already loaded */
1683 hr
= IFileSourceFilter_GetCurFile(pfile
, &filename
, &mt
);
1685 WARN("GetCurFile (%x)\n", hr
);
1689 TRACE("File %s\n", debugstr_w(filename
));
1690 TRACE("MajorType %s\n", debugstr_guid(&mt
.majortype
));
1691 TRACE("SubType %s\n", debugstr_guid(&mt
.subtype
));
1694 *ppFilter
= preader
;
1695 IFileSourceFilter_Release(pfile
);
1701 IFileSourceFilter_Release(pfile
);
1702 IFilterGraph2_RemoveFilter(iface
, preader
);
1703 IBaseFilter_Release(preader
);
1708 static HRESULT WINAPI
FilterGraph2_SetLogFile(IFilterGraph2
*iface
, DWORD_PTR hFile
)
1710 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1712 TRACE("(%p/%p)->(%08x): stub !!!\n", This
, iface
, (DWORD
) hFile
);
1717 static HRESULT WINAPI
FilterGraph2_Abort(IFilterGraph2
*iface
)
1719 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1721 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1726 static HRESULT WINAPI
FilterGraph2_ShouldOperationContinue(IFilterGraph2
*iface
)
1728 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1730 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1735 /*** IFilterGraph2 methods ***/
1736 static HRESULT WINAPI
FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2
*iface
,
1737 IMoniker
*pMoniker
, IBindCtx
*pCtx
, LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1739 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1741 IBaseFilter
* pfilter
;
1743 TRACE("(%p/%p)->(%p %p %s %p)\n", This
, iface
, pMoniker
, pCtx
, debugstr_w(lpcwstrFilterName
), ppFilter
);
1745 hr
= IMoniker_BindToObject(pMoniker
, pCtx
, NULL
, &IID_IBaseFilter
, (void**)&pfilter
);
1747 WARN("Unable to bind moniker to filter object (%x)\n", hr
);
1751 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, lpcwstrFilterName
);
1753 WARN("Unable to add filter (%x)\n", hr
);
1754 IBaseFilter_Release(pfilter
);
1759 *ppFilter
= pfilter
;
1760 else IBaseFilter_Release(pfilter
);
1765 static HRESULT WINAPI
FilterGraph2_ReconnectEx(IFilterGraph2
*iface
, IPin
*ppin
,
1766 const AM_MEDIA_TYPE
*pmt
)
1768 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1770 TRACE("(%p/%p)->(%p %p): stub !!!\n", This
, iface
, ppin
, pmt
);
1775 static HRESULT WINAPI
FilterGraph2_RenderEx(IFilterGraph2
*iface
, IPin
*pPinOut
, DWORD dwFlags
,
1778 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1780 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This
, iface
, pPinOut
, dwFlags
, pvContext
);
1786 static const IFilterGraph2Vtbl IFilterGraph2_VTable
=
1788 FilterGraph2_QueryInterface
,
1789 FilterGraph2_AddRef
,
1790 FilterGraph2_Release
,
1791 FilterGraph2_AddFilter
,
1792 FilterGraph2_RemoveFilter
,
1793 FilterGraph2_EnumFilters
,
1794 FilterGraph2_FindFilterByName
,
1795 FilterGraph2_ConnectDirect
,
1796 FilterGraph2_Reconnect
,
1797 FilterGraph2_Disconnect
,
1798 FilterGraph2_SetDefaultSyncSource
,
1799 FilterGraph2_Connect
,
1800 FilterGraph2_Render
,
1801 FilterGraph2_RenderFile
,
1802 FilterGraph2_AddSourceFilter
,
1803 FilterGraph2_SetLogFile
,
1805 FilterGraph2_ShouldOperationContinue
,
1806 FilterGraph2_AddSourceFilterForMoniker
,
1807 FilterGraph2_ReconnectEx
,
1808 FilterGraph2_RenderEx
1811 static inline IFilterGraphImpl
*impl_from_IMediaControl(IMediaControl
*iface
)
1813 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaControl_iface
);
1816 static HRESULT WINAPI
MediaControl_QueryInterface(IMediaControl
*iface
, REFIID riid
, void **ppvObj
)
1818 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1820 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1822 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
1825 static ULONG WINAPI
MediaControl_AddRef(IMediaControl
*iface
)
1827 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1829 TRACE("(%p/%p)->()\n", This
, iface
);
1831 return IUnknown_AddRef(This
->outer_unk
);
1834 static ULONG WINAPI
MediaControl_Release(IMediaControl
*iface
)
1836 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1838 TRACE("(%p/%p)->()\n", This
, iface
);
1840 return IUnknown_Release(This
->outer_unk
);
1844 /*** IDispatch methods ***/
1845 static HRESULT WINAPI
MediaControl_GetTypeInfoCount(IMediaControl
*iface
, UINT
*pctinfo
)
1847 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1849 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
1854 static HRESULT WINAPI
MediaControl_GetTypeInfo(IMediaControl
*iface
, UINT iTInfo
, LCID lcid
,
1855 ITypeInfo
**ppTInfo
)
1857 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1859 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
1864 static HRESULT WINAPI
MediaControl_GetIDsOfNames(IMediaControl
*iface
, REFIID riid
,
1865 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1867 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1869 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1874 static HRESULT WINAPI
MediaControl_Invoke(IMediaControl
*iface
, DISPID dispIdMember
, REFIID riid
,
1875 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
1878 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1880 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
);
1885 typedef HRESULT(WINAPI
*fnFoundFilter
)(IBaseFilter
*, DWORD_PTR data
);
1887 static HRESULT
ExploreGraph(IFilterGraphImpl
* pGraph
, IPin
* pOutputPin
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1896 TRACE("%p %p\n", pGraph
, pOutputPin
);
1897 PinInfo
.pFilter
= NULL
;
1899 hr
= IPin_ConnectedTo(pOutputPin
, &pInputPin
);
1903 hr
= IPin_QueryPinInfo(pInputPin
, &PinInfo
);
1905 hr
= GetInternalConnections(PinInfo
.pFilter
, pInputPin
, &ppPins
, &nb
);
1906 IPin_Release(pInputPin
);
1913 TRACE("Reached a renderer\n");
1914 /* Count renderers for end of stream notification */
1915 pGraph
->nRenderers
++;
1919 for(i
= 0; i
< nb
; i
++)
1921 /* Explore the graph downstream from this pin
1922 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1923 * several input pins are connected to the same output (a MUX for instance). */
1924 ExploreGraph(pGraph
, ppPins
[i
], FoundFilter
, data
);
1925 IPin_Release(ppPins
[i
]);
1928 CoTaskMemFree(ppPins
);
1930 TRACE("Doing stuff with filter %p\n", PinInfo
.pFilter
);
1932 FoundFilter(PinInfo
.pFilter
, data
);
1935 if (PinInfo
.pFilter
) IBaseFilter_Release(PinInfo
.pFilter
);
1939 static HRESULT WINAPI
SendRun(IBaseFilter
*pFilter
, DWORD_PTR data
)
1941 REFERENCE_TIME time
= *(REFERENCE_TIME
*)data
;
1942 return IBaseFilter_Run(pFilter
, time
);
1945 static HRESULT WINAPI
SendPause(IBaseFilter
*pFilter
, DWORD_PTR data
)
1947 return IBaseFilter_Pause(pFilter
);
1950 static HRESULT WINAPI
SendStop(IBaseFilter
*pFilter
, DWORD_PTR data
)
1952 return IBaseFilter_Stop(pFilter
);
1955 static HRESULT WINAPI
SendGetState(IBaseFilter
*pFilter
, DWORD_PTR data
)
1958 DWORD time_end
= data
;
1959 DWORD time_now
= GetTickCount();
1962 if (time_end
== INFINITE
)
1966 else if (time_end
> time_now
)
1968 wait
= time_end
- time_now
;
1973 return IBaseFilter_GetState(pFilter
, wait
, &state
);
1977 static HRESULT
SendFilterMessage(IFilterGraphImpl
*This
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1980 IBaseFilter
* pfilter
;
1987 TRACE("(%p)->()\n", This
);
1989 /* Explorer the graph from source filters to renderers, determine renderers
1990 * number and run filters from renderers to source filters */
1991 This
->nRenderers
= 0;
1992 ResetEvent(This
->hEventCompletion
);
1994 for(i
= 0; i
< This
->nFilters
; i
++)
1997 pfilter
= This
->ppFiltersInGraph
[i
];
1998 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
2001 WARN("Enum pins failed %x\n", hr
);
2004 /* Check if it is a source filter */
2005 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
2007 IPin_QueryDirection(pPin
, &dir
);
2009 if (dir
== PINDIR_INPUT
)
2017 TRACE("Found a source filter %p\n", pfilter
);
2018 IEnumPins_Reset(pEnum
);
2019 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
2021 /* Explore the graph downstream from this pin */
2022 ExploreGraph(This
, pPin
, FoundFilter
, data
);
2025 FoundFilter(pfilter
, data
);
2027 IEnumPins_Release(pEnum
);
2033 /*** IMediaControl methods ***/
2034 static HRESULT WINAPI
MediaControl_Run(IMediaControl
*iface
)
2036 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2038 TRACE("(%p/%p)->()\n", This
, iface
);
2040 EnterCriticalSection(&This
->cs
);
2041 if (This
->state
== State_Running
)
2043 This
->EcCompleteCount
= 0;
2045 if (This
->defaultclock
&& !This
->refClock
)
2046 IFilterGraph2_SetDefaultSyncSource(&This
->IFilterGraph2_iface
);
2051 IReferenceClock_GetTime(This
->refClock
, &now
);
2052 if (This
->state
== State_Stopped
)
2053 This
->start_time
= now
+ 500000;
2054 else if (This
->pause_time
>= 0)
2055 This
->start_time
+= now
- This
->pause_time
;
2057 This
->start_time
= now
;
2059 else This
->start_time
= 0;
2061 SendFilterMessage(This
, SendRun
, (DWORD_PTR
)&This
->start_time
);
2062 This
->state
= State_Running
;
2064 LeaveCriticalSection(&This
->cs
);
2068 static HRESULT WINAPI
MediaControl_Pause(IMediaControl
*iface
)
2070 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2072 TRACE("(%p/%p)->()\n", This
, iface
);
2074 EnterCriticalSection(&This
->cs
);
2075 if (This
->state
== State_Paused
)
2078 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2079 IReferenceClock_GetTime(This
->refClock
, &This
->pause_time
);
2081 This
->pause_time
= -1;
2083 SendFilterMessage(This
, SendPause
, 0);
2084 This
->state
= State_Paused
;
2086 LeaveCriticalSection(&This
->cs
);
2090 static HRESULT WINAPI
MediaControl_Stop(IMediaControl
*iface
)
2092 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2094 TRACE("(%p/%p)->()\n", This
, iface
);
2096 if (This
->state
== State_Stopped
) return S_OK
;
2098 EnterCriticalSection(&This
->cs
);
2099 if (This
->state
== State_Running
) SendFilterMessage(This
, SendPause
, 0);
2100 SendFilterMessage(This
, SendStop
, 0);
2101 This
->state
= State_Stopped
;
2102 LeaveCriticalSection(&This
->cs
);
2106 static HRESULT WINAPI
MediaControl_GetState(IMediaControl
*iface
, LONG msTimeout
,
2109 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2112 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pfs
);
2117 EnterCriticalSection(&This
->cs
);
2122 end
= GetTickCount() + msTimeout
;
2124 else if (msTimeout
< 0)
2133 SendFilterMessage(This
, SendGetState
, end
);
2135 LeaveCriticalSection(&This
->cs
);
2140 static HRESULT WINAPI
MediaControl_RenderFile(IMediaControl
*iface
, BSTR strFilename
)
2142 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2144 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strFilename
), strFilename
);
2146 return IFilterGraph2_RenderFile(&This
->IFilterGraph2_iface
, strFilename
, NULL
);
2149 static HRESULT WINAPI
MediaControl_AddSourceFilter(IMediaControl
*iface
, BSTR strFilename
,
2152 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2154 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
, ppUnk
);
2159 static HRESULT WINAPI
MediaControl_get_FilterCollection(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_get_RegFilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2170 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2172 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2177 static HRESULT WINAPI
MediaControl_StopWhenReady(IMediaControl
*iface
)
2179 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2181 FIXME("(%p/%p)->(): stub !!!\n", This
, iface
);
2187 static const IMediaControlVtbl IMediaControl_VTable
=
2189 MediaControl_QueryInterface
,
2190 MediaControl_AddRef
,
2191 MediaControl_Release
,
2192 MediaControl_GetTypeInfoCount
,
2193 MediaControl_GetTypeInfo
,
2194 MediaControl_GetIDsOfNames
,
2195 MediaControl_Invoke
,
2199 MediaControl_GetState
,
2200 MediaControl_RenderFile
,
2201 MediaControl_AddSourceFilter
,
2202 MediaControl_get_FilterCollection
,
2203 MediaControl_get_RegFilterCollection
,
2204 MediaControl_StopWhenReady
2207 static inline IFilterGraphImpl
*impl_from_IMediaSeeking(IMediaSeeking
*iface
)
2209 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaSeeking_iface
);
2212 static HRESULT WINAPI
MediaSeeking_QueryInterface(IMediaSeeking
*iface
, REFIID riid
, void **ppvObj
)
2214 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2216 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2218 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2221 static ULONG WINAPI
MediaSeeking_AddRef(IMediaSeeking
*iface
)
2223 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2225 TRACE("(%p/%p)->()\n", This
, iface
);
2227 return IUnknown_AddRef(This
->outer_unk
);
2230 static ULONG WINAPI
MediaSeeking_Release(IMediaSeeking
*iface
)
2232 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2234 TRACE("(%p/%p)->()\n", This
, iface
);
2236 return IUnknown_Release(This
->outer_unk
);
2239 typedef HRESULT (WINAPI
*fnFoundSeek
)(IFilterGraphImpl
*This
, IMediaSeeking
*, DWORD_PTR arg
);
2241 static HRESULT
all_renderers_seek(IFilterGraphImpl
*This
, fnFoundSeek FoundSeek
, DWORD_PTR arg
) {
2242 BOOL allnotimpl
= TRUE
;
2244 HRESULT hr
, hr_return
= S_OK
;
2246 TRACE("(%p)->(%p %08lx)\n", This
, FoundSeek
, arg
);
2247 /* Send a message to all renderers, they are responsible for broadcasting it further */
2249 for(i
= 0; i
< This
->nFilters
; i
++)
2251 IMediaSeeking
*seek
= NULL
;
2252 IBaseFilter
* pfilter
= This
->ppFiltersInGraph
[i
];
2253 IAMFilterMiscFlags
*flags
= NULL
;
2255 IBaseFilter_QueryInterface(pfilter
, &IID_IAMFilterMiscFlags
, (void**)&flags
);
2258 filterflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
2259 IAMFilterMiscFlags_Release(flags
);
2260 if (filterflags
!= AM_FILTER_MISC_FLAGS_IS_RENDERER
)
2263 IBaseFilter_QueryInterface(pfilter
, &IID_IMediaSeeking
, (void**)&seek
);
2266 hr
= FoundSeek(This
, seek
, arg
);
2267 IMediaSeeking_Release(seek
);
2268 if (hr_return
!= E_NOTIMPL
)
2270 if (hr_return
== S_OK
|| (FAILED(hr
) && hr
!= E_NOTIMPL
&& SUCCEEDED(hr_return
)))
2279 static HRESULT WINAPI
FoundCapabilities(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pcaps
)
2284 hr
= IMediaSeeking_GetCapabilities(seek
, &caps
);
2288 /* Only add common capabilities everything supports */
2289 *(DWORD
*)pcaps
&= caps
;
2294 /*** IMediaSeeking methods ***/
2295 static HRESULT WINAPI
MediaSeeking_GetCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2297 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2300 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2305 EnterCriticalSection(&This
->cs
);
2306 *pCapabilities
= 0xffffffff;
2308 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2309 LeaveCriticalSection(&This
->cs
);
2314 static HRESULT WINAPI
MediaSeeking_CheckCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2316 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2320 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2325 EnterCriticalSection(&This
->cs
);
2326 originalcaps
= *pCapabilities
;
2327 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2328 LeaveCriticalSection(&This
->cs
);
2333 if (!*pCapabilities
)
2335 if (*pCapabilities
!= originalcaps
)
2340 static HRESULT WINAPI
MediaSeeking_IsFormatSupported(IMediaSeeking
*iface
, const GUID
*pFormat
)
2342 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2347 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2349 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2351 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2358 static HRESULT WINAPI
MediaSeeking_QueryPreferredFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2360 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2365 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This
, iface
, pFormat
);
2366 memcpy(pFormat
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
2371 static HRESULT WINAPI
MediaSeeking_GetTimeFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2373 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2378 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2379 memcpy(pFormat
, &This
->timeformatseek
, sizeof(GUID
));
2384 static HRESULT WINAPI
MediaSeeking_IsUsingTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2386 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2388 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2392 if (memcmp(pFormat
, &This
->timeformatseek
, sizeof(GUID
)))
2398 static HRESULT WINAPI
MediaSeeking_SetTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2400 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2405 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2407 if (This
->state
!= State_Stopped
)
2408 return VFW_E_WRONG_STATE
;
2410 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2412 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2413 return E_INVALIDARG
;
2419 static HRESULT WINAPI
FoundDuration(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pduration
)
2422 LONGLONG duration
= 0, *pdur
= (LONGLONG
*)pduration
;
2424 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
2428 if (*pdur
< duration
)
2433 static HRESULT WINAPI
MediaSeeking_GetDuration(IMediaSeeking
*iface
, LONGLONG
*pDuration
)
2435 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2438 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDuration
);
2443 EnterCriticalSection(&This
->cs
);
2445 hr
= all_renderers_seek(This
, FoundDuration
, (DWORD_PTR
)pDuration
);
2446 LeaveCriticalSection(&This
->cs
);
2448 TRACE("--->%08x\n", hr
);
2452 static HRESULT WINAPI
MediaSeeking_GetStopPosition(IMediaSeeking
*iface
, LONGLONG
*pStop
)
2454 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2457 TRACE("(%p/%p)->(%p)\n", This
, iface
, pStop
);
2462 EnterCriticalSection(&This
->cs
);
2463 if (This
->stop_position
< 0)
2464 /* Stop position not set, use duration instead */
2465 hr
= IMediaSeeking_GetDuration(iface
, pStop
);
2467 *pStop
= This
->stop_position
;
2468 LeaveCriticalSection(&This
->cs
);
2473 static HRESULT WINAPI
MediaSeeking_GetCurrentPosition(IMediaSeeking
*iface
, LONGLONG
*pCurrent
)
2475 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2481 EnterCriticalSection(&This
->cs
);
2482 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2484 IReferenceClock_GetTime(This
->refClock
, &time
);
2486 time
-= This
->start_time
;
2488 if (This
->pause_time
> 0)
2489 time
+= This
->pause_time
;
2491 LeaveCriticalSection(&This
->cs
);
2493 TRACE("Time: %u.%03u\n", (DWORD
)(*pCurrent
/ 10000000), (DWORD
)((*pCurrent
/ 10000)%1000));
2498 static HRESULT WINAPI
MediaSeeking_ConvertTimeFormat(IMediaSeeking
*iface
, LONGLONG
*pTarget
,
2499 const GUID
*pTargetFormat
, LONGLONG Source
, const GUID
*pSourceFormat
)
2501 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2503 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This
, iface
, pTarget
,
2504 pTargetFormat
, wine_dbgstr_longlong(Source
), pSourceFormat
);
2510 LONGLONG
* current
, *stop
;
2511 DWORD curflags
, stopflags
;
2514 static HRESULT WINAPI
found_setposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2516 struct pos_args
*args
= (void*)pargs
;
2518 return IMediaSeeking_SetPositions(seek
, args
->current
, args
->curflags
, args
->stop
, args
->stopflags
);
2521 static HRESULT WINAPI
MediaSeeking_SetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2522 DWORD dwCurrentFlags
, LONGLONG
*pStop
, DWORD dwStopFlags
)
2524 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2527 struct pos_args args
;
2529 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This
, iface
, pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
2531 EnterCriticalSection(&This
->cs
);
2532 state
= This
->state
;
2533 TRACE("State: %s\n", state
== State_Running
? "Running" : (state
== State_Paused
? "Paused" : (state
== State_Stopped
? "Stopped" : "UNKNOWN")));
2535 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_AbsolutePositioning
&&
2536 (dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2537 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags
& 0x7);
2539 if ((dwStopFlags
& 0x7) == AM_SEEKING_AbsolutePositioning
)
2540 This
->stop_position
= *pStop
;
2541 else if ((dwStopFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2542 FIXME("Stop position not handled yet!\n");
2544 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2545 IMediaControl_Pause(&This
->IMediaControl_iface
);
2546 args
.current
= pCurrent
;
2548 args
.curflags
= dwCurrentFlags
;
2549 args
.stopflags
= dwStopFlags
;
2550 hr
= all_renderers_seek(This
, found_setposition
, (DWORD_PTR
)&args
);
2552 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2553 This
->pause_time
= This
->start_time
= -1;
2554 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2555 IMediaControl_Run(&This
->IMediaControl_iface
);
2556 LeaveCriticalSection(&This
->cs
);
2561 static HRESULT WINAPI
MediaSeeking_GetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2564 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2567 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pCurrent
, pStop
);
2568 hr
= IMediaSeeking_GetCurrentPosition(iface
, pCurrent
);
2570 hr
= IMediaSeeking_GetStopPosition(iface
, pStop
);
2575 static HRESULT WINAPI
MediaSeeking_GetAvailable(IMediaSeeking
*iface
, LONGLONG
*pEarliest
,
2578 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2580 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This
, iface
, pEarliest
, pLatest
);
2585 static HRESULT WINAPI
MediaSeeking_SetRate(IMediaSeeking
*iface
, double dRate
)
2587 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2589 FIXME("(%p/%p)->(%f): stub !!!\n", This
, iface
, dRate
);
2594 static HRESULT WINAPI
MediaSeeking_GetRate(IMediaSeeking
*iface
, double *pdRate
)
2596 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2598 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pdRate
);
2603 static HRESULT WINAPI
MediaSeeking_GetPreroll(IMediaSeeking
*iface
, LONGLONG
*pllPreroll
)
2605 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2607 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pllPreroll
);
2613 static const IMediaSeekingVtbl IMediaSeeking_VTable
=
2615 MediaSeeking_QueryInterface
,
2616 MediaSeeking_AddRef
,
2617 MediaSeeking_Release
,
2618 MediaSeeking_GetCapabilities
,
2619 MediaSeeking_CheckCapabilities
,
2620 MediaSeeking_IsFormatSupported
,
2621 MediaSeeking_QueryPreferredFormat
,
2622 MediaSeeking_GetTimeFormat
,
2623 MediaSeeking_IsUsingTimeFormat
,
2624 MediaSeeking_SetTimeFormat
,
2625 MediaSeeking_GetDuration
,
2626 MediaSeeking_GetStopPosition
,
2627 MediaSeeking_GetCurrentPosition
,
2628 MediaSeeking_ConvertTimeFormat
,
2629 MediaSeeking_SetPositions
,
2630 MediaSeeking_GetPositions
,
2631 MediaSeeking_GetAvailable
,
2632 MediaSeeking_SetRate
,
2633 MediaSeeking_GetRate
,
2634 MediaSeeking_GetPreroll
2637 static inline IFilterGraphImpl
*impl_from_IMediaPosition(IMediaPosition
*iface
)
2639 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaPosition_iface
);
2642 /*** IUnknown methods ***/
2643 static HRESULT WINAPI
MediaPosition_QueryInterface(IMediaPosition
* iface
, REFIID riid
, void** ppvObj
)
2645 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2647 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2649 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2652 static ULONG WINAPI
MediaPosition_AddRef(IMediaPosition
*iface
)
2654 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2656 TRACE("(%p/%p)->()\n", This
, iface
);
2658 return IUnknown_AddRef(This
->outer_unk
);
2661 static ULONG WINAPI
MediaPosition_Release(IMediaPosition
*iface
)
2663 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2665 TRACE("(%p/%p)->()\n", This
, iface
);
2667 return IUnknown_Release(This
->outer_unk
);
2670 /*** IDispatch methods ***/
2671 static HRESULT WINAPI
MediaPosition_GetTypeInfoCount(IMediaPosition
*iface
, UINT
* pctinfo
)
2673 FIXME("(%p) stub!\n", iface
);
2677 static HRESULT WINAPI
MediaPosition_GetTypeInfo(IMediaPosition
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2679 FIXME("(%p) stub!\n", iface
);
2683 static HRESULT WINAPI
MediaPosition_GetIDsOfNames(IMediaPosition
* iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2685 FIXME("(%p) stub!\n", iface
);
2689 static HRESULT WINAPI
MediaPosition_Invoke(IMediaPosition
* iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2691 FIXME("(%p) stub!\n", iface
);
2695 static HRESULT
ConvertFromREFTIME(IMediaSeeking
*seek
, REFTIME time_in
, LONGLONG
*time_out
)
2700 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2703 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2705 FIXME("Unsupported time format.\n");
2709 *time_out
= (LONGLONG
) (time_in
* 10000000); /* convert from 1 second intervals to 100 ns intervals */
2713 static HRESULT
ConvertToREFTIME(IMediaSeeking
*seek
, LONGLONG time_in
, REFTIME
*time_out
)
2718 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2721 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2723 FIXME("Unsupported time format.\n");
2727 *time_out
= (REFTIME
)time_in
/ 10000000; /* convert from 100 ns intervals to 1 second intervals */
2731 /*** IMediaPosition methods ***/
2732 static HRESULT WINAPI
MediaPosition_get_Duration(IMediaPosition
* iface
, REFTIME
*plength
)
2735 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2736 HRESULT hr
= IMediaSeeking_GetDuration(&This
->IMediaSeeking_iface
, &duration
);
2739 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, duration
, plength
);
2742 static HRESULT WINAPI
MediaPosition_put_CurrentPosition(IMediaPosition
* iface
, REFTIME llTime
)
2744 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2748 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2751 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, &reftime
,
2752 AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
2755 static HRESULT WINAPI
MediaPosition_get_CurrentPosition(IMediaPosition
* iface
, REFTIME
*pllTime
)
2757 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2761 hr
= IMediaSeeking_GetCurrentPosition(&This
->IMediaSeeking_iface
, &pos
);
2764 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2767 static HRESULT WINAPI
MediaPosition_get_StopTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2769 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2771 HRESULT hr
= IMediaSeeking_GetStopPosition(&This
->IMediaSeeking_iface
, &pos
);
2774 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2777 static HRESULT WINAPI
MediaPosition_put_StopTime(IMediaPosition
* iface
, REFTIME llTime
)
2779 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2783 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2786 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, NULL
, AM_SEEKING_NoPositioning
,
2787 &reftime
, AM_SEEKING_AbsolutePositioning
);
2790 static HRESULT WINAPI
MediaPosition_get_PrerollTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2792 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2796 static HRESULT WINAPI
MediaPosition_put_PrerollTime(IMediaPosition
* iface
, REFTIME llTime
)
2798 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2802 static HRESULT WINAPI
MediaPosition_put_Rate(IMediaPosition
* iface
, double dRate
)
2804 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2805 return IMediaSeeking_SetRate(&This
->IMediaSeeking_iface
, dRate
);
2808 static HRESULT WINAPI
MediaPosition_get_Rate(IMediaPosition
* iface
, double *pdRate
)
2810 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2811 return IMediaSeeking_GetRate(&This
->IMediaSeeking_iface
, pdRate
);
2814 static HRESULT WINAPI
MediaPosition_CanSeekForward(IMediaPosition
* iface
, LONG
*pCanSeekForward
)
2816 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekForward
);
2820 static HRESULT WINAPI
MediaPosition_CanSeekBackward(IMediaPosition
* iface
, LONG
*pCanSeekBackward
)
2822 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekBackward
);
2827 static const IMediaPositionVtbl IMediaPosition_VTable
=
2829 MediaPosition_QueryInterface
,
2830 MediaPosition_AddRef
,
2831 MediaPosition_Release
,
2832 MediaPosition_GetTypeInfoCount
,
2833 MediaPosition_GetTypeInfo
,
2834 MediaPosition_GetIDsOfNames
,
2835 MediaPosition_Invoke
,
2836 MediaPosition_get_Duration
,
2837 MediaPosition_put_CurrentPosition
,
2838 MediaPosition_get_CurrentPosition
,
2839 MediaPosition_get_StopTime
,
2840 MediaPosition_put_StopTime
,
2841 MediaPosition_get_PrerollTime
,
2842 MediaPosition_put_PrerollTime
,
2843 MediaPosition_put_Rate
,
2844 MediaPosition_get_Rate
,
2845 MediaPosition_CanSeekForward
,
2846 MediaPosition_CanSeekBackward
2849 static inline IFilterGraphImpl
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
2851 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IObjectWithSite_iface
);
2854 /*** IUnknown methods ***/
2855 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
* iface
, REFIID riid
, void** ppvObj
)
2857 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2859 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2861 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2864 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
2866 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2868 TRACE("(%p/%p)->()\n", This
, iface
);
2870 return IUnknown_AddRef(This
->outer_unk
);
2873 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
2875 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2877 TRACE("(%p/%p)->()\n", This
, iface
);
2879 return IUnknown_Release(This
->outer_unk
);
2882 /*** IObjectWithSite methods ***/
2884 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
2886 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2888 TRACE("(%p/%p)->()\n", This
, iface
);
2889 if (This
->pSite
) IUnknown_Release(This
->pSite
);
2890 This
->pSite
= pUnkSite
;
2891 IUnknown_AddRef(This
->pSite
);
2895 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
*iface
, REFIID riid
, PVOID
*ppvSite
)
2897 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2899 TRACE("(%p/%p)->(%s)\n", This
, iface
,debugstr_guid(riid
));
2905 return IUnknown_QueryInterface(This
->pSite
, riid
, ppvSite
);
2908 static const IObjectWithSiteVtbl IObjectWithSite_VTable
=
2910 ObjectWithSite_QueryInterface
,
2911 ObjectWithSite_AddRef
,
2912 ObjectWithSite_Release
,
2913 ObjectWithSite_SetSite
,
2914 ObjectWithSite_GetSite
,
2917 static HRESULT
GetTargetInterface(IFilterGraphImpl
* pGraph
, REFIID riid
, LPVOID
* ppvObj
)
2919 HRESULT hr
= E_NOINTERFACE
;
2923 /* Check if the interface type is already registered */
2924 for (entry
= 0; entry
< pGraph
->nItfCacheEntries
; entry
++)
2925 if (riid
== pGraph
->ItfCacheEntries
[entry
].riid
)
2927 if (pGraph
->ItfCacheEntries
[entry
].iface
)
2929 /* Return the interface if available */
2930 *ppvObj
= pGraph
->ItfCacheEntries
[entry
].iface
;
2936 if (entry
>= MAX_ITF_CACHE_ENTRIES
)
2938 FIXME("Not enough space to store interface in the cache\n");
2939 return E_OUTOFMEMORY
;
2942 /* Find a filter supporting the requested interface */
2943 for (i
= 0; i
< pGraph
->nFilters
; i
++)
2945 hr
= IBaseFilter_QueryInterface(pGraph
->ppFiltersInGraph
[i
], riid
, ppvObj
);
2948 pGraph
->ItfCacheEntries
[entry
].riid
= riid
;
2949 pGraph
->ItfCacheEntries
[entry
].filter
= pGraph
->ppFiltersInGraph
[i
];
2950 pGraph
->ItfCacheEntries
[entry
].iface
= *ppvObj
;
2951 if (entry
>= pGraph
->nItfCacheEntries
)
2952 pGraph
->nItfCacheEntries
++;
2955 if (hr
!= E_NOINTERFACE
)
2962 static inline IFilterGraphImpl
*impl_from_IBasicAudio(IBasicAudio
*iface
)
2964 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicAudio_iface
);
2967 static HRESULT WINAPI
BasicAudio_QueryInterface(IBasicAudio
*iface
, REFIID riid
, void **ppvObj
)
2969 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2971 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2973 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2976 static ULONG WINAPI
BasicAudio_AddRef(IBasicAudio
*iface
)
2978 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2980 TRACE("(%p/%p)->()\n", This
, iface
);
2982 return IUnknown_AddRef(This
->outer_unk
);
2985 static ULONG WINAPI
BasicAudio_Release(IBasicAudio
*iface
)
2987 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2989 TRACE("(%p/%p)->()\n", This
, iface
);
2991 return IUnknown_Release(This
->outer_unk
);
2994 /*** IDispatch methods ***/
2995 static HRESULT WINAPI
BasicAudio_GetTypeInfoCount(IBasicAudio
*iface
, UINT
*pctinfo
)
2997 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2998 IBasicAudio
* pBasicAudio
;
3001 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3003 EnterCriticalSection(&This
->cs
);
3005 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3008 hr
= IBasicAudio_GetTypeInfoCount(pBasicAudio
, pctinfo
);
3010 LeaveCriticalSection(&This
->cs
);
3015 static HRESULT WINAPI
BasicAudio_GetTypeInfo(IBasicAudio
*iface
, UINT iTInfo
, LCID lcid
,
3016 ITypeInfo
**ppTInfo
)
3018 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3019 IBasicAudio
* pBasicAudio
;
3022 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3024 EnterCriticalSection(&This
->cs
);
3026 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3029 hr
= IBasicAudio_GetTypeInfo(pBasicAudio
, iTInfo
, lcid
, ppTInfo
);
3031 LeaveCriticalSection(&This
->cs
);
3036 static HRESULT WINAPI
BasicAudio_GetIDsOfNames(IBasicAudio
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
3037 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3039 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3040 IBasicAudio
* pBasicAudio
;
3043 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3045 EnterCriticalSection(&This
->cs
);
3047 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3050 hr
= IBasicAudio_GetIDsOfNames(pBasicAudio
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3052 LeaveCriticalSection(&This
->cs
);
3057 static HRESULT WINAPI
BasicAudio_Invoke(IBasicAudio
*iface
, DISPID dispIdMember
, REFIID riid
,
3058 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3061 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3062 IBasicAudio
* pBasicAudio
;
3065 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
);
3067 EnterCriticalSection(&This
->cs
);
3069 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3072 hr
= IBasicAudio_Invoke(pBasicAudio
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3074 LeaveCriticalSection(&This
->cs
);
3079 /*** IBasicAudio methods ***/
3080 static HRESULT WINAPI
BasicAudio_put_Volume(IBasicAudio
*iface
, LONG lVolume
)
3082 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3083 IBasicAudio
* pBasicAudio
;
3086 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
3088 EnterCriticalSection(&This
->cs
);
3090 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3093 hr
= IBasicAudio_put_Volume(pBasicAudio
, lVolume
);
3095 LeaveCriticalSection(&This
->cs
);
3100 static HRESULT WINAPI
BasicAudio_get_Volume(IBasicAudio
*iface
, LONG
*plVolume
)
3102 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3103 IBasicAudio
* pBasicAudio
;
3106 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
3108 EnterCriticalSection(&This
->cs
);
3110 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3113 hr
= IBasicAudio_get_Volume(pBasicAudio
, plVolume
);
3115 LeaveCriticalSection(&This
->cs
);
3120 static HRESULT WINAPI
BasicAudio_put_Balance(IBasicAudio
*iface
, LONG lBalance
)
3122 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3123 IBasicAudio
* pBasicAudio
;
3126 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
3128 EnterCriticalSection(&This
->cs
);
3130 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3133 hr
= IBasicAudio_put_Balance(pBasicAudio
, lBalance
);
3135 LeaveCriticalSection(&This
->cs
);
3140 static HRESULT WINAPI
BasicAudio_get_Balance(IBasicAudio
*iface
, LONG
*plBalance
)
3142 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3143 IBasicAudio
* pBasicAudio
;
3146 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
3148 EnterCriticalSection(&This
->cs
);
3150 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3153 hr
= IBasicAudio_get_Balance(pBasicAudio
, plBalance
);
3155 LeaveCriticalSection(&This
->cs
);
3160 static const IBasicAudioVtbl IBasicAudio_VTable
=
3162 BasicAudio_QueryInterface
,
3165 BasicAudio_GetTypeInfoCount
,
3166 BasicAudio_GetTypeInfo
,
3167 BasicAudio_GetIDsOfNames
,
3169 BasicAudio_put_Volume
,
3170 BasicAudio_get_Volume
,
3171 BasicAudio_put_Balance
,
3172 BasicAudio_get_Balance
3175 static inline IFilterGraphImpl
*impl_from_IBasicVideo2(IBasicVideo2
*iface
)
3177 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicVideo2_iface
);
3180 static HRESULT WINAPI
BasicVideo_QueryInterface(IBasicVideo2
*iface
, REFIID riid
, void **ppvObj
)
3182 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3184 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3186 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
3189 static ULONG WINAPI
BasicVideo_AddRef(IBasicVideo2
*iface
)
3191 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3193 TRACE("(%p/%p)->()\n", This
, iface
);
3195 return IUnknown_AddRef(This
->outer_unk
);
3198 static ULONG WINAPI
BasicVideo_Release(IBasicVideo2
*iface
)
3200 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3202 TRACE("(%p/%p)->()\n", This
, iface
);
3204 return IUnknown_Release(This
->outer_unk
);
3207 /*** IDispatch methods ***/
3208 static HRESULT WINAPI
BasicVideo_GetTypeInfoCount(IBasicVideo2
*iface
, UINT
*pctinfo
)
3210 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3211 IBasicVideo
*pBasicVideo
;
3214 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3216 EnterCriticalSection(&This
->cs
);
3218 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3221 hr
= IBasicVideo_GetTypeInfoCount(pBasicVideo
, pctinfo
);
3223 LeaveCriticalSection(&This
->cs
);
3228 static HRESULT WINAPI
BasicVideo_GetTypeInfo(IBasicVideo2
*iface
, UINT iTInfo
, LCID lcid
,
3229 ITypeInfo
**ppTInfo
)
3231 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3232 IBasicVideo
*pBasicVideo
;
3235 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3237 EnterCriticalSection(&This
->cs
);
3239 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3242 hr
= IBasicVideo_GetTypeInfo(pBasicVideo
, iTInfo
, lcid
, ppTInfo
);
3244 LeaveCriticalSection(&This
->cs
);
3249 static HRESULT WINAPI
BasicVideo_GetIDsOfNames(IBasicVideo2
*iface
, REFIID riid
,
3250 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3252 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3253 IBasicVideo
*pBasicVideo
;
3256 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3258 EnterCriticalSection(&This
->cs
);
3260 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3263 hr
= IBasicVideo_GetIDsOfNames(pBasicVideo
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3265 LeaveCriticalSection(&This
->cs
);
3270 static HRESULT WINAPI
BasicVideo_Invoke(IBasicVideo2
*iface
, DISPID dispIdMember
, REFIID riid
,
3271 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3274 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3275 IBasicVideo
*pBasicVideo
;
3278 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
);
3280 EnterCriticalSection(&This
->cs
);
3282 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3285 hr
= IBasicVideo_Invoke(pBasicVideo
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3287 LeaveCriticalSection(&This
->cs
);
3292 /*** IBasicVideo methods ***/
3293 static HRESULT WINAPI
BasicVideo_get_AvgTimePerFrame(IBasicVideo2
*iface
, REFTIME
*pAvgTimePerFrame
)
3295 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3296 IBasicVideo
*pBasicVideo
;
3299 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
3301 EnterCriticalSection(&This
->cs
);
3303 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3306 hr
= IBasicVideo_get_AvgTimePerFrame(pBasicVideo
, pAvgTimePerFrame
);
3308 LeaveCriticalSection(&This
->cs
);
3313 static HRESULT WINAPI
BasicVideo_get_BitRate(IBasicVideo2
*iface
, LONG
*pBitRate
)
3315 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3316 IBasicVideo
*pBasicVideo
;
3319 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
3321 EnterCriticalSection(&This
->cs
);
3323 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3326 hr
= IBasicVideo_get_BitRate(pBasicVideo
, pBitRate
);
3328 LeaveCriticalSection(&This
->cs
);
3333 static HRESULT WINAPI
BasicVideo_get_BitErrorRate(IBasicVideo2
*iface
, LONG
*pBitErrorRate
)
3335 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3336 IBasicVideo
*pBasicVideo
;
3339 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
3341 EnterCriticalSection(&This
->cs
);
3343 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3346 hr
= IBasicVideo_get_BitErrorRate(pBasicVideo
, pBitErrorRate
);
3348 LeaveCriticalSection(&This
->cs
);
3353 static HRESULT WINAPI
BasicVideo_get_VideoWidth(IBasicVideo2
*iface
, LONG
*pVideoWidth
)
3355 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3356 IBasicVideo
*pBasicVideo
;
3359 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
3361 EnterCriticalSection(&This
->cs
);
3363 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3366 hr
= IBasicVideo_get_VideoWidth(pBasicVideo
, pVideoWidth
);
3368 LeaveCriticalSection(&This
->cs
);
3373 static HRESULT WINAPI
BasicVideo_get_VideoHeight(IBasicVideo2
*iface
, LONG
*pVideoHeight
)
3375 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3376 IBasicVideo
*pBasicVideo
;
3379 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
3381 EnterCriticalSection(&This
->cs
);
3383 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3386 hr
= IBasicVideo_get_VideoHeight(pBasicVideo
, pVideoHeight
);
3388 LeaveCriticalSection(&This
->cs
);
3393 static HRESULT WINAPI
BasicVideo_put_SourceLeft(IBasicVideo2
*iface
, LONG SourceLeft
)
3395 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3396 IBasicVideo
*pBasicVideo
;
3399 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceLeft
);
3401 EnterCriticalSection(&This
->cs
);
3403 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3406 hr
= IBasicVideo_put_SourceLeft(pBasicVideo
, SourceLeft
);
3408 LeaveCriticalSection(&This
->cs
);
3413 static HRESULT WINAPI
BasicVideo_get_SourceLeft(IBasicVideo2
*iface
, LONG
*pSourceLeft
)
3415 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3416 IBasicVideo
*pBasicVideo
;
3419 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
3421 EnterCriticalSection(&This
->cs
);
3423 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3426 hr
= IBasicVideo_get_SourceLeft(pBasicVideo
, pSourceLeft
);
3428 LeaveCriticalSection(&This
->cs
);
3433 static HRESULT WINAPI
BasicVideo_put_SourceWidth(IBasicVideo2
*iface
, LONG SourceWidth
)
3435 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3436 IBasicVideo
*pBasicVideo
;
3439 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceWidth
);
3441 EnterCriticalSection(&This
->cs
);
3443 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3446 hr
= IBasicVideo_put_SourceWidth(pBasicVideo
, SourceWidth
);
3448 LeaveCriticalSection(&This
->cs
);
3453 static HRESULT WINAPI
BasicVideo_get_SourceWidth(IBasicVideo2
*iface
, LONG
*pSourceWidth
)
3455 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3456 IBasicVideo
*pBasicVideo
;
3459 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
3461 EnterCriticalSection(&This
->cs
);
3463 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3466 hr
= IBasicVideo_get_SourceWidth(pBasicVideo
, pSourceWidth
);
3468 LeaveCriticalSection(&This
->cs
);
3473 static HRESULT WINAPI
BasicVideo_put_SourceTop(IBasicVideo2
*iface
, LONG SourceTop
)
3475 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3476 IBasicVideo
*pBasicVideo
;
3479 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceTop
);
3481 EnterCriticalSection(&This
->cs
);
3483 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3486 hr
= IBasicVideo_put_SourceTop(pBasicVideo
, SourceTop
);
3488 LeaveCriticalSection(&This
->cs
);
3493 static HRESULT WINAPI
BasicVideo_get_SourceTop(IBasicVideo2
*iface
, LONG
*pSourceTop
)
3495 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3496 IBasicVideo
*pBasicVideo
;
3499 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
3501 EnterCriticalSection(&This
->cs
);
3503 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3506 hr
= IBasicVideo_get_SourceTop(pBasicVideo
, pSourceTop
);
3508 LeaveCriticalSection(&This
->cs
);
3513 static HRESULT WINAPI
BasicVideo_put_SourceHeight(IBasicVideo2
*iface
, LONG SourceHeight
)
3515 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3516 IBasicVideo
*pBasicVideo
;
3519 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceHeight
);
3521 EnterCriticalSection(&This
->cs
);
3523 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3526 hr
= IBasicVideo_put_SourceHeight(pBasicVideo
, SourceHeight
);
3528 LeaveCriticalSection(&This
->cs
);
3533 static HRESULT WINAPI
BasicVideo_get_SourceHeight(IBasicVideo2
*iface
, LONG
*pSourceHeight
)
3535 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3536 IBasicVideo
*pBasicVideo
;
3539 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
3541 EnterCriticalSection(&This
->cs
);
3543 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3546 hr
= IBasicVideo_get_SourceHeight(pBasicVideo
, pSourceHeight
);
3548 LeaveCriticalSection(&This
->cs
);
3553 static HRESULT WINAPI
BasicVideo_put_DestinationLeft(IBasicVideo2
*iface
, LONG DestinationLeft
)
3555 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3556 IBasicVideo
*pBasicVideo
;
3559 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationLeft
);
3561 EnterCriticalSection(&This
->cs
);
3563 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3566 hr
= IBasicVideo_put_DestinationLeft(pBasicVideo
, DestinationLeft
);
3568 LeaveCriticalSection(&This
->cs
);
3573 static HRESULT WINAPI
BasicVideo_get_DestinationLeft(IBasicVideo2
*iface
, LONG
*pDestinationLeft
)
3575 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3576 IBasicVideo
*pBasicVideo
;
3579 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
3581 EnterCriticalSection(&This
->cs
);
3583 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3586 hr
= IBasicVideo_get_DestinationLeft(pBasicVideo
, pDestinationLeft
);
3588 LeaveCriticalSection(&This
->cs
);
3593 static HRESULT WINAPI
BasicVideo_put_DestinationWidth(IBasicVideo2
*iface
, LONG DestinationWidth
)
3595 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3596 IBasicVideo
*pBasicVideo
;
3599 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationWidth
);
3601 EnterCriticalSection(&This
->cs
);
3603 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3606 hr
= IBasicVideo_put_DestinationWidth(pBasicVideo
, DestinationWidth
);
3608 LeaveCriticalSection(&This
->cs
);
3613 static HRESULT WINAPI
BasicVideo_get_DestinationWidth(IBasicVideo2
*iface
, LONG
*pDestinationWidth
)
3615 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3616 IBasicVideo
*pBasicVideo
;
3619 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
3621 EnterCriticalSection(&This
->cs
);
3623 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3626 hr
= IBasicVideo_get_DestinationWidth(pBasicVideo
, pDestinationWidth
);
3628 LeaveCriticalSection(&This
->cs
);
3633 static HRESULT WINAPI
BasicVideo_put_DestinationTop(IBasicVideo2
*iface
, LONG DestinationTop
)
3635 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3636 IBasicVideo
*pBasicVideo
;
3639 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationTop
);
3641 EnterCriticalSection(&This
->cs
);
3643 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3646 hr
= IBasicVideo_put_DestinationTop(pBasicVideo
, DestinationTop
);
3648 LeaveCriticalSection(&This
->cs
);
3653 static HRESULT WINAPI
BasicVideo_get_DestinationTop(IBasicVideo2
*iface
, LONG
*pDestinationTop
)
3655 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3656 IBasicVideo
*pBasicVideo
;
3659 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
3661 EnterCriticalSection(&This
->cs
);
3663 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3666 hr
= IBasicVideo_get_DestinationTop(pBasicVideo
, pDestinationTop
);
3668 LeaveCriticalSection(&This
->cs
);
3673 static HRESULT WINAPI
BasicVideo_put_DestinationHeight(IBasicVideo2
*iface
, LONG DestinationHeight
)
3675 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3676 IBasicVideo
*pBasicVideo
;
3679 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationHeight
);
3681 EnterCriticalSection(&This
->cs
);
3683 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3686 hr
= IBasicVideo_put_DestinationHeight(pBasicVideo
, DestinationHeight
);
3688 LeaveCriticalSection(&This
->cs
);
3693 static HRESULT WINAPI
BasicVideo_get_DestinationHeight(IBasicVideo2
*iface
,
3694 LONG
*pDestinationHeight
)
3696 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3697 IBasicVideo
*pBasicVideo
;
3700 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
3702 EnterCriticalSection(&This
->cs
);
3704 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3707 hr
= IBasicVideo_get_DestinationHeight(pBasicVideo
, pDestinationHeight
);
3709 LeaveCriticalSection(&This
->cs
);
3714 static HRESULT WINAPI
BasicVideo_SetSourcePosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3715 LONG Width
, LONG Height
)
3717 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3718 IBasicVideo
*pBasicVideo
;
3721 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3723 EnterCriticalSection(&This
->cs
);
3725 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3728 hr
= IBasicVideo_SetSourcePosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3730 LeaveCriticalSection(&This
->cs
);
3735 static HRESULT WINAPI
BasicVideo_GetSourcePosition(IBasicVideo2
*iface
, LONG
*pLeft
, LONG
*pTop
,
3736 LONG
*pWidth
, LONG
*pHeight
)
3738 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3739 IBasicVideo
*pBasicVideo
;
3742 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3744 EnterCriticalSection(&This
->cs
);
3746 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3749 hr
= IBasicVideo_GetSourcePosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3751 LeaveCriticalSection(&This
->cs
);
3756 static HRESULT WINAPI
BasicVideo_SetDefaultSourcePosition(IBasicVideo2
*iface
)
3758 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3759 IBasicVideo
*pBasicVideo
;
3762 TRACE("(%p/%p)->()\n", This
, iface
);
3764 EnterCriticalSection(&This
->cs
);
3766 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3769 hr
= IBasicVideo_SetDefaultSourcePosition(pBasicVideo
);
3771 LeaveCriticalSection(&This
->cs
);
3776 static HRESULT WINAPI
BasicVideo_SetDestinationPosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3777 LONG Width
, LONG Height
)
3779 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3780 IBasicVideo
*pBasicVideo
;
3783 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3785 EnterCriticalSection(&This
->cs
);
3787 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3790 hr
= IBasicVideo_SetDestinationPosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3792 LeaveCriticalSection(&This
->cs
);
3797 static HRESULT WINAPI
BasicVideo_GetDestinationPosition(IBasicVideo2
*iface
, LONG
*pLeft
,
3798 LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
3800 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3801 IBasicVideo
*pBasicVideo
;
3804 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3806 EnterCriticalSection(&This
->cs
);
3808 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3811 hr
= IBasicVideo_GetDestinationPosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3813 LeaveCriticalSection(&This
->cs
);
3818 static HRESULT WINAPI
BasicVideo_SetDefaultDestinationPosition(IBasicVideo2
*iface
)
3820 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3821 IBasicVideo
*pBasicVideo
;
3824 TRACE("(%p/%p)->()\n", This
, iface
);
3826 EnterCriticalSection(&This
->cs
);
3828 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3831 hr
= IBasicVideo_SetDefaultDestinationPosition(pBasicVideo
);
3833 LeaveCriticalSection(&This
->cs
);
3838 static HRESULT WINAPI
BasicVideo_GetVideoSize(IBasicVideo2
*iface
, LONG
*pWidth
, LONG
*pHeight
)
3840 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3841 IBasicVideo
*pBasicVideo
;
3844 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
3846 EnterCriticalSection(&This
->cs
);
3848 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3851 hr
= IBasicVideo_GetVideoSize(pBasicVideo
, pWidth
, pHeight
);
3853 LeaveCriticalSection(&This
->cs
);
3858 static HRESULT WINAPI
BasicVideo_GetVideoPaletteEntries(IBasicVideo2
*iface
, LONG StartIndex
,
3859 LONG Entries
, LONG
*pRetrieved
, LONG
*pPalette
)
3861 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3862 IBasicVideo
*pBasicVideo
;
3865 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3867 EnterCriticalSection(&This
->cs
);
3869 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3872 hr
= IBasicVideo_GetVideoPaletteEntries(pBasicVideo
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3874 LeaveCriticalSection(&This
->cs
);
3879 static HRESULT WINAPI
BasicVideo_GetCurrentImage(IBasicVideo2
*iface
, LONG
*pBufferSize
,
3882 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3883 IBasicVideo
*pBasicVideo
;
3886 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pBufferSize
, pDIBImage
);
3888 EnterCriticalSection(&This
->cs
);
3890 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3893 hr
= IBasicVideo_GetCurrentImage(pBasicVideo
, pBufferSize
, pDIBImage
);
3895 LeaveCriticalSection(&This
->cs
);
3900 static HRESULT WINAPI
BasicVideo_IsUsingDefaultSource(IBasicVideo2
*iface
)
3902 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3903 IBasicVideo
*pBasicVideo
;
3906 TRACE("(%p/%p)->()\n", This
, iface
);
3908 EnterCriticalSection(&This
->cs
);
3910 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3913 hr
= IBasicVideo_IsUsingDefaultSource(pBasicVideo
);
3915 LeaveCriticalSection(&This
->cs
);
3920 static HRESULT WINAPI
BasicVideo_IsUsingDefaultDestination(IBasicVideo2
*iface
)
3922 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3923 IBasicVideo
*pBasicVideo
;
3926 TRACE("(%p/%p)->()\n", This
, iface
);
3928 EnterCriticalSection(&This
->cs
);
3930 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3933 hr
= IBasicVideo_IsUsingDefaultDestination(pBasicVideo
);
3935 LeaveCriticalSection(&This
->cs
);
3940 static HRESULT WINAPI
BasicVideo2_GetPreferredAspectRatio(IBasicVideo2
*iface
, LONG
*plAspectX
,
3943 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3944 IBasicVideo2
*pBasicVideo2
;
3947 TRACE("(%p/%p)->()\n", This
, iface
);
3949 EnterCriticalSection(&This
->cs
);
3951 hr
= GetTargetInterface(This
, &IID_IBasicVideo2
, (LPVOID
*)&pBasicVideo2
);
3954 hr
= BasicVideo2_GetPreferredAspectRatio(iface
, plAspectX
, plAspectY
);
3956 LeaveCriticalSection(&This
->cs
);
3961 static const IBasicVideo2Vtbl IBasicVideo_VTable
=
3963 BasicVideo_QueryInterface
,
3966 BasicVideo_GetTypeInfoCount
,
3967 BasicVideo_GetTypeInfo
,
3968 BasicVideo_GetIDsOfNames
,
3970 BasicVideo_get_AvgTimePerFrame
,
3971 BasicVideo_get_BitRate
,
3972 BasicVideo_get_BitErrorRate
,
3973 BasicVideo_get_VideoWidth
,
3974 BasicVideo_get_VideoHeight
,
3975 BasicVideo_put_SourceLeft
,
3976 BasicVideo_get_SourceLeft
,
3977 BasicVideo_put_SourceWidth
,
3978 BasicVideo_get_SourceWidth
,
3979 BasicVideo_put_SourceTop
,
3980 BasicVideo_get_SourceTop
,
3981 BasicVideo_put_SourceHeight
,
3982 BasicVideo_get_SourceHeight
,
3983 BasicVideo_put_DestinationLeft
,
3984 BasicVideo_get_DestinationLeft
,
3985 BasicVideo_put_DestinationWidth
,
3986 BasicVideo_get_DestinationWidth
,
3987 BasicVideo_put_DestinationTop
,
3988 BasicVideo_get_DestinationTop
,
3989 BasicVideo_put_DestinationHeight
,
3990 BasicVideo_get_DestinationHeight
,
3991 BasicVideo_SetSourcePosition
,
3992 BasicVideo_GetSourcePosition
,
3993 BasicVideo_SetDefaultSourcePosition
,
3994 BasicVideo_SetDestinationPosition
,
3995 BasicVideo_GetDestinationPosition
,
3996 BasicVideo_SetDefaultDestinationPosition
,
3997 BasicVideo_GetVideoSize
,
3998 BasicVideo_GetVideoPaletteEntries
,
3999 BasicVideo_GetCurrentImage
,
4000 BasicVideo_IsUsingDefaultSource
,
4001 BasicVideo_IsUsingDefaultDestination
,
4002 BasicVideo2_GetPreferredAspectRatio
4005 static inline IFilterGraphImpl
*impl_from_IVideoWindow(IVideoWindow
*iface
)
4007 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IVideoWindow_iface
);
4010 static HRESULT WINAPI
VideoWindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, void **ppvObj
)
4012 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4014 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4016 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4019 static ULONG WINAPI
VideoWindow_AddRef(IVideoWindow
*iface
)
4021 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4023 TRACE("(%p/%p)->()\n", This
, iface
);
4025 return IUnknown_AddRef(This
->outer_unk
);
4028 static ULONG WINAPI
VideoWindow_Release(IVideoWindow
*iface
)
4030 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4032 TRACE("(%p/%p)->()\n", This
, iface
);
4034 return IUnknown_Release(This
->outer_unk
);
4037 /*** IDispatch methods ***/
4038 static HRESULT WINAPI
VideoWindow_GetTypeInfoCount(IVideoWindow
*iface
, UINT
*pctinfo
)
4040 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4041 IVideoWindow
*pVideoWindow
;
4044 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
4046 EnterCriticalSection(&This
->cs
);
4048 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4051 hr
= IVideoWindow_GetTypeInfoCount(pVideoWindow
, pctinfo
);
4053 LeaveCriticalSection(&This
->cs
);
4058 static HRESULT WINAPI
VideoWindow_GetTypeInfo(IVideoWindow
*iface
, UINT iTInfo
, LCID lcid
,
4059 ITypeInfo
**ppTInfo
)
4061 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4062 IVideoWindow
*pVideoWindow
;
4065 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4067 EnterCriticalSection(&This
->cs
);
4069 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4072 hr
= IVideoWindow_GetTypeInfo(pVideoWindow
, iTInfo
, lcid
, ppTInfo
);
4074 LeaveCriticalSection(&This
->cs
);
4079 static HRESULT WINAPI
VideoWindow_GetIDsOfNames(IVideoWindow
*iface
, REFIID riid
,
4080 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
4082 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4083 IVideoWindow
*pVideoWindow
;
4086 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4088 EnterCriticalSection(&This
->cs
);
4090 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4093 hr
= IVideoWindow_GetIDsOfNames(pVideoWindow
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4095 LeaveCriticalSection(&This
->cs
);
4100 static HRESULT WINAPI
VideoWindow_Invoke(IVideoWindow
*iface
, DISPID dispIdMember
, REFIID riid
,
4101 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
4104 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4105 IVideoWindow
*pVideoWindow
;
4108 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
);
4110 EnterCriticalSection(&This
->cs
);
4112 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4115 hr
= IVideoWindow_Invoke(pVideoWindow
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
4117 LeaveCriticalSection(&This
->cs
);
4123 /*** IVideoWindow methods ***/
4124 static HRESULT WINAPI
VideoWindow_put_Caption(IVideoWindow
*iface
, BSTR strCaption
)
4126 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4127 IVideoWindow
*pVideoWindow
;
4130 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strCaption
), strCaption
);
4132 EnterCriticalSection(&This
->cs
);
4134 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4137 hr
= IVideoWindow_put_Caption(pVideoWindow
, strCaption
);
4139 LeaveCriticalSection(&This
->cs
);
4144 static HRESULT WINAPI
VideoWindow_get_Caption(IVideoWindow
*iface
, BSTR
*strCaption
)
4146 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4147 IVideoWindow
*pVideoWindow
;
4150 TRACE("(%p/%p)->(%p)\n", This
, iface
, strCaption
);
4152 EnterCriticalSection(&This
->cs
);
4154 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4157 hr
= IVideoWindow_get_Caption(pVideoWindow
, strCaption
);
4159 LeaveCriticalSection(&This
->cs
);
4164 static HRESULT WINAPI
VideoWindow_put_WindowStyle(IVideoWindow
*iface
, LONG WindowStyle
)
4166 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4167 IVideoWindow
*pVideoWindow
;
4170 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyle
);
4172 EnterCriticalSection(&This
->cs
);
4174 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4177 hr
= IVideoWindow_put_WindowStyle(pVideoWindow
, WindowStyle
);
4179 LeaveCriticalSection(&This
->cs
);
4184 static HRESULT WINAPI
VideoWindow_get_WindowStyle(IVideoWindow
*iface
, LONG
*WindowStyle
)
4186 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4187 IVideoWindow
*pVideoWindow
;
4190 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyle
);
4192 EnterCriticalSection(&This
->cs
);
4194 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4197 hr
= IVideoWindow_get_WindowStyle(pVideoWindow
, WindowStyle
);
4199 LeaveCriticalSection(&This
->cs
);
4204 static HRESULT WINAPI
VideoWindow_put_WindowStyleEx(IVideoWindow
*iface
, LONG WindowStyleEx
)
4206 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4207 IVideoWindow
*pVideoWindow
;
4210 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyleEx
);
4212 EnterCriticalSection(&This
->cs
);
4214 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4217 hr
= IVideoWindow_put_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4219 LeaveCriticalSection(&This
->cs
);
4224 static HRESULT WINAPI
VideoWindow_get_WindowStyleEx(IVideoWindow
*iface
, LONG
*WindowStyleEx
)
4226 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4227 IVideoWindow
*pVideoWindow
;
4230 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyleEx
);
4232 EnterCriticalSection(&This
->cs
);
4234 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4237 hr
= IVideoWindow_get_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4239 LeaveCriticalSection(&This
->cs
);
4244 static HRESULT WINAPI
VideoWindow_put_AutoShow(IVideoWindow
*iface
, LONG AutoShow
)
4246 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4247 IVideoWindow
*pVideoWindow
;
4250 TRACE("(%p/%p)->(%d)\n", This
, iface
, AutoShow
);
4252 EnterCriticalSection(&This
->cs
);
4254 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4257 hr
= IVideoWindow_put_AutoShow(pVideoWindow
, AutoShow
);
4259 LeaveCriticalSection(&This
->cs
);
4264 static HRESULT WINAPI
VideoWindow_get_AutoShow(IVideoWindow
*iface
, LONG
*AutoShow
)
4266 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4267 IVideoWindow
*pVideoWindow
;
4270 TRACE("(%p/%p)->(%p)\n", This
, iface
, AutoShow
);
4272 EnterCriticalSection(&This
->cs
);
4274 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4277 hr
= IVideoWindow_get_AutoShow(pVideoWindow
, AutoShow
);
4279 LeaveCriticalSection(&This
->cs
);
4284 static HRESULT WINAPI
VideoWindow_put_WindowState(IVideoWindow
*iface
, LONG WindowState
)
4286 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4287 IVideoWindow
*pVideoWindow
;
4290 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowState
);
4292 EnterCriticalSection(&This
->cs
);
4294 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4297 hr
= IVideoWindow_put_WindowState(pVideoWindow
, WindowState
);
4299 LeaveCriticalSection(&This
->cs
);
4304 static HRESULT WINAPI
VideoWindow_get_WindowState(IVideoWindow
*iface
, LONG
*WindowState
)
4306 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4307 IVideoWindow
*pVideoWindow
;
4310 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowState
);
4312 EnterCriticalSection(&This
->cs
);
4314 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4317 hr
= IVideoWindow_get_WindowState(pVideoWindow
, WindowState
);
4319 LeaveCriticalSection(&This
->cs
);
4324 static HRESULT WINAPI
VideoWindow_put_BackgroundPalette(IVideoWindow
*iface
, LONG BackgroundPalette
)
4326 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4327 IVideoWindow
*pVideoWindow
;
4330 TRACE("(%p/%p)->(%d)\n", This
, iface
, BackgroundPalette
);
4332 EnterCriticalSection(&This
->cs
);
4334 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4337 hr
= IVideoWindow_put_BackgroundPalette(pVideoWindow
, BackgroundPalette
);
4339 LeaveCriticalSection(&This
->cs
);
4344 static HRESULT WINAPI
VideoWindow_get_BackgroundPalette(IVideoWindow
*iface
,
4345 LONG
*pBackgroundPalette
)
4347 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4348 IVideoWindow
*pVideoWindow
;
4351 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBackgroundPalette
);
4353 EnterCriticalSection(&This
->cs
);
4355 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4358 hr
= IVideoWindow_get_BackgroundPalette(pVideoWindow
, pBackgroundPalette
);
4360 LeaveCriticalSection(&This
->cs
);
4365 static HRESULT WINAPI
VideoWindow_put_Visible(IVideoWindow
*iface
, LONG Visible
)
4367 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4368 IVideoWindow
*pVideoWindow
;
4371 TRACE("(%p/%p)->(%d)\n", This
, iface
, Visible
);
4373 EnterCriticalSection(&This
->cs
);
4375 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4378 hr
= IVideoWindow_put_Visible(pVideoWindow
, Visible
);
4380 LeaveCriticalSection(&This
->cs
);
4385 static HRESULT WINAPI
VideoWindow_get_Visible(IVideoWindow
*iface
, LONG
*pVisible
)
4387 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4388 IVideoWindow
*pVideoWindow
;
4391 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVisible
);
4393 EnterCriticalSection(&This
->cs
);
4395 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4398 hr
= IVideoWindow_get_Visible(pVideoWindow
, pVisible
);
4400 LeaveCriticalSection(&This
->cs
);
4405 static HRESULT WINAPI
VideoWindow_put_Left(IVideoWindow
*iface
, LONG Left
)
4407 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4408 IVideoWindow
*pVideoWindow
;
4411 TRACE("(%p/%p)->(%d)\n", This
, iface
, Left
);
4413 EnterCriticalSection(&This
->cs
);
4415 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4418 hr
= IVideoWindow_put_Left(pVideoWindow
, Left
);
4420 LeaveCriticalSection(&This
->cs
);
4425 static HRESULT WINAPI
VideoWindow_get_Left(IVideoWindow
*iface
, LONG
*pLeft
)
4427 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4428 IVideoWindow
*pVideoWindow
;
4431 TRACE("(%p/%p)->(%p)\n", This
, iface
, pLeft
);
4433 EnterCriticalSection(&This
->cs
);
4435 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4438 hr
= IVideoWindow_get_Left(pVideoWindow
, pLeft
);
4440 LeaveCriticalSection(&This
->cs
);
4445 static HRESULT WINAPI
VideoWindow_put_Width(IVideoWindow
*iface
, LONG Width
)
4447 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4448 IVideoWindow
*pVideoWindow
;
4451 TRACE("(%p/%p)->(%d)\n", This
, iface
, Width
);
4453 EnterCriticalSection(&This
->cs
);
4455 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4458 hr
= IVideoWindow_put_Width(pVideoWindow
, Width
);
4460 LeaveCriticalSection(&This
->cs
);
4465 static HRESULT WINAPI
VideoWindow_get_Width(IVideoWindow
*iface
, LONG
*pWidth
)
4467 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4468 IVideoWindow
*pVideoWindow
;
4471 TRACE("(%p/%p)->(%p)\n", This
, iface
, pWidth
);
4473 EnterCriticalSection(&This
->cs
);
4475 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4478 hr
= IVideoWindow_get_Width(pVideoWindow
, pWidth
);
4480 LeaveCriticalSection(&This
->cs
);
4485 static HRESULT WINAPI
VideoWindow_put_Top(IVideoWindow
*iface
, LONG Top
)
4487 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4488 IVideoWindow
*pVideoWindow
;
4491 TRACE("(%p/%p)->(%d)\n", This
, iface
, Top
);
4493 EnterCriticalSection(&This
->cs
);
4495 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4498 hr
= IVideoWindow_put_Top(pVideoWindow
, Top
);
4500 LeaveCriticalSection(&This
->cs
);
4505 static HRESULT WINAPI
VideoWindow_get_Top(IVideoWindow
*iface
, LONG
*pTop
)
4507 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4508 IVideoWindow
*pVideoWindow
;
4511 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTop
);
4513 EnterCriticalSection(&This
->cs
);
4515 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4518 hr
= IVideoWindow_get_Top(pVideoWindow
, pTop
);
4520 LeaveCriticalSection(&This
->cs
);
4525 static HRESULT WINAPI
VideoWindow_put_Height(IVideoWindow
*iface
, LONG Height
)
4527 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4528 IVideoWindow
*pVideoWindow
;
4531 TRACE("(%p/%p)->(%d)\n", This
, iface
, Height
);
4533 EnterCriticalSection(&This
->cs
);
4535 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4538 hr
= IVideoWindow_put_Height(pVideoWindow
, Height
);
4540 LeaveCriticalSection(&This
->cs
);
4545 static HRESULT WINAPI
VideoWindow_get_Height(IVideoWindow
*iface
, LONG
*pHeight
)
4547 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4548 IVideoWindow
*pVideoWindow
;
4551 TRACE("(%p/%p)->(%p)\n", This
, iface
, pHeight
);
4553 EnterCriticalSection(&This
->cs
);
4555 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4558 hr
= IVideoWindow_get_Height(pVideoWindow
, pHeight
);
4560 LeaveCriticalSection(&This
->cs
);
4565 static HRESULT WINAPI
VideoWindow_put_Owner(IVideoWindow
*iface
, OAHWND Owner
)
4567 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4568 IVideoWindow
*pVideoWindow
;
4571 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Owner
);
4573 EnterCriticalSection(&This
->cs
);
4575 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4578 hr
= IVideoWindow_put_Owner(pVideoWindow
, Owner
);
4580 LeaveCriticalSection(&This
->cs
);
4585 static HRESULT WINAPI
VideoWindow_get_Owner(IVideoWindow
*iface
, OAHWND
*Owner
)
4587 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4588 IVideoWindow
*pVideoWindow
;
4591 TRACE("(%p/%p)->(%p)\n", This
, iface
, Owner
);
4593 EnterCriticalSection(&This
->cs
);
4595 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4598 hr
= IVideoWindow_get_Owner(pVideoWindow
, Owner
);
4600 LeaveCriticalSection(&This
->cs
);
4605 static HRESULT WINAPI
VideoWindow_put_MessageDrain(IVideoWindow
*iface
, OAHWND Drain
)
4607 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4608 IVideoWindow
*pVideoWindow
;
4611 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Drain
);
4613 EnterCriticalSection(&This
->cs
);
4615 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4618 hr
= IVideoWindow_put_MessageDrain(pVideoWindow
, Drain
);
4620 LeaveCriticalSection(&This
->cs
);
4625 static HRESULT WINAPI
VideoWindow_get_MessageDrain(IVideoWindow
*iface
, OAHWND
*Drain
)
4627 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4628 IVideoWindow
*pVideoWindow
;
4631 TRACE("(%p/%p)->(%p)\n", This
, iface
, Drain
);
4633 EnterCriticalSection(&This
->cs
);
4635 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4638 hr
= IVideoWindow_get_MessageDrain(pVideoWindow
, Drain
);
4640 LeaveCriticalSection(&This
->cs
);
4645 static HRESULT WINAPI
VideoWindow_get_BorderColor(IVideoWindow
*iface
, LONG
*Color
)
4647 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4648 IVideoWindow
*pVideoWindow
;
4651 TRACE("(%p/%p)->(%p)\n", This
, iface
, Color
);
4653 EnterCriticalSection(&This
->cs
);
4655 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4658 hr
= IVideoWindow_get_BorderColor(pVideoWindow
, Color
);
4660 LeaveCriticalSection(&This
->cs
);
4665 static HRESULT WINAPI
VideoWindow_put_BorderColor(IVideoWindow
*iface
, LONG Color
)
4667 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4668 IVideoWindow
*pVideoWindow
;
4671 TRACE("(%p/%p)->(%d)\n", This
, iface
, Color
);
4673 EnterCriticalSection(&This
->cs
);
4675 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4678 hr
= IVideoWindow_put_BorderColor(pVideoWindow
, Color
);
4680 LeaveCriticalSection(&This
->cs
);
4685 static HRESULT WINAPI
VideoWindow_get_FullScreenMode(IVideoWindow
*iface
, LONG
*FullScreenMode
)
4687 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4688 IVideoWindow
*pVideoWindow
;
4691 TRACE("(%p/%p)->(%p)\n", This
, iface
, FullScreenMode
);
4693 EnterCriticalSection(&This
->cs
);
4695 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4698 hr
= IVideoWindow_get_FullScreenMode(pVideoWindow
, FullScreenMode
);
4700 LeaveCriticalSection(&This
->cs
);
4705 static HRESULT WINAPI
VideoWindow_put_FullScreenMode(IVideoWindow
*iface
, LONG FullScreenMode
)
4707 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4708 IVideoWindow
*pVideoWindow
;
4711 TRACE("(%p/%p)->(%d)\n", This
, iface
, FullScreenMode
);
4713 EnterCriticalSection(&This
->cs
);
4715 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4718 hr
= IVideoWindow_put_FullScreenMode(pVideoWindow
, FullScreenMode
);
4720 LeaveCriticalSection(&This
->cs
);
4725 static HRESULT WINAPI
VideoWindow_SetWindowForeground(IVideoWindow
*iface
, LONG Focus
)
4727 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4728 IVideoWindow
*pVideoWindow
;
4731 TRACE("(%p/%p)->(%d)\n", This
, iface
, Focus
);
4733 EnterCriticalSection(&This
->cs
);
4735 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4738 hr
= IVideoWindow_SetWindowForeground(pVideoWindow
, Focus
);
4740 LeaveCriticalSection(&This
->cs
);
4745 static HRESULT WINAPI
VideoWindow_NotifyOwnerMessage(IVideoWindow
*iface
, OAHWND hwnd
, LONG uMsg
,
4746 LONG_PTR wParam
, LONG_PTR lParam
)
4748 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4749 IVideoWindow
*pVideoWindow
;
4752 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This
, iface
, hwnd
, uMsg
, wParam
, lParam
);
4754 EnterCriticalSection(&This
->cs
);
4756 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4759 hr
= IVideoWindow_NotifyOwnerMessage(pVideoWindow
, hwnd
, uMsg
, wParam
, lParam
);
4761 LeaveCriticalSection(&This
->cs
);
4766 static HRESULT WINAPI
VideoWindow_SetWindowPosition(IVideoWindow
*iface
, LONG Left
, LONG Top
,
4767 LONG Width
, LONG Height
)
4769 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4770 IVideoWindow
*pVideoWindow
;
4773 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
4775 EnterCriticalSection(&This
->cs
);
4777 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4780 hr
= IVideoWindow_SetWindowPosition(pVideoWindow
, Left
, Top
, Width
, Height
);
4782 LeaveCriticalSection(&This
->cs
);
4787 static HRESULT WINAPI
VideoWindow_GetWindowPosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4788 LONG
*pWidth
, LONG
*pHeight
)
4790 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4791 IVideoWindow
*pVideoWindow
;
4794 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4796 EnterCriticalSection(&This
->cs
);
4798 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4801 hr
= IVideoWindow_GetWindowPosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4803 LeaveCriticalSection(&This
->cs
);
4808 static HRESULT WINAPI
VideoWindow_GetMinIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4811 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4812 IVideoWindow
*pVideoWindow
;
4815 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4817 EnterCriticalSection(&This
->cs
);
4819 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4822 hr
= IVideoWindow_GetMinIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4824 LeaveCriticalSection(&This
->cs
);
4829 static HRESULT WINAPI
VideoWindow_GetMaxIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4832 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4833 IVideoWindow
*pVideoWindow
;
4836 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4838 EnterCriticalSection(&This
->cs
);
4840 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4843 hr
= IVideoWindow_GetMaxIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4845 LeaveCriticalSection(&This
->cs
);
4850 static HRESULT WINAPI
VideoWindow_GetRestorePosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4851 LONG
*pWidth
, LONG
*pHeight
)
4853 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4854 IVideoWindow
*pVideoWindow
;
4857 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4859 EnterCriticalSection(&This
->cs
);
4861 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4864 hr
= IVideoWindow_GetRestorePosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4866 LeaveCriticalSection(&This
->cs
);
4871 static HRESULT WINAPI
VideoWindow_HideCursor(IVideoWindow
*iface
, LONG HideCursor
)
4873 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4874 IVideoWindow
*pVideoWindow
;
4877 TRACE("(%p/%p)->(%d)\n", This
, iface
, HideCursor
);
4879 EnterCriticalSection(&This
->cs
);
4881 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4884 hr
= IVideoWindow_HideCursor(pVideoWindow
, HideCursor
);
4886 LeaveCriticalSection(&This
->cs
);
4891 static HRESULT WINAPI
VideoWindow_IsCursorHidden(IVideoWindow
*iface
, LONG
*CursorHidden
)
4893 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4894 IVideoWindow
*pVideoWindow
;
4897 TRACE("(%p/%p)->(%p)\n", This
, iface
, CursorHidden
);
4899 EnterCriticalSection(&This
->cs
);
4901 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4904 hr
= IVideoWindow_IsCursorHidden(pVideoWindow
, CursorHidden
);
4906 LeaveCriticalSection(&This
->cs
);
4912 static const IVideoWindowVtbl IVideoWindow_VTable
=
4914 VideoWindow_QueryInterface
,
4916 VideoWindow_Release
,
4917 VideoWindow_GetTypeInfoCount
,
4918 VideoWindow_GetTypeInfo
,
4919 VideoWindow_GetIDsOfNames
,
4921 VideoWindow_put_Caption
,
4922 VideoWindow_get_Caption
,
4923 VideoWindow_put_WindowStyle
,
4924 VideoWindow_get_WindowStyle
,
4925 VideoWindow_put_WindowStyleEx
,
4926 VideoWindow_get_WindowStyleEx
,
4927 VideoWindow_put_AutoShow
,
4928 VideoWindow_get_AutoShow
,
4929 VideoWindow_put_WindowState
,
4930 VideoWindow_get_WindowState
,
4931 VideoWindow_put_BackgroundPalette
,
4932 VideoWindow_get_BackgroundPalette
,
4933 VideoWindow_put_Visible
,
4934 VideoWindow_get_Visible
,
4935 VideoWindow_put_Left
,
4936 VideoWindow_get_Left
,
4937 VideoWindow_put_Width
,
4938 VideoWindow_get_Width
,
4939 VideoWindow_put_Top
,
4940 VideoWindow_get_Top
,
4941 VideoWindow_put_Height
,
4942 VideoWindow_get_Height
,
4943 VideoWindow_put_Owner
,
4944 VideoWindow_get_Owner
,
4945 VideoWindow_put_MessageDrain
,
4946 VideoWindow_get_MessageDrain
,
4947 VideoWindow_get_BorderColor
,
4948 VideoWindow_put_BorderColor
,
4949 VideoWindow_get_FullScreenMode
,
4950 VideoWindow_put_FullScreenMode
,
4951 VideoWindow_SetWindowForeground
,
4952 VideoWindow_NotifyOwnerMessage
,
4953 VideoWindow_SetWindowPosition
,
4954 VideoWindow_GetWindowPosition
,
4955 VideoWindow_GetMinIdealImageSize
,
4956 VideoWindow_GetMaxIdealImageSize
,
4957 VideoWindow_GetRestorePosition
,
4958 VideoWindow_HideCursor
,
4959 VideoWindow_IsCursorHidden
4962 static inline IFilterGraphImpl
*impl_from_IMediaEventEx(IMediaEventEx
*iface
)
4964 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventEx_iface
);
4967 static HRESULT WINAPI
MediaEvent_QueryInterface(IMediaEventEx
*iface
, REFIID riid
, void **ppvObj
)
4969 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4971 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4973 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4976 static ULONG WINAPI
MediaEvent_AddRef(IMediaEventEx
*iface
)
4978 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4980 TRACE("(%p/%p)->()\n", This
, iface
);
4982 return IUnknown_AddRef(This
->outer_unk
);
4985 static ULONG WINAPI
MediaEvent_Release(IMediaEventEx
*iface
)
4987 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4989 TRACE("(%p/%p)->()\n", This
, iface
);
4991 return IUnknown_Release(This
->outer_unk
);
4994 /*** IDispatch methods ***/
4995 static HRESULT WINAPI
MediaEvent_GetTypeInfoCount(IMediaEventEx
*iface
, UINT
*pctinfo
)
4997 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4999 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
5004 static HRESULT WINAPI
MediaEvent_GetTypeInfo(IMediaEventEx
*iface
, UINT iTInfo
, LCID lcid
,
5005 ITypeInfo
**ppTInfo
)
5007 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5009 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
5014 static HRESULT WINAPI
MediaEvent_GetIDsOfNames(IMediaEventEx
*iface
, REFIID riid
,
5015 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
5017 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5019 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
5024 static HRESULT WINAPI
MediaEvent_Invoke(IMediaEventEx
*iface
, DISPID dispIdMember
, REFIID riid
,
5025 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
5028 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5030 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
);
5035 /*** IMediaEvent methods ***/
5036 static HRESULT WINAPI
MediaEvent_GetEventHandle(IMediaEventEx
*iface
, OAEVENT
*hEvent
)
5038 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5040 TRACE("(%p/%p)->(%p)\n", This
, iface
, hEvent
);
5042 *hEvent
= (OAEVENT
)This
->evqueue
.msg_event
;
5047 static HRESULT WINAPI
MediaEvent_GetEvent(IMediaEventEx
*iface
, LONG
*lEventCode
, LONG_PTR
*lParam1
,
5048 LONG_PTR
*lParam2
, LONG msTimeout
)
5050 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5053 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This
, iface
, lEventCode
, lParam1
, lParam2
, msTimeout
);
5055 if (EventsQueue_GetEvent(&This
->evqueue
, &evt
, msTimeout
))
5057 *lEventCode
= evt
.lEventCode
;
5058 *lParam1
= evt
.lParam1
;
5059 *lParam2
= evt
.lParam2
;
5067 static HRESULT WINAPI
MediaEvent_WaitForCompletion(IMediaEventEx
*iface
, LONG msTimeout
,
5070 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5072 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pEvCode
);
5074 if (This
->state
!= State_Running
)
5075 return VFW_E_WRONG_STATE
;
5077 if (WaitForSingleObject(This
->hEventCompletion
, msTimeout
) == WAIT_OBJECT_0
)
5079 *pEvCode
= This
->CompletionStatus
;
5087 static HRESULT WINAPI
MediaEvent_CancelDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5089 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5091 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5093 if (lEvCode
== EC_COMPLETE
)
5094 This
->HandleEcComplete
= FALSE
;
5095 else if (lEvCode
== EC_REPAINT
)
5096 This
->HandleEcRepaint
= FALSE
;
5097 else if (lEvCode
== EC_CLOCK_CHANGED
)
5098 This
->HandleEcClockChanged
= FALSE
;
5105 static HRESULT WINAPI
MediaEvent_RestoreDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5107 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5109 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5111 if (lEvCode
== EC_COMPLETE
)
5112 This
->HandleEcComplete
= TRUE
;
5113 else if (lEvCode
== EC_REPAINT
)
5114 This
->HandleEcRepaint
= TRUE
;
5115 else if (lEvCode
== EC_CLOCK_CHANGED
)
5116 This
->HandleEcClockChanged
= TRUE
;
5123 static HRESULT WINAPI
MediaEvent_FreeEventParams(IMediaEventEx
*iface
, LONG lEvCode
,
5124 LONG_PTR lParam1
, LONG_PTR lParam2
)
5126 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5128 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This
, iface
, lEvCode
, lParam1
, lParam2
);
5133 /*** IMediaEventEx methods ***/
5134 static HRESULT WINAPI
MediaEvent_SetNotifyWindow(IMediaEventEx
*iface
, OAHWND hwnd
, LONG lMsg
,
5135 LONG_PTR lInstanceData
)
5137 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5139 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This
, iface
, hwnd
, lMsg
, lInstanceData
);
5141 This
->notif
.hWnd
= (HWND
)hwnd
;
5142 This
->notif
.msg
= lMsg
;
5143 This
->notif
.instance
= lInstanceData
;
5148 static HRESULT WINAPI
MediaEvent_SetNotifyFlags(IMediaEventEx
*iface
, LONG lNoNotifyFlags
)
5150 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5152 TRACE("(%p/%p)->(%d)\n", This
, iface
, lNoNotifyFlags
);
5154 if ((lNoNotifyFlags
!= 0) && (lNoNotifyFlags
!= 1))
5155 return E_INVALIDARG
;
5157 This
->notif
.disabled
= lNoNotifyFlags
;
5162 static HRESULT WINAPI
MediaEvent_GetNotifyFlags(IMediaEventEx
*iface
, LONG
*lplNoNotifyFlags
)
5164 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5166 TRACE("(%p/%p)->(%p)\n", This
, iface
, lplNoNotifyFlags
);
5168 if (!lplNoNotifyFlags
)
5171 *lplNoNotifyFlags
= This
->notif
.disabled
;
5177 static const IMediaEventExVtbl IMediaEventEx_VTable
=
5179 MediaEvent_QueryInterface
,
5182 MediaEvent_GetTypeInfoCount
,
5183 MediaEvent_GetTypeInfo
,
5184 MediaEvent_GetIDsOfNames
,
5186 MediaEvent_GetEventHandle
,
5187 MediaEvent_GetEvent
,
5188 MediaEvent_WaitForCompletion
,
5189 MediaEvent_CancelDefaultHandling
,
5190 MediaEvent_RestoreDefaultHandling
,
5191 MediaEvent_FreeEventParams
,
5192 MediaEvent_SetNotifyWindow
,
5193 MediaEvent_SetNotifyFlags
,
5194 MediaEvent_GetNotifyFlags
5198 static inline IFilterGraphImpl
*impl_from_IMediaFilter(IMediaFilter
*iface
)
5200 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaFilter_iface
);
5203 static HRESULT WINAPI
MediaFilter_QueryInterface(IMediaFilter
*iface
, REFIID riid
, void **ppv
)
5205 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5207 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5210 static ULONG WINAPI
MediaFilter_AddRef(IMediaFilter
*iface
)
5212 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5214 return IUnknown_AddRef(This
->outer_unk
);
5217 static ULONG WINAPI
MediaFilter_Release(IMediaFilter
*iface
)
5219 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5221 return IUnknown_Release(This
->outer_unk
);
5224 static HRESULT WINAPI
MediaFilter_GetClassID(IMediaFilter
*iface
, CLSID
* pClassID
)
5226 FIXME("(%p): stub\n", pClassID
);
5231 static HRESULT WINAPI
MediaFilter_Stop(IMediaFilter
*iface
)
5233 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5235 return MediaControl_Stop(&This
->IMediaControl_iface
);
5238 static HRESULT WINAPI
MediaFilter_Pause(IMediaFilter
*iface
)
5240 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5242 return MediaControl_Pause(&This
->IMediaControl_iface
);
5245 static HRESULT WINAPI
MediaFilter_Run(IMediaFilter
*iface
, REFERENCE_TIME tStart
)
5247 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5250 FIXME("Run called with non-null tStart: %x%08x\n",
5251 (int)(tStart
>>32), (int)tStart
);
5253 return MediaControl_Run(&This
->IMediaControl_iface
);
5256 static HRESULT WINAPI
MediaFilter_GetState(IMediaFilter
*iface
, DWORD dwMsTimeout
,
5257 FILTER_STATE
*pState
)
5259 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5261 return MediaControl_GetState(&This
->IMediaControl_iface
, dwMsTimeout
, (OAFilterState
*)pState
);
5264 static HRESULT WINAPI
MediaFilter_SetSyncSource(IMediaFilter
*iface
, IReferenceClock
*pClock
)
5266 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5270 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClock
);
5272 EnterCriticalSection(&This
->cs
);
5274 for (i
= 0;i
< This
->nFilters
;i
++)
5276 hr
= IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], pClock
);
5284 IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], This
->refClock
);
5289 IReferenceClock_Release(This
->refClock
);
5290 This
->refClock
= pClock
;
5292 IReferenceClock_AddRef(This
->refClock
);
5293 This
->defaultclock
= FALSE
;
5295 if (This
->HandleEcClockChanged
)
5297 IMediaEventSink
*pEventSink
;
5300 eshr
= IMediaFilter_QueryInterface(iface
, &IID_IMediaEventSink
, (void **)&pEventSink
);
5301 if (SUCCEEDED(eshr
))
5303 IMediaEventSink_Notify(pEventSink
, EC_CLOCK_CHANGED
, 0, 0);
5304 IMediaEventSink_Release(pEventSink
);
5309 LeaveCriticalSection(&This
->cs
);
5314 static HRESULT WINAPI
MediaFilter_GetSyncSource(IMediaFilter
*iface
, IReferenceClock
**ppClock
)
5316 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5318 TRACE("(%p/%p)->(%p)\n", iface
, This
, ppClock
);
5323 EnterCriticalSection(&This
->cs
);
5325 *ppClock
= This
->refClock
;
5327 IReferenceClock_AddRef(*ppClock
);
5329 LeaveCriticalSection(&This
->cs
);
5334 static const IMediaFilterVtbl IMediaFilter_VTable
=
5336 MediaFilter_QueryInterface
,
5338 MediaFilter_Release
,
5339 MediaFilter_GetClassID
,
5343 MediaFilter_GetState
,
5344 MediaFilter_SetSyncSource
,
5345 MediaFilter_GetSyncSource
5348 static inline IFilterGraphImpl
*impl_from_IMediaEventSink(IMediaEventSink
*iface
)
5350 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventSink_iface
);
5353 static HRESULT WINAPI
MediaEventSink_QueryInterface(IMediaEventSink
*iface
, REFIID riid
, void **ppv
)
5355 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5357 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5360 static ULONG WINAPI
MediaEventSink_AddRef(IMediaEventSink
*iface
)
5362 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5364 return IUnknown_AddRef(This
->outer_unk
);
5367 static ULONG WINAPI
MediaEventSink_Release(IMediaEventSink
*iface
)
5369 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5371 return IUnknown_Release(This
->outer_unk
);
5374 static HRESULT WINAPI
MediaEventSink_Notify(IMediaEventSink
*iface
, LONG EventCode
,
5375 LONG_PTR EventParam1
, LONG_PTR EventParam2
)
5377 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5380 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This
, iface
, EventCode
, EventParam1
, EventParam2
);
5382 /* We need thread safety here, let's use the events queue's one */
5383 EnterCriticalSection(&This
->evqueue
.msg_crst
);
5385 if ((EventCode
== EC_COMPLETE
) && This
->HandleEcComplete
)
5387 TRACE("Process EC_COMPLETE notification\n");
5388 if (++This
->EcCompleteCount
== This
->nRenderers
)
5390 evt
.lEventCode
= EC_COMPLETE
;
5393 TRACE("Send EC_COMPLETE to app\n");
5394 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5395 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5397 TRACE("Send Window message\n");
5398 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5400 This
->CompletionStatus
= EC_COMPLETE
;
5401 SetEvent(This
->hEventCompletion
);
5404 else if ((EventCode
== EC_REPAINT
) && This
->HandleEcRepaint
)
5406 /* FIXME: Not handled yet */
5410 evt
.lEventCode
= EventCode
;
5411 evt
.lParam1
= EventParam1
;
5412 evt
.lParam2
= EventParam2
;
5413 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5414 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5415 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5418 LeaveCriticalSection(&This
->evqueue
.msg_crst
);
5422 static const IMediaEventSinkVtbl IMediaEventSink_VTable
=
5424 MediaEventSink_QueryInterface
,
5425 MediaEventSink_AddRef
,
5426 MediaEventSink_Release
,
5427 MediaEventSink_Notify
5430 static inline IFilterGraphImpl
*impl_from_IGraphConfig(IGraphConfig
*iface
)
5432 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphConfig_iface
);
5435 static HRESULT WINAPI
GraphConfig_QueryInterface(IGraphConfig
*iface
, REFIID riid
, void **ppv
)
5437 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5439 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5442 static ULONG WINAPI
GraphConfig_AddRef(IGraphConfig
*iface
)
5444 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5446 return IUnknown_AddRef(This
->outer_unk
);
5449 static ULONG WINAPI
GraphConfig_Release(IGraphConfig
*iface
)
5451 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5453 return IUnknown_Release(This
->outer_unk
);
5456 static HRESULT WINAPI
GraphConfig_Reconnect(IGraphConfig
*iface
, IPin
*pOutputPin
, IPin
*pInputPin
,
5457 const AM_MEDIA_TYPE
*pmtFirstConnection
, IBaseFilter
*pUsingFilter
, HANDLE hAbortEvent
,
5460 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5462 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This
, pOutputPin
, pInputPin
, pmtFirstConnection
, pUsingFilter
, hAbortEvent
, dwFlags
);
5467 static HRESULT WINAPI
GraphConfig_Reconfigure(IGraphConfig
*iface
, IGraphConfigCallback
*pCallback
,
5468 void *pvContext
, DWORD dwFlags
, HANDLE hAbortEvent
)
5470 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5473 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This
, pCallback
, pvContext
, dwFlags
, hAbortEvent
);
5476 FIXME("The parameter hAbortEvent is not handled!\n");
5478 EnterCriticalSection(&This
->cs
);
5480 hr
= IGraphConfigCallback_Reconfigure(pCallback
, pvContext
, dwFlags
);
5482 LeaveCriticalSection(&This
->cs
);
5487 static HRESULT WINAPI
GraphConfig_AddFilterToCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5489 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5491 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5496 static HRESULT WINAPI
GraphConfig_EnumCacheFilter(IGraphConfig
*iface
, IEnumFilters
**pEnum
)
5498 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5500 FIXME("(%p)->(%p): stub!\n", This
, pEnum
);
5505 static HRESULT WINAPI
GraphConfig_RemoveFilterFromCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5507 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5509 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5514 static HRESULT WINAPI
GraphConfig_GetStartTime(IGraphConfig
*iface
, REFERENCE_TIME
*prtStart
)
5516 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5518 FIXME("(%p)->(%p): stub!\n", This
, prtStart
);
5523 static HRESULT WINAPI
GraphConfig_PushThroughData(IGraphConfig
*iface
, IPin
*pOutputPin
,
5524 IPinConnection
*pConnection
, HANDLE hEventAbort
)
5526 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5528 FIXME("(%p)->(%p, %p, %p): stub!\n", This
, pOutputPin
, pConnection
, hEventAbort
);
5533 static HRESULT WINAPI
GraphConfig_SetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5536 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5538 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5543 static HRESULT WINAPI
GraphConfig_GetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5546 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5548 FIXME("(%p)->(%p, %p): stub!\n", This
, pFilter
, dwFlags
);
5553 static HRESULT WINAPI
GraphConfig_RemoveFilterEx(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5556 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5558 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5563 static const IGraphConfigVtbl IGraphConfig_VTable
=
5565 GraphConfig_QueryInterface
,
5567 GraphConfig_Release
,
5568 GraphConfig_Reconnect
,
5569 GraphConfig_Reconfigure
,
5570 GraphConfig_AddFilterToCache
,
5571 GraphConfig_EnumCacheFilter
,
5572 GraphConfig_RemoveFilterFromCache
,
5573 GraphConfig_GetStartTime
,
5574 GraphConfig_PushThroughData
,
5575 GraphConfig_SetFilterFlags
,
5576 GraphConfig_GetFilterFlags
,
5577 GraphConfig_RemoveFilterEx
5580 static inline IFilterGraphImpl
*impl_from_IGraphVersion(IGraphVersion
*iface
)
5582 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphVersion_iface
);
5585 static HRESULT WINAPI
GraphVersion_QueryInterface(IGraphVersion
*iface
, REFIID riid
, void **ppv
)
5587 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5589 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5592 static ULONG WINAPI
GraphVersion_AddRef(IGraphVersion
*iface
)
5594 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5596 return IUnknown_AddRef(This
->outer_unk
);
5599 static ULONG WINAPI
GraphVersion_Release(IGraphVersion
*iface
)
5601 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5603 return IUnknown_Release(This
->outer_unk
);
5606 static HRESULT WINAPI
GraphVersion_QueryVersion(IGraphVersion
*iface
, LONG
*pVersion
)
5608 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5613 TRACE("(%p)->(%p): current version %i\n", This
, pVersion
, This
->version
);
5615 *pVersion
= This
->version
;
5619 static const IGraphVersionVtbl IGraphVersion_VTable
=
5621 GraphVersion_QueryInterface
,
5622 GraphVersion_AddRef
,
5623 GraphVersion_Release
,
5624 GraphVersion_QueryVersion
,
5627 static const IUnknownVtbl IInner_VTable
=
5629 FilterGraphInner_QueryInterface
,
5630 FilterGraphInner_AddRef
,
5631 FilterGraphInner_Release
5634 /* This is the only function that actually creates a FilterGraph class... */
5635 HRESULT
FilterGraph_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5637 IFilterGraphImpl
*fimpl
;
5640 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
5644 fimpl
= CoTaskMemAlloc(sizeof(*fimpl
));
5645 fimpl
->defaultclock
= TRUE
;
5646 fimpl
->IUnknown_inner
.lpVtbl
= &IInner_VTable
;
5647 fimpl
->IFilterGraph2_iface
.lpVtbl
= &IFilterGraph2_VTable
;
5648 fimpl
->IMediaControl_iface
.lpVtbl
= &IMediaControl_VTable
;
5649 fimpl
->IMediaSeeking_iface
.lpVtbl
= &IMediaSeeking_VTable
;
5650 fimpl
->IBasicAudio_iface
.lpVtbl
= &IBasicAudio_VTable
;
5651 fimpl
->IBasicVideo2_iface
.lpVtbl
= &IBasicVideo_VTable
;
5652 fimpl
->IVideoWindow_iface
.lpVtbl
= &IVideoWindow_VTable
;
5653 fimpl
->IMediaEventEx_iface
.lpVtbl
= &IMediaEventEx_VTable
;
5654 fimpl
->IMediaFilter_iface
.lpVtbl
= &IMediaFilter_VTable
;
5655 fimpl
->IMediaEventSink_iface
.lpVtbl
= &IMediaEventSink_VTable
;
5656 fimpl
->IGraphConfig_iface
.lpVtbl
= &IGraphConfig_VTable
;
5657 fimpl
->IMediaPosition_iface
.lpVtbl
= &IMediaPosition_VTable
;
5658 fimpl
->IObjectWithSite_iface
.lpVtbl
= &IObjectWithSite_VTable
;
5659 fimpl
->IGraphVersion_iface
.lpVtbl
= &IGraphVersion_VTable
;
5661 fimpl
->ppFiltersInGraph
= NULL
;
5662 fimpl
->pFilterNames
= NULL
;
5663 fimpl
->nFilters
= 0;
5664 fimpl
->filterCapacity
= 0;
5665 fimpl
->nameIndex
= 1;
5666 fimpl
->refClock
= NULL
;
5667 fimpl
->hEventCompletion
= CreateEventW(0, TRUE
, FALSE
, 0);
5668 fimpl
->HandleEcComplete
= TRUE
;
5669 fimpl
->HandleEcRepaint
= TRUE
;
5670 fimpl
->HandleEcClockChanged
= TRUE
;
5671 fimpl
->notif
.hWnd
= 0;
5672 fimpl
->notif
.disabled
= FALSE
;
5673 fimpl
->nRenderers
= 0;
5674 fimpl
->EcCompleteCount
= 0;
5675 fimpl
->refClockProvider
= NULL
;
5676 fimpl
->state
= State_Stopped
;
5677 fimpl
->pSite
= NULL
;
5678 EventsQueue_Init(&fimpl
->evqueue
);
5679 InitializeCriticalSection(&fimpl
->cs
);
5680 fimpl
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IFilterGraphImpl.cs");
5681 fimpl
->nItfCacheEntries
= 0;
5682 memcpy(&fimpl
->timeformatseek
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
5683 fimpl
->start_time
= fimpl
->pause_time
= 0;
5684 fimpl
->stop_position
= -1;
5685 fimpl
->punkFilterMapper2
= NULL
;
5686 fimpl
->recursioncount
= 0;
5690 fimpl
->outer_unk
= pUnkOuter
;
5692 fimpl
->outer_unk
= &fimpl
->IUnknown_inner
;
5694 /* create Filtermapper aggregated. */
5695 hr
= CoCreateInstance(&CLSID_FilterMapper2
, fimpl
->outer_unk
, CLSCTX_INPROC_SERVER
,
5696 &IID_IUnknown
, (void**)&fimpl
->punkFilterMapper2
);
5699 hr
= IUnknown_QueryInterface(fimpl
->punkFilterMapper2
, &IID_IFilterMapper2
,
5700 (void**)&fimpl
->pFilterMapper2
);
5703 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5704 IUnknown_Release(fimpl
->outer_unk
);
5707 ERR("Unable to create filter mapper (%x)\n", hr
);
5708 if (fimpl
->punkFilterMapper2
) IUnknown_Release(fimpl
->punkFilterMapper2
);
5709 CloseHandle(fimpl
->hEventCompletion
);
5710 EventsQueue_Destroy(&fimpl
->evqueue
);
5711 fimpl
->cs
.DebugInfo
->Spare
[0] = 0;
5712 DeleteCriticalSection(&fimpl
->cs
);
5713 CoTaskMemFree(fimpl
);
5717 *ppObj
= &fimpl
->IUnknown_inner
;
5721 HRESULT
FilterGraphNoThread_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5723 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5724 return FilterGraph_create(pUnkOuter
, ppObj
);