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
21 #include "quartz_private.h"
24 HWND hWnd
; /* Target window */
25 UINT msg
; /* User window message */
26 LONG_PTR instance
; /* User data */
27 int disabled
; /* Disabled messages posting */
31 LONG lEventCode
; /* Event code */
32 LONG_PTR lParam1
; /* Param1 */
33 LONG_PTR lParam2
; /* Param2 */
36 /* messages ring implementation for queuing events (taken from winmm) */
37 #define EVENTS_RING_BUFFER_INCREMENT 64
43 CRITICAL_SECTION msg_crst
;
44 HANDLE msg_event
; /* Signaled for no empty queue */
47 static int EventsQueue_Init(EventsQueue
* omr
)
51 omr
->msg_event
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
52 omr
->ring_buffer_size
= EVENTS_RING_BUFFER_INCREMENT
;
53 omr
->messages
= CoTaskMemAlloc(omr
->ring_buffer_size
* sizeof(Event
));
54 ZeroMemory(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
56 InitializeCriticalSection(&omr
->msg_crst
);
57 omr
->msg_crst
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": EventsQueue.msg_crst");
61 static int EventsQueue_Destroy(EventsQueue
* omr
)
63 CloseHandle(omr
->msg_event
);
64 CoTaskMemFree(omr
->messages
);
65 omr
->msg_crst
.DebugInfo
->Spare
[0] = 0;
66 DeleteCriticalSection(&omr
->msg_crst
);
70 static BOOL
EventsQueue_PutEvent(EventsQueue
* omr
, const Event
* evt
)
72 EnterCriticalSection(&omr
->msg_crst
);
73 if (omr
->msg_toget
== ((omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
))
75 int old_ring_buffer_size
= omr
->ring_buffer_size
;
76 omr
->ring_buffer_size
+= EVENTS_RING_BUFFER_INCREMENT
;
77 TRACE("omr->ring_buffer_size=%d\n",omr
->ring_buffer_size
);
78 omr
->messages
= CoTaskMemRealloc(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
79 /* Now we need to rearrange the ring buffer so that the new
80 buffers just allocated are in between omr->msg_tosave and
83 if (omr
->msg_tosave
< omr
->msg_toget
)
85 memmove(&(omr
->messages
[omr
->msg_toget
+ EVENTS_RING_BUFFER_INCREMENT
]),
86 &(omr
->messages
[omr
->msg_toget
]),
87 sizeof(Event
)*(old_ring_buffer_size
- omr
->msg_toget
)
89 omr
->msg_toget
+= EVENTS_RING_BUFFER_INCREMENT
;
92 omr
->messages
[omr
->msg_tosave
] = *evt
;
93 SetEvent(omr
->msg_event
);
94 omr
->msg_tosave
= (omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
;
95 LeaveCriticalSection(&omr
->msg_crst
);
99 static BOOL
EventsQueue_GetEvent(EventsQueue
* omr
, Event
* evt
, LONG msTimeOut
)
101 if (WaitForSingleObject(omr
->msg_event
, msTimeOut
) != WAIT_OBJECT_0
)
104 EnterCriticalSection(&omr
->msg_crst
);
106 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
108 LeaveCriticalSection(&omr
->msg_crst
);
112 *evt
= omr
->messages
[omr
->msg_toget
];
113 omr
->msg_toget
= (omr
->msg_toget
+ 1) % omr
->ring_buffer_size
;
115 /* Mark the buffer as empty if needed */
116 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
117 ResetEvent(omr
->msg_event
);
119 LeaveCriticalSection(&omr
->msg_crst
);
123 #define MAX_ITF_CACHE_ENTRIES 3
124 typedef struct _ITF_CACHE_ENTRY
{
130 typedef struct _IFilterGraphImpl
{
131 IUnknown IUnknown_inner
;
132 IFilterGraph2 IFilterGraph2_iface
;
133 IMediaControl IMediaControl_iface
;
134 IMediaSeeking IMediaSeeking_iface
;
135 IBasicAudio IBasicAudio_iface
;
136 IBasicVideo2 IBasicVideo2_iface
;
137 IVideoWindow IVideoWindow_iface
;
138 IMediaEventEx IMediaEventEx_iface
;
139 IMediaFilter IMediaFilter_iface
;
140 IMediaEventSink IMediaEventSink_iface
;
141 IGraphConfig IGraphConfig_iface
;
142 IMediaPosition IMediaPosition_iface
;
143 IObjectWithSite IObjectWithSite_iface
;
144 IGraphVersion IGraphVersion_iface
;
145 /* IAMGraphStreams */
150 /* IRegisterServiceProvider */
151 /* IResourceMananger */
152 /* IServiceProvider */
153 /* IVideoFrameStep */
157 IUnknown
*punkFilterMapper2
;
158 IFilterMapper2
* pFilterMapper2
;
159 IBaseFilter
** ppFiltersInGraph
;
160 LPWSTR
* pFilterNames
;
164 IReferenceClock
*refClock
;
165 IBaseFilter
*refClockProvider
;
167 HANDLE hEventCompletion
;
168 int CompletionStatus
;
172 int HandleEcComplete
;
174 int HandleEcClockChanged
;
177 ITF_CACHE_ENTRY ItfCacheEntries
[MAX_ITF_CACHE_ENTRIES
];
178 int nItfCacheEntries
;
181 REFERENCE_TIME start_time
;
182 REFERENCE_TIME pause_time
;
188 static inline IFilterGraphImpl
*impl_from_IUnknown(IUnknown
*iface
)
190 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IUnknown_inner
);
193 static HRESULT WINAPI
FilterGraphInner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObj
)
195 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
196 TRACE("(%p)->(%s (%p), %p)\n", This
, debugstr_guid(riid
), riid
, ppvObj
);
198 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
199 *ppvObj
= &This
->IUnknown_inner
;
200 TRACE(" returning IUnknown interface (%p)\n", *ppvObj
);
201 } else if (IsEqualGUID(&IID_IFilterGraph
, riid
) ||
202 IsEqualGUID(&IID_IFilterGraph2
, riid
) ||
203 IsEqualGUID(&IID_IGraphBuilder
, riid
)) {
204 *ppvObj
= &This
->IFilterGraph2_iface
;
205 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj
);
206 } else if (IsEqualGUID(&IID_IMediaControl
, riid
)) {
207 *ppvObj
= &This
->IMediaControl_iface
;
208 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj
);
209 } else if (IsEqualGUID(&IID_IMediaSeeking
, riid
)) {
210 *ppvObj
= &This
->IMediaSeeking_iface
;
211 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj
);
212 } else if (IsEqualGUID(&IID_IBasicAudio
, riid
)) {
213 *ppvObj
= &This
->IBasicAudio_iface
;
214 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj
);
215 } else if (IsEqualGUID(&IID_IBasicVideo
, riid
) ||
216 IsEqualGUID(&IID_IBasicVideo2
, riid
)) {
217 *ppvObj
= &This
->IBasicVideo2_iface
;
218 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj
);
219 } else if (IsEqualGUID(&IID_IVideoWindow
, riid
)) {
220 *ppvObj
= &This
->IVideoWindow_iface
;
221 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj
);
222 } else if (IsEqualGUID(&IID_IMediaEvent
, riid
) ||
223 IsEqualGUID(&IID_IMediaEventEx
, riid
)) {
224 *ppvObj
= &This
->IMediaEventEx_iface
;
225 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj
);
226 } else if (IsEqualGUID(&IID_IMediaFilter
, riid
) ||
227 IsEqualGUID(&IID_IPersist
, riid
)) {
228 *ppvObj
= &This
->IMediaFilter_iface
;
229 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj
);
230 } else if (IsEqualGUID(&IID_IMediaEventSink
, riid
)) {
231 *ppvObj
= &This
->IMediaEventSink_iface
;
232 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj
);
233 } else if (IsEqualGUID(&IID_IGraphConfig
, riid
)) {
234 *ppvObj
= &This
->IGraphConfig_iface
;
235 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
236 } else if (IsEqualGUID(&IID_IMediaPosition
, riid
)) {
237 *ppvObj
= &This
->IMediaPosition_iface
;
238 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj
);
239 } else if (IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
240 *ppvObj
= &This
->IObjectWithSite_iface
;
241 TRACE(" returning IObjectWithSite interface (%p)\n", *ppvObj
);
242 } else if (IsEqualGUID(&IID_IFilterMapper
, riid
)) {
243 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj
);
244 return IUnknown_QueryInterface(This
->punkFilterMapper2
, riid
, ppvObj
);
245 } else if (IsEqualGUID(&IID_IFilterMapper2
, riid
)) {
246 *ppvObj
= This
->pFilterMapper2
;
247 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj
);
248 } else if (IsEqualGUID(&IID_IFilterMapper3
, riid
)) {
249 *ppvObj
= This
->pFilterMapper2
;
250 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj
);
251 } else if (IsEqualGUID(&IID_IGraphVersion
, riid
)) {
252 *ppvObj
= &This
->IGraphConfig_iface
;
253 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
256 FIXME("unknown interface %s\n", debugstr_guid(riid
));
257 return E_NOINTERFACE
;
260 IUnknown_AddRef((IUnknown
*)*ppvObj
);
264 static ULONG WINAPI
FilterGraphInner_AddRef(IUnknown
*iface
)
266 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
267 ULONG ref
= InterlockedIncrement(&This
->ref
);
269 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
274 static ULONG WINAPI
FilterGraphInner_Release(IUnknown
*iface
)
276 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
277 ULONG ref
= InterlockedDecrement(&This
->ref
);
279 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
284 This
->ref
= 1; /* guard against reentrancy (aggregation). */
286 IMediaControl_Stop(&This
->IMediaControl_iface
);
288 while (This
->nFilters
)
289 IFilterGraph2_RemoveFilter(&This
->IFilterGraph2_iface
, This
->ppFiltersInGraph
[0]);
292 IReferenceClock_Release(This
->refClock
);
294 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
296 if (This
->ItfCacheEntries
[i
].iface
)
297 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
300 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 */
301 IUnknown_AddRef(This
->outer_unk
);
302 IFilterMapper2_Release(This
->pFilterMapper2
);
303 IUnknown_Release(This
->punkFilterMapper2
);
305 if (This
->pSite
) IUnknown_Release(This
->pSite
);
307 CloseHandle(This
->hEventCompletion
);
308 EventsQueue_Destroy(&This
->evqueue
);
309 This
->cs
.DebugInfo
->Spare
[0] = 0;
310 DeleteCriticalSection(&This
->cs
);
311 CoTaskMemFree(This
->ppFiltersInGraph
);
312 CoTaskMemFree(This
->pFilterNames
);
318 static inline IFilterGraphImpl
*impl_from_IFilterGraph2(IFilterGraph2
*iface
)
320 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IFilterGraph2_iface
);
323 static HRESULT WINAPI
FilterGraph2_QueryInterface(IFilterGraph2
*iface
, REFIID riid
, void **ppvObj
)
325 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
327 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
329 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
332 static ULONG WINAPI
FilterGraph2_AddRef(IFilterGraph2
*iface
)
334 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
336 TRACE("(%p/%p)->()\n", This
, iface
);
338 return IUnknown_AddRef(This
->outer_unk
);
341 static ULONG WINAPI
FilterGraph2_Release(IFilterGraph2
*iface
)
343 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
345 TRACE("(%p/%p)->()\n", This
, iface
);
347 return IUnknown_Release(This
->outer_unk
);
350 /*** IFilterGraph methods ***/
351 static HRESULT WINAPI
FilterGraph2_AddFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
,
354 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
357 WCHAR
* wszFilterName
= NULL
;
358 BOOL duplicate_name
= FALSE
;
360 TRACE("(%p/%p)->(%p, %s (%p))\n", This
, iface
, pFilter
, debugstr_w(pName
), pName
);
365 wszFilterName
= CoTaskMemAlloc( (pName
? strlenW(pName
) + 6 : 5) * sizeof(WCHAR
) );
369 /* Check if name already exists */
370 for(i
= 0; i
< This
->nFilters
; i
++)
371 if (!strcmpW(This
->pFilterNames
[i
], pName
))
373 duplicate_name
= TRUE
;
378 /* If no name given or name already existing, generate one */
379 if (!pName
|| duplicate_name
)
381 static const WCHAR wszFmt1
[] = {'%','s',' ','%','0','4','d',0};
382 static const WCHAR wszFmt2
[] = {'%','0','4','d',0};
384 for (j
= 0; j
< 10000 ; j
++)
388 sprintfW(wszFilterName
, wszFmt1
, pName
, This
->nameIndex
);
390 sprintfW(wszFilterName
, wszFmt2
, This
->nameIndex
);
391 TRACE("Generated name %s\n", debugstr_w(wszFilterName
));
393 /* Check if the generated name already exists */
394 for(i
= 0; i
< This
->nFilters
; i
++)
395 if (!strcmpW(This
->pFilterNames
[i
], wszFilterName
))
398 /* Compute next index and exit if generated name is suitable */
399 if (This
->nameIndex
++ == 10000)
401 if (i
== This
->nFilters
)
404 /* Unable to find a suitable name */
407 CoTaskMemFree(wszFilterName
);
408 return VFW_E_DUPLICATE_NAME
;
412 memcpy(wszFilterName
, pName
, (strlenW(pName
) + 1) * sizeof(WCHAR
));
414 if (This
->nFilters
+ 1 > This
->filterCapacity
)
416 int newCapacity
= This
->filterCapacity
? 2 * This
->filterCapacity
: 1;
417 IBaseFilter
** ppNewFilters
= CoTaskMemAlloc(newCapacity
* sizeof(IBaseFilter
*));
418 LPWSTR
* pNewNames
= CoTaskMemAlloc(newCapacity
* sizeof(LPWSTR
));
419 memcpy(ppNewFilters
, This
->ppFiltersInGraph
, This
->nFilters
* sizeof(IBaseFilter
*));
420 memcpy(pNewNames
, This
->pFilterNames
, This
->nFilters
* sizeof(LPWSTR
));
421 if (This
->filterCapacity
)
423 CoTaskMemFree(This
->ppFiltersInGraph
);
424 CoTaskMemFree(This
->pFilterNames
);
426 This
->ppFiltersInGraph
= ppNewFilters
;
427 This
->pFilterNames
= pNewNames
;
428 This
->filterCapacity
= newCapacity
;
431 hr
= IBaseFilter_JoinFilterGraph(pFilter
, (IFilterGraph
*)&This
->IFilterGraph2_iface
, wszFilterName
);
435 IBaseFilter_AddRef(pFilter
);
436 This
->ppFiltersInGraph
[This
->nFilters
] = pFilter
;
437 This
->pFilterNames
[This
->nFilters
] = wszFilterName
;
440 IBaseFilter_SetSyncSource(pFilter
, This
->refClock
);
443 CoTaskMemFree(wszFilterName
);
445 if (SUCCEEDED(hr
) && duplicate_name
)
446 return VFW_S_DUPLICATE_NAME
;
451 static HRESULT WINAPI
FilterGraph2_RemoveFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
)
453 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
457 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFilter
);
459 /* FIXME: check graph is stopped */
461 for (i
= 0; i
< This
->nFilters
; i
++)
463 if (This
->ppFiltersInGraph
[i
] == pFilter
)
465 IEnumPins
*penumpins
= NULL
;
468 if (This
->defaultclock
&& This
->refClockProvider
== pFilter
)
470 IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, NULL
);
471 This
->defaultclock
= TRUE
;
474 TRACE("Removing filter %s\n", debugstr_w(This
->pFilterNames
[i
]));
475 IBaseFilter_GetState(pFilter
, 0, &state
);
476 if (state
== State_Running
)
477 IBaseFilter_Pause(pFilter
);
478 if (state
!= State_Stopped
)
479 IBaseFilter_Stop(pFilter
);
481 hr
= IBaseFilter_EnumPins(pFilter
, &penumpins
);
484 while(IEnumPins_Next(penumpins
, 1, &ppin
, NULL
) == S_OK
)
488 IPin_ConnectedTo(ppin
, &victim
);
491 h
= IPin_Disconnect(victim
);
492 TRACE("Disconnect other side: %08x\n", h
);
493 if (h
== VFW_E_NOT_STOPPED
)
496 IPin_QueryPinInfo(victim
, &pinfo
);
498 IBaseFilter_GetState(pinfo
.pFilter
, 0, &state
);
499 if (state
== State_Running
)
500 IBaseFilter_Pause(pinfo
.pFilter
);
501 IBaseFilter_Stop(pinfo
.pFilter
);
502 IBaseFilter_Release(pinfo
.pFilter
);
503 h
= IPin_Disconnect(victim
);
504 TRACE("Disconnect retry: %08x\n", h
);
506 IPin_Release(victim
);
508 h
= IPin_Disconnect(ppin
);
509 TRACE("Disconnect 2: %08x\n", h
);
513 IEnumPins_Release(penumpins
);
516 hr
= IBaseFilter_JoinFilterGraph(pFilter
, NULL
, This
->pFilterNames
[i
]);
519 IBaseFilter_SetSyncSource(pFilter
, NULL
);
520 IBaseFilter_Release(pFilter
);
521 CoTaskMemFree(This
->pFilterNames
[i
]);
522 memmove(This
->ppFiltersInGraph
+i
, This
->ppFiltersInGraph
+i
+1, sizeof(IBaseFilter
*)*(This
->nFilters
- 1 - i
));
523 memmove(This
->pFilterNames
+i
, This
->pFilterNames
+i
+1, sizeof(LPWSTR
)*(This
->nFilters
- 1 - i
));
526 /* Invalidate interfaces in the cache */
527 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
528 if (pFilter
== This
->ItfCacheEntries
[i
].filter
)
530 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
531 This
->ItfCacheEntries
[i
].iface
= NULL
;
532 This
->ItfCacheEntries
[i
].filter
= NULL
;
540 return hr
; /* FIXME: check this error code */
543 static HRESULT WINAPI
FilterGraph2_EnumFilters(IFilterGraph2
*iface
, IEnumFilters
**ppEnum
)
545 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
547 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppEnum
);
549 return IEnumFiltersImpl_Construct(&This
->IGraphVersion_iface
, &This
->ppFiltersInGraph
, &This
->nFilters
, ppEnum
);
552 static HRESULT WINAPI
FilterGraph2_FindFilterByName(IFilterGraph2
*iface
, LPCWSTR pName
,
553 IBaseFilter
**ppFilter
)
555 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
558 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_w(pName
), pName
, ppFilter
);
563 for (i
= 0; i
< This
->nFilters
; i
++)
565 if (!strcmpW(pName
, This
->pFilterNames
[i
]))
567 *ppFilter
= This
->ppFiltersInGraph
[i
];
568 IBaseFilter_AddRef(*ppFilter
);
574 return VFW_E_NOT_FOUND
;
577 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
578 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
580 static HRESULT
CheckCircularConnection(IFilterGraphImpl
*This
, IPin
*out
, IPin
*in
)
584 PIN_INFO info_out
, info_in
;
586 hr
= IPin_QueryPinInfo(out
, &info_out
);
589 if (info_out
.dir
!= PINDIR_OUTPUT
)
591 IBaseFilter_Release(info_out
.pFilter
);
595 hr
= IPin_QueryPinInfo(in
, &info_in
);
597 IBaseFilter_Release(info_in
.pFilter
);
600 if (info_in
.dir
!= PINDIR_INPUT
)
606 if (info_out
.pFilter
== info_in
.pFilter
)
607 hr
= VFW_E_CIRCULAR_GRAPH
;
613 hr
= IBaseFilter_EnumPins(info_out
.pFilter
, &enumpins
);
617 IEnumPins_Reset(enumpins
);
618 while ((hr
= IEnumPins_Next(enumpins
, 1, &test
, NULL
)) == S_OK
)
620 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
621 IPin_QueryDirection(test
, &dir
);
622 if (dir
== PINDIR_INPUT
)
625 IPin_ConnectedTo(test
, &victim
);
628 hr
= CheckCircularConnection(This
, victim
, in
);
629 IPin_Release(victim
);
639 IEnumPins_Release(enumpins
);
643 IBaseFilter_Release(info_out
.pFilter
);
645 ERR("Checking filtergraph returned %08x, something's not right!\n", hr
);
648 /* Debugging filtergraphs not enabled */
654 /* NOTE: despite the implication, it doesn't matter which
655 * way round you put in the input and output pins */
656 static HRESULT WINAPI
FilterGraph2_ConnectDirect(IFilterGraph2
*iface
, IPin
*ppinIn
, IPin
*ppinOut
,
657 const AM_MEDIA_TYPE
*pmt
)
659 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
663 TRACE("(%p/%p)->(%p, %p, %p)\n", This
, iface
, ppinIn
, ppinOut
, pmt
);
665 /* FIXME: check pins are in graph */
667 if (TRACE_ON(quartz
))
671 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
675 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
676 IBaseFilter_Release(PinInfo
.pFilter
);
678 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
682 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
683 IBaseFilter_Release(PinInfo
.pFilter
);
686 hr
= IPin_QueryDirection(ppinIn
, &dir
);
689 if (dir
== PINDIR_INPUT
)
691 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
693 hr
= IPin_Connect(ppinOut
, ppinIn
, pmt
);
697 hr
= CheckCircularConnection(This
, ppinIn
, ppinOut
);
699 hr
= IPin_Connect(ppinIn
, ppinOut
, pmt
);
706 static HRESULT WINAPI
FilterGraph2_Reconnect(IFilterGraph2
*iface
, IPin
*ppin
)
708 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
709 IPin
*pConnectedTo
= NULL
;
711 PIN_DIRECTION pindir
;
713 IPin_QueryDirection(ppin
, &pindir
);
714 hr
= IPin_ConnectedTo(ppin
, &pConnectedTo
);
716 TRACE("Querying connected to failed: %x\n", hr
);
719 IPin_Disconnect(ppin
);
720 IPin_Disconnect(pConnectedTo
);
721 if (pindir
== PINDIR_INPUT
)
722 hr
= IPin_Connect(pConnectedTo
, ppin
, NULL
);
724 hr
= IPin_Connect(ppin
, pConnectedTo
, NULL
);
725 IPin_Release(pConnectedTo
);
727 WARN("Reconnecting pins failed, pins are not connected now..\n");
728 TRACE("(%p->%p) -- %p %p -> %x\n", iface
, This
, ppin
, pConnectedTo
, hr
);
732 static HRESULT WINAPI
FilterGraph2_Disconnect(IFilterGraph2
*iface
, IPin
*ppin
)
734 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
736 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppin
);
741 return IPin_Disconnect(ppin
);
744 static HRESULT WINAPI
FilterGraph2_SetDefaultSyncSource(IFilterGraph2
*iface
)
746 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
747 IReferenceClock
*pClock
= NULL
;
751 TRACE("(%p/%p)->() live sources not handled properly!\n", iface
, This
);
753 EnterCriticalSection(&This
->cs
);
755 for (i
= 0; i
< This
->nFilters
; ++i
)
758 IAMFilterMiscFlags
*flags
= NULL
;
759 IBaseFilter_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IAMFilterMiscFlags
, (void**)&flags
);
762 miscflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
763 IAMFilterMiscFlags_Release(flags
);
764 if (miscflags
== AM_FILTER_MISC_FLAGS_IS_RENDERER
)
765 IBaseFilter_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IReferenceClock
, (void**)&pClock
);
772 hr
= CoCreateInstance(&CLSID_SystemClock
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IReferenceClock
, (LPVOID
*)&pClock
);
773 This
->refClockProvider
= NULL
;
776 This
->refClockProvider
= This
->ppFiltersInGraph
[i
];
780 hr
= IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, pClock
);
781 This
->defaultclock
= TRUE
;
782 IReferenceClock_Release(pClock
);
784 LeaveCriticalSection(&This
->cs
);
789 static HRESULT
GetFilterInfo(IMoniker
* pMoniker
, VARIANT
* pvar
)
791 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
792 IPropertyBag
* pPropBagCat
= NULL
;
797 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
800 hr
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, pvar
, NULL
);
803 TRACE("Moniker = %s\n", debugstr_w(V_BSTR(pvar
)));
806 IPropertyBag_Release(pPropBagCat
);
811 static HRESULT
GetInternalConnections(IBaseFilter
* pfilter
, IPin
* pinputpin
, IPin
*** pppins
, ULONG
* pnb
)
816 TRACE("(%p, %p, %p, %p)\n", pfilter
, pinputpin
, pppins
, pnb
);
817 hr
= IPin_QueryInternalConnections(pinputpin
, NULL
, &nb
);
820 } else if (hr
== S_FALSE
) {
821 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*nb
);
822 hr
= IPin_QueryInternalConnections(pinputpin
, *pppins
, &nb
);
824 WARN("Error (%x)\n", hr
);
826 } else if (hr
== E_NOTIMPL
) {
827 /* Input connected to all outputs */
828 IEnumPins
* penumpins
;
831 TRACE("E_NOTIMPL\n");
832 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
834 WARN("filter Enumpins failed (%x)\n", hr
);
838 /* Count output pins */
839 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
840 PIN_DIRECTION pindir
;
841 IPin_QueryDirection(ppin
, &pindir
);
842 if (pindir
== PINDIR_OUTPUT
)
846 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*i
);
847 /* Retrieve output pins */
848 IEnumPins_Reset(penumpins
);
850 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
851 PIN_DIRECTION pindir
;
852 IPin_QueryDirection(ppin
, &pindir
);
853 if (pindir
== PINDIR_OUTPUT
)
854 (*pppins
)[i
++] = ppin
;
858 IEnumPins_Release(penumpins
);
861 WARN("Next failed (%x)\n", hr
);
864 } else if (FAILED(hr
)) {
865 WARN("Cannot get internal connection (%x)\n", hr
);
873 /*** IGraphBuilder methods ***/
874 static HRESULT WINAPI
FilterGraph2_Connect(IFilterGraph2
*iface
, IPin
*ppinOut
, IPin
*ppinIn
)
876 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
878 AM_MEDIA_TYPE
* mt
= NULL
;
879 IEnumMediaTypes
* penummt
= NULL
;
881 IEnumPins
* penumpins
;
882 IEnumMoniker
* pEnumMoniker
;
892 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, ppinOut
, ppinIn
);
894 if (TRACE_ON(quartz
))
896 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
900 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
901 IBaseFilter_Release(PinInfo
.pFilter
);
903 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
907 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
908 IBaseFilter_Release(PinInfo
.pFilter
);
911 EnterCriticalSection(&This
->cs
);
912 ++This
->recursioncount
;
913 if (This
->recursioncount
>= 5)
915 WARN("Recursion count has reached %d\n", This
->recursioncount
);
916 hr
= VFW_E_CANNOT_CONNECT
;
920 hr
= IPin_QueryDirection(ppinOut
, &dir
);
924 if (dir
== PINDIR_INPUT
)
933 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
937 /* Try direct connection first */
938 hr
= IPin_Connect(ppinOut
, ppinIn
, NULL
);
942 TRACE("Direct connection failed, trying to render using extra filters\n");
944 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
948 hr
= IBaseFilter_GetClassID(PinInfo
.pFilter
, &FilterCLSID
);
949 IBaseFilter_Release(PinInfo
.pFilter
);
953 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
954 * filter to the minor mediatype of input pin of the renderer */
955 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
958 WARN("EnumMediaTypes (%x)\n", hr
);
962 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
964 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
970 WARN("No media type found!\n");
971 hr
= VFW_E_INVALIDMEDIATYPE
;
974 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
975 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
977 /* Try to find a suitable filter that can connect to the pin to render */
978 tab
[0] = mt
->majortype
;
979 tab
[1] = mt
->subtype
;
980 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
982 WARN("Unable to enum filters (%x)\n", hr
);
986 hr
= VFW_E_CANNOT_RENDER
;
987 while(IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
992 IPin
* ppinfilter
= NULL
;
993 IBaseFilter
* pfilter
= NULL
;
994 IAMGraphBuilderCallback
*callback
= NULL
;
996 hr
= GetFilterInfo(pMoniker
, &var
);
998 WARN("Unable to retrieve filter info (%x)\n", hr
);
1002 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1003 IMoniker_Release(pMoniker
);
1005 WARN("Unable to create filter (%x), trying next one\n", hr
);
1009 hr
= IBaseFilter_GetClassID(pfilter
, &clsid
);
1012 IBaseFilter_Release(pfilter
);
1016 if (IsEqualGUID(&clsid
, &FilterCLSID
)) {
1017 /* Skip filter (same as the one the output pin belongs to) */
1018 IBaseFilter_Release(pfilter
);
1024 IUnknown_QueryInterface(This
->pSite
, &IID_IAMGraphBuilderCallback
, (LPVOID
*)&callback
);
1028 rc
= IAMGraphBuilderCallback_SelectedFilter(callback
, pMoniker
);
1031 TRACE("Filter rejected by IAMGraphBuilderCallback_SelectedFilter\n");
1032 IAMGraphBuilderCallback_Release(callback
);
1041 rc
= IAMGraphBuilderCallback_CreatedFilter(callback
, pfilter
);
1042 IAMGraphBuilderCallback_Release(callback
);
1045 IBaseFilter_Release(pfilter
);
1047 TRACE("Filter rejected by IAMGraphBuilderCallback_CreatedFilter\n");
1052 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1054 WARN("Unable to add filter (%x)\n", hr
);
1055 IBaseFilter_Release(pfilter
);
1062 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1064 WARN("Enumpins (%x)\n", hr
);
1068 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1069 IEnumPins_Release(penumpins
);
1072 WARN("Obtaining next pin: (%x)\n", hr
);
1076 WARN("Cannot use this filter: no pins\n");
1080 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1082 TRACE("Cannot connect to filter (%x), trying next one\n", hr
);
1085 TRACE("Successfully connected to filter, follow chain...\n");
1087 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1088 hr
= GetInternalConnections(pfilter
, ppinfilter
, &ppins
, &nb
);
1090 if (SUCCEEDED(hr
)) {
1092 IPin_Disconnect(ppinfilter
);
1093 IPin_Disconnect(ppinOut
);
1096 TRACE("pins to consider: %d\n", nb
);
1097 for(i
= 0; i
< nb
; i
++)
1099 LPWSTR pinname
= NULL
;
1101 TRACE("Processing pin %u\n", i
);
1103 hr
= IPin_QueryId(ppins
[i
], &pinname
);
1106 if (pinname
[0] == '~')
1108 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname
));
1112 hr
= IFilterGraph2_Connect(iface
, ppins
[i
], ppinIn
);
1113 CoTaskMemFree(pinname
);
1117 TRACE("Cannot connect pin %p (%x)\n", ppinfilter
, hr
);
1119 IPin_Release(ppins
[i
]);
1120 if (SUCCEEDED(hr
)) break;
1122 while (++i
< nb
) IPin_Release(ppins
[i
]);
1123 CoTaskMemFree(ppins
);
1124 IPin_Release(ppinfilter
);
1125 IBaseFilter_Release(pfilter
);
1128 IPin_Disconnect(ppinfilter
);
1129 IPin_Disconnect(ppinOut
);
1130 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1138 if (ppinfilter
) IPin_Release(ppinfilter
);
1140 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1141 IBaseFilter_Release(pfilter
);
1143 while (++i
< nb
) IPin_Release(ppins
[i
]);
1144 CoTaskMemFree(ppins
);
1149 IEnumMediaTypes_Release(penummt
);
1151 DeleteMediaType(mt
);
1152 --This
->recursioncount
;
1153 LeaveCriticalSection(&This
->cs
);
1154 TRACE("--> %08x\n", hr
);
1155 return SUCCEEDED(hr
) ? S_OK
: hr
;
1158 static HRESULT
FilterGraph2_RenderRecurse(IFilterGraphImpl
*This
, IPin
*ppinOut
)
1160 /* This pin has been connected now, try to call render on all pins that aren't connected */
1163 IEnumPins
*enumpins
= NULL
;
1164 BOOL renderany
= FALSE
;
1165 BOOL renderall
= TRUE
;
1167 IPin_QueryPinInfo(ppinOut
, &info
);
1169 IBaseFilter_EnumPins(info
.pFilter
, &enumpins
);
1170 /* Don't need to hold a reference, IEnumPins does */
1171 IBaseFilter_Release(info
.pFilter
);
1173 IEnumPins_Reset(enumpins
);
1174 while (IEnumPins_Next(enumpins
, 1, &to
, NULL
) == S_OK
)
1176 PIN_DIRECTION dir
= PINDIR_INPUT
;
1178 IPin_QueryDirection(to
, &dir
);
1180 if (dir
== PINDIR_OUTPUT
)
1184 IPin_ConnectedTo(to
, &out
);
1188 hr
= IFilterGraph2_Render(&This
->IFilterGraph2_iface
, to
);
1201 IEnumPins_Release(enumpins
);
1207 return VFW_S_PARTIAL_RENDER
;
1209 return VFW_E_CANNOT_RENDER
;
1212 /* Ogg hates me if I create a direct rendering method
1214 * It can only connect to a pin properly once, so use a recursive method that does
1216 * +----+ --- (PIN 1) (Render is called on this pin)
1218 * +----+ --- (PIN 2)
1220 * Enumerate possible renderers that EXACTLY match the requested type
1222 * If none is available, try to add intermediate filters that can connect to the input pin
1223 * then call Render on that intermediate pin's output pins
1224 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1225 * and another filter that can connect to the input pin is tried
1226 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1227 * It's recursive, but fun!
1230 static HRESULT WINAPI
FilterGraph2_Render(IFilterGraph2
*iface
, IPin
*ppinOut
)
1232 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1233 IEnumMediaTypes
* penummt
;
1238 IEnumMoniker
* pEnumMoniker
;
1244 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppinOut
);
1246 if (TRACE_ON(quartz
))
1250 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
1254 TRACE("Filter owning pin => %p\n", PinInfo
.pFilter
);
1255 IBaseFilter_Release(PinInfo
.pFilter
);
1258 /* Try to find out if there is a renderer for the specified subtype already, and use that
1260 EnterCriticalSection(&This
->cs
);
1261 for (x
= 0; x
< This
->nFilters
; ++x
)
1263 IEnumPins
*enumpins
= NULL
;
1266 hr
= IBaseFilter_EnumPins(This
->ppFiltersInGraph
[x
], &enumpins
);
1268 if (FAILED(hr
) || !enumpins
)
1271 IEnumPins_Reset(enumpins
);
1272 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
1275 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
1277 IPin_QueryDirection(pin
, &dir
);
1278 if (dir
!= PINDIR_INPUT
)
1283 IPin_ConnectedTo(pin
, &to
);
1287 hr
= FilterGraph2_ConnectDirect(iface
, ppinOut
, pin
, NULL
);
1290 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut
, pin
, hr
);
1293 hr
= FilterGraph2_RenderRecurse(This
, pin
);
1296 IPin_Disconnect(ppinOut
);
1297 IPin_Disconnect(pin
);
1300 IEnumPins_Release(enumpins
);
1301 LeaveCriticalSection(&This
->cs
);
1304 WARN("Could not connect!\n");
1311 IEnumPins_Release(enumpins
);
1314 LeaveCriticalSection(&This
->cs
);
1316 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
1318 WARN("EnumMediaTypes (%x)\n", hr
);
1322 IEnumMediaTypes_Reset(penummt
);
1324 /* Looks like no existing renderer of the kind exists
1325 * Try adding new ones
1327 tab
[0] = tab
[1] = GUID_NULL
;
1328 while (SUCCEEDED(hr
))
1330 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1332 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1337 hr
= VFW_E_CANNOT_RENDER
;
1342 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1343 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1345 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1346 if (IsEqualIID(&tab
[0], &mt
->majortype
) && IsEqualIID(&tab
[1], &mt
->subtype
))
1348 DeleteMediaType(mt
);
1352 /* Try to find a suitable renderer with the same media type */
1353 tab
[0] = mt
->majortype
;
1354 tab
[1] = mt
->subtype
;
1355 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1358 WARN("Unable to enum filters (%x)\n", hr
);
1364 while (IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1368 IBaseFilter
* pfilter
= NULL
;
1369 IEnumPins
* penumpins
= NULL
;
1372 hr
= GetFilterInfo(pMoniker
, &var
);
1374 WARN("Unable to retrieve filter info (%x)\n", hr
);
1378 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1379 IMoniker_Release(pMoniker
);
1382 WARN("Unable to create filter (%x), trying next one\n", hr
);
1386 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1388 WARN("Unable to add filter (%x)\n", hr
);
1389 IBaseFilter_Release(pfilter
);
1394 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1396 WARN("Splitter Enumpins (%x)\n", hr
);
1400 while ((hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
)) == S_OK
)
1410 hr
= IPin_QueryDirection(ppinfilter
, &dir
);
1412 IPin_Release(ppinfilter
);
1413 WARN("QueryDirection failed (%x)\n", hr
);
1416 if (dir
!= PINDIR_INPUT
) {
1417 IPin_Release(ppinfilter
);
1418 continue; /* Wrong direction */
1421 /* Connect the pin to the "Renderer" */
1422 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1423 IPin_Release(ppinfilter
);
1426 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_BSTR(&var
)), hr
);
1429 TRACE("Connected, recursing %s\n", debugstr_w(V_BSTR(&var
)));
1433 hr
= FilterGraph2_RenderRecurse(This
, ppinfilter
);
1435 WARN("Unable to connect recursively (%x)\n", hr
);
1438 IBaseFilter_Release(pfilter
);
1441 if (SUCCEEDED(hr
)) {
1442 IEnumPins_Release(penumpins
);
1443 break; /* out of IEnumMoniker_Next loop */
1446 /* IEnumPins_Next failed, all other failure case caught by goto error */
1447 WARN("IEnumPins_Next (%x)\n", hr
);
1453 IEnumPins_Release(penumpins
);
1455 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1456 IBaseFilter_Release(pfilter
);
1458 if (SUCCEEDED(hr
)) DebugBreak();
1461 IEnumMoniker_Release(pEnumMoniker
);
1463 DeleteMediaType(mt
);
1469 IEnumMediaTypes_Release(penummt
);
1473 static HRESULT WINAPI
FilterGraph2_RenderFile(IFilterGraph2
*iface
, LPCWSTR lpcwstrFile
,
1474 LPCWSTR lpcwstrPlayList
)
1476 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1477 static const WCHAR string
[] = {'R','e','a','d','e','r',0};
1478 IBaseFilter
* preader
= NULL
;
1479 IPin
* ppinreader
= NULL
;
1480 IEnumPins
* penumpins
= NULL
;
1482 BOOL partial
= FALSE
;
1485 TRACE("(%p/%p)->(%s, %s)\n", This
, iface
, debugstr_w(lpcwstrFile
), debugstr_w(lpcwstrPlayList
));
1487 if (lpcwstrPlayList
!= NULL
)
1488 return E_INVALIDARG
;
1490 hr
= IFilterGraph2_AddSourceFilter(iface
, lpcwstrFile
, string
, &preader
);
1495 hr
= IBaseFilter_EnumPins(preader
, &penumpins
);
1498 while (IEnumPins_Next(penumpins
, 1, &ppinreader
, NULL
) == S_OK
)
1502 IPin_QueryDirection(ppinreader
, &dir
);
1503 if (dir
== PINDIR_OUTPUT
)
1507 hr
= IFilterGraph2_Render(iface
, ppinreader
);
1508 TRACE("Render %08x\n", hr
);
1510 for (i
= 0; i
< This
->nFilters
; ++i
)
1511 TRACE("Filters in chain: %s\n", debugstr_w(This
->pFilterNames
[i
]));
1518 IPin_Release(ppinreader
);
1520 IEnumPins_Release(penumpins
);
1523 hr
= VFW_E_CANNOT_RENDER
;
1525 hr
= VFW_S_PARTIAL_RENDER
;
1529 IBaseFilter_Release(preader
);
1531 TRACE("--> %08x\n", hr
);
1535 static HRESULT
CreateFilterInstanceAndLoadFile(GUID
* clsid
, LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1537 IFileSourceFilter
*source
= NULL
;
1538 HRESULT hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1539 TRACE("CLSID: %s\n", debugstr_guid(clsid
));
1543 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&source
);
1546 IBaseFilter_Release(*filter
);
1550 /* Load the file in the file source filter */
1551 hr
= IFileSourceFilter_Load(source
, pszFileName
, NULL
);
1552 IFileSourceFilter_Release(source
);
1554 WARN("Load (%x)\n", hr
);
1555 IBaseFilter_Release(*filter
);
1562 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1563 static HRESULT
GetFileSourceFilter(LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1567 IAsyncReader
* pReader
= NULL
;
1568 IFileSourceFilter
* pSource
= NULL
;
1569 IPin
* pOutputPin
= NULL
;
1570 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
1572 /* Try to find a match without reading the file first */
1573 hr
= GetClassMediaFile(NULL
, pszFileName
, NULL
, NULL
, &clsid
);
1576 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1578 /* Now create a AyncReader instance, to check for signature bytes in the file */
1579 hr
= CoCreateInstance(&CLSID_AsyncReader
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1583 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&pSource
);
1586 IBaseFilter_Release(*filter
);
1590 hr
= IFileSourceFilter_Load(pSource
, pszFileName
, NULL
);
1591 IFileSourceFilter_Release(pSource
);
1594 IBaseFilter_Release(*filter
);
1598 hr
= IBaseFilter_FindPin(*filter
, wszOutputPinName
, &pOutputPin
);
1601 IBaseFilter_Release(*filter
);
1605 hr
= IPin_QueryInterface(pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
1606 IPin_Release(pOutputPin
);
1609 IBaseFilter_Release(*filter
);
1613 /* Try again find a match */
1614 hr
= GetClassMediaFile(pReader
, pszFileName
, NULL
, NULL
, &clsid
);
1615 IAsyncReader_Release(pReader
);
1619 /* Release the AsyncReader filter and create the matching one */
1620 IBaseFilter_Release(*filter
);
1621 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1624 /* Return the AsyncReader filter */
1628 static HRESULT WINAPI
FilterGraph2_AddSourceFilter(IFilterGraph2
*iface
, LPCWSTR lpcwstrFileName
,
1629 LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1631 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1633 IBaseFilter
* preader
;
1634 IFileSourceFilter
* pfile
= NULL
;
1638 TRACE("(%p/%p)->(%s, %s, %p)\n", This
, iface
, debugstr_w(lpcwstrFileName
), debugstr_w(lpcwstrFilterName
), ppFilter
);
1640 /* Try from file name first, then fall back to default asynchronous reader */
1641 hr
= GetFileSourceFilter(lpcwstrFileName
, &preader
);
1643 WARN("Unable to create file source filter (%x)\n", hr
);
1647 hr
= IFilterGraph2_AddFilter(iface
, preader
, lpcwstrFilterName
);
1649 WARN("Unable add filter (%x)\n", hr
);
1650 IBaseFilter_Release(preader
);
1654 hr
= IBaseFilter_QueryInterface(preader
, &IID_IFileSourceFilter
, (LPVOID
*)&pfile
);
1656 WARN("Unable to get IFileSourceInterface (%x)\n", hr
);
1660 /* The file has been already loaded */
1661 hr
= IFileSourceFilter_GetCurFile(pfile
, &filename
, &mt
);
1663 WARN("GetCurFile (%x)\n", hr
);
1667 TRACE("File %s\n", debugstr_w(filename
));
1668 TRACE("MajorType %s\n", debugstr_guid(&mt
.majortype
));
1669 TRACE("SubType %s\n", debugstr_guid(&mt
.subtype
));
1672 *ppFilter
= preader
;
1673 IFileSourceFilter_Release(pfile
);
1679 IFileSourceFilter_Release(pfile
);
1680 IFilterGraph2_RemoveFilter(iface
, preader
);
1681 IBaseFilter_Release(preader
);
1686 static HRESULT WINAPI
FilterGraph2_SetLogFile(IFilterGraph2
*iface
, DWORD_PTR hFile
)
1688 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1690 TRACE("(%p/%p)->(%08x): stub !!!\n", This
, iface
, (DWORD
) hFile
);
1695 static HRESULT WINAPI
FilterGraph2_Abort(IFilterGraph2
*iface
)
1697 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1699 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1704 static HRESULT WINAPI
FilterGraph2_ShouldOperationContinue(IFilterGraph2
*iface
)
1706 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1708 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1713 /*** IFilterGraph2 methods ***/
1714 static HRESULT WINAPI
FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2
*iface
,
1715 IMoniker
*pMoniker
, IBindCtx
*pCtx
, LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1717 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1719 IBaseFilter
* pfilter
;
1721 TRACE("(%p/%p)->(%p %p %s %p)\n", This
, iface
, pMoniker
, pCtx
, debugstr_w(lpcwstrFilterName
), ppFilter
);
1723 hr
= IMoniker_BindToObject(pMoniker
, pCtx
, NULL
, &IID_IBaseFilter
, (void**)&pfilter
);
1725 WARN("Unable to bind moniker to filter object (%x)\n", hr
);
1729 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, lpcwstrFilterName
);
1731 WARN("Unable to add filter (%x)\n", hr
);
1732 IBaseFilter_Release(pfilter
);
1737 *ppFilter
= pfilter
;
1738 else IBaseFilter_Release(pfilter
);
1743 static HRESULT WINAPI
FilterGraph2_ReconnectEx(IFilterGraph2
*iface
, IPin
*ppin
,
1744 const AM_MEDIA_TYPE
*pmt
)
1746 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1748 TRACE("(%p/%p)->(%p %p): stub !!!\n", This
, iface
, ppin
, pmt
);
1753 static HRESULT WINAPI
FilterGraph2_RenderEx(IFilterGraph2
*iface
, IPin
*pPinOut
, DWORD dwFlags
,
1756 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1758 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This
, iface
, pPinOut
, dwFlags
, pvContext
);
1764 static const IFilterGraph2Vtbl IFilterGraph2_VTable
=
1766 FilterGraph2_QueryInterface
,
1767 FilterGraph2_AddRef
,
1768 FilterGraph2_Release
,
1769 FilterGraph2_AddFilter
,
1770 FilterGraph2_RemoveFilter
,
1771 FilterGraph2_EnumFilters
,
1772 FilterGraph2_FindFilterByName
,
1773 FilterGraph2_ConnectDirect
,
1774 FilterGraph2_Reconnect
,
1775 FilterGraph2_Disconnect
,
1776 FilterGraph2_SetDefaultSyncSource
,
1777 FilterGraph2_Connect
,
1778 FilterGraph2_Render
,
1779 FilterGraph2_RenderFile
,
1780 FilterGraph2_AddSourceFilter
,
1781 FilterGraph2_SetLogFile
,
1783 FilterGraph2_ShouldOperationContinue
,
1784 FilterGraph2_AddSourceFilterForMoniker
,
1785 FilterGraph2_ReconnectEx
,
1786 FilterGraph2_RenderEx
1789 static inline IFilterGraphImpl
*impl_from_IMediaControl(IMediaControl
*iface
)
1791 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaControl_iface
);
1794 static HRESULT WINAPI
MediaControl_QueryInterface(IMediaControl
*iface
, REFIID riid
, void **ppvObj
)
1796 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1798 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1800 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
1803 static ULONG WINAPI
MediaControl_AddRef(IMediaControl
*iface
)
1805 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1807 TRACE("(%p/%p)->()\n", This
, iface
);
1809 return IUnknown_AddRef(This
->outer_unk
);
1812 static ULONG WINAPI
MediaControl_Release(IMediaControl
*iface
)
1814 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1816 TRACE("(%p/%p)->()\n", This
, iface
);
1818 return IUnknown_Release(This
->outer_unk
);
1822 /*** IDispatch methods ***/
1823 static HRESULT WINAPI
MediaControl_GetTypeInfoCount(IMediaControl
*iface
, UINT
*pctinfo
)
1825 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1827 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
1832 static HRESULT WINAPI
MediaControl_GetTypeInfo(IMediaControl
*iface
, UINT iTInfo
, LCID lcid
,
1833 ITypeInfo
**ppTInfo
)
1835 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1837 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
1842 static HRESULT WINAPI
MediaControl_GetIDsOfNames(IMediaControl
*iface
, REFIID riid
,
1843 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1845 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1847 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1852 static HRESULT WINAPI
MediaControl_Invoke(IMediaControl
*iface
, DISPID dispIdMember
, REFIID riid
,
1853 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
1856 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1858 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
);
1863 typedef HRESULT(WINAPI
*fnFoundFilter
)(IBaseFilter
*, DWORD_PTR data
);
1865 static HRESULT
ExploreGraph(IFilterGraphImpl
* pGraph
, IPin
* pOutputPin
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1874 TRACE("%p %p\n", pGraph
, pOutputPin
);
1875 PinInfo
.pFilter
= NULL
;
1877 hr
= IPin_ConnectedTo(pOutputPin
, &pInputPin
);
1881 hr
= IPin_QueryPinInfo(pInputPin
, &PinInfo
);
1883 hr
= GetInternalConnections(PinInfo
.pFilter
, pInputPin
, &ppPins
, &nb
);
1884 IPin_Release(pInputPin
);
1891 TRACE("Reached a renderer\n");
1892 /* Count renderers for end of stream notification */
1893 pGraph
->nRenderers
++;
1897 for(i
= 0; i
< nb
; i
++)
1899 /* Explore the graph downstream from this pin
1900 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1901 * several input pins are connected to the same output (a MUX for instance). */
1902 ExploreGraph(pGraph
, ppPins
[i
], FoundFilter
, data
);
1903 IPin_Release(ppPins
[i
]);
1906 CoTaskMemFree(ppPins
);
1908 TRACE("Doing stuff with filter %p\n", PinInfo
.pFilter
);
1910 FoundFilter(PinInfo
.pFilter
, data
);
1913 if (PinInfo
.pFilter
) IBaseFilter_Release(PinInfo
.pFilter
);
1917 static HRESULT WINAPI
SendRun(IBaseFilter
*pFilter
, DWORD_PTR data
)
1919 REFERENCE_TIME time
= *(REFERENCE_TIME
*)data
;
1920 return IBaseFilter_Run(pFilter
, time
);
1923 static HRESULT WINAPI
SendPause(IBaseFilter
*pFilter
, DWORD_PTR data
)
1925 return IBaseFilter_Pause(pFilter
);
1928 static HRESULT WINAPI
SendStop(IBaseFilter
*pFilter
, DWORD_PTR data
)
1930 return IBaseFilter_Stop(pFilter
);
1933 static HRESULT WINAPI
SendGetState(IBaseFilter
*pFilter
, DWORD_PTR data
)
1936 DWORD time_end
= data
;
1937 DWORD time_now
= GetTickCount();
1940 if (time_end
== INFINITE
)
1944 else if (time_end
> time_now
)
1946 wait
= time_end
- time_now
;
1951 return IBaseFilter_GetState(pFilter
, wait
, &state
);
1955 static HRESULT
SendFilterMessage(IFilterGraphImpl
*This
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1958 IBaseFilter
* pfilter
;
1965 TRACE("(%p)->()\n", This
);
1967 /* Explorer the graph from source filters to renderers, determine renderers
1968 * number and run filters from renderers to source filters */
1969 This
->nRenderers
= 0;
1970 ResetEvent(This
->hEventCompletion
);
1972 for(i
= 0; i
< This
->nFilters
; i
++)
1975 pfilter
= This
->ppFiltersInGraph
[i
];
1976 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
1979 WARN("Enum pins failed %x\n", hr
);
1982 /* Check if it is a source filter */
1983 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1985 IPin_QueryDirection(pPin
, &dir
);
1987 if (dir
== PINDIR_INPUT
)
1995 TRACE("Found a source filter %p\n", pfilter
);
1996 IEnumPins_Reset(pEnum
);
1997 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1999 /* Explore the graph downstream from this pin */
2000 ExploreGraph(This
, pPin
, FoundFilter
, data
);
2003 FoundFilter(pfilter
, data
);
2005 IEnumPins_Release(pEnum
);
2011 /*** IMediaControl methods ***/
2012 static HRESULT WINAPI
MediaControl_Run(IMediaControl
*iface
)
2014 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2016 TRACE("(%p/%p)->()\n", This
, iface
);
2018 EnterCriticalSection(&This
->cs
);
2019 if (This
->state
== State_Running
)
2021 This
->EcCompleteCount
= 0;
2023 if (This
->defaultclock
&& !This
->refClock
)
2024 IFilterGraph2_SetDefaultSyncSource(&This
->IFilterGraph2_iface
);
2029 IReferenceClock_GetTime(This
->refClock
, &now
);
2030 if (This
->state
== State_Stopped
)
2031 This
->start_time
= now
+ 500000;
2032 else if (This
->pause_time
>= 0)
2033 This
->start_time
+= now
- This
->pause_time
;
2035 This
->start_time
= now
;
2037 else This
->start_time
= 0;
2039 SendFilterMessage(This
, SendRun
, (DWORD_PTR
)&This
->start_time
);
2040 This
->state
= State_Running
;
2042 LeaveCriticalSection(&This
->cs
);
2046 static HRESULT WINAPI
MediaControl_Pause(IMediaControl
*iface
)
2048 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2050 TRACE("(%p/%p)->()\n", This
, iface
);
2052 EnterCriticalSection(&This
->cs
);
2053 if (This
->state
== State_Paused
)
2056 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2057 IReferenceClock_GetTime(This
->refClock
, &This
->pause_time
);
2059 This
->pause_time
= -1;
2061 SendFilterMessage(This
, SendPause
, 0);
2062 This
->state
= State_Paused
;
2064 LeaveCriticalSection(&This
->cs
);
2068 static HRESULT WINAPI
MediaControl_Stop(IMediaControl
*iface
)
2070 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2072 TRACE("(%p/%p)->()\n", This
, iface
);
2074 if (This
->state
== State_Stopped
) return S_OK
;
2076 EnterCriticalSection(&This
->cs
);
2077 if (This
->state
== State_Running
) SendFilterMessage(This
, SendPause
, 0);
2078 SendFilterMessage(This
, SendStop
, 0);
2079 This
->state
= State_Stopped
;
2080 LeaveCriticalSection(&This
->cs
);
2084 static HRESULT WINAPI
MediaControl_GetState(IMediaControl
*iface
, LONG msTimeout
,
2087 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2090 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pfs
);
2095 EnterCriticalSection(&This
->cs
);
2100 end
= GetTickCount() + msTimeout
;
2102 else if (msTimeout
< 0)
2111 SendFilterMessage(This
, SendGetState
, end
);
2113 LeaveCriticalSection(&This
->cs
);
2118 static HRESULT WINAPI
MediaControl_RenderFile(IMediaControl
*iface
, BSTR strFilename
)
2120 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2122 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strFilename
), strFilename
);
2124 return IFilterGraph2_RenderFile(&This
->IFilterGraph2_iface
, strFilename
, NULL
);
2127 static HRESULT WINAPI
MediaControl_AddSourceFilter(IMediaControl
*iface
, BSTR strFilename
,
2130 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2132 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
, ppUnk
);
2137 static HRESULT WINAPI
MediaControl_get_FilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2139 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2141 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2146 static HRESULT WINAPI
MediaControl_get_RegFilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2148 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2150 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2155 static HRESULT WINAPI
MediaControl_StopWhenReady(IMediaControl
*iface
)
2157 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2159 FIXME("(%p/%p)->(): stub !!!\n", This
, iface
);
2165 static const IMediaControlVtbl IMediaControl_VTable
=
2167 MediaControl_QueryInterface
,
2168 MediaControl_AddRef
,
2169 MediaControl_Release
,
2170 MediaControl_GetTypeInfoCount
,
2171 MediaControl_GetTypeInfo
,
2172 MediaControl_GetIDsOfNames
,
2173 MediaControl_Invoke
,
2177 MediaControl_GetState
,
2178 MediaControl_RenderFile
,
2179 MediaControl_AddSourceFilter
,
2180 MediaControl_get_FilterCollection
,
2181 MediaControl_get_RegFilterCollection
,
2182 MediaControl_StopWhenReady
2185 static inline IFilterGraphImpl
*impl_from_IMediaSeeking(IMediaSeeking
*iface
)
2187 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaSeeking_iface
);
2190 static HRESULT WINAPI
MediaSeeking_QueryInterface(IMediaSeeking
*iface
, REFIID riid
, void **ppvObj
)
2192 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2194 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2196 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2199 static ULONG WINAPI
MediaSeeking_AddRef(IMediaSeeking
*iface
)
2201 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2203 TRACE("(%p/%p)->()\n", This
, iface
);
2205 return IUnknown_AddRef(This
->outer_unk
);
2208 static ULONG WINAPI
MediaSeeking_Release(IMediaSeeking
*iface
)
2210 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2212 TRACE("(%p/%p)->()\n", This
, iface
);
2214 return IUnknown_Release(This
->outer_unk
);
2217 typedef HRESULT (WINAPI
*fnFoundSeek
)(IFilterGraphImpl
*This
, IMediaSeeking
*, DWORD_PTR arg
);
2219 static HRESULT
all_renderers_seek(IFilterGraphImpl
*This
, fnFoundSeek FoundSeek
, DWORD_PTR arg
) {
2220 BOOL allnotimpl
= TRUE
;
2222 HRESULT hr
, hr_return
= S_OK
;
2224 TRACE("(%p)->(%p %08lx)\n", This
, FoundSeek
, arg
);
2225 /* Send a message to all renderers, they are responsible for broadcasting it further */
2227 for(i
= 0; i
< This
->nFilters
; i
++)
2229 IMediaSeeking
*seek
= NULL
;
2230 IBaseFilter
* pfilter
= This
->ppFiltersInGraph
[i
];
2231 IAMFilterMiscFlags
*flags
= NULL
;
2233 IBaseFilter_QueryInterface(pfilter
, &IID_IAMFilterMiscFlags
, (void**)&flags
);
2236 filterflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
2237 IAMFilterMiscFlags_Release(flags
);
2238 if (filterflags
!= AM_FILTER_MISC_FLAGS_IS_RENDERER
)
2241 IBaseFilter_QueryInterface(pfilter
, &IID_IMediaSeeking
, (void**)&seek
);
2244 hr
= FoundSeek(This
, seek
, arg
);
2245 IMediaSeeking_Release(seek
);
2246 if (hr_return
!= E_NOTIMPL
)
2248 if (hr_return
== S_OK
|| (FAILED(hr
) && hr
!= E_NOTIMPL
&& SUCCEEDED(hr_return
)))
2257 static HRESULT WINAPI
FoundCapabilities(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pcaps
)
2262 hr
= IMediaSeeking_GetCapabilities(seek
, &caps
);
2266 /* Only add common capabilities everything supports */
2267 *(DWORD
*)pcaps
&= caps
;
2272 /*** IMediaSeeking methods ***/
2273 static HRESULT WINAPI
MediaSeeking_GetCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2275 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2278 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2283 EnterCriticalSection(&This
->cs
);
2284 *pCapabilities
= 0xffffffff;
2286 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2287 LeaveCriticalSection(&This
->cs
);
2292 static HRESULT WINAPI
MediaSeeking_CheckCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2294 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2298 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2303 EnterCriticalSection(&This
->cs
);
2304 originalcaps
= *pCapabilities
;
2305 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2306 LeaveCriticalSection(&This
->cs
);
2311 if (!*pCapabilities
)
2313 if (*pCapabilities
!= originalcaps
)
2318 static HRESULT WINAPI
MediaSeeking_IsFormatSupported(IMediaSeeking
*iface
, const GUID
*pFormat
)
2320 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2325 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2327 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2329 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2336 static HRESULT WINAPI
MediaSeeking_QueryPreferredFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2338 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2343 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This
, iface
, pFormat
);
2344 memcpy(pFormat
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
2349 static HRESULT WINAPI
MediaSeeking_GetTimeFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2351 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2356 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2357 memcpy(pFormat
, &This
->timeformatseek
, sizeof(GUID
));
2362 static HRESULT WINAPI
MediaSeeking_IsUsingTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2364 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2366 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2370 if (memcmp(pFormat
, &This
->timeformatseek
, sizeof(GUID
)))
2376 static HRESULT WINAPI
MediaSeeking_SetTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2378 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2383 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2385 if (This
->state
!= State_Stopped
)
2386 return VFW_E_WRONG_STATE
;
2388 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2390 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2391 return E_INVALIDARG
;
2397 static HRESULT WINAPI
FoundDuration(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pduration
)
2400 LONGLONG duration
= 0, *pdur
= (LONGLONG
*)pduration
;
2402 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
2406 if (*pdur
< duration
)
2411 static HRESULT WINAPI
MediaSeeking_GetDuration(IMediaSeeking
*iface
, LONGLONG
*pDuration
)
2413 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2416 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDuration
);
2421 EnterCriticalSection(&This
->cs
);
2423 hr
= all_renderers_seek(This
, FoundDuration
, (DWORD_PTR
)pDuration
);
2424 LeaveCriticalSection(&This
->cs
);
2426 TRACE("--->%08x\n", hr
);
2430 static HRESULT WINAPI
MediaSeeking_ConvertTimeFormat(IMediaSeeking
*iface
, LONGLONG
*pTarget
,
2431 const GUID
*pTargetFormat
, LONGLONG Source
, const GUID
*pSourceFormat
)
2433 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2435 TRACE("(%p/%p)->(%p, %s, 0x%s, %s)\n", This
, iface
, pTarget
,
2436 debugstr_guid(pTargetFormat
), wine_dbgstr_longlong(Source
), debugstr_guid(pSourceFormat
));
2439 pSourceFormat
= &This
->timeformatseek
;
2441 if (IsEqualGUID(pTargetFormat
, pSourceFormat
))
2444 FIXME("conversion %s->%s not supported\n", debugstr_guid(pSourceFormat
), debugstr_guid(pTargetFormat
));
2450 LONGLONG
* current
, *stop
;
2451 DWORD curflags
, stopflags
;
2454 static HRESULT WINAPI
found_setposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2456 struct pos_args
*args
= (void*)pargs
;
2458 return IMediaSeeking_SetPositions(seek
, args
->current
, args
->curflags
, args
->stop
, args
->stopflags
);
2461 static HRESULT WINAPI
MediaSeeking_SetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2462 DWORD dwCurrentFlags
, LONGLONG
*pStop
, DWORD dwStopFlags
)
2464 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2467 struct pos_args args
;
2469 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This
, iface
, pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
2471 EnterCriticalSection(&This
->cs
);
2472 state
= This
->state
;
2473 TRACE("State: %s\n", state
== State_Running
? "Running" : (state
== State_Paused
? "Paused" : (state
== State_Stopped
? "Stopped" : "UNKNOWN")));
2475 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_AbsolutePositioning
&&
2476 (dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2477 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags
& 0x7);
2479 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2480 IMediaControl_Pause(&This
->IMediaControl_iface
);
2481 args
.current
= pCurrent
;
2483 args
.curflags
= dwCurrentFlags
;
2484 args
.stopflags
= dwStopFlags
;
2485 hr
= all_renderers_seek(This
, found_setposition
, (DWORD_PTR
)&args
);
2487 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2488 This
->pause_time
= This
->start_time
= -1;
2489 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2490 IMediaControl_Run(&This
->IMediaControl_iface
);
2491 LeaveCriticalSection(&This
->cs
);
2496 static HRESULT WINAPI
found_getposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2498 struct pos_args
*args
= (void*)pargs
;
2500 return IMediaSeeking_GetPositions(seek
, args
->current
, args
->stop
);
2503 static HRESULT WINAPI
MediaSeeking_GetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2506 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2507 struct pos_args args
;
2511 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pCurrent
, pStop
);
2513 args
.current
= pCurrent
;
2515 EnterCriticalSection(&This
->cs
);
2516 hr
= all_renderers_seek(This
, found_getposition
, (DWORD_PTR
)&args
);
2517 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2519 IReferenceClock_GetTime(This
->refClock
, &time
);
2521 time
-= This
->start_time
;
2523 if (This
->pause_time
> 0)
2524 time
+= This
->pause_time
;
2526 LeaveCriticalSection(&This
->cs
);
2531 static HRESULT WINAPI
MediaSeeking_GetCurrentPosition(IMediaSeeking
*iface
, LONGLONG
*pCurrent
)
2539 hr
= MediaSeeking_GetPositions(iface
, pCurrent
, &time
);
2541 TRACE("Time: %u.%03u\n", (DWORD
)(*pCurrent
/ 10000000), (DWORD
)((*pCurrent
/ 10000)%1000));
2546 static HRESULT WINAPI
MediaSeeking_GetStopPosition(IMediaSeeking
*iface
, LONGLONG
*pStop
)
2548 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2552 TRACE("(%p/%p)->(%p)\n", This
, iface
, pStop
);
2557 hr
= MediaSeeking_GetPositions(iface
, &time
, pStop
);
2562 static HRESULT WINAPI
MediaSeeking_GetAvailable(IMediaSeeking
*iface
, LONGLONG
*pEarliest
,
2565 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2567 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This
, iface
, pEarliest
, pLatest
);
2572 static HRESULT WINAPI
MediaSeeking_SetRate(IMediaSeeking
*iface
, double dRate
)
2574 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2576 FIXME("(%p/%p)->(%f): stub !!!\n", This
, iface
, dRate
);
2581 static HRESULT WINAPI
MediaSeeking_GetRate(IMediaSeeking
*iface
, double *pdRate
)
2583 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2585 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pdRate
);
2590 static HRESULT WINAPI
MediaSeeking_GetPreroll(IMediaSeeking
*iface
, LONGLONG
*pllPreroll
)
2592 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2594 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pllPreroll
);
2600 static const IMediaSeekingVtbl IMediaSeeking_VTable
=
2602 MediaSeeking_QueryInterface
,
2603 MediaSeeking_AddRef
,
2604 MediaSeeking_Release
,
2605 MediaSeeking_GetCapabilities
,
2606 MediaSeeking_CheckCapabilities
,
2607 MediaSeeking_IsFormatSupported
,
2608 MediaSeeking_QueryPreferredFormat
,
2609 MediaSeeking_GetTimeFormat
,
2610 MediaSeeking_IsUsingTimeFormat
,
2611 MediaSeeking_SetTimeFormat
,
2612 MediaSeeking_GetDuration
,
2613 MediaSeeking_GetStopPosition
,
2614 MediaSeeking_GetCurrentPosition
,
2615 MediaSeeking_ConvertTimeFormat
,
2616 MediaSeeking_SetPositions
,
2617 MediaSeeking_GetPositions
,
2618 MediaSeeking_GetAvailable
,
2619 MediaSeeking_SetRate
,
2620 MediaSeeking_GetRate
,
2621 MediaSeeking_GetPreroll
2624 static inline IFilterGraphImpl
*impl_from_IMediaPosition(IMediaPosition
*iface
)
2626 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaPosition_iface
);
2629 /*** IUnknown methods ***/
2630 static HRESULT WINAPI
MediaPosition_QueryInterface(IMediaPosition
* iface
, REFIID riid
, void** ppvObj
)
2632 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2634 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2636 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2639 static ULONG WINAPI
MediaPosition_AddRef(IMediaPosition
*iface
)
2641 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2643 TRACE("(%p/%p)->()\n", This
, iface
);
2645 return IUnknown_AddRef(This
->outer_unk
);
2648 static ULONG WINAPI
MediaPosition_Release(IMediaPosition
*iface
)
2650 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2652 TRACE("(%p/%p)->()\n", This
, iface
);
2654 return IUnknown_Release(This
->outer_unk
);
2657 /*** IDispatch methods ***/
2658 static HRESULT WINAPI
MediaPosition_GetTypeInfoCount(IMediaPosition
*iface
, UINT
* pctinfo
)
2660 FIXME("(%p) stub!\n", iface
);
2664 static HRESULT WINAPI
MediaPosition_GetTypeInfo(IMediaPosition
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2666 FIXME("(%p) stub!\n", iface
);
2670 static HRESULT WINAPI
MediaPosition_GetIDsOfNames(IMediaPosition
* iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2672 FIXME("(%p) stub!\n", iface
);
2676 static HRESULT WINAPI
MediaPosition_Invoke(IMediaPosition
* iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2678 FIXME("(%p) stub!\n", iface
);
2682 static HRESULT
ConvertFromREFTIME(IMediaSeeking
*seek
, REFTIME time_in
, LONGLONG
*time_out
)
2687 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2690 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2692 FIXME("Unsupported time format.\n");
2696 *time_out
= (LONGLONG
) (time_in
* 10000000); /* convert from 1 second intervals to 100 ns intervals */
2700 static HRESULT
ConvertToREFTIME(IMediaSeeking
*seek
, LONGLONG time_in
, REFTIME
*time_out
)
2705 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2708 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2710 FIXME("Unsupported time format.\n");
2714 *time_out
= (REFTIME
)time_in
/ 10000000; /* convert from 100 ns intervals to 1 second intervals */
2718 /*** IMediaPosition methods ***/
2719 static HRESULT WINAPI
MediaPosition_get_Duration(IMediaPosition
* iface
, REFTIME
*plength
)
2722 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2723 HRESULT hr
= IMediaSeeking_GetDuration(&This
->IMediaSeeking_iface
, &duration
);
2726 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, duration
, plength
);
2729 static HRESULT WINAPI
MediaPosition_put_CurrentPosition(IMediaPosition
* iface
, REFTIME llTime
)
2731 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2735 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2738 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, &reftime
,
2739 AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
2742 static HRESULT WINAPI
MediaPosition_get_CurrentPosition(IMediaPosition
* iface
, REFTIME
*pllTime
)
2744 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2748 hr
= IMediaSeeking_GetCurrentPosition(&This
->IMediaSeeking_iface
, &pos
);
2751 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2754 static HRESULT WINAPI
MediaPosition_get_StopTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2756 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2758 HRESULT hr
= IMediaSeeking_GetStopPosition(&This
->IMediaSeeking_iface
, &pos
);
2761 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2764 static HRESULT WINAPI
MediaPosition_put_StopTime(IMediaPosition
* iface
, REFTIME llTime
)
2766 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2770 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2773 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, NULL
, AM_SEEKING_NoPositioning
,
2774 &reftime
, AM_SEEKING_AbsolutePositioning
);
2777 static HRESULT WINAPI
MediaPosition_get_PrerollTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2779 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2783 static HRESULT WINAPI
MediaPosition_put_PrerollTime(IMediaPosition
* iface
, REFTIME llTime
)
2785 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2789 static HRESULT WINAPI
MediaPosition_put_Rate(IMediaPosition
* iface
, double dRate
)
2791 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2792 return IMediaSeeking_SetRate(&This
->IMediaSeeking_iface
, dRate
);
2795 static HRESULT WINAPI
MediaPosition_get_Rate(IMediaPosition
* iface
, double *pdRate
)
2797 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2798 return IMediaSeeking_GetRate(&This
->IMediaSeeking_iface
, pdRate
);
2801 static HRESULT WINAPI
MediaPosition_CanSeekForward(IMediaPosition
* iface
, LONG
*pCanSeekForward
)
2803 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekForward
);
2807 static HRESULT WINAPI
MediaPosition_CanSeekBackward(IMediaPosition
* iface
, LONG
*pCanSeekBackward
)
2809 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekBackward
);
2814 static const IMediaPositionVtbl IMediaPosition_VTable
=
2816 MediaPosition_QueryInterface
,
2817 MediaPosition_AddRef
,
2818 MediaPosition_Release
,
2819 MediaPosition_GetTypeInfoCount
,
2820 MediaPosition_GetTypeInfo
,
2821 MediaPosition_GetIDsOfNames
,
2822 MediaPosition_Invoke
,
2823 MediaPosition_get_Duration
,
2824 MediaPosition_put_CurrentPosition
,
2825 MediaPosition_get_CurrentPosition
,
2826 MediaPosition_get_StopTime
,
2827 MediaPosition_put_StopTime
,
2828 MediaPosition_get_PrerollTime
,
2829 MediaPosition_put_PrerollTime
,
2830 MediaPosition_put_Rate
,
2831 MediaPosition_get_Rate
,
2832 MediaPosition_CanSeekForward
,
2833 MediaPosition_CanSeekBackward
2836 static inline IFilterGraphImpl
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
2838 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IObjectWithSite_iface
);
2841 /*** IUnknown methods ***/
2842 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
* iface
, REFIID riid
, void** ppvObj
)
2844 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2846 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2848 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2851 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
2853 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2855 TRACE("(%p/%p)->()\n", This
, iface
);
2857 return IUnknown_AddRef(This
->outer_unk
);
2860 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
2862 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2864 TRACE("(%p/%p)->()\n", This
, iface
);
2866 return IUnknown_Release(This
->outer_unk
);
2869 /*** IObjectWithSite methods ***/
2871 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
2873 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2875 TRACE("(%p/%p)->()\n", This
, iface
);
2876 if (This
->pSite
) IUnknown_Release(This
->pSite
);
2877 This
->pSite
= pUnkSite
;
2878 IUnknown_AddRef(This
->pSite
);
2882 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
*iface
, REFIID riid
, PVOID
*ppvSite
)
2884 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2886 TRACE("(%p/%p)->(%s)\n", This
, iface
,debugstr_guid(riid
));
2892 return IUnknown_QueryInterface(This
->pSite
, riid
, ppvSite
);
2895 static const IObjectWithSiteVtbl IObjectWithSite_VTable
=
2897 ObjectWithSite_QueryInterface
,
2898 ObjectWithSite_AddRef
,
2899 ObjectWithSite_Release
,
2900 ObjectWithSite_SetSite
,
2901 ObjectWithSite_GetSite
,
2904 static HRESULT
GetTargetInterface(IFilterGraphImpl
* pGraph
, REFIID riid
, LPVOID
* ppvObj
)
2906 HRESULT hr
= E_NOINTERFACE
;
2910 /* Check if the interface type is already registered */
2911 for (entry
= 0; entry
< pGraph
->nItfCacheEntries
; entry
++)
2912 if (riid
== pGraph
->ItfCacheEntries
[entry
].riid
)
2914 if (pGraph
->ItfCacheEntries
[entry
].iface
)
2916 /* Return the interface if available */
2917 *ppvObj
= pGraph
->ItfCacheEntries
[entry
].iface
;
2923 if (entry
>= MAX_ITF_CACHE_ENTRIES
)
2925 FIXME("Not enough space to store interface in the cache\n");
2926 return E_OUTOFMEMORY
;
2929 /* Find a filter supporting the requested interface */
2930 for (i
= 0; i
< pGraph
->nFilters
; i
++)
2932 hr
= IBaseFilter_QueryInterface(pGraph
->ppFiltersInGraph
[i
], riid
, ppvObj
);
2935 pGraph
->ItfCacheEntries
[entry
].riid
= riid
;
2936 pGraph
->ItfCacheEntries
[entry
].filter
= pGraph
->ppFiltersInGraph
[i
];
2937 pGraph
->ItfCacheEntries
[entry
].iface
= *ppvObj
;
2938 if (entry
>= pGraph
->nItfCacheEntries
)
2939 pGraph
->nItfCacheEntries
++;
2942 if (hr
!= E_NOINTERFACE
)
2949 static inline IFilterGraphImpl
*impl_from_IBasicAudio(IBasicAudio
*iface
)
2951 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicAudio_iface
);
2954 static HRESULT WINAPI
BasicAudio_QueryInterface(IBasicAudio
*iface
, REFIID riid
, void **ppvObj
)
2956 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2958 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2960 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2963 static ULONG WINAPI
BasicAudio_AddRef(IBasicAudio
*iface
)
2965 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2967 TRACE("(%p/%p)->()\n", This
, iface
);
2969 return IUnknown_AddRef(This
->outer_unk
);
2972 static ULONG WINAPI
BasicAudio_Release(IBasicAudio
*iface
)
2974 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2976 TRACE("(%p/%p)->()\n", This
, iface
);
2978 return IUnknown_Release(This
->outer_unk
);
2981 /*** IDispatch methods ***/
2982 static HRESULT WINAPI
BasicAudio_GetTypeInfoCount(IBasicAudio
*iface
, UINT
*pctinfo
)
2984 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2985 IBasicAudio
* pBasicAudio
;
2988 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
2990 EnterCriticalSection(&This
->cs
);
2992 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2995 hr
= IBasicAudio_GetTypeInfoCount(pBasicAudio
, pctinfo
);
2997 LeaveCriticalSection(&This
->cs
);
3002 static HRESULT WINAPI
BasicAudio_GetTypeInfo(IBasicAudio
*iface
, UINT iTInfo
, LCID lcid
,
3003 ITypeInfo
**ppTInfo
)
3005 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3006 IBasicAudio
* pBasicAudio
;
3009 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3011 EnterCriticalSection(&This
->cs
);
3013 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3016 hr
= IBasicAudio_GetTypeInfo(pBasicAudio
, iTInfo
, lcid
, ppTInfo
);
3018 LeaveCriticalSection(&This
->cs
);
3023 static HRESULT WINAPI
BasicAudio_GetIDsOfNames(IBasicAudio
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
3024 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3026 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3027 IBasicAudio
* pBasicAudio
;
3030 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3032 EnterCriticalSection(&This
->cs
);
3034 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3037 hr
= IBasicAudio_GetIDsOfNames(pBasicAudio
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3039 LeaveCriticalSection(&This
->cs
);
3044 static HRESULT WINAPI
BasicAudio_Invoke(IBasicAudio
*iface
, DISPID dispIdMember
, REFIID riid
,
3045 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3048 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3049 IBasicAudio
* pBasicAudio
;
3052 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
);
3054 EnterCriticalSection(&This
->cs
);
3056 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3059 hr
= IBasicAudio_Invoke(pBasicAudio
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3061 LeaveCriticalSection(&This
->cs
);
3066 /*** IBasicAudio methods ***/
3067 static HRESULT WINAPI
BasicAudio_put_Volume(IBasicAudio
*iface
, LONG lVolume
)
3069 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3070 IBasicAudio
* pBasicAudio
;
3073 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
3075 EnterCriticalSection(&This
->cs
);
3077 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3080 hr
= IBasicAudio_put_Volume(pBasicAudio
, lVolume
);
3082 LeaveCriticalSection(&This
->cs
);
3087 static HRESULT WINAPI
BasicAudio_get_Volume(IBasicAudio
*iface
, LONG
*plVolume
)
3089 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3090 IBasicAudio
* pBasicAudio
;
3093 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
3095 EnterCriticalSection(&This
->cs
);
3097 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3100 hr
= IBasicAudio_get_Volume(pBasicAudio
, plVolume
);
3102 LeaveCriticalSection(&This
->cs
);
3107 static HRESULT WINAPI
BasicAudio_put_Balance(IBasicAudio
*iface
, LONG lBalance
)
3109 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3110 IBasicAudio
* pBasicAudio
;
3113 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
3115 EnterCriticalSection(&This
->cs
);
3117 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3120 hr
= IBasicAudio_put_Balance(pBasicAudio
, lBalance
);
3122 LeaveCriticalSection(&This
->cs
);
3127 static HRESULT WINAPI
BasicAudio_get_Balance(IBasicAudio
*iface
, LONG
*plBalance
)
3129 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3130 IBasicAudio
* pBasicAudio
;
3133 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
3135 EnterCriticalSection(&This
->cs
);
3137 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3140 hr
= IBasicAudio_get_Balance(pBasicAudio
, plBalance
);
3142 LeaveCriticalSection(&This
->cs
);
3147 static const IBasicAudioVtbl IBasicAudio_VTable
=
3149 BasicAudio_QueryInterface
,
3152 BasicAudio_GetTypeInfoCount
,
3153 BasicAudio_GetTypeInfo
,
3154 BasicAudio_GetIDsOfNames
,
3156 BasicAudio_put_Volume
,
3157 BasicAudio_get_Volume
,
3158 BasicAudio_put_Balance
,
3159 BasicAudio_get_Balance
3162 static inline IFilterGraphImpl
*impl_from_IBasicVideo2(IBasicVideo2
*iface
)
3164 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicVideo2_iface
);
3167 static HRESULT WINAPI
BasicVideo_QueryInterface(IBasicVideo2
*iface
, REFIID riid
, void **ppvObj
)
3169 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3171 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3173 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
3176 static ULONG WINAPI
BasicVideo_AddRef(IBasicVideo2
*iface
)
3178 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3180 TRACE("(%p/%p)->()\n", This
, iface
);
3182 return IUnknown_AddRef(This
->outer_unk
);
3185 static ULONG WINAPI
BasicVideo_Release(IBasicVideo2
*iface
)
3187 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3189 TRACE("(%p/%p)->()\n", This
, iface
);
3191 return IUnknown_Release(This
->outer_unk
);
3194 /*** IDispatch methods ***/
3195 static HRESULT WINAPI
BasicVideo_GetTypeInfoCount(IBasicVideo2
*iface
, UINT
*pctinfo
)
3197 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3198 IBasicVideo
*pBasicVideo
;
3201 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3203 EnterCriticalSection(&This
->cs
);
3205 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3208 hr
= IBasicVideo_GetTypeInfoCount(pBasicVideo
, pctinfo
);
3210 LeaveCriticalSection(&This
->cs
);
3215 static HRESULT WINAPI
BasicVideo_GetTypeInfo(IBasicVideo2
*iface
, UINT iTInfo
, LCID lcid
,
3216 ITypeInfo
**ppTInfo
)
3218 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3219 IBasicVideo
*pBasicVideo
;
3222 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3224 EnterCriticalSection(&This
->cs
);
3226 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3229 hr
= IBasicVideo_GetTypeInfo(pBasicVideo
, iTInfo
, lcid
, ppTInfo
);
3231 LeaveCriticalSection(&This
->cs
);
3236 static HRESULT WINAPI
BasicVideo_GetIDsOfNames(IBasicVideo2
*iface
, REFIID riid
,
3237 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3239 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3240 IBasicVideo
*pBasicVideo
;
3243 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3245 EnterCriticalSection(&This
->cs
);
3247 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3250 hr
= IBasicVideo_GetIDsOfNames(pBasicVideo
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3252 LeaveCriticalSection(&This
->cs
);
3257 static HRESULT WINAPI
BasicVideo_Invoke(IBasicVideo2
*iface
, DISPID dispIdMember
, REFIID riid
,
3258 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3261 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3262 IBasicVideo
*pBasicVideo
;
3265 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
);
3267 EnterCriticalSection(&This
->cs
);
3269 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3272 hr
= IBasicVideo_Invoke(pBasicVideo
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3274 LeaveCriticalSection(&This
->cs
);
3279 /*** IBasicVideo methods ***/
3280 static HRESULT WINAPI
BasicVideo_get_AvgTimePerFrame(IBasicVideo2
*iface
, REFTIME
*pAvgTimePerFrame
)
3282 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3283 IBasicVideo
*pBasicVideo
;
3286 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
3288 EnterCriticalSection(&This
->cs
);
3290 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3293 hr
= IBasicVideo_get_AvgTimePerFrame(pBasicVideo
, pAvgTimePerFrame
);
3295 LeaveCriticalSection(&This
->cs
);
3300 static HRESULT WINAPI
BasicVideo_get_BitRate(IBasicVideo2
*iface
, LONG
*pBitRate
)
3302 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3303 IBasicVideo
*pBasicVideo
;
3306 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
3308 EnterCriticalSection(&This
->cs
);
3310 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3313 hr
= IBasicVideo_get_BitRate(pBasicVideo
, pBitRate
);
3315 LeaveCriticalSection(&This
->cs
);
3320 static HRESULT WINAPI
BasicVideo_get_BitErrorRate(IBasicVideo2
*iface
, LONG
*pBitErrorRate
)
3322 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3323 IBasicVideo
*pBasicVideo
;
3326 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
3328 EnterCriticalSection(&This
->cs
);
3330 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3333 hr
= IBasicVideo_get_BitErrorRate(pBasicVideo
, pBitErrorRate
);
3335 LeaveCriticalSection(&This
->cs
);
3340 static HRESULT WINAPI
BasicVideo_get_VideoWidth(IBasicVideo2
*iface
, LONG
*pVideoWidth
)
3342 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3343 IBasicVideo
*pBasicVideo
;
3346 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
3348 EnterCriticalSection(&This
->cs
);
3350 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3353 hr
= IBasicVideo_get_VideoWidth(pBasicVideo
, pVideoWidth
);
3355 LeaveCriticalSection(&This
->cs
);
3360 static HRESULT WINAPI
BasicVideo_get_VideoHeight(IBasicVideo2
*iface
, LONG
*pVideoHeight
)
3362 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3363 IBasicVideo
*pBasicVideo
;
3366 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
3368 EnterCriticalSection(&This
->cs
);
3370 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3373 hr
= IBasicVideo_get_VideoHeight(pBasicVideo
, pVideoHeight
);
3375 LeaveCriticalSection(&This
->cs
);
3380 static HRESULT WINAPI
BasicVideo_put_SourceLeft(IBasicVideo2
*iface
, LONG SourceLeft
)
3382 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3383 IBasicVideo
*pBasicVideo
;
3386 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceLeft
);
3388 EnterCriticalSection(&This
->cs
);
3390 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3393 hr
= IBasicVideo_put_SourceLeft(pBasicVideo
, SourceLeft
);
3395 LeaveCriticalSection(&This
->cs
);
3400 static HRESULT WINAPI
BasicVideo_get_SourceLeft(IBasicVideo2
*iface
, LONG
*pSourceLeft
)
3402 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3403 IBasicVideo
*pBasicVideo
;
3406 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
3408 EnterCriticalSection(&This
->cs
);
3410 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3413 hr
= IBasicVideo_get_SourceLeft(pBasicVideo
, pSourceLeft
);
3415 LeaveCriticalSection(&This
->cs
);
3420 static HRESULT WINAPI
BasicVideo_put_SourceWidth(IBasicVideo2
*iface
, LONG SourceWidth
)
3422 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3423 IBasicVideo
*pBasicVideo
;
3426 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceWidth
);
3428 EnterCriticalSection(&This
->cs
);
3430 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3433 hr
= IBasicVideo_put_SourceWidth(pBasicVideo
, SourceWidth
);
3435 LeaveCriticalSection(&This
->cs
);
3440 static HRESULT WINAPI
BasicVideo_get_SourceWidth(IBasicVideo2
*iface
, LONG
*pSourceWidth
)
3442 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3443 IBasicVideo
*pBasicVideo
;
3446 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
3448 EnterCriticalSection(&This
->cs
);
3450 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3453 hr
= IBasicVideo_get_SourceWidth(pBasicVideo
, pSourceWidth
);
3455 LeaveCriticalSection(&This
->cs
);
3460 static HRESULT WINAPI
BasicVideo_put_SourceTop(IBasicVideo2
*iface
, LONG SourceTop
)
3462 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3463 IBasicVideo
*pBasicVideo
;
3466 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceTop
);
3468 EnterCriticalSection(&This
->cs
);
3470 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3473 hr
= IBasicVideo_put_SourceTop(pBasicVideo
, SourceTop
);
3475 LeaveCriticalSection(&This
->cs
);
3480 static HRESULT WINAPI
BasicVideo_get_SourceTop(IBasicVideo2
*iface
, LONG
*pSourceTop
)
3482 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3483 IBasicVideo
*pBasicVideo
;
3486 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
3488 EnterCriticalSection(&This
->cs
);
3490 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3493 hr
= IBasicVideo_get_SourceTop(pBasicVideo
, pSourceTop
);
3495 LeaveCriticalSection(&This
->cs
);
3500 static HRESULT WINAPI
BasicVideo_put_SourceHeight(IBasicVideo2
*iface
, LONG SourceHeight
)
3502 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3503 IBasicVideo
*pBasicVideo
;
3506 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceHeight
);
3508 EnterCriticalSection(&This
->cs
);
3510 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3513 hr
= IBasicVideo_put_SourceHeight(pBasicVideo
, SourceHeight
);
3515 LeaveCriticalSection(&This
->cs
);
3520 static HRESULT WINAPI
BasicVideo_get_SourceHeight(IBasicVideo2
*iface
, LONG
*pSourceHeight
)
3522 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3523 IBasicVideo
*pBasicVideo
;
3526 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
3528 EnterCriticalSection(&This
->cs
);
3530 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3533 hr
= IBasicVideo_get_SourceHeight(pBasicVideo
, pSourceHeight
);
3535 LeaveCriticalSection(&This
->cs
);
3540 static HRESULT WINAPI
BasicVideo_put_DestinationLeft(IBasicVideo2
*iface
, LONG DestinationLeft
)
3542 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3543 IBasicVideo
*pBasicVideo
;
3546 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationLeft
);
3548 EnterCriticalSection(&This
->cs
);
3550 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3553 hr
= IBasicVideo_put_DestinationLeft(pBasicVideo
, DestinationLeft
);
3555 LeaveCriticalSection(&This
->cs
);
3560 static HRESULT WINAPI
BasicVideo_get_DestinationLeft(IBasicVideo2
*iface
, LONG
*pDestinationLeft
)
3562 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3563 IBasicVideo
*pBasicVideo
;
3566 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
3568 EnterCriticalSection(&This
->cs
);
3570 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3573 hr
= IBasicVideo_get_DestinationLeft(pBasicVideo
, pDestinationLeft
);
3575 LeaveCriticalSection(&This
->cs
);
3580 static HRESULT WINAPI
BasicVideo_put_DestinationWidth(IBasicVideo2
*iface
, LONG DestinationWidth
)
3582 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3583 IBasicVideo
*pBasicVideo
;
3586 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationWidth
);
3588 EnterCriticalSection(&This
->cs
);
3590 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3593 hr
= IBasicVideo_put_DestinationWidth(pBasicVideo
, DestinationWidth
);
3595 LeaveCriticalSection(&This
->cs
);
3600 static HRESULT WINAPI
BasicVideo_get_DestinationWidth(IBasicVideo2
*iface
, LONG
*pDestinationWidth
)
3602 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3603 IBasicVideo
*pBasicVideo
;
3606 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
3608 EnterCriticalSection(&This
->cs
);
3610 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3613 hr
= IBasicVideo_get_DestinationWidth(pBasicVideo
, pDestinationWidth
);
3615 LeaveCriticalSection(&This
->cs
);
3620 static HRESULT WINAPI
BasicVideo_put_DestinationTop(IBasicVideo2
*iface
, LONG DestinationTop
)
3622 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3623 IBasicVideo
*pBasicVideo
;
3626 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationTop
);
3628 EnterCriticalSection(&This
->cs
);
3630 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3633 hr
= IBasicVideo_put_DestinationTop(pBasicVideo
, DestinationTop
);
3635 LeaveCriticalSection(&This
->cs
);
3640 static HRESULT WINAPI
BasicVideo_get_DestinationTop(IBasicVideo2
*iface
, LONG
*pDestinationTop
)
3642 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3643 IBasicVideo
*pBasicVideo
;
3646 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
3648 EnterCriticalSection(&This
->cs
);
3650 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3653 hr
= IBasicVideo_get_DestinationTop(pBasicVideo
, pDestinationTop
);
3655 LeaveCriticalSection(&This
->cs
);
3660 static HRESULT WINAPI
BasicVideo_put_DestinationHeight(IBasicVideo2
*iface
, LONG DestinationHeight
)
3662 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3663 IBasicVideo
*pBasicVideo
;
3666 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationHeight
);
3668 EnterCriticalSection(&This
->cs
);
3670 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3673 hr
= IBasicVideo_put_DestinationHeight(pBasicVideo
, DestinationHeight
);
3675 LeaveCriticalSection(&This
->cs
);
3680 static HRESULT WINAPI
BasicVideo_get_DestinationHeight(IBasicVideo2
*iface
,
3681 LONG
*pDestinationHeight
)
3683 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3684 IBasicVideo
*pBasicVideo
;
3687 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
3689 EnterCriticalSection(&This
->cs
);
3691 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3694 hr
= IBasicVideo_get_DestinationHeight(pBasicVideo
, pDestinationHeight
);
3696 LeaveCriticalSection(&This
->cs
);
3701 static HRESULT WINAPI
BasicVideo_SetSourcePosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3702 LONG Width
, LONG Height
)
3704 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3705 IBasicVideo
*pBasicVideo
;
3708 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3710 EnterCriticalSection(&This
->cs
);
3712 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3715 hr
= IBasicVideo_SetSourcePosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3717 LeaveCriticalSection(&This
->cs
);
3722 static HRESULT WINAPI
BasicVideo_GetSourcePosition(IBasicVideo2
*iface
, LONG
*pLeft
, LONG
*pTop
,
3723 LONG
*pWidth
, LONG
*pHeight
)
3725 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3726 IBasicVideo
*pBasicVideo
;
3729 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3731 EnterCriticalSection(&This
->cs
);
3733 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3736 hr
= IBasicVideo_GetSourcePosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3738 LeaveCriticalSection(&This
->cs
);
3743 static HRESULT WINAPI
BasicVideo_SetDefaultSourcePosition(IBasicVideo2
*iface
)
3745 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3746 IBasicVideo
*pBasicVideo
;
3749 TRACE("(%p/%p)->()\n", This
, iface
);
3751 EnterCriticalSection(&This
->cs
);
3753 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3756 hr
= IBasicVideo_SetDefaultSourcePosition(pBasicVideo
);
3758 LeaveCriticalSection(&This
->cs
);
3763 static HRESULT WINAPI
BasicVideo_SetDestinationPosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3764 LONG Width
, LONG Height
)
3766 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3767 IBasicVideo
*pBasicVideo
;
3770 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3772 EnterCriticalSection(&This
->cs
);
3774 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3777 hr
= IBasicVideo_SetDestinationPosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3779 LeaveCriticalSection(&This
->cs
);
3784 static HRESULT WINAPI
BasicVideo_GetDestinationPosition(IBasicVideo2
*iface
, LONG
*pLeft
,
3785 LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
3787 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3788 IBasicVideo
*pBasicVideo
;
3791 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3793 EnterCriticalSection(&This
->cs
);
3795 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3798 hr
= IBasicVideo_GetDestinationPosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3800 LeaveCriticalSection(&This
->cs
);
3805 static HRESULT WINAPI
BasicVideo_SetDefaultDestinationPosition(IBasicVideo2
*iface
)
3807 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3808 IBasicVideo
*pBasicVideo
;
3811 TRACE("(%p/%p)->()\n", This
, iface
);
3813 EnterCriticalSection(&This
->cs
);
3815 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3818 hr
= IBasicVideo_SetDefaultDestinationPosition(pBasicVideo
);
3820 LeaveCriticalSection(&This
->cs
);
3825 static HRESULT WINAPI
BasicVideo_GetVideoSize(IBasicVideo2
*iface
, LONG
*pWidth
, LONG
*pHeight
)
3827 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3828 IBasicVideo
*pBasicVideo
;
3831 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
3833 EnterCriticalSection(&This
->cs
);
3835 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3838 hr
= IBasicVideo_GetVideoSize(pBasicVideo
, pWidth
, pHeight
);
3840 LeaveCriticalSection(&This
->cs
);
3845 static HRESULT WINAPI
BasicVideo_GetVideoPaletteEntries(IBasicVideo2
*iface
, LONG StartIndex
,
3846 LONG Entries
, LONG
*pRetrieved
, LONG
*pPalette
)
3848 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3849 IBasicVideo
*pBasicVideo
;
3852 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3854 EnterCriticalSection(&This
->cs
);
3856 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3859 hr
= IBasicVideo_GetVideoPaletteEntries(pBasicVideo
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3861 LeaveCriticalSection(&This
->cs
);
3866 static HRESULT WINAPI
BasicVideo_GetCurrentImage(IBasicVideo2
*iface
, LONG
*pBufferSize
,
3869 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3870 IBasicVideo
*pBasicVideo
;
3873 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pBufferSize
, pDIBImage
);
3875 EnterCriticalSection(&This
->cs
);
3877 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3880 hr
= IBasicVideo_GetCurrentImage(pBasicVideo
, pBufferSize
, pDIBImage
);
3882 LeaveCriticalSection(&This
->cs
);
3887 static HRESULT WINAPI
BasicVideo_IsUsingDefaultSource(IBasicVideo2
*iface
)
3889 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3890 IBasicVideo
*pBasicVideo
;
3893 TRACE("(%p/%p)->()\n", This
, iface
);
3895 EnterCriticalSection(&This
->cs
);
3897 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3900 hr
= IBasicVideo_IsUsingDefaultSource(pBasicVideo
);
3902 LeaveCriticalSection(&This
->cs
);
3907 static HRESULT WINAPI
BasicVideo_IsUsingDefaultDestination(IBasicVideo2
*iface
)
3909 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3910 IBasicVideo
*pBasicVideo
;
3913 TRACE("(%p/%p)->()\n", This
, iface
);
3915 EnterCriticalSection(&This
->cs
);
3917 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3920 hr
= IBasicVideo_IsUsingDefaultDestination(pBasicVideo
);
3922 LeaveCriticalSection(&This
->cs
);
3927 static HRESULT WINAPI
BasicVideo2_GetPreferredAspectRatio(IBasicVideo2
*iface
, LONG
*plAspectX
,
3930 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3931 IBasicVideo2
*pBasicVideo2
;
3934 TRACE("(%p/%p)->()\n", This
, iface
);
3936 EnterCriticalSection(&This
->cs
);
3938 hr
= GetTargetInterface(This
, &IID_IBasicVideo2
, (LPVOID
*)&pBasicVideo2
);
3941 hr
= BasicVideo2_GetPreferredAspectRatio(iface
, plAspectX
, plAspectY
);
3943 LeaveCriticalSection(&This
->cs
);
3948 static const IBasicVideo2Vtbl IBasicVideo_VTable
=
3950 BasicVideo_QueryInterface
,
3953 BasicVideo_GetTypeInfoCount
,
3954 BasicVideo_GetTypeInfo
,
3955 BasicVideo_GetIDsOfNames
,
3957 BasicVideo_get_AvgTimePerFrame
,
3958 BasicVideo_get_BitRate
,
3959 BasicVideo_get_BitErrorRate
,
3960 BasicVideo_get_VideoWidth
,
3961 BasicVideo_get_VideoHeight
,
3962 BasicVideo_put_SourceLeft
,
3963 BasicVideo_get_SourceLeft
,
3964 BasicVideo_put_SourceWidth
,
3965 BasicVideo_get_SourceWidth
,
3966 BasicVideo_put_SourceTop
,
3967 BasicVideo_get_SourceTop
,
3968 BasicVideo_put_SourceHeight
,
3969 BasicVideo_get_SourceHeight
,
3970 BasicVideo_put_DestinationLeft
,
3971 BasicVideo_get_DestinationLeft
,
3972 BasicVideo_put_DestinationWidth
,
3973 BasicVideo_get_DestinationWidth
,
3974 BasicVideo_put_DestinationTop
,
3975 BasicVideo_get_DestinationTop
,
3976 BasicVideo_put_DestinationHeight
,
3977 BasicVideo_get_DestinationHeight
,
3978 BasicVideo_SetSourcePosition
,
3979 BasicVideo_GetSourcePosition
,
3980 BasicVideo_SetDefaultSourcePosition
,
3981 BasicVideo_SetDestinationPosition
,
3982 BasicVideo_GetDestinationPosition
,
3983 BasicVideo_SetDefaultDestinationPosition
,
3984 BasicVideo_GetVideoSize
,
3985 BasicVideo_GetVideoPaletteEntries
,
3986 BasicVideo_GetCurrentImage
,
3987 BasicVideo_IsUsingDefaultSource
,
3988 BasicVideo_IsUsingDefaultDestination
,
3989 BasicVideo2_GetPreferredAspectRatio
3992 static inline IFilterGraphImpl
*impl_from_IVideoWindow(IVideoWindow
*iface
)
3994 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IVideoWindow_iface
);
3997 static HRESULT WINAPI
VideoWindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, void **ppvObj
)
3999 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4001 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4003 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4006 static ULONG WINAPI
VideoWindow_AddRef(IVideoWindow
*iface
)
4008 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4010 TRACE("(%p/%p)->()\n", This
, iface
);
4012 return IUnknown_AddRef(This
->outer_unk
);
4015 static ULONG WINAPI
VideoWindow_Release(IVideoWindow
*iface
)
4017 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4019 TRACE("(%p/%p)->()\n", This
, iface
);
4021 return IUnknown_Release(This
->outer_unk
);
4024 /*** IDispatch methods ***/
4025 static HRESULT WINAPI
VideoWindow_GetTypeInfoCount(IVideoWindow
*iface
, UINT
*pctinfo
)
4027 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4028 IVideoWindow
*pVideoWindow
;
4031 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
4033 EnterCriticalSection(&This
->cs
);
4035 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4038 hr
= IVideoWindow_GetTypeInfoCount(pVideoWindow
, pctinfo
);
4040 LeaveCriticalSection(&This
->cs
);
4045 static HRESULT WINAPI
VideoWindow_GetTypeInfo(IVideoWindow
*iface
, UINT iTInfo
, LCID lcid
,
4046 ITypeInfo
**ppTInfo
)
4048 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4049 IVideoWindow
*pVideoWindow
;
4052 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4054 EnterCriticalSection(&This
->cs
);
4056 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4059 hr
= IVideoWindow_GetTypeInfo(pVideoWindow
, iTInfo
, lcid
, ppTInfo
);
4061 LeaveCriticalSection(&This
->cs
);
4066 static HRESULT WINAPI
VideoWindow_GetIDsOfNames(IVideoWindow
*iface
, REFIID riid
,
4067 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
4069 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4070 IVideoWindow
*pVideoWindow
;
4073 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4075 EnterCriticalSection(&This
->cs
);
4077 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4080 hr
= IVideoWindow_GetIDsOfNames(pVideoWindow
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4082 LeaveCriticalSection(&This
->cs
);
4087 static HRESULT WINAPI
VideoWindow_Invoke(IVideoWindow
*iface
, DISPID dispIdMember
, REFIID riid
,
4088 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
4091 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4092 IVideoWindow
*pVideoWindow
;
4095 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
);
4097 EnterCriticalSection(&This
->cs
);
4099 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4102 hr
= IVideoWindow_Invoke(pVideoWindow
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
4104 LeaveCriticalSection(&This
->cs
);
4110 /*** IVideoWindow methods ***/
4111 static HRESULT WINAPI
VideoWindow_put_Caption(IVideoWindow
*iface
, BSTR strCaption
)
4113 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4114 IVideoWindow
*pVideoWindow
;
4117 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strCaption
), strCaption
);
4119 EnterCriticalSection(&This
->cs
);
4121 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4124 hr
= IVideoWindow_put_Caption(pVideoWindow
, strCaption
);
4126 LeaveCriticalSection(&This
->cs
);
4131 static HRESULT WINAPI
VideoWindow_get_Caption(IVideoWindow
*iface
, BSTR
*strCaption
)
4133 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4134 IVideoWindow
*pVideoWindow
;
4137 TRACE("(%p/%p)->(%p)\n", This
, iface
, strCaption
);
4139 EnterCriticalSection(&This
->cs
);
4141 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4144 hr
= IVideoWindow_get_Caption(pVideoWindow
, strCaption
);
4146 LeaveCriticalSection(&This
->cs
);
4151 static HRESULT WINAPI
VideoWindow_put_WindowStyle(IVideoWindow
*iface
, LONG WindowStyle
)
4153 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4154 IVideoWindow
*pVideoWindow
;
4157 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyle
);
4159 EnterCriticalSection(&This
->cs
);
4161 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4164 hr
= IVideoWindow_put_WindowStyle(pVideoWindow
, WindowStyle
);
4166 LeaveCriticalSection(&This
->cs
);
4171 static HRESULT WINAPI
VideoWindow_get_WindowStyle(IVideoWindow
*iface
, LONG
*WindowStyle
)
4173 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4174 IVideoWindow
*pVideoWindow
;
4177 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyle
);
4179 EnterCriticalSection(&This
->cs
);
4181 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4184 hr
= IVideoWindow_get_WindowStyle(pVideoWindow
, WindowStyle
);
4186 LeaveCriticalSection(&This
->cs
);
4191 static HRESULT WINAPI
VideoWindow_put_WindowStyleEx(IVideoWindow
*iface
, LONG WindowStyleEx
)
4193 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4194 IVideoWindow
*pVideoWindow
;
4197 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyleEx
);
4199 EnterCriticalSection(&This
->cs
);
4201 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4204 hr
= IVideoWindow_put_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4206 LeaveCriticalSection(&This
->cs
);
4211 static HRESULT WINAPI
VideoWindow_get_WindowStyleEx(IVideoWindow
*iface
, LONG
*WindowStyleEx
)
4213 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4214 IVideoWindow
*pVideoWindow
;
4217 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyleEx
);
4219 EnterCriticalSection(&This
->cs
);
4221 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4224 hr
= IVideoWindow_get_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4226 LeaveCriticalSection(&This
->cs
);
4231 static HRESULT WINAPI
VideoWindow_put_AutoShow(IVideoWindow
*iface
, LONG AutoShow
)
4233 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4234 IVideoWindow
*pVideoWindow
;
4237 TRACE("(%p/%p)->(%d)\n", This
, iface
, AutoShow
);
4239 EnterCriticalSection(&This
->cs
);
4241 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4244 hr
= IVideoWindow_put_AutoShow(pVideoWindow
, AutoShow
);
4246 LeaveCriticalSection(&This
->cs
);
4251 static HRESULT WINAPI
VideoWindow_get_AutoShow(IVideoWindow
*iface
, LONG
*AutoShow
)
4253 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4254 IVideoWindow
*pVideoWindow
;
4257 TRACE("(%p/%p)->(%p)\n", This
, iface
, AutoShow
);
4259 EnterCriticalSection(&This
->cs
);
4261 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4264 hr
= IVideoWindow_get_AutoShow(pVideoWindow
, AutoShow
);
4266 LeaveCriticalSection(&This
->cs
);
4271 static HRESULT WINAPI
VideoWindow_put_WindowState(IVideoWindow
*iface
, LONG WindowState
)
4273 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4274 IVideoWindow
*pVideoWindow
;
4277 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowState
);
4279 EnterCriticalSection(&This
->cs
);
4281 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4284 hr
= IVideoWindow_put_WindowState(pVideoWindow
, WindowState
);
4286 LeaveCriticalSection(&This
->cs
);
4291 static HRESULT WINAPI
VideoWindow_get_WindowState(IVideoWindow
*iface
, LONG
*WindowState
)
4293 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4294 IVideoWindow
*pVideoWindow
;
4297 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowState
);
4299 EnterCriticalSection(&This
->cs
);
4301 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4304 hr
= IVideoWindow_get_WindowState(pVideoWindow
, WindowState
);
4306 LeaveCriticalSection(&This
->cs
);
4311 static HRESULT WINAPI
VideoWindow_put_BackgroundPalette(IVideoWindow
*iface
, LONG BackgroundPalette
)
4313 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4314 IVideoWindow
*pVideoWindow
;
4317 TRACE("(%p/%p)->(%d)\n", This
, iface
, BackgroundPalette
);
4319 EnterCriticalSection(&This
->cs
);
4321 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4324 hr
= IVideoWindow_put_BackgroundPalette(pVideoWindow
, BackgroundPalette
);
4326 LeaveCriticalSection(&This
->cs
);
4331 static HRESULT WINAPI
VideoWindow_get_BackgroundPalette(IVideoWindow
*iface
,
4332 LONG
*pBackgroundPalette
)
4334 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4335 IVideoWindow
*pVideoWindow
;
4338 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBackgroundPalette
);
4340 EnterCriticalSection(&This
->cs
);
4342 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4345 hr
= IVideoWindow_get_BackgroundPalette(pVideoWindow
, pBackgroundPalette
);
4347 LeaveCriticalSection(&This
->cs
);
4352 static HRESULT WINAPI
VideoWindow_put_Visible(IVideoWindow
*iface
, LONG Visible
)
4354 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4355 IVideoWindow
*pVideoWindow
;
4358 TRACE("(%p/%p)->(%d)\n", This
, iface
, Visible
);
4360 EnterCriticalSection(&This
->cs
);
4362 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4365 hr
= IVideoWindow_put_Visible(pVideoWindow
, Visible
);
4367 LeaveCriticalSection(&This
->cs
);
4372 static HRESULT WINAPI
VideoWindow_get_Visible(IVideoWindow
*iface
, LONG
*pVisible
)
4374 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4375 IVideoWindow
*pVideoWindow
;
4378 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVisible
);
4380 EnterCriticalSection(&This
->cs
);
4382 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4385 hr
= IVideoWindow_get_Visible(pVideoWindow
, pVisible
);
4387 LeaveCriticalSection(&This
->cs
);
4392 static HRESULT WINAPI
VideoWindow_put_Left(IVideoWindow
*iface
, LONG Left
)
4394 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4395 IVideoWindow
*pVideoWindow
;
4398 TRACE("(%p/%p)->(%d)\n", This
, iface
, Left
);
4400 EnterCriticalSection(&This
->cs
);
4402 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4405 hr
= IVideoWindow_put_Left(pVideoWindow
, Left
);
4407 LeaveCriticalSection(&This
->cs
);
4412 static HRESULT WINAPI
VideoWindow_get_Left(IVideoWindow
*iface
, LONG
*pLeft
)
4414 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4415 IVideoWindow
*pVideoWindow
;
4418 TRACE("(%p/%p)->(%p)\n", This
, iface
, pLeft
);
4420 EnterCriticalSection(&This
->cs
);
4422 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4425 hr
= IVideoWindow_get_Left(pVideoWindow
, pLeft
);
4427 LeaveCriticalSection(&This
->cs
);
4432 static HRESULT WINAPI
VideoWindow_put_Width(IVideoWindow
*iface
, LONG Width
)
4434 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4435 IVideoWindow
*pVideoWindow
;
4438 TRACE("(%p/%p)->(%d)\n", This
, iface
, Width
);
4440 EnterCriticalSection(&This
->cs
);
4442 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4445 hr
= IVideoWindow_put_Width(pVideoWindow
, Width
);
4447 LeaveCriticalSection(&This
->cs
);
4452 static HRESULT WINAPI
VideoWindow_get_Width(IVideoWindow
*iface
, LONG
*pWidth
)
4454 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4455 IVideoWindow
*pVideoWindow
;
4458 TRACE("(%p/%p)->(%p)\n", This
, iface
, pWidth
);
4460 EnterCriticalSection(&This
->cs
);
4462 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4465 hr
= IVideoWindow_get_Width(pVideoWindow
, pWidth
);
4467 LeaveCriticalSection(&This
->cs
);
4472 static HRESULT WINAPI
VideoWindow_put_Top(IVideoWindow
*iface
, LONG Top
)
4474 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4475 IVideoWindow
*pVideoWindow
;
4478 TRACE("(%p/%p)->(%d)\n", This
, iface
, Top
);
4480 EnterCriticalSection(&This
->cs
);
4482 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4485 hr
= IVideoWindow_put_Top(pVideoWindow
, Top
);
4487 LeaveCriticalSection(&This
->cs
);
4492 static HRESULT WINAPI
VideoWindow_get_Top(IVideoWindow
*iface
, LONG
*pTop
)
4494 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4495 IVideoWindow
*pVideoWindow
;
4498 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTop
);
4500 EnterCriticalSection(&This
->cs
);
4502 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4505 hr
= IVideoWindow_get_Top(pVideoWindow
, pTop
);
4507 LeaveCriticalSection(&This
->cs
);
4512 static HRESULT WINAPI
VideoWindow_put_Height(IVideoWindow
*iface
, LONG Height
)
4514 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4515 IVideoWindow
*pVideoWindow
;
4518 TRACE("(%p/%p)->(%d)\n", This
, iface
, Height
);
4520 EnterCriticalSection(&This
->cs
);
4522 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4525 hr
= IVideoWindow_put_Height(pVideoWindow
, Height
);
4527 LeaveCriticalSection(&This
->cs
);
4532 static HRESULT WINAPI
VideoWindow_get_Height(IVideoWindow
*iface
, LONG
*pHeight
)
4534 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4535 IVideoWindow
*pVideoWindow
;
4538 TRACE("(%p/%p)->(%p)\n", This
, iface
, pHeight
);
4540 EnterCriticalSection(&This
->cs
);
4542 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4545 hr
= IVideoWindow_get_Height(pVideoWindow
, pHeight
);
4547 LeaveCriticalSection(&This
->cs
);
4552 static HRESULT WINAPI
VideoWindow_put_Owner(IVideoWindow
*iface
, OAHWND Owner
)
4554 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4555 IVideoWindow
*pVideoWindow
;
4558 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Owner
);
4560 EnterCriticalSection(&This
->cs
);
4562 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4565 hr
= IVideoWindow_put_Owner(pVideoWindow
, Owner
);
4567 LeaveCriticalSection(&This
->cs
);
4572 static HRESULT WINAPI
VideoWindow_get_Owner(IVideoWindow
*iface
, OAHWND
*Owner
)
4574 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4575 IVideoWindow
*pVideoWindow
;
4578 TRACE("(%p/%p)->(%p)\n", This
, iface
, Owner
);
4580 EnterCriticalSection(&This
->cs
);
4582 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4585 hr
= IVideoWindow_get_Owner(pVideoWindow
, Owner
);
4587 LeaveCriticalSection(&This
->cs
);
4592 static HRESULT WINAPI
VideoWindow_put_MessageDrain(IVideoWindow
*iface
, OAHWND Drain
)
4594 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4595 IVideoWindow
*pVideoWindow
;
4598 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Drain
);
4600 EnterCriticalSection(&This
->cs
);
4602 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4605 hr
= IVideoWindow_put_MessageDrain(pVideoWindow
, Drain
);
4607 LeaveCriticalSection(&This
->cs
);
4612 static HRESULT WINAPI
VideoWindow_get_MessageDrain(IVideoWindow
*iface
, OAHWND
*Drain
)
4614 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4615 IVideoWindow
*pVideoWindow
;
4618 TRACE("(%p/%p)->(%p)\n", This
, iface
, Drain
);
4620 EnterCriticalSection(&This
->cs
);
4622 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4625 hr
= IVideoWindow_get_MessageDrain(pVideoWindow
, Drain
);
4627 LeaveCriticalSection(&This
->cs
);
4632 static HRESULT WINAPI
VideoWindow_get_BorderColor(IVideoWindow
*iface
, LONG
*Color
)
4634 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4635 IVideoWindow
*pVideoWindow
;
4638 TRACE("(%p/%p)->(%p)\n", This
, iface
, Color
);
4640 EnterCriticalSection(&This
->cs
);
4642 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4645 hr
= IVideoWindow_get_BorderColor(pVideoWindow
, Color
);
4647 LeaveCriticalSection(&This
->cs
);
4652 static HRESULT WINAPI
VideoWindow_put_BorderColor(IVideoWindow
*iface
, LONG Color
)
4654 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4655 IVideoWindow
*pVideoWindow
;
4658 TRACE("(%p/%p)->(%d)\n", This
, iface
, Color
);
4660 EnterCriticalSection(&This
->cs
);
4662 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4665 hr
= IVideoWindow_put_BorderColor(pVideoWindow
, Color
);
4667 LeaveCriticalSection(&This
->cs
);
4672 static HRESULT WINAPI
VideoWindow_get_FullScreenMode(IVideoWindow
*iface
, LONG
*FullScreenMode
)
4674 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4675 IVideoWindow
*pVideoWindow
;
4678 TRACE("(%p/%p)->(%p)\n", This
, iface
, FullScreenMode
);
4680 EnterCriticalSection(&This
->cs
);
4682 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4685 hr
= IVideoWindow_get_FullScreenMode(pVideoWindow
, FullScreenMode
);
4687 LeaveCriticalSection(&This
->cs
);
4692 static HRESULT WINAPI
VideoWindow_put_FullScreenMode(IVideoWindow
*iface
, LONG FullScreenMode
)
4694 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4695 IVideoWindow
*pVideoWindow
;
4698 TRACE("(%p/%p)->(%d)\n", This
, iface
, FullScreenMode
);
4700 EnterCriticalSection(&This
->cs
);
4702 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4705 hr
= IVideoWindow_put_FullScreenMode(pVideoWindow
, FullScreenMode
);
4707 LeaveCriticalSection(&This
->cs
);
4712 static HRESULT WINAPI
VideoWindow_SetWindowForeground(IVideoWindow
*iface
, LONG Focus
)
4714 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4715 IVideoWindow
*pVideoWindow
;
4718 TRACE("(%p/%p)->(%d)\n", This
, iface
, Focus
);
4720 EnterCriticalSection(&This
->cs
);
4722 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4725 hr
= IVideoWindow_SetWindowForeground(pVideoWindow
, Focus
);
4727 LeaveCriticalSection(&This
->cs
);
4732 static HRESULT WINAPI
VideoWindow_NotifyOwnerMessage(IVideoWindow
*iface
, OAHWND hwnd
, LONG uMsg
,
4733 LONG_PTR wParam
, LONG_PTR lParam
)
4735 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4736 IVideoWindow
*pVideoWindow
;
4739 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This
, iface
, hwnd
, uMsg
, wParam
, lParam
);
4741 EnterCriticalSection(&This
->cs
);
4743 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4746 hr
= IVideoWindow_NotifyOwnerMessage(pVideoWindow
, hwnd
, uMsg
, wParam
, lParam
);
4748 LeaveCriticalSection(&This
->cs
);
4753 static HRESULT WINAPI
VideoWindow_SetWindowPosition(IVideoWindow
*iface
, LONG Left
, LONG Top
,
4754 LONG Width
, LONG Height
)
4756 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4757 IVideoWindow
*pVideoWindow
;
4760 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
4762 EnterCriticalSection(&This
->cs
);
4764 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4767 hr
= IVideoWindow_SetWindowPosition(pVideoWindow
, Left
, Top
, Width
, Height
);
4769 LeaveCriticalSection(&This
->cs
);
4774 static HRESULT WINAPI
VideoWindow_GetWindowPosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4775 LONG
*pWidth
, LONG
*pHeight
)
4777 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4778 IVideoWindow
*pVideoWindow
;
4781 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4783 EnterCriticalSection(&This
->cs
);
4785 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4788 hr
= IVideoWindow_GetWindowPosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4790 LeaveCriticalSection(&This
->cs
);
4795 static HRESULT WINAPI
VideoWindow_GetMinIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4798 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4799 IVideoWindow
*pVideoWindow
;
4802 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4804 EnterCriticalSection(&This
->cs
);
4806 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4809 hr
= IVideoWindow_GetMinIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4811 LeaveCriticalSection(&This
->cs
);
4816 static HRESULT WINAPI
VideoWindow_GetMaxIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4819 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4820 IVideoWindow
*pVideoWindow
;
4823 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4825 EnterCriticalSection(&This
->cs
);
4827 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4830 hr
= IVideoWindow_GetMaxIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4832 LeaveCriticalSection(&This
->cs
);
4837 static HRESULT WINAPI
VideoWindow_GetRestorePosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4838 LONG
*pWidth
, LONG
*pHeight
)
4840 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4841 IVideoWindow
*pVideoWindow
;
4844 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4846 EnterCriticalSection(&This
->cs
);
4848 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4851 hr
= IVideoWindow_GetRestorePosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4853 LeaveCriticalSection(&This
->cs
);
4858 static HRESULT WINAPI
VideoWindow_HideCursor(IVideoWindow
*iface
, LONG HideCursor
)
4860 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4861 IVideoWindow
*pVideoWindow
;
4864 TRACE("(%p/%p)->(%d)\n", This
, iface
, HideCursor
);
4866 EnterCriticalSection(&This
->cs
);
4868 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4871 hr
= IVideoWindow_HideCursor(pVideoWindow
, HideCursor
);
4873 LeaveCriticalSection(&This
->cs
);
4878 static HRESULT WINAPI
VideoWindow_IsCursorHidden(IVideoWindow
*iface
, LONG
*CursorHidden
)
4880 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4881 IVideoWindow
*pVideoWindow
;
4884 TRACE("(%p/%p)->(%p)\n", This
, iface
, CursorHidden
);
4886 EnterCriticalSection(&This
->cs
);
4888 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4891 hr
= IVideoWindow_IsCursorHidden(pVideoWindow
, CursorHidden
);
4893 LeaveCriticalSection(&This
->cs
);
4899 static const IVideoWindowVtbl IVideoWindow_VTable
=
4901 VideoWindow_QueryInterface
,
4903 VideoWindow_Release
,
4904 VideoWindow_GetTypeInfoCount
,
4905 VideoWindow_GetTypeInfo
,
4906 VideoWindow_GetIDsOfNames
,
4908 VideoWindow_put_Caption
,
4909 VideoWindow_get_Caption
,
4910 VideoWindow_put_WindowStyle
,
4911 VideoWindow_get_WindowStyle
,
4912 VideoWindow_put_WindowStyleEx
,
4913 VideoWindow_get_WindowStyleEx
,
4914 VideoWindow_put_AutoShow
,
4915 VideoWindow_get_AutoShow
,
4916 VideoWindow_put_WindowState
,
4917 VideoWindow_get_WindowState
,
4918 VideoWindow_put_BackgroundPalette
,
4919 VideoWindow_get_BackgroundPalette
,
4920 VideoWindow_put_Visible
,
4921 VideoWindow_get_Visible
,
4922 VideoWindow_put_Left
,
4923 VideoWindow_get_Left
,
4924 VideoWindow_put_Width
,
4925 VideoWindow_get_Width
,
4926 VideoWindow_put_Top
,
4927 VideoWindow_get_Top
,
4928 VideoWindow_put_Height
,
4929 VideoWindow_get_Height
,
4930 VideoWindow_put_Owner
,
4931 VideoWindow_get_Owner
,
4932 VideoWindow_put_MessageDrain
,
4933 VideoWindow_get_MessageDrain
,
4934 VideoWindow_get_BorderColor
,
4935 VideoWindow_put_BorderColor
,
4936 VideoWindow_get_FullScreenMode
,
4937 VideoWindow_put_FullScreenMode
,
4938 VideoWindow_SetWindowForeground
,
4939 VideoWindow_NotifyOwnerMessage
,
4940 VideoWindow_SetWindowPosition
,
4941 VideoWindow_GetWindowPosition
,
4942 VideoWindow_GetMinIdealImageSize
,
4943 VideoWindow_GetMaxIdealImageSize
,
4944 VideoWindow_GetRestorePosition
,
4945 VideoWindow_HideCursor
,
4946 VideoWindow_IsCursorHidden
4949 static inline IFilterGraphImpl
*impl_from_IMediaEventEx(IMediaEventEx
*iface
)
4951 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventEx_iface
);
4954 static HRESULT WINAPI
MediaEvent_QueryInterface(IMediaEventEx
*iface
, REFIID riid
, void **ppvObj
)
4956 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4958 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4960 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4963 static ULONG WINAPI
MediaEvent_AddRef(IMediaEventEx
*iface
)
4965 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4967 TRACE("(%p/%p)->()\n", This
, iface
);
4969 return IUnknown_AddRef(This
->outer_unk
);
4972 static ULONG WINAPI
MediaEvent_Release(IMediaEventEx
*iface
)
4974 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4976 TRACE("(%p/%p)->()\n", This
, iface
);
4978 return IUnknown_Release(This
->outer_unk
);
4981 /*** IDispatch methods ***/
4982 static HRESULT WINAPI
MediaEvent_GetTypeInfoCount(IMediaEventEx
*iface
, UINT
*pctinfo
)
4984 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4986 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
4991 static HRESULT WINAPI
MediaEvent_GetTypeInfo(IMediaEventEx
*iface
, UINT iTInfo
, LCID lcid
,
4992 ITypeInfo
**ppTInfo
)
4994 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4996 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
5001 static HRESULT WINAPI
MediaEvent_GetIDsOfNames(IMediaEventEx
*iface
, REFIID riid
,
5002 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
5004 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5006 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
5011 static HRESULT WINAPI
MediaEvent_Invoke(IMediaEventEx
*iface
, DISPID dispIdMember
, REFIID riid
,
5012 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
5015 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5017 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
);
5022 /*** IMediaEvent methods ***/
5023 static HRESULT WINAPI
MediaEvent_GetEventHandle(IMediaEventEx
*iface
, OAEVENT
*hEvent
)
5025 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5027 TRACE("(%p/%p)->(%p)\n", This
, iface
, hEvent
);
5029 *hEvent
= (OAEVENT
)This
->evqueue
.msg_event
;
5034 static HRESULT WINAPI
MediaEvent_GetEvent(IMediaEventEx
*iface
, LONG
*lEventCode
, LONG_PTR
*lParam1
,
5035 LONG_PTR
*lParam2
, LONG msTimeout
)
5037 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5040 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This
, iface
, lEventCode
, lParam1
, lParam2
, msTimeout
);
5042 if (EventsQueue_GetEvent(&This
->evqueue
, &evt
, msTimeout
))
5044 *lEventCode
= evt
.lEventCode
;
5045 *lParam1
= evt
.lParam1
;
5046 *lParam2
= evt
.lParam2
;
5054 static HRESULT WINAPI
MediaEvent_WaitForCompletion(IMediaEventEx
*iface
, LONG msTimeout
,
5057 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5059 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pEvCode
);
5061 if (This
->state
!= State_Running
)
5062 return VFW_E_WRONG_STATE
;
5064 if (WaitForSingleObject(This
->hEventCompletion
, msTimeout
) == WAIT_OBJECT_0
)
5066 *pEvCode
= This
->CompletionStatus
;
5074 static HRESULT WINAPI
MediaEvent_CancelDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5076 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5078 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5080 if (lEvCode
== EC_COMPLETE
)
5081 This
->HandleEcComplete
= FALSE
;
5082 else if (lEvCode
== EC_REPAINT
)
5083 This
->HandleEcRepaint
= FALSE
;
5084 else if (lEvCode
== EC_CLOCK_CHANGED
)
5085 This
->HandleEcClockChanged
= FALSE
;
5092 static HRESULT WINAPI
MediaEvent_RestoreDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5094 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5096 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5098 if (lEvCode
== EC_COMPLETE
)
5099 This
->HandleEcComplete
= TRUE
;
5100 else if (lEvCode
== EC_REPAINT
)
5101 This
->HandleEcRepaint
= TRUE
;
5102 else if (lEvCode
== EC_CLOCK_CHANGED
)
5103 This
->HandleEcClockChanged
= TRUE
;
5110 static HRESULT WINAPI
MediaEvent_FreeEventParams(IMediaEventEx
*iface
, LONG lEvCode
,
5111 LONG_PTR lParam1
, LONG_PTR lParam2
)
5113 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5115 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This
, iface
, lEvCode
, lParam1
, lParam2
);
5120 /*** IMediaEventEx methods ***/
5121 static HRESULT WINAPI
MediaEvent_SetNotifyWindow(IMediaEventEx
*iface
, OAHWND hwnd
, LONG lMsg
,
5122 LONG_PTR lInstanceData
)
5124 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5126 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This
, iface
, hwnd
, lMsg
, lInstanceData
);
5128 This
->notif
.hWnd
= (HWND
)hwnd
;
5129 This
->notif
.msg
= lMsg
;
5130 This
->notif
.instance
= lInstanceData
;
5135 static HRESULT WINAPI
MediaEvent_SetNotifyFlags(IMediaEventEx
*iface
, LONG lNoNotifyFlags
)
5137 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5139 TRACE("(%p/%p)->(%d)\n", This
, iface
, lNoNotifyFlags
);
5141 if ((lNoNotifyFlags
!= 0) && (lNoNotifyFlags
!= 1))
5142 return E_INVALIDARG
;
5144 This
->notif
.disabled
= lNoNotifyFlags
;
5149 static HRESULT WINAPI
MediaEvent_GetNotifyFlags(IMediaEventEx
*iface
, LONG
*lplNoNotifyFlags
)
5151 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5153 TRACE("(%p/%p)->(%p)\n", This
, iface
, lplNoNotifyFlags
);
5155 if (!lplNoNotifyFlags
)
5158 *lplNoNotifyFlags
= This
->notif
.disabled
;
5164 static const IMediaEventExVtbl IMediaEventEx_VTable
=
5166 MediaEvent_QueryInterface
,
5169 MediaEvent_GetTypeInfoCount
,
5170 MediaEvent_GetTypeInfo
,
5171 MediaEvent_GetIDsOfNames
,
5173 MediaEvent_GetEventHandle
,
5174 MediaEvent_GetEvent
,
5175 MediaEvent_WaitForCompletion
,
5176 MediaEvent_CancelDefaultHandling
,
5177 MediaEvent_RestoreDefaultHandling
,
5178 MediaEvent_FreeEventParams
,
5179 MediaEvent_SetNotifyWindow
,
5180 MediaEvent_SetNotifyFlags
,
5181 MediaEvent_GetNotifyFlags
5185 static inline IFilterGraphImpl
*impl_from_IMediaFilter(IMediaFilter
*iface
)
5187 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaFilter_iface
);
5190 static HRESULT WINAPI
MediaFilter_QueryInterface(IMediaFilter
*iface
, REFIID riid
, void **ppv
)
5192 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5194 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5197 static ULONG WINAPI
MediaFilter_AddRef(IMediaFilter
*iface
)
5199 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5201 return IUnknown_AddRef(This
->outer_unk
);
5204 static ULONG WINAPI
MediaFilter_Release(IMediaFilter
*iface
)
5206 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5208 return IUnknown_Release(This
->outer_unk
);
5211 static HRESULT WINAPI
MediaFilter_GetClassID(IMediaFilter
*iface
, CLSID
* pClassID
)
5213 FIXME("(%p): stub\n", pClassID
);
5218 static HRESULT WINAPI
MediaFilter_Stop(IMediaFilter
*iface
)
5220 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5222 return MediaControl_Stop(&This
->IMediaControl_iface
);
5225 static HRESULT WINAPI
MediaFilter_Pause(IMediaFilter
*iface
)
5227 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5229 return MediaControl_Pause(&This
->IMediaControl_iface
);
5232 static HRESULT WINAPI
MediaFilter_Run(IMediaFilter
*iface
, REFERENCE_TIME tStart
)
5234 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5237 FIXME("Run called with non-null tStart: %x%08x\n",
5238 (int)(tStart
>>32), (int)tStart
);
5240 return MediaControl_Run(&This
->IMediaControl_iface
);
5243 static HRESULT WINAPI
MediaFilter_GetState(IMediaFilter
*iface
, DWORD dwMsTimeout
,
5244 FILTER_STATE
*pState
)
5246 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5248 return MediaControl_GetState(&This
->IMediaControl_iface
, dwMsTimeout
, (OAFilterState
*)pState
);
5251 static HRESULT WINAPI
MediaFilter_SetSyncSource(IMediaFilter
*iface
, IReferenceClock
*pClock
)
5253 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5257 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClock
);
5259 EnterCriticalSection(&This
->cs
);
5261 for (i
= 0;i
< This
->nFilters
;i
++)
5263 hr
= IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], pClock
);
5271 IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], This
->refClock
);
5276 IReferenceClock_Release(This
->refClock
);
5277 This
->refClock
= pClock
;
5279 IReferenceClock_AddRef(This
->refClock
);
5280 This
->defaultclock
= FALSE
;
5282 if (This
->HandleEcClockChanged
)
5284 IMediaEventSink
*pEventSink
;
5287 eshr
= IMediaFilter_QueryInterface(iface
, &IID_IMediaEventSink
, (void **)&pEventSink
);
5288 if (SUCCEEDED(eshr
))
5290 IMediaEventSink_Notify(pEventSink
, EC_CLOCK_CHANGED
, 0, 0);
5291 IMediaEventSink_Release(pEventSink
);
5296 LeaveCriticalSection(&This
->cs
);
5301 static HRESULT WINAPI
MediaFilter_GetSyncSource(IMediaFilter
*iface
, IReferenceClock
**ppClock
)
5303 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5305 TRACE("(%p/%p)->(%p)\n", iface
, This
, ppClock
);
5310 EnterCriticalSection(&This
->cs
);
5312 *ppClock
= This
->refClock
;
5314 IReferenceClock_AddRef(*ppClock
);
5316 LeaveCriticalSection(&This
->cs
);
5321 static const IMediaFilterVtbl IMediaFilter_VTable
=
5323 MediaFilter_QueryInterface
,
5325 MediaFilter_Release
,
5326 MediaFilter_GetClassID
,
5330 MediaFilter_GetState
,
5331 MediaFilter_SetSyncSource
,
5332 MediaFilter_GetSyncSource
5335 static inline IFilterGraphImpl
*impl_from_IMediaEventSink(IMediaEventSink
*iface
)
5337 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventSink_iface
);
5340 static HRESULT WINAPI
MediaEventSink_QueryInterface(IMediaEventSink
*iface
, REFIID riid
, void **ppv
)
5342 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5344 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5347 static ULONG WINAPI
MediaEventSink_AddRef(IMediaEventSink
*iface
)
5349 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5351 return IUnknown_AddRef(This
->outer_unk
);
5354 static ULONG WINAPI
MediaEventSink_Release(IMediaEventSink
*iface
)
5356 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5358 return IUnknown_Release(This
->outer_unk
);
5361 static HRESULT WINAPI
MediaEventSink_Notify(IMediaEventSink
*iface
, LONG EventCode
,
5362 LONG_PTR EventParam1
, LONG_PTR EventParam2
)
5364 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5367 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This
, iface
, EventCode
, EventParam1
, EventParam2
);
5369 /* We need thread safety here, let's use the events queue's one */
5370 EnterCriticalSection(&This
->evqueue
.msg_crst
);
5372 if ((EventCode
== EC_COMPLETE
) && This
->HandleEcComplete
)
5374 TRACE("Process EC_COMPLETE notification\n");
5375 if (++This
->EcCompleteCount
== This
->nRenderers
)
5377 evt
.lEventCode
= EC_COMPLETE
;
5380 TRACE("Send EC_COMPLETE to app\n");
5381 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5382 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5384 TRACE("Send Window message\n");
5385 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5387 This
->CompletionStatus
= EC_COMPLETE
;
5388 SetEvent(This
->hEventCompletion
);
5391 else if ((EventCode
== EC_REPAINT
) && This
->HandleEcRepaint
)
5393 /* FIXME: Not handled yet */
5397 evt
.lEventCode
= EventCode
;
5398 evt
.lParam1
= EventParam1
;
5399 evt
.lParam2
= EventParam2
;
5400 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5401 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5402 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5405 LeaveCriticalSection(&This
->evqueue
.msg_crst
);
5409 static const IMediaEventSinkVtbl IMediaEventSink_VTable
=
5411 MediaEventSink_QueryInterface
,
5412 MediaEventSink_AddRef
,
5413 MediaEventSink_Release
,
5414 MediaEventSink_Notify
5417 static inline IFilterGraphImpl
*impl_from_IGraphConfig(IGraphConfig
*iface
)
5419 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphConfig_iface
);
5422 static HRESULT WINAPI
GraphConfig_QueryInterface(IGraphConfig
*iface
, REFIID riid
, void **ppv
)
5424 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5426 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5429 static ULONG WINAPI
GraphConfig_AddRef(IGraphConfig
*iface
)
5431 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5433 return IUnknown_AddRef(This
->outer_unk
);
5436 static ULONG WINAPI
GraphConfig_Release(IGraphConfig
*iface
)
5438 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5440 return IUnknown_Release(This
->outer_unk
);
5443 static HRESULT WINAPI
GraphConfig_Reconnect(IGraphConfig
*iface
, IPin
*pOutputPin
, IPin
*pInputPin
,
5444 const AM_MEDIA_TYPE
*pmtFirstConnection
, IBaseFilter
*pUsingFilter
, HANDLE hAbortEvent
,
5447 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5449 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This
, pOutputPin
, pInputPin
, pmtFirstConnection
, pUsingFilter
, hAbortEvent
, dwFlags
);
5454 static HRESULT WINAPI
GraphConfig_Reconfigure(IGraphConfig
*iface
, IGraphConfigCallback
*pCallback
,
5455 void *pvContext
, DWORD dwFlags
, HANDLE hAbortEvent
)
5457 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5460 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This
, pCallback
, pvContext
, dwFlags
, hAbortEvent
);
5463 FIXME("The parameter hAbortEvent is not handled!\n");
5465 EnterCriticalSection(&This
->cs
);
5467 hr
= IGraphConfigCallback_Reconfigure(pCallback
, pvContext
, dwFlags
);
5469 LeaveCriticalSection(&This
->cs
);
5474 static HRESULT WINAPI
GraphConfig_AddFilterToCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5476 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5478 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5483 static HRESULT WINAPI
GraphConfig_EnumCacheFilter(IGraphConfig
*iface
, IEnumFilters
**pEnum
)
5485 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5487 FIXME("(%p)->(%p): stub!\n", This
, pEnum
);
5492 static HRESULT WINAPI
GraphConfig_RemoveFilterFromCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5494 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5496 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5501 static HRESULT WINAPI
GraphConfig_GetStartTime(IGraphConfig
*iface
, REFERENCE_TIME
*prtStart
)
5503 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5505 FIXME("(%p)->(%p): stub!\n", This
, prtStart
);
5510 static HRESULT WINAPI
GraphConfig_PushThroughData(IGraphConfig
*iface
, IPin
*pOutputPin
,
5511 IPinConnection
*pConnection
, HANDLE hEventAbort
)
5513 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5515 FIXME("(%p)->(%p, %p, %p): stub!\n", This
, pOutputPin
, pConnection
, hEventAbort
);
5520 static HRESULT WINAPI
GraphConfig_SetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5523 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5525 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5530 static HRESULT WINAPI
GraphConfig_GetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5533 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5535 FIXME("(%p)->(%p, %p): stub!\n", This
, pFilter
, dwFlags
);
5540 static HRESULT WINAPI
GraphConfig_RemoveFilterEx(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5543 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5545 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5550 static const IGraphConfigVtbl IGraphConfig_VTable
=
5552 GraphConfig_QueryInterface
,
5554 GraphConfig_Release
,
5555 GraphConfig_Reconnect
,
5556 GraphConfig_Reconfigure
,
5557 GraphConfig_AddFilterToCache
,
5558 GraphConfig_EnumCacheFilter
,
5559 GraphConfig_RemoveFilterFromCache
,
5560 GraphConfig_GetStartTime
,
5561 GraphConfig_PushThroughData
,
5562 GraphConfig_SetFilterFlags
,
5563 GraphConfig_GetFilterFlags
,
5564 GraphConfig_RemoveFilterEx
5567 static inline IFilterGraphImpl
*impl_from_IGraphVersion(IGraphVersion
*iface
)
5569 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphVersion_iface
);
5572 static HRESULT WINAPI
GraphVersion_QueryInterface(IGraphVersion
*iface
, REFIID riid
, void **ppv
)
5574 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5576 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5579 static ULONG WINAPI
GraphVersion_AddRef(IGraphVersion
*iface
)
5581 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5583 return IUnknown_AddRef(This
->outer_unk
);
5586 static ULONG WINAPI
GraphVersion_Release(IGraphVersion
*iface
)
5588 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5590 return IUnknown_Release(This
->outer_unk
);
5593 static HRESULT WINAPI
GraphVersion_QueryVersion(IGraphVersion
*iface
, LONG
*pVersion
)
5595 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5600 TRACE("(%p)->(%p): current version %i\n", This
, pVersion
, This
->version
);
5602 *pVersion
= This
->version
;
5606 static const IGraphVersionVtbl IGraphVersion_VTable
=
5608 GraphVersion_QueryInterface
,
5609 GraphVersion_AddRef
,
5610 GraphVersion_Release
,
5611 GraphVersion_QueryVersion
,
5614 static const IUnknownVtbl IInner_VTable
=
5616 FilterGraphInner_QueryInterface
,
5617 FilterGraphInner_AddRef
,
5618 FilterGraphInner_Release
5621 /* This is the only function that actually creates a FilterGraph class... */
5622 HRESULT
FilterGraph_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5624 IFilterGraphImpl
*fimpl
;
5627 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
5631 fimpl
= CoTaskMemAlloc(sizeof(*fimpl
));
5632 fimpl
->defaultclock
= TRUE
;
5633 fimpl
->IUnknown_inner
.lpVtbl
= &IInner_VTable
;
5634 fimpl
->IFilterGraph2_iface
.lpVtbl
= &IFilterGraph2_VTable
;
5635 fimpl
->IMediaControl_iface
.lpVtbl
= &IMediaControl_VTable
;
5636 fimpl
->IMediaSeeking_iface
.lpVtbl
= &IMediaSeeking_VTable
;
5637 fimpl
->IBasicAudio_iface
.lpVtbl
= &IBasicAudio_VTable
;
5638 fimpl
->IBasicVideo2_iface
.lpVtbl
= &IBasicVideo_VTable
;
5639 fimpl
->IVideoWindow_iface
.lpVtbl
= &IVideoWindow_VTable
;
5640 fimpl
->IMediaEventEx_iface
.lpVtbl
= &IMediaEventEx_VTable
;
5641 fimpl
->IMediaFilter_iface
.lpVtbl
= &IMediaFilter_VTable
;
5642 fimpl
->IMediaEventSink_iface
.lpVtbl
= &IMediaEventSink_VTable
;
5643 fimpl
->IGraphConfig_iface
.lpVtbl
= &IGraphConfig_VTable
;
5644 fimpl
->IMediaPosition_iface
.lpVtbl
= &IMediaPosition_VTable
;
5645 fimpl
->IObjectWithSite_iface
.lpVtbl
= &IObjectWithSite_VTable
;
5646 fimpl
->IGraphVersion_iface
.lpVtbl
= &IGraphVersion_VTable
;
5648 fimpl
->ppFiltersInGraph
= NULL
;
5649 fimpl
->pFilterNames
= NULL
;
5650 fimpl
->nFilters
= 0;
5651 fimpl
->filterCapacity
= 0;
5652 fimpl
->nameIndex
= 1;
5653 fimpl
->refClock
= NULL
;
5654 fimpl
->hEventCompletion
= CreateEventW(0, TRUE
, FALSE
, 0);
5655 fimpl
->HandleEcComplete
= TRUE
;
5656 fimpl
->HandleEcRepaint
= TRUE
;
5657 fimpl
->HandleEcClockChanged
= TRUE
;
5658 fimpl
->notif
.hWnd
= 0;
5659 fimpl
->notif
.disabled
= FALSE
;
5660 fimpl
->nRenderers
= 0;
5661 fimpl
->EcCompleteCount
= 0;
5662 fimpl
->refClockProvider
= NULL
;
5663 fimpl
->state
= State_Stopped
;
5664 fimpl
->pSite
= NULL
;
5665 EventsQueue_Init(&fimpl
->evqueue
);
5666 InitializeCriticalSection(&fimpl
->cs
);
5667 fimpl
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IFilterGraphImpl.cs");
5668 fimpl
->nItfCacheEntries
= 0;
5669 memcpy(&fimpl
->timeformatseek
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
5670 fimpl
->start_time
= fimpl
->pause_time
= 0;
5671 fimpl
->punkFilterMapper2
= NULL
;
5672 fimpl
->recursioncount
= 0;
5676 fimpl
->outer_unk
= pUnkOuter
;
5678 fimpl
->outer_unk
= &fimpl
->IUnknown_inner
;
5680 /* create Filtermapper aggregated. */
5681 hr
= CoCreateInstance(&CLSID_FilterMapper2
, fimpl
->outer_unk
, CLSCTX_INPROC_SERVER
,
5682 &IID_IUnknown
, (void**)&fimpl
->punkFilterMapper2
);
5685 hr
= IUnknown_QueryInterface(fimpl
->punkFilterMapper2
, &IID_IFilterMapper2
,
5686 (void**)&fimpl
->pFilterMapper2
);
5689 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5690 IUnknown_Release(fimpl
->outer_unk
);
5693 ERR("Unable to create filter mapper (%x)\n", hr
);
5694 if (fimpl
->punkFilterMapper2
) IUnknown_Release(fimpl
->punkFilterMapper2
);
5695 CloseHandle(fimpl
->hEventCompletion
);
5696 EventsQueue_Destroy(&fimpl
->evqueue
);
5697 fimpl
->cs
.DebugInfo
->Spare
[0] = 0;
5698 DeleteCriticalSection(&fimpl
->cs
);
5699 CoTaskMemFree(fimpl
);
5703 *ppObj
= &fimpl
->IUnknown_inner
;
5707 HRESULT
FilterGraphNoThread_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5709 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5710 return FilterGraph_create(pUnkOuter
, ppObj
);