1 /* DirectShow FilterGraph object (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
33 #include "quartz_private.h"
39 #include "wine/unicode.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
45 HWND hWnd
; /* Target window */
46 UINT msg
; /* User window message */
47 LONG_PTR instance
; /* User data */
48 int disabled
; /* Disabled messages posting */
52 LONG lEventCode
; /* Event code */
53 LONG_PTR lParam1
; /* Param1 */
54 LONG_PTR lParam2
; /* Param2 */
57 /* messages ring implementation for queuing events (taken from winmm) */
58 #define EVENTS_RING_BUFFER_INCREMENT 64
64 CRITICAL_SECTION msg_crst
;
65 HANDLE msg_event
; /* Signaled for no empty queue */
68 static int EventsQueue_Init(EventsQueue
* omr
)
72 omr
->msg_event
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
73 omr
->ring_buffer_size
= EVENTS_RING_BUFFER_INCREMENT
;
74 omr
->messages
= CoTaskMemAlloc(omr
->ring_buffer_size
* sizeof(Event
));
75 ZeroMemory(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
77 InitializeCriticalSection(&omr
->msg_crst
);
78 omr
->msg_crst
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": EventsQueue.msg_crst");
82 static int EventsQueue_Destroy(EventsQueue
* omr
)
84 CloseHandle(omr
->msg_event
);
85 CoTaskMemFree(omr
->messages
);
86 omr
->msg_crst
.DebugInfo
->Spare
[0] = 0;
87 DeleteCriticalSection(&omr
->msg_crst
);
91 static int EventsQueue_PutEvent(EventsQueue
* omr
, const Event
* evt
)
93 EnterCriticalSection(&omr
->msg_crst
);
94 if (omr
->msg_toget
== ((omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
))
96 int old_ring_buffer_size
= omr
->ring_buffer_size
;
97 omr
->ring_buffer_size
+= EVENTS_RING_BUFFER_INCREMENT
;
98 TRACE("omr->ring_buffer_size=%d\n",omr
->ring_buffer_size
);
99 omr
->messages
= CoTaskMemRealloc(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
100 /* Now we need to rearrange the ring buffer so that the new
101 buffers just allocated are in between omr->msg_tosave and
104 if (omr
->msg_tosave
< omr
->msg_toget
)
106 memmove(&(omr
->messages
[omr
->msg_toget
+ EVENTS_RING_BUFFER_INCREMENT
]),
107 &(omr
->messages
[omr
->msg_toget
]),
108 sizeof(Event
)*(old_ring_buffer_size
- omr
->msg_toget
)
110 omr
->msg_toget
+= EVENTS_RING_BUFFER_INCREMENT
;
113 omr
->messages
[omr
->msg_tosave
] = *evt
;
114 SetEvent(omr
->msg_event
);
115 omr
->msg_tosave
= (omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
;
116 LeaveCriticalSection(&omr
->msg_crst
);
120 static int EventsQueue_GetEvent(EventsQueue
* omr
, Event
* evt
, LONG msTimeOut
)
122 if (WaitForSingleObject(omr
->msg_event
, msTimeOut
) != WAIT_OBJECT_0
)
125 EnterCriticalSection(&omr
->msg_crst
);
127 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
129 LeaveCriticalSection(&omr
->msg_crst
);
133 *evt
= omr
->messages
[omr
->msg_toget
];
134 omr
->msg_toget
= (omr
->msg_toget
+ 1) % omr
->ring_buffer_size
;
136 /* Mark the buffer as empty if needed */
137 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
138 ResetEvent(omr
->msg_event
);
140 LeaveCriticalSection(&omr
->msg_crst
);
144 #define MAX_ITF_CACHE_ENTRIES 3
145 typedef struct _ITF_CACHE_ENTRY
{
151 typedef struct _IFilterGraphImpl
{
152 IFilterGraph2 IFilterGraph2_iface
;
153 IMediaControl IMediaControl_iface
;
154 IMediaSeeking IMediaSeeking_iface
;
155 IBasicAudio IBasicAudio_iface
;
156 IBasicVideo2 IBasicVideo2_iface
;
157 IVideoWindow IVideoWindow_iface
;
158 IMediaEventEx IMediaEventEx_iface
;
159 IMediaFilter IMediaFilter_iface
;
160 IMediaEventSink IMediaEventSink_iface
;
161 IGraphConfig IGraphConfig_iface
;
162 IMediaPosition IMediaPosition_iface
;
163 IObjectWithSite IObjectWithSite_iface
;
164 const IUnknownVtbl
* IInner_vtbl
;
165 /* IAMGraphStreams */
171 /* IRegisterServiceProvider */
172 /* IResourceMananger */
173 /* IServiceProvider */
174 /* IVideoFrameStep */
177 IUnknown
*punkFilterMapper2
;
178 IFilterMapper2
* pFilterMapper2
;
179 IBaseFilter
** ppFiltersInGraph
;
180 LPWSTR
* pFilterNames
;
184 IReferenceClock
*refClock
;
185 IBaseFilter
*refClockProvider
;
187 HANDLE hEventCompletion
;
188 int CompletionStatus
;
192 int HandleEcComplete
;
194 int HandleEcClockChanged
;
197 ITF_CACHE_ENTRY ItfCacheEntries
[MAX_ITF_CACHE_ENTRIES
];
198 int nItfCacheEntries
;
199 IUnknown
* pUnkOuter
;
204 REFERENCE_TIME start_time
;
205 REFERENCE_TIME pause_time
;
206 LONGLONG stop_position
;
211 static HRESULT
Filtergraph_QueryInterface(IFilterGraphImpl
*This
,
212 REFIID riid
, LPVOID
* ppv
);
213 static ULONG
Filtergraph_AddRef(IFilterGraphImpl
*This
);
214 static ULONG
Filtergraph_Release(IFilterGraphImpl
*This
);
216 static HRESULT WINAPI
FilterGraphInner_QueryInterface(IUnknown
* iface
,
219 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
220 TRACE("(%p)->(%s (%p), %p)\n", This
, debugstr_guid(riid
), riid
, ppvObj
);
222 if (This
->bAggregatable
)
223 This
->bUnkOuterValid
= TRUE
;
225 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
226 *ppvObj
= &(This
->IInner_vtbl
);
227 TRACE(" returning IUnknown interface (%p)\n", *ppvObj
);
228 } else if (IsEqualGUID(&IID_IFilterGraph
, riid
) ||
229 IsEqualGUID(&IID_IFilterGraph2
, riid
) ||
230 IsEqualGUID(&IID_IGraphBuilder
, riid
)) {
231 *ppvObj
= &This
->IFilterGraph2_iface
;
232 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj
);
233 } else if (IsEqualGUID(&IID_IMediaControl
, riid
)) {
234 *ppvObj
= &This
->IMediaControl_iface
;
235 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj
);
236 } else if (IsEqualGUID(&IID_IMediaSeeking
, riid
)) {
237 *ppvObj
= &This
->IMediaSeeking_iface
;
238 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj
);
239 } else if (IsEqualGUID(&IID_IBasicAudio
, riid
)) {
240 *ppvObj
= &This
->IBasicAudio_iface
;
241 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj
);
242 } else if (IsEqualGUID(&IID_IBasicVideo
, riid
) ||
243 IsEqualGUID(&IID_IBasicVideo2
, riid
)) {
244 *ppvObj
= &This
->IBasicVideo2_iface
;
245 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj
);
246 } else if (IsEqualGUID(&IID_IVideoWindow
, riid
)) {
247 *ppvObj
= &This
->IVideoWindow_iface
;
248 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj
);
249 } else if (IsEqualGUID(&IID_IMediaEvent
, riid
) ||
250 IsEqualGUID(&IID_IMediaEventEx
, riid
)) {
251 *ppvObj
= &This
->IMediaEventEx_iface
;
252 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj
);
253 } else if (IsEqualGUID(&IID_IMediaFilter
, riid
) ||
254 IsEqualGUID(&IID_IPersist
, riid
)) {
255 *ppvObj
= &This
->IMediaFilter_iface
;
256 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj
);
257 } else if (IsEqualGUID(&IID_IMediaEventSink
, riid
)) {
258 *ppvObj
= &This
->IMediaEventSink_iface
;
259 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj
);
260 } else if (IsEqualGUID(&IID_IGraphConfig
, riid
)) {
261 *ppvObj
= &This
->IGraphConfig_iface
;
262 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
263 } else if (IsEqualGUID(&IID_IMediaPosition
, riid
)) {
264 *ppvObj
= &This
->IMediaPosition_iface
;
265 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj
);
266 } else if (IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
267 *ppvObj
= &This
->IObjectWithSite_iface
;
268 TRACE(" returning IObjectWithSite interface (%p)\n", *ppvObj
);
269 } else if (IsEqualGUID(&IID_IFilterMapper
, riid
)) {
270 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj
);
271 return IUnknown_QueryInterface(This
->punkFilterMapper2
, riid
, ppvObj
);
272 } else if (IsEqualGUID(&IID_IFilterMapper2
, riid
)) {
273 *ppvObj
= This
->pFilterMapper2
;
274 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj
);
275 } else if (IsEqualGUID(&IID_IFilterMapper3
, riid
)) {
276 *ppvObj
= This
->pFilterMapper2
;
277 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj
);
280 FIXME("unknown interface %s\n", debugstr_guid(riid
));
281 return E_NOINTERFACE
;
284 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
288 static ULONG WINAPI
FilterGraphInner_AddRef(IUnknown
* iface
) {
289 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
290 ULONG ref
= InterlockedIncrement(&This
->ref
);
292 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
297 static ULONG WINAPI
FilterGraphInner_Release(IUnknown
* iface
)
299 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
300 ULONG ref
= InterlockedDecrement(&This
->ref
);
302 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
307 This
->ref
= 1; /* guard against reentrancy (aggregation). */
309 IMediaControl_Stop(&This
->IMediaControl_iface
);
311 while (This
->nFilters
)
312 IFilterGraph2_RemoveFilter((IFilterGraph2
*)This
, This
->ppFiltersInGraph
[0]);
315 IReferenceClock_Release(This
->refClock
);
317 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
319 if (This
->ItfCacheEntries
[i
].iface
)
320 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
323 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 interface below.
325 * NOTE: Filtergraph_AddRef isn't suitable, because bUnkOuterValid may be FALSE but punkOuter non-NULL
326 * and already passed as punkOuter to filtermapper in FilterGraph_create - this will happen in case of
327 * CoCreateInstance of filtergraph with non-null pUnkOuter and REFIID other than IID_Unknown that is
328 * cleaning up after error. */
329 if (This
->pUnkOuter
) IUnknown_AddRef(This
->pUnkOuter
);
330 else IUnknown_AddRef((IUnknown
*)&This
->IInner_vtbl
);
332 IFilterMapper2_Release(This
->pFilterMapper2
);
333 IUnknown_Release(This
->punkFilterMapper2
);
335 if (This
->pSite
) IUnknown_Release(This
->pSite
);
337 CloseHandle(This
->hEventCompletion
);
338 EventsQueue_Destroy(&This
->evqueue
);
339 This
->cs
.DebugInfo
->Spare
[0] = 0;
340 DeleteCriticalSection(&This
->cs
);
341 CoTaskMemFree(This
->ppFiltersInGraph
);
342 CoTaskMemFree(This
->pFilterNames
);
348 static inline IFilterGraphImpl
*impl_from_IFilterGraph2(IFilterGraph2
*iface
)
350 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IFilterGraph2_iface
);
353 static HRESULT WINAPI
FilterGraph2_QueryInterface(IFilterGraph2
*iface
, REFIID riid
, void **ppvObj
)
355 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
357 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
359 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
362 static ULONG WINAPI
FilterGraph2_AddRef(IFilterGraph2
*iface
)
364 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
366 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This
, iface
);
368 return Filtergraph_AddRef(This
);
371 static ULONG WINAPI
FilterGraph2_Release(IFilterGraph2
*iface
)
373 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
375 TRACE("(%p/%p)->() calling FilterGraph Release\n", This
, iface
);
377 return Filtergraph_Release(This
);
380 /*** IFilterGraph methods ***/
381 static HRESULT WINAPI
FilterGraph2_AddFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
,
384 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
387 WCHAR
* wszFilterName
= NULL
;
388 int duplicate_name
= FALSE
;
390 TRACE("(%p/%p)->(%p, %s (%p))\n", This
, iface
, pFilter
, debugstr_w(pName
), pName
);
395 wszFilterName
= CoTaskMemAlloc( (pName
? strlenW(pName
) + 6 : 5) * sizeof(WCHAR
) );
399 /* Check if name already exists */
400 for(i
= 0; i
< This
->nFilters
; i
++)
401 if (!strcmpW(This
->pFilterNames
[i
], pName
))
403 duplicate_name
= TRUE
;
408 /* If no name given or name already existing, generate one */
409 if (!pName
|| duplicate_name
)
411 static const WCHAR wszFmt1
[] = {'%','s',' ','%','0','4','d',0};
412 static const WCHAR wszFmt2
[] = {'%','0','4','d',0};
414 for (j
= 0; j
< 10000 ; j
++)
418 sprintfW(wszFilterName
, wszFmt1
, pName
, This
->nameIndex
);
420 sprintfW(wszFilterName
, wszFmt2
, This
->nameIndex
);
421 TRACE("Generated name %s\n", debugstr_w(wszFilterName
));
423 /* Check if the generated name already exists */
424 for(i
= 0; i
< This
->nFilters
; i
++)
425 if (!strcmpW(This
->pFilterNames
[i
], wszFilterName
))
428 /* Compute next index and exit if generated name is suitable */
429 if (This
->nameIndex
++ == 10000)
431 if (i
== This
->nFilters
)
434 /* Unable to find a suitable name */
437 CoTaskMemFree(wszFilterName
);
438 return VFW_E_DUPLICATE_NAME
;
442 memcpy(wszFilterName
, pName
, (strlenW(pName
) + 1) * sizeof(WCHAR
));
444 if (This
->nFilters
+ 1 > This
->filterCapacity
)
446 int newCapacity
= This
->filterCapacity
? 2 * This
->filterCapacity
: 1;
447 IBaseFilter
** ppNewFilters
= CoTaskMemAlloc(newCapacity
* sizeof(IBaseFilter
*));
448 LPWSTR
* pNewNames
= CoTaskMemAlloc(newCapacity
* sizeof(LPWSTR
));
449 memcpy(ppNewFilters
, This
->ppFiltersInGraph
, This
->nFilters
* sizeof(IBaseFilter
*));
450 memcpy(pNewNames
, This
->pFilterNames
, This
->nFilters
* sizeof(LPWSTR
));
451 if (This
->filterCapacity
)
453 CoTaskMemFree(This
->ppFiltersInGraph
);
454 CoTaskMemFree(This
->pFilterNames
);
456 This
->ppFiltersInGraph
= ppNewFilters
;
457 This
->pFilterNames
= pNewNames
;
458 This
->filterCapacity
= newCapacity
;
461 hr
= IBaseFilter_JoinFilterGraph(pFilter
, (IFilterGraph
*)This
, wszFilterName
);
465 IBaseFilter_AddRef(pFilter
);
466 This
->ppFiltersInGraph
[This
->nFilters
] = pFilter
;
467 This
->pFilterNames
[This
->nFilters
] = wszFilterName
;
469 IBaseFilter_SetSyncSource(pFilter
, This
->refClock
);
472 CoTaskMemFree(wszFilterName
);
474 if (SUCCEEDED(hr
) && duplicate_name
)
475 return VFW_S_DUPLICATE_NAME
;
480 static HRESULT WINAPI
FilterGraph2_RemoveFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
)
482 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
486 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFilter
);
488 /* FIXME: check graph is stopped */
490 for (i
= 0; i
< This
->nFilters
; i
++)
492 if (This
->ppFiltersInGraph
[i
] == pFilter
)
494 IEnumPins
*penumpins
= NULL
;
497 if (This
->defaultclock
&& This
->refClockProvider
== pFilter
)
499 IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, NULL
);
500 This
->defaultclock
= 1;
503 TRACE("Removing filter %s\n", debugstr_w(This
->pFilterNames
[i
]));
504 IBaseFilter_GetState(pFilter
, 0, &state
);
505 if (state
== State_Running
)
506 IBaseFilter_Pause(pFilter
);
507 if (state
!= State_Stopped
)
508 IBaseFilter_Stop(pFilter
);
510 hr
= IBaseFilter_EnumPins(pFilter
, &penumpins
);
513 while(IEnumPins_Next(penumpins
, 1, &ppin
, NULL
) == S_OK
)
517 IPin_ConnectedTo(ppin
, &victim
);
520 h
= IPin_Disconnect(victim
);
521 TRACE("Disconnect other side: %08x\n", h
);
522 if (h
== VFW_E_NOT_STOPPED
)
525 IPin_QueryPinInfo(victim
, &pinfo
);
527 IBaseFilter_GetState(pinfo
.pFilter
, 0, &state
);
528 if (state
== State_Running
)
529 IBaseFilter_Pause(pinfo
.pFilter
);
530 IBaseFilter_Stop(pinfo
.pFilter
);
531 IBaseFilter_Release(pinfo
.pFilter
);
532 h
= IPin_Disconnect(victim
);
533 TRACE("Disconnect retry: %08x\n", h
);
535 IPin_Release(victim
);
537 h
= IPin_Disconnect(ppin
);
538 TRACE("Disconnect 2: %08x\n", h
);
542 IEnumPins_Release(penumpins
);
545 hr
= IBaseFilter_JoinFilterGraph(pFilter
, NULL
, This
->pFilterNames
[i
]);
548 IBaseFilter_SetSyncSource(pFilter
, NULL
);
549 IBaseFilter_Release(pFilter
);
550 CoTaskMemFree(This
->pFilterNames
[i
]);
551 memmove(This
->ppFiltersInGraph
+i
, This
->ppFiltersInGraph
+i
+1, sizeof(IBaseFilter
*)*(This
->nFilters
- 1 - i
));
552 memmove(This
->pFilterNames
+i
, This
->pFilterNames
+i
+1, sizeof(LPWSTR
)*(This
->nFilters
- 1 - i
));
554 /* Invalidate interfaces in the cache */
555 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
556 if (pFilter
== This
->ItfCacheEntries
[i
].filter
)
558 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
559 This
->ItfCacheEntries
[i
].iface
= NULL
;
560 This
->ItfCacheEntries
[i
].filter
= NULL
;
568 return hr
; /* FIXME: check this error code */
571 static HRESULT WINAPI
FilterGraph2_EnumFilters(IFilterGraph2
*iface
, IEnumFilters
**ppEnum
)
573 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
575 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppEnum
);
577 return IEnumFiltersImpl_Construct(This
->ppFiltersInGraph
, This
->nFilters
, ppEnum
);
580 static HRESULT WINAPI
FilterGraph2_FindFilterByName(IFilterGraph2
*iface
, LPCWSTR pName
,
581 IBaseFilter
**ppFilter
)
583 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
586 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_w(pName
), pName
, ppFilter
);
591 for (i
= 0; i
< This
->nFilters
; i
++)
593 if (!strcmpW(pName
, This
->pFilterNames
[i
]))
595 *ppFilter
= This
->ppFiltersInGraph
[i
];
596 IBaseFilter_AddRef(*ppFilter
);
602 return VFW_E_NOT_FOUND
;
605 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
606 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
608 static HRESULT
CheckCircularConnection(IFilterGraphImpl
*This
, IPin
*out
, IPin
*in
)
612 PIN_INFO info_out
, info_in
;
614 hr
= IPin_QueryPinInfo(out
, &info_out
);
617 if (info_out
.dir
!= PINDIR_OUTPUT
)
619 IBaseFilter_Release(info_out
.pFilter
);
623 hr
= IPin_QueryPinInfo(in
, &info_in
);
625 IBaseFilter_Release(info_in
.pFilter
);
628 if (info_in
.dir
!= PINDIR_INPUT
)
634 if (info_out
.pFilter
== info_in
.pFilter
)
635 hr
= VFW_E_CIRCULAR_GRAPH
;
641 hr
= IBaseFilter_EnumPins(info_out
.pFilter
, &enumpins
);
645 IEnumPins_Reset(enumpins
);
646 while ((hr
= IEnumPins_Next(enumpins
, 1, &test
, NULL
)) == S_OK
)
648 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
649 IPin_QueryDirection(test
, &dir
);
650 if (dir
== PINDIR_INPUT
)
653 IPin_ConnectedTo(test
, &victim
);
656 hr
= CheckCircularConnection(This
, victim
, in
);
657 IPin_Release(victim
);
667 IEnumPins_Release(enumpins
);
671 IBaseFilter_Release(info_out
.pFilter
);
673 ERR("Checking filtergraph returned %08x, something's not right!\n", hr
);
676 /* Debugging filtergraphs not enabled */
682 /* NOTE: despite the implication, it doesn't matter which
683 * way round you put in the input and output pins */
684 static HRESULT WINAPI
FilterGraph2_ConnectDirect(IFilterGraph2
*iface
, IPin
*ppinIn
, IPin
*ppinOut
,
685 const AM_MEDIA_TYPE
*pmt
)
687 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
691 TRACE("(%p/%p)->(%p, %p, %p)\n", This
, iface
, ppinIn
, ppinOut
, pmt
);
693 /* FIXME: check pins are in graph */
695 if (TRACE_ON(quartz
))
699 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
703 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
704 IBaseFilter_Release(PinInfo
.pFilter
);
706 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
710 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
711 IBaseFilter_Release(PinInfo
.pFilter
);
714 hr
= IPin_QueryDirection(ppinIn
, &dir
);
717 if (dir
== PINDIR_INPUT
)
719 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
721 hr
= IPin_Connect(ppinOut
, ppinIn
, pmt
);
725 hr
= CheckCircularConnection(This
, ppinIn
, ppinOut
);
727 hr
= IPin_Connect(ppinIn
, ppinOut
, pmt
);
734 static HRESULT WINAPI
FilterGraph2_Reconnect(IFilterGraph2
*iface
, IPin
*ppin
)
736 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
737 IPin
*pConnectedTo
= NULL
;
739 PIN_DIRECTION pindir
;
741 IPin_QueryDirection(ppin
, &pindir
);
742 hr
= IPin_ConnectedTo(ppin
, &pConnectedTo
);
744 TRACE("Querying connected to failed: %x\n", hr
);
747 IPin_Disconnect(ppin
);
748 IPin_Disconnect(pConnectedTo
);
749 if (pindir
== PINDIR_INPUT
)
750 hr
= IPin_Connect(pConnectedTo
, ppin
, NULL
);
752 hr
= IPin_Connect(ppin
, pConnectedTo
, NULL
);
753 IPin_Release(pConnectedTo
);
755 WARN("Reconnecting pins failed, pins are not connected now..\n");
756 TRACE("(%p->%p) -- %p %p -> %x\n", iface
, This
, ppin
, pConnectedTo
, hr
);
760 static HRESULT WINAPI
FilterGraph2_Disconnect(IFilterGraph2
*iface
, IPin
*ppin
)
762 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
764 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppin
);
769 return IPin_Disconnect(ppin
);
772 static HRESULT WINAPI
FilterGraph2_SetDefaultSyncSource(IFilterGraph2
*iface
)
774 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
775 IReferenceClock
*pClock
= NULL
;
779 TRACE("(%p/%p)->() live sources not handled properly!\n", iface
, This
);
781 EnterCriticalSection(&This
->cs
);
783 for (i
= 0; i
< This
->nFilters
; ++i
)
786 IAMFilterMiscFlags
*flags
= NULL
;
787 IUnknown_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IAMFilterMiscFlags
, (void**)&flags
);
790 miscflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
791 IUnknown_Release(flags
);
792 if (miscflags
== AM_FILTER_MISC_FLAGS_IS_RENDERER
)
793 IUnknown_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IReferenceClock
, (void**)&pClock
);
800 hr
= CoCreateInstance(&CLSID_SystemClock
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IReferenceClock
, (LPVOID
*)&pClock
);
801 This
->refClockProvider
= NULL
;
804 This
->refClockProvider
= This
->ppFiltersInGraph
[i
];
808 hr
= IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, pClock
);
809 This
->defaultclock
= TRUE
;
810 IReferenceClock_Release(pClock
);
812 LeaveCriticalSection(&This
->cs
);
817 static HRESULT
GetFilterInfo(IMoniker
* pMoniker
, GUID
* pclsid
, VARIANT
* pvar
)
819 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
820 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
821 IPropertyBag
* pPropBagCat
= NULL
;
826 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
829 hr
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, pvar
, NULL
);
832 hr
= CLSIDFromString(V_UNION(pvar
, bstrVal
), pclsid
);
837 hr
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, pvar
, NULL
);
840 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid
), debugstr_w(V_UNION(pvar
, bstrVal
)));
843 IPropertyBag_Release(pPropBagCat
);
848 static HRESULT
GetInternalConnections(IBaseFilter
* pfilter
, IPin
* pinputpin
, IPin
*** pppins
, ULONG
* pnb
)
853 TRACE("(%p, %p, %p, %p)\n", pfilter
, pinputpin
, pppins
, pnb
);
854 hr
= IPin_QueryInternalConnections(pinputpin
, NULL
, &nb
);
857 } else if (hr
== S_FALSE
) {
858 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*nb
);
859 hr
= IPin_QueryInternalConnections(pinputpin
, *pppins
, &nb
);
861 WARN("Error (%x)\n", hr
);
863 } else if (hr
== E_NOTIMPL
) {
864 /* Input connected to all outputs */
865 IEnumPins
* penumpins
;
868 TRACE("E_NOTIMPL\n");
869 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
871 WARN("filter Enumpins failed (%x)\n", hr
);
875 /* Count output pins */
876 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
877 PIN_DIRECTION pindir
;
878 IPin_QueryDirection(ppin
, &pindir
);
879 if (pindir
== PINDIR_OUTPUT
)
883 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*i
);
884 /* Retrieve output pins */
885 IEnumPins_Reset(penumpins
);
887 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
888 PIN_DIRECTION pindir
;
889 IPin_QueryDirection(ppin
, &pindir
);
890 if (pindir
== PINDIR_OUTPUT
)
891 (*pppins
)[i
++] = ppin
;
895 IEnumPins_Release(penumpins
);
898 WARN("Next failed (%x)\n", hr
);
901 } else if (FAILED(hr
)) {
902 WARN("Cannot get internal connection (%x)\n", hr
);
910 /*** IGraphBuilder methods ***/
911 static HRESULT WINAPI
FilterGraph2_Connect(IFilterGraph2
*iface
, IPin
*ppinOut
, IPin
*ppinIn
)
913 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
915 AM_MEDIA_TYPE
* mt
= NULL
;
916 IEnumMediaTypes
* penummt
= NULL
;
918 IEnumPins
* penumpins
;
919 IEnumMoniker
* pEnumMoniker
;
928 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, ppinOut
, ppinIn
);
930 if (TRACE_ON(quartz
))
932 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
936 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
937 IBaseFilter_Release(PinInfo
.pFilter
);
939 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
943 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
944 IBaseFilter_Release(PinInfo
.pFilter
);
947 EnterCriticalSection(&This
->cs
);
948 ++This
->recursioncount
;
949 if (This
->recursioncount
>= 5)
951 WARN("Recursion count has reached %d\n", This
->recursioncount
);
952 hr
= VFW_E_CANNOT_CONNECT
;
956 hr
= IPin_QueryDirection(ppinOut
, &dir
);
960 if (dir
== PINDIR_INPUT
)
969 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
973 /* Try direct connection first */
974 hr
= IPin_Connect(ppinOut
, ppinIn
, NULL
);
978 TRACE("Direct connection failed, trying to render using extra filters\n");
980 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
984 hr
= IBaseFilter_GetClassID(PinInfo
.pFilter
, &FilterCLSID
);
985 IBaseFilter_Release(PinInfo
.pFilter
);
989 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
990 * filter to the minor mediatype of input pin of the renderer */
991 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
994 WARN("EnumMediaTypes (%x)\n", hr
);
998 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1000 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1006 WARN("No media type found!\n");
1007 hr
= VFW_E_INVALIDMEDIATYPE
;
1010 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1011 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1013 /* Try to find a suitable filter that can connect to the pin to render */
1014 tab
[0] = mt
->majortype
;
1015 tab
[1] = mt
->subtype
;
1016 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1018 WARN("Unable to enum filters (%x)\n", hr
);
1022 hr
= VFW_E_CANNOT_RENDER
;
1023 while(IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1028 IPin
* ppinfilter
= NULL
;
1029 IBaseFilter
* pfilter
= NULL
;
1030 IAMGraphBuilderCallback
*callback
= NULL
;
1032 hr
= GetFilterInfo(pMoniker
, &clsid
, &var
);
1033 IMoniker_Release(pMoniker
);
1035 WARN("Unable to retrieve filter info (%x)\n", hr
);
1039 if (IsEqualGUID(&clsid
, &FilterCLSID
)) {
1040 /* Skip filter (same as the one the output pin belongs to) */
1046 IUnknown_QueryInterface(This
->pSite
, &IID_IAMGraphBuilderCallback
, (LPVOID
*)&callback
);
1050 rc
= IAMGraphBuilderCallback_SelectedFilter(callback
, pMoniker
);
1053 TRACE("Filter rejected by IAMGraphBuilderCallback_SelectedFilter\n");
1054 IUnknown_Release(callback
);
1060 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1062 WARN("Unable to create filter (%x), trying next one\n", hr
);
1069 rc
= IAMGraphBuilderCallback_CreatedFilter(callback
, pfilter
);
1070 IUnknown_Release(callback
);
1073 IBaseFilter_Release(pfilter
);
1075 TRACE("Filter rejected by IAMGraphBuilderCallback_CreatedFilter\n");
1080 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_UNION(&var
, bstrVal
));
1082 WARN("Unable to add filter (%x)\n", hr
);
1083 IBaseFilter_Release(pfilter
);
1090 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1092 WARN("Enumpins (%x)\n", hr
);
1096 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1097 IEnumPins_Release(penumpins
);
1100 WARN("Obtaining next pin: (%x)\n", hr
);
1104 WARN("Cannot use this filter: no pins\n");
1108 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1110 TRACE("Cannot connect to filter (%x), trying next one\n", hr
);
1113 TRACE("Successfully connected to filter, follow chain...\n");
1115 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1116 hr
= GetInternalConnections(pfilter
, ppinfilter
, &ppins
, &nb
);
1118 if (SUCCEEDED(hr
)) {
1121 IPin_Disconnect(ppinfilter
);
1122 IPin_Disconnect(ppinOut
);
1125 TRACE("pins to consider: %d\n", nb
);
1126 for(i
= 0; i
< nb
; i
++)
1128 LPWSTR pinname
= NULL
;
1130 TRACE("Processing pin %u\n", i
);
1132 hr
= IPin_QueryId(ppins
[i
], &pinname
);
1135 if (pinname
[0] == '~')
1137 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname
));
1141 hr
= IFilterGraph2_Connect(iface
, ppins
[i
], ppinIn
);
1142 CoTaskMemFree(pinname
);
1146 TRACE("Cannot connect pin %p (%x)\n", ppinfilter
, hr
);
1148 IPin_Release(ppins
[i
]);
1149 if (SUCCEEDED(hr
)) break;
1151 while (++i
< nb
) IPin_Release(ppins
[i
]);
1152 CoTaskMemFree(ppins
);
1153 IPin_Release(ppinfilter
);
1154 IBaseFilter_Release(pfilter
);
1157 IPin_Disconnect(ppinfilter
);
1158 IPin_Disconnect(ppinOut
);
1159 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1167 if (ppinfilter
) IPin_Release(ppinfilter
);
1169 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1170 IBaseFilter_Release(pfilter
);
1176 IEnumMediaTypes_Release(penummt
);
1178 DeleteMediaType(mt
);
1179 --This
->recursioncount
;
1180 LeaveCriticalSection(&This
->cs
);
1181 TRACE("--> %08x\n", hr
);
1182 return SUCCEEDED(hr
) ? S_OK
: hr
;
1185 static HRESULT
FilterGraph2_RenderRecurse(IFilterGraphImpl
*This
, IPin
*ppinOut
)
1187 /* This pin has been connected now, try to call render on all pins that aren't connected */
1190 IEnumPins
*enumpins
= NULL
;
1191 BOOL renderany
= FALSE
;
1192 BOOL renderall
= TRUE
;
1194 IPin_QueryPinInfo(ppinOut
, &info
);
1196 IBaseFilter_EnumPins(info
.pFilter
, &enumpins
);
1197 /* Don't need to hold a reference, IEnumPins does */
1198 IBaseFilter_Release(info
.pFilter
);
1200 IEnumPins_Reset(enumpins
);
1201 while (IEnumPins_Next(enumpins
, 1, &to
, NULL
) == S_OK
)
1203 PIN_DIRECTION dir
= PINDIR_INPUT
;
1205 IPin_QueryDirection(to
, &dir
);
1207 if (dir
== PINDIR_OUTPUT
)
1211 IPin_ConnectedTo(to
, &out
);
1215 hr
= IFilterGraph2_Render(&This
->IFilterGraph2_iface
, to
);
1228 IEnumPins_Release(enumpins
);
1234 return VFW_S_PARTIAL_RENDER
;
1236 return VFW_E_CANNOT_RENDER
;
1239 /* Ogg hates me if I create a direct rendering method
1241 * It can only connect to a pin properly once, so use a recursive method that does
1243 * +----+ --- (PIN 1) (Render is called on this pin)
1245 * +----+ --- (PIN 2)
1247 * Enumerate possible renderers that EXACTLY match the requested type
1249 * If none is available, try to add intermediate filters that can connect to the input pin
1250 * then call Render on that intermediate pin's output pins
1251 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1252 * and another filter that can connect to the input pin is tried
1253 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1254 * It's recursive, but fun!
1257 static HRESULT WINAPI
FilterGraph2_Render(IFilterGraph2
*iface
, IPin
*ppinOut
)
1259 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1260 IEnumMediaTypes
* penummt
;
1265 IEnumMoniker
* pEnumMoniker
;
1271 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppinOut
);
1273 if (TRACE_ON(quartz
))
1277 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
1281 TRACE("Filter owning pin => %p\n", PinInfo
.pFilter
);
1282 IBaseFilter_Release(PinInfo
.pFilter
);
1285 /* Try to find out if there is a renderer for the specified subtype already, and use that
1287 EnterCriticalSection(&This
->cs
);
1288 for (x
= 0; x
< This
->nFilters
; ++x
)
1290 IEnumPins
*enumpins
= NULL
;
1293 hr
= IBaseFilter_EnumPins(This
->ppFiltersInGraph
[x
], &enumpins
);
1295 if (FAILED(hr
) || !enumpins
)
1298 IEnumPins_Reset(enumpins
);
1299 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
1302 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
1304 IPin_QueryDirection(pin
, &dir
);
1305 if (dir
!= PINDIR_INPUT
)
1310 IPin_ConnectedTo(pin
, &to
);
1314 hr
= FilterGraph2_ConnectDirect(iface
, ppinOut
, pin
, NULL
);
1317 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut
, pin
, hr
);
1320 hr
= FilterGraph2_RenderRecurse(This
, pin
);
1323 IPin_Disconnect(ppinOut
);
1324 IPin_Disconnect(pin
);
1327 IEnumPins_Release(enumpins
);
1328 LeaveCriticalSection(&This
->cs
);
1331 WARN("Could not connect!\n");
1338 IEnumPins_Release(enumpins
);
1341 LeaveCriticalSection(&This
->cs
);
1343 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
1345 WARN("EnumMediaTypes (%x)\n", hr
);
1349 IEnumMediaTypes_Reset(penummt
);
1351 /* Looks like no existing renderer of the kind exists
1352 * Try adding new ones
1354 tab
[0] = tab
[1] = GUID_NULL
;
1355 while (SUCCEEDED(hr
))
1357 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1359 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1364 hr
= VFW_E_CANNOT_RENDER
;
1369 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1370 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1372 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1373 if (IsEqualIID(&tab
[0], &mt
->majortype
) && IsEqualIID(&tab
[1], &mt
->subtype
))
1375 DeleteMediaType(mt
);
1379 /* Try to find a suitable renderer with the same media type */
1380 tab
[0] = mt
->majortype
;
1381 tab
[1] = mt
->subtype
;
1382 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1385 WARN("Unable to enum filters (%x)\n", hr
);
1391 while (IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1396 IBaseFilter
* pfilter
= NULL
;
1397 IEnumPins
* penumpins
= NULL
;
1400 hr
= GetFilterInfo(pMoniker
, &clsid
, &var
);
1401 IMoniker_Release(pMoniker
);
1403 WARN("Unable to retrieve filter info (%x)\n", hr
);
1407 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1410 WARN("Unable to create filter (%x), trying next one\n", hr
);
1414 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_UNION(&var
, bstrVal
));
1416 WARN("Unable to add filter (%x)\n", hr
);
1417 IBaseFilter_Release(pfilter
);
1422 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1424 WARN("Splitter Enumpins (%x)\n", hr
);
1428 while ((hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
)) == S_OK
)
1438 hr
= IPin_QueryDirection(ppinfilter
, &dir
);
1440 IPin_Release(ppinfilter
);
1441 WARN("QueryDirection failed (%x)\n", hr
);
1444 if (dir
!= PINDIR_INPUT
) {
1445 IPin_Release(ppinfilter
);
1446 continue; /* Wrong direction */
1449 /* Connect the pin to the "Renderer" */
1450 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1451 IPin_Release(ppinfilter
);
1454 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_UNION(&var
, bstrVal
)), hr
);
1457 TRACE("Connected, recursing %s\n", debugstr_w(V_UNION(&var
, bstrVal
)));
1461 hr
= FilterGraph2_RenderRecurse(This
, ppinfilter
);
1463 WARN("Unable to connect recursively (%x)\n", hr
);
1466 IBaseFilter_Release(pfilter
);
1469 if (SUCCEEDED(hr
)) {
1470 IEnumPins_Release(penumpins
);
1471 break; /* out of IEnumMoniker_Next loop */
1474 /* IEnumPins_Next failed, all other failure case caught by goto error */
1475 WARN("IEnumPins_Next (%x)\n", hr
);
1481 IEnumPins_Release(penumpins
);
1483 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1484 IBaseFilter_Release(pfilter
);
1486 if (SUCCEEDED(hr
)) DebugBreak();
1489 IEnumMoniker_Release(pEnumMoniker
);
1491 DeleteMediaType(mt
);
1497 IEnumMediaTypes_Release(penummt
);
1501 static HRESULT WINAPI
FilterGraph2_RenderFile(IFilterGraph2
*iface
, LPCWSTR lpcwstrFile
,
1502 LPCWSTR lpcwstrPlayList
)
1504 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1505 static const WCHAR string
[] = {'R','e','a','d','e','r',0};
1506 IBaseFilter
* preader
= NULL
;
1507 IPin
* ppinreader
= NULL
;
1508 IEnumPins
* penumpins
= NULL
;
1510 BOOL partial
= FALSE
;
1511 HRESULT any
= FALSE
;
1513 TRACE("(%p/%p)->(%s, %s)\n", This
, iface
, debugstr_w(lpcwstrFile
), debugstr_w(lpcwstrPlayList
));
1515 if (lpcwstrPlayList
!= NULL
)
1516 return E_INVALIDARG
;
1518 hr
= IFilterGraph2_AddSourceFilter(iface
, lpcwstrFile
, string
, &preader
);
1523 hr
= IBaseFilter_EnumPins(preader
, &penumpins
);
1526 while (IEnumPins_Next(penumpins
, 1, &ppinreader
, NULL
) == S_OK
)
1530 IPin_QueryDirection(ppinreader
, &dir
);
1531 if (dir
== PINDIR_OUTPUT
)
1535 hr
= IFilterGraph2_Render(iface
, ppinreader
);
1536 TRACE("Render %08x\n", hr
);
1538 for (i
= 0; i
< This
->nFilters
; ++i
)
1539 TRACE("Filters in chain: %s\n", debugstr_w(This
->pFilterNames
[i
]));
1546 IPin_Release(ppinreader
);
1548 IEnumPins_Release(penumpins
);
1551 hr
= VFW_E_CANNOT_RENDER
;
1553 hr
= VFW_S_PARTIAL_RENDER
;
1557 IBaseFilter_Release(preader
);
1559 TRACE("--> %08x\n", hr
);
1563 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1564 static HRESULT
GetFileSourceFilter(LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1566 static const WCHAR wszReg
[] = {'M','e','d','i','a',' ','T','y','p','e','\\','E','x','t','e','n','s','i','o','n','s',0};
1571 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszReg
, 0, KEY_READ
, &extkey
);
1572 hr
= HRESULT_FROM_WIN32(lRet
);
1576 static const WCHAR filtersource
[] = {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
1577 WCHAR
*ext
= PathFindExtensionW(pszFileName
);
1578 WCHAR clsid_key
[39];
1580 DWORD size
= sizeof(clsid_key
);
1585 CloseHandle(extkey
);
1589 lRet
= RegOpenKeyExW(extkey
, ext
, 0, KEY_READ
, &pathkey
);
1590 hr
= HRESULT_FROM_WIN32(lRet
);
1591 CloseHandle(extkey
);
1595 lRet
= RegQueryValueExW(pathkey
, filtersource
, NULL
, NULL
, (LPBYTE
)clsid_key
, &size
);
1596 hr
= HRESULT_FROM_WIN32(lRet
);
1597 CloseHandle(pathkey
);
1601 CLSIDFromString(clsid_key
, &clsid
);
1603 TRACE("CLSID: %s\n", debugstr_guid(&clsid
));
1604 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1607 IFileSourceFilter
*source
= NULL
;
1608 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&source
);
1610 IFileSourceFilter_Release(source
);
1612 IBaseFilter_Release(*filter
);
1620 static HRESULT WINAPI
FilterGraph2_AddSourceFilter(IFilterGraph2
*iface
, LPCWSTR lpcwstrFileName
,
1621 LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1623 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1625 IBaseFilter
* preader
;
1626 IFileSourceFilter
* pfile
= NULL
;
1630 TRACE("(%p/%p)->(%s, %s, %p)\n", This
, iface
, debugstr_w(lpcwstrFileName
), debugstr_w(lpcwstrFilterName
), ppFilter
);
1632 /* Try from file name first, then fall back to default asynchronous reader */
1633 hr
= GetFileSourceFilter(lpcwstrFileName
, &preader
);
1636 hr
= CoCreateInstance(&CLSID_AsyncReader
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&preader
);
1638 WARN("Unable to create file source filter (%x)\n", hr
);
1642 hr
= IFilterGraph2_AddFilter(iface
, preader
, lpcwstrFilterName
);
1644 WARN("Unable add filter (%x)\n", hr
);
1645 IBaseFilter_Release(preader
);
1649 hr
= IBaseFilter_QueryInterface(preader
, &IID_IFileSourceFilter
, (LPVOID
*)&pfile
);
1651 WARN("Unable to get IFileSourceInterface (%x)\n", hr
);
1655 /* Load the file in the file source filter */
1656 hr
= IFileSourceFilter_Load(pfile
, lpcwstrFileName
, NULL
);
1658 WARN("Load (%x)\n", hr
);
1662 IFileSourceFilter_GetCurFile(pfile
, &filename
, &mt
);
1664 WARN("GetCurFile (%x)\n", hr
);
1668 TRACE("File %s\n", debugstr_w(filename
));
1669 TRACE("MajorType %s\n", debugstr_guid(&mt
.majortype
));
1670 TRACE("SubType %s\n", debugstr_guid(&mt
.subtype
));
1673 *ppFilter
= preader
;
1674 IFileSourceFilter_Release(pfile
);
1680 IFileSourceFilter_Release(pfile
);
1681 IFilterGraph2_RemoveFilter(iface
, preader
);
1682 IBaseFilter_Release(preader
);
1687 static HRESULT WINAPI
FilterGraph2_SetLogFile(IFilterGraph2
*iface
, DWORD_PTR hFile
)
1689 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1691 TRACE("(%p/%p)->(%08x): stub !!!\n", This
, iface
, (DWORD
) hFile
);
1696 static HRESULT WINAPI
FilterGraph2_Abort(IFilterGraph2
*iface
)
1698 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1700 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1705 static HRESULT WINAPI
FilterGraph2_ShouldOperationContinue(IFilterGraph2
*iface
)
1707 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1709 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1714 /*** IFilterGraph2 methods ***/
1715 static HRESULT WINAPI
FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2
*iface
,
1716 IMoniker
*pMoniker
, IBindCtx
*pCtx
, LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1718 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1720 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This
, iface
, pMoniker
, pCtx
, debugstr_w(lpcwstrFilterName
), ppFilter
);
1725 static HRESULT WINAPI
FilterGraph2_ReconnectEx(IFilterGraph2
*iface
, IPin
*ppin
,
1726 const AM_MEDIA_TYPE
*pmt
)
1728 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1730 TRACE("(%p/%p)->(%p %p): stub !!!\n", This
, iface
, ppin
, pmt
);
1735 static HRESULT WINAPI
FilterGraph2_RenderEx(IFilterGraph2
*iface
, IPin
*pPinOut
, DWORD dwFlags
,
1738 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1740 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This
, iface
, pPinOut
, dwFlags
, pvContext
);
1746 static const IFilterGraph2Vtbl IFilterGraph2_VTable
=
1748 FilterGraph2_QueryInterface
,
1749 FilterGraph2_AddRef
,
1750 FilterGraph2_Release
,
1751 FilterGraph2_AddFilter
,
1752 FilterGraph2_RemoveFilter
,
1753 FilterGraph2_EnumFilters
,
1754 FilterGraph2_FindFilterByName
,
1755 FilterGraph2_ConnectDirect
,
1756 FilterGraph2_Reconnect
,
1757 FilterGraph2_Disconnect
,
1758 FilterGraph2_SetDefaultSyncSource
,
1759 FilterGraph2_Connect
,
1760 FilterGraph2_Render
,
1761 FilterGraph2_RenderFile
,
1762 FilterGraph2_AddSourceFilter
,
1763 FilterGraph2_SetLogFile
,
1765 FilterGraph2_ShouldOperationContinue
,
1766 FilterGraph2_AddSourceFilterForMoniker
,
1767 FilterGraph2_ReconnectEx
,
1768 FilterGraph2_RenderEx
1771 static inline IFilterGraphImpl
*impl_from_IMediaControl(IMediaControl
*iface
)
1773 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaControl_iface
);
1776 static HRESULT WINAPI
MediaControl_QueryInterface(IMediaControl
*iface
, REFIID riid
, void **ppvObj
)
1778 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1780 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1782 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
1785 static ULONG WINAPI
MediaControl_AddRef(IMediaControl
*iface
)
1787 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1789 TRACE("(%p/%p)->()\n", This
, iface
);
1791 return Filtergraph_AddRef(This
);
1794 static ULONG WINAPI
MediaControl_Release(IMediaControl
*iface
)
1796 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1798 TRACE("(%p/%p)->()\n", This
, iface
);
1800 return Filtergraph_Release(This
);
1804 /*** IDispatch methods ***/
1805 static HRESULT WINAPI
MediaControl_GetTypeInfoCount(IMediaControl
*iface
, UINT
*pctinfo
)
1807 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1809 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
1814 static HRESULT WINAPI
MediaControl_GetTypeInfo(IMediaControl
*iface
, UINT iTInfo
, LCID lcid
,
1815 ITypeInfo
**ppTInfo
)
1817 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1819 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
1824 static HRESULT WINAPI
MediaControl_GetIDsOfNames(IMediaControl
*iface
, REFIID riid
,
1825 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1827 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1829 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1834 static HRESULT WINAPI
MediaControl_Invoke(IMediaControl
*iface
, DISPID dispIdMember
, REFIID riid
,
1835 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
1838 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1840 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
);
1845 typedef HRESULT(WINAPI
*fnFoundFilter
)(IBaseFilter
*, DWORD_PTR data
);
1847 static HRESULT
ExploreGraph(IFilterGraphImpl
* pGraph
, IPin
* pOutputPin
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1856 TRACE("%p %p\n", pGraph
, pOutputPin
);
1857 PinInfo
.pFilter
= NULL
;
1859 hr
= IPin_ConnectedTo(pOutputPin
, &pInputPin
);
1863 hr
= IPin_QueryPinInfo(pInputPin
, &PinInfo
);
1865 hr
= GetInternalConnections(PinInfo
.pFilter
, pInputPin
, &ppPins
, &nb
);
1866 IPin_Release(pInputPin
);
1873 TRACE("Reached a renderer\n");
1874 /* Count renderers for end of stream notification */
1875 pGraph
->nRenderers
++;
1879 for(i
= 0; i
< nb
; i
++)
1881 /* Explore the graph downstream from this pin
1882 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1883 * several input pins are connected to the same output (a MUX for instance). */
1884 ExploreGraph(pGraph
, ppPins
[i
], FoundFilter
, data
);
1885 IPin_Release(ppPins
[i
]);
1888 CoTaskMemFree(ppPins
);
1890 TRACE("Doing stuff with filter %p\n", PinInfo
.pFilter
);
1892 FoundFilter(PinInfo
.pFilter
, data
);
1895 if (PinInfo
.pFilter
) IBaseFilter_Release(PinInfo
.pFilter
);
1899 static HRESULT WINAPI
SendRun(IBaseFilter
*pFilter
, DWORD_PTR data
)
1901 REFERENCE_TIME time
= *(REFERENCE_TIME
*)data
;
1902 return IBaseFilter_Run(pFilter
, time
);
1905 static HRESULT WINAPI
SendPause(IBaseFilter
*pFilter
, DWORD_PTR data
)
1907 return IBaseFilter_Pause(pFilter
);
1910 static HRESULT WINAPI
SendStop(IBaseFilter
*pFilter
, DWORD_PTR data
)
1912 return IBaseFilter_Stop(pFilter
);
1915 static HRESULT WINAPI
SendGetState(IBaseFilter
*pFilter
, DWORD_PTR data
)
1918 DWORD time_end
= data
;
1919 DWORD time_now
= GetTickCount();
1922 if (time_end
== INFINITE
)
1926 else if (time_end
> time_now
)
1928 wait
= time_end
- time_now
;
1933 return IBaseFilter_GetState(pFilter
, wait
, &state
);
1937 static HRESULT
SendFilterMessage(IFilterGraphImpl
*This
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1940 IBaseFilter
* pfilter
;
1947 TRACE("(%p)->()\n", This
);
1949 /* Explorer the graph from source filters to renderers, determine renderers
1950 * number and run filters from renderers to source filters */
1951 This
->nRenderers
= 0;
1952 ResetEvent(This
->hEventCompletion
);
1954 for(i
= 0; i
< This
->nFilters
; i
++)
1957 pfilter
= This
->ppFiltersInGraph
[i
];
1958 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
1961 WARN("Enum pins failed %x\n", hr
);
1964 /* Check if it is a source filter */
1965 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1967 IPin_QueryDirection(pPin
, &dir
);
1969 if (dir
== PINDIR_INPUT
)
1977 TRACE("Found a source filter %p\n", pfilter
);
1978 IEnumPins_Reset(pEnum
);
1979 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1981 /* Explore the graph downstream from this pin */
1982 ExploreGraph(This
, pPin
, FoundFilter
, data
);
1985 FoundFilter(pfilter
, data
);
1987 IEnumPins_Release(pEnum
);
1993 /*** IMediaControl methods ***/
1994 static HRESULT WINAPI
MediaControl_Run(IMediaControl
*iface
)
1996 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1998 TRACE("(%p/%p)->()\n", This
, iface
);
2000 EnterCriticalSection(&This
->cs
);
2001 if (This
->state
== State_Running
)
2003 This
->EcCompleteCount
= 0;
2005 if (This
->defaultclock
&& !This
->refClock
)
2006 IFilterGraph2_SetDefaultSyncSource((IFilterGraph2
*)This
);
2011 IReferenceClock_GetTime(This
->refClock
, &now
);
2012 if (This
->state
== State_Stopped
)
2013 This
->start_time
= now
+ 500000;
2014 else if (This
->pause_time
>= 0)
2015 This
->start_time
+= now
- This
->pause_time
;
2017 This
->start_time
= now
;
2019 else This
->start_time
= 0;
2021 SendFilterMessage(This
, SendRun
, (DWORD_PTR
)&This
->start_time
);
2022 This
->state
= State_Running
;
2024 LeaveCriticalSection(&This
->cs
);
2028 static HRESULT WINAPI
MediaControl_Pause(IMediaControl
*iface
)
2030 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2032 TRACE("(%p/%p)->()\n", This
, iface
);
2034 EnterCriticalSection(&This
->cs
);
2035 if (This
->state
== State_Paused
)
2038 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2039 IReferenceClock_GetTime(This
->refClock
, &This
->pause_time
);
2041 This
->pause_time
= -1;
2043 SendFilterMessage(This
, SendPause
, 0);
2044 This
->state
= State_Paused
;
2046 LeaveCriticalSection(&This
->cs
);
2050 static HRESULT WINAPI
MediaControl_Stop(IMediaControl
*iface
)
2052 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2054 TRACE("(%p/%p)->()\n", This
, iface
);
2056 if (This
->state
== State_Stopped
) return S_OK
;
2058 EnterCriticalSection(&This
->cs
);
2059 if (This
->state
== State_Running
) SendFilterMessage(This
, SendPause
, 0);
2060 SendFilterMessage(This
, SendStop
, 0);
2061 This
->state
= State_Stopped
;
2062 LeaveCriticalSection(&This
->cs
);
2066 static HRESULT WINAPI
MediaControl_GetState(IMediaControl
*iface
, LONG msTimeout
,
2069 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2072 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pfs
);
2077 EnterCriticalSection(&This
->cs
);
2082 end
= GetTickCount() + msTimeout
;
2084 else if (msTimeout
< 0)
2093 SendFilterMessage(This
, SendGetState
, end
);
2095 LeaveCriticalSection(&This
->cs
);
2100 static HRESULT WINAPI
MediaControl_RenderFile(IMediaControl
*iface
, BSTR strFilename
)
2102 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2104 FIXME("(%p/%p)->(%s (%p)): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
);
2109 static HRESULT WINAPI
MediaControl_AddSourceFilter(IMediaControl
*iface
, BSTR strFilename
,
2112 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2114 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
, ppUnk
);
2119 static HRESULT WINAPI
MediaControl_get_FilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2121 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2123 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2128 static HRESULT WINAPI
MediaControl_get_RegFilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2130 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2132 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2137 static HRESULT WINAPI
MediaControl_StopWhenReady(IMediaControl
*iface
)
2139 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2141 FIXME("(%p/%p)->(): stub !!!\n", This
, iface
);
2147 static const IMediaControlVtbl IMediaControl_VTable
=
2149 MediaControl_QueryInterface
,
2150 MediaControl_AddRef
,
2151 MediaControl_Release
,
2152 MediaControl_GetTypeInfoCount
,
2153 MediaControl_GetTypeInfo
,
2154 MediaControl_GetIDsOfNames
,
2155 MediaControl_Invoke
,
2159 MediaControl_GetState
,
2160 MediaControl_RenderFile
,
2161 MediaControl_AddSourceFilter
,
2162 MediaControl_get_FilterCollection
,
2163 MediaControl_get_RegFilterCollection
,
2164 MediaControl_StopWhenReady
2167 static inline IFilterGraphImpl
*impl_from_IMediaSeeking(IMediaSeeking
*iface
)
2169 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaSeeking_iface
);
2172 static HRESULT WINAPI
MediaSeeking_QueryInterface(IMediaSeeking
*iface
, REFIID riid
, void **ppvObj
)
2174 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2176 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2178 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2181 static ULONG WINAPI
MediaSeeking_AddRef(IMediaSeeking
*iface
)
2183 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2185 TRACE("(%p/%p)->()\n", This
, iface
);
2187 return Filtergraph_AddRef(This
);
2190 static ULONG WINAPI
MediaSeeking_Release(IMediaSeeking
*iface
)
2192 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2194 TRACE("(%p/%p)->()\n", This
, iface
);
2196 return Filtergraph_Release(This
);
2199 typedef HRESULT (WINAPI
*fnFoundSeek
)(IFilterGraphImpl
*This
, IMediaSeeking
*, DWORD_PTR arg
);
2201 static HRESULT
all_renderers_seek(IFilterGraphImpl
*This
, fnFoundSeek FoundSeek
, DWORD_PTR arg
) {
2202 BOOL allnotimpl
= TRUE
;
2204 HRESULT hr
, hr_return
= S_OK
;
2206 TRACE("(%p)->(%p %08lx)\n", This
, FoundSeek
, arg
);
2207 /* Send a message to all renderers, they are responsible for broadcasting it further */
2209 for(i
= 0; i
< This
->nFilters
; i
++)
2211 IMediaSeeking
*seek
= NULL
;
2212 IBaseFilter
* pfilter
= This
->ppFiltersInGraph
[i
];
2213 IAMFilterMiscFlags
*flags
= NULL
;
2215 IUnknown_QueryInterface(pfilter
, &IID_IAMFilterMiscFlags
, (void**)&flags
);
2218 filterflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
2219 IUnknown_Release(flags
);
2220 if (filterflags
!= AM_FILTER_MISC_FLAGS_IS_RENDERER
)
2223 IBaseFilter_QueryInterface(pfilter
, &IID_IMediaSeeking
, (void**)&seek
);
2226 hr
= FoundSeek(This
, seek
, arg
);
2227 IMediaSeeking_Release(seek
);
2228 if (hr_return
!= E_NOTIMPL
)
2230 if (hr_return
== S_OK
|| (FAILED(hr
) && hr
!= E_NOTIMPL
&& SUCCEEDED(hr_return
)))
2239 static HRESULT WINAPI
FoundCapabilities(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pcaps
)
2244 hr
= IMediaSeeking_GetCapabilities(seek
, &caps
);
2248 /* Only add common capabilities everything supports */
2249 *(DWORD
*)pcaps
&= caps
;
2254 /*** IMediaSeeking methods ***/
2255 static HRESULT WINAPI
MediaSeeking_GetCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2257 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2260 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2265 EnterCriticalSection(&This
->cs
);
2266 *pCapabilities
= 0xffffffff;
2268 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2269 LeaveCriticalSection(&This
->cs
);
2274 static HRESULT WINAPI
MediaSeeking_CheckCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2276 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2280 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2285 EnterCriticalSection(&This
->cs
);
2286 originalcaps
= *pCapabilities
;
2287 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2288 LeaveCriticalSection(&This
->cs
);
2293 if (!*pCapabilities
)
2295 if (*pCapabilities
!= originalcaps
)
2300 static HRESULT WINAPI
MediaSeeking_IsFormatSupported(IMediaSeeking
*iface
, const GUID
*pFormat
)
2302 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2307 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2309 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2311 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2318 static HRESULT WINAPI
MediaSeeking_QueryPreferredFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2320 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2325 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This
, iface
, pFormat
);
2326 memcpy(pFormat
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
2331 static HRESULT WINAPI
MediaSeeking_GetTimeFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2333 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2338 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2339 memcpy(pFormat
, &This
->timeformatseek
, sizeof(GUID
));
2344 static HRESULT WINAPI
MediaSeeking_IsUsingTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2346 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2348 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2352 if (memcmp(pFormat
, &This
->timeformatseek
, sizeof(GUID
)))
2358 static HRESULT WINAPI
MediaSeeking_SetTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2360 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2365 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2367 if (This
->state
!= State_Stopped
)
2368 return VFW_E_WRONG_STATE
;
2370 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2372 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2373 return E_INVALIDARG
;
2379 static HRESULT WINAPI
FoundDuration(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pduration
)
2382 LONGLONG duration
= 0, *pdur
= (LONGLONG
*)pduration
;
2384 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
2388 if (*pdur
< duration
)
2393 static HRESULT WINAPI
MediaSeeking_GetDuration(IMediaSeeking
*iface
, LONGLONG
*pDuration
)
2395 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2398 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDuration
);
2403 EnterCriticalSection(&This
->cs
);
2405 hr
= all_renderers_seek(This
, FoundDuration
, (DWORD_PTR
)pDuration
);
2406 LeaveCriticalSection(&This
->cs
);
2408 TRACE("--->%08x\n", hr
);
2412 static HRESULT WINAPI
MediaSeeking_GetStopPosition(IMediaSeeking
*iface
, LONGLONG
*pStop
)
2414 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2417 TRACE("(%p/%p)->(%p)\n", This
, iface
, pStop
);
2422 EnterCriticalSection(&This
->cs
);
2423 if (This
->stop_position
< 0)
2424 /* Stop position not set, use duration instead */
2425 hr
= IMediaSeeking_GetDuration(iface
, pStop
);
2427 *pStop
= This
->stop_position
;
2428 LeaveCriticalSection(&This
->cs
);
2433 static HRESULT WINAPI
FoundCurrentPosition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pposition
)
2436 LONGLONG pos
= 0, *ppos
= (LONGLONG
*)pposition
;
2438 hr
= IMediaSeeking_GetCurrentPosition(seek
, &pos
);
2442 if (*ppos
< 0 || pos
< *ppos
)
2447 static HRESULT WINAPI
MediaSeeking_GetCurrentPosition(IMediaSeeking
*iface
, LONGLONG
*pCurrent
)
2449 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2455 EnterCriticalSection(&This
->cs
);
2457 hr
= all_renderers_seek(This
, FoundCurrentPosition
, (DWORD_PTR
)pCurrent
);
2458 if (hr
== E_NOTIMPL
) {
2462 LeaveCriticalSection(&This
->cs
);
2464 TRACE("Time: %u.%03u\n", (DWORD
)(*pCurrent
/ 10000000), (DWORD
)((*pCurrent
/ 10000)%1000));
2469 static HRESULT WINAPI
MediaSeeking_ConvertTimeFormat(IMediaSeeking
*iface
, LONGLONG
*pTarget
,
2470 const GUID
*pTargetFormat
, LONGLONG Source
, const GUID
*pSourceFormat
)
2472 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2474 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This
, iface
, pTarget
,
2475 pTargetFormat
, wine_dbgstr_longlong(Source
), pSourceFormat
);
2481 LONGLONG
* current
, *stop
;
2482 DWORD curflags
, stopflags
;
2485 static HRESULT WINAPI
found_setposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2487 struct pos_args
*args
= (void*)pargs
;
2489 return IMediaSeeking_SetPositions(seek
, args
->current
, args
->curflags
, args
->stop
, args
->stopflags
);
2492 static HRESULT WINAPI
MediaSeeking_SetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2493 DWORD dwCurrentFlags
, LONGLONG
*pStop
, DWORD dwStopFlags
)
2495 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2498 struct pos_args args
;
2500 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This
, iface
, pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
2502 EnterCriticalSection(&This
->cs
);
2503 state
= This
->state
;
2504 TRACE("State: %s\n", state
== State_Running
? "Running" : (state
== State_Paused
? "Paused" : (state
== State_Stopped
? "Stopped" : "UNKNOWN")));
2506 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_AbsolutePositioning
&&
2507 (dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2508 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags
& 0x7);
2510 if ((dwStopFlags
& 0x7) == AM_SEEKING_AbsolutePositioning
)
2511 This
->stop_position
= *pStop
;
2512 else if ((dwStopFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2513 FIXME("Stop position not handled yet!\n");
2515 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2516 IMediaControl_Pause(&This
->IMediaControl_iface
);
2517 args
.current
= pCurrent
;
2519 args
.curflags
= dwCurrentFlags
;
2520 args
.stopflags
= dwStopFlags
;
2521 hr
= all_renderers_seek(This
, found_setposition
, (DWORD_PTR
)&args
);
2523 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2524 This
->pause_time
= This
->start_time
= -1;
2525 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2526 IMediaControl_Run(&This
->IMediaControl_iface
);
2527 LeaveCriticalSection(&This
->cs
);
2532 static HRESULT WINAPI
MediaSeeking_GetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2535 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2538 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pCurrent
, pStop
);
2539 hr
= IMediaSeeking_GetCurrentPosition(iface
, pCurrent
);
2541 hr
= IMediaSeeking_GetStopPosition(iface
, pStop
);
2546 static HRESULT WINAPI
MediaSeeking_GetAvailable(IMediaSeeking
*iface
, LONGLONG
*pEarliest
,
2549 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2551 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This
, iface
, pEarliest
, pLatest
);
2556 static HRESULT WINAPI
MediaSeeking_SetRate(IMediaSeeking
*iface
, double dRate
)
2558 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2560 FIXME("(%p/%p)->(%f): stub !!!\n", This
, iface
, dRate
);
2565 static HRESULT WINAPI
MediaSeeking_GetRate(IMediaSeeking
*iface
, double *pdRate
)
2567 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2569 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pdRate
);
2574 static HRESULT WINAPI
MediaSeeking_GetPreroll(IMediaSeeking
*iface
, LONGLONG
*pllPreroll
)
2576 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2578 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pllPreroll
);
2584 static const IMediaSeekingVtbl IMediaSeeking_VTable
=
2586 MediaSeeking_QueryInterface
,
2587 MediaSeeking_AddRef
,
2588 MediaSeeking_Release
,
2589 MediaSeeking_GetCapabilities
,
2590 MediaSeeking_CheckCapabilities
,
2591 MediaSeeking_IsFormatSupported
,
2592 MediaSeeking_QueryPreferredFormat
,
2593 MediaSeeking_GetTimeFormat
,
2594 MediaSeeking_IsUsingTimeFormat
,
2595 MediaSeeking_SetTimeFormat
,
2596 MediaSeeking_GetDuration
,
2597 MediaSeeking_GetStopPosition
,
2598 MediaSeeking_GetCurrentPosition
,
2599 MediaSeeking_ConvertTimeFormat
,
2600 MediaSeeking_SetPositions
,
2601 MediaSeeking_GetPositions
,
2602 MediaSeeking_GetAvailable
,
2603 MediaSeeking_SetRate
,
2604 MediaSeeking_GetRate
,
2605 MediaSeeking_GetPreroll
2608 static inline IFilterGraphImpl
*impl_from_IMediaPosition(IMediaPosition
*iface
)
2610 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaPosition_iface
);
2613 /*** IUnknown methods ***/
2614 static HRESULT WINAPI
MediaPosition_QueryInterface(IMediaPosition
* iface
, REFIID riid
, void** ppvObj
)
2616 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2618 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2619 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2622 static ULONG WINAPI
MediaPosition_AddRef(IMediaPosition
*iface
)
2624 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2626 TRACE("(%p/%p)->()\n", This
, iface
);
2627 return Filtergraph_AddRef(This
);
2630 static ULONG WINAPI
MediaPosition_Release(IMediaPosition
*iface
)
2632 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2634 TRACE("(%p/%p)->()\n", This
, iface
);
2635 return Filtergraph_Release(This
);
2638 /*** IDispatch methods ***/
2639 static HRESULT WINAPI
MediaPosition_GetTypeInfoCount(IMediaPosition
*iface
, UINT
* pctinfo
){
2640 FIXME("(%p) stub!\n", iface
);
2644 static HRESULT WINAPI
MediaPosition_GetTypeInfo(IMediaPosition
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
){
2645 FIXME("(%p) stub!\n", iface
);
2649 static HRESULT WINAPI
MediaPosition_GetIDsOfNames(IMediaPosition
* iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
){
2650 FIXME("(%p) stub!\n", iface
);
2654 static HRESULT WINAPI
MediaPosition_Invoke(IMediaPosition
* iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
){
2655 FIXME("(%p) stub!\n", iface
);
2659 static HRESULT
ConvertFromREFTIME(IMediaSeeking
*seek
, REFTIME time_in
, LONGLONG
*time_out
)
2664 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2667 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2669 FIXME("Unsupported time format.\n");
2673 *time_out
= (LONGLONG
) (time_in
* 10000000); /* convert from 1 second intervals to 100 ns intervals */
2677 static HRESULT
ConvertToREFTIME(IMediaSeeking
*seek
, LONGLONG time_in
, REFTIME
*time_out
)
2682 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2685 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2687 FIXME("Unsupported time format.\n");
2691 *time_out
= (REFTIME
)time_in
/ 10000000; /* convert from 100 ns intervals to 1 second intervals */
2695 /*** IMediaPosition methods ***/
2696 static HRESULT WINAPI
MediaPosition_get_Duration(IMediaPosition
* iface
, REFTIME
*plength
)
2699 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2700 HRESULT hr
= IMediaSeeking_GetDuration(&This
->IMediaSeeking_iface
, &duration
);
2703 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, duration
, plength
);
2706 static HRESULT WINAPI
MediaPosition_put_CurrentPosition(IMediaPosition
* iface
, REFTIME llTime
)
2708 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2712 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2715 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, &reftime
,
2716 AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
2719 static HRESULT WINAPI
MediaPosition_get_CurrentPosition(IMediaPosition
* iface
, REFTIME
*pllTime
)
2721 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2725 hr
= IMediaSeeking_GetCurrentPosition(&This
->IMediaSeeking_iface
, &pos
);
2728 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2731 static HRESULT WINAPI
MediaPosition_get_StopTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2733 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2735 HRESULT hr
= IMediaSeeking_GetStopPosition(&This
->IMediaSeeking_iface
, &pos
);
2738 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2741 static HRESULT WINAPI
MediaPosition_put_StopTime(IMediaPosition
* iface
, REFTIME llTime
)
2743 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2747 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2750 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, NULL
, AM_SEEKING_NoPositioning
,
2751 &reftime
, AM_SEEKING_AbsolutePositioning
);
2754 static HRESULT WINAPI
MediaPosition_get_PrerollTime(IMediaPosition
* iface
, REFTIME
*pllTime
){
2755 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2759 static HRESULT WINAPI
MediaPosition_put_PrerollTime(IMediaPosition
* iface
, REFTIME llTime
){
2760 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2764 static HRESULT WINAPI
MediaPosition_put_Rate(IMediaPosition
* iface
, double dRate
)
2766 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2767 return IMediaSeeking_SetRate(&This
->IMediaSeeking_iface
, dRate
);
2770 static HRESULT WINAPI
MediaPosition_get_Rate(IMediaPosition
* iface
, double *pdRate
)
2772 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2773 return IMediaSeeking_GetRate(&This
->IMediaSeeking_iface
, pdRate
);
2776 static HRESULT WINAPI
MediaPosition_CanSeekForward(IMediaPosition
* iface
, LONG
*pCanSeekForward
){
2777 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekForward
);
2781 static HRESULT WINAPI
MediaPosition_CanSeekBackward(IMediaPosition
* iface
, LONG
*pCanSeekBackward
){
2782 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekBackward
);
2787 static const IMediaPositionVtbl IMediaPosition_VTable
=
2789 MediaPosition_QueryInterface
,
2790 MediaPosition_AddRef
,
2791 MediaPosition_Release
,
2792 MediaPosition_GetTypeInfoCount
,
2793 MediaPosition_GetTypeInfo
,
2794 MediaPosition_GetIDsOfNames
,
2795 MediaPosition_Invoke
,
2796 MediaPosition_get_Duration
,
2797 MediaPosition_put_CurrentPosition
,
2798 MediaPosition_get_CurrentPosition
,
2799 MediaPosition_get_StopTime
,
2800 MediaPosition_put_StopTime
,
2801 MediaPosition_get_PrerollTime
,
2802 MediaPosition_put_PrerollTime
,
2803 MediaPosition_put_Rate
,
2804 MediaPosition_get_Rate
,
2805 MediaPosition_CanSeekForward
,
2806 MediaPosition_CanSeekBackward
2809 static inline IFilterGraphImpl
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
2811 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IObjectWithSite_iface
);
2814 /*** IUnknown methods ***/
2815 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
* iface
, REFIID riid
, void** ppvObj
)
2817 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2819 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2820 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2823 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
2825 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2827 TRACE("(%p/%p)->()\n", This
, iface
);
2828 return Filtergraph_AddRef(This
);
2831 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
2833 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2835 TRACE("(%p/%p)->()\n", This
, iface
);
2836 return Filtergraph_Release(This
);
2839 /*** IObjectWithSite methods ***/
2841 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
2843 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2845 TRACE("(%p/%p)->()\n", This
, iface
);
2846 if (This
->pSite
) IUnknown_Release(This
->pSite
);
2847 This
->pSite
= pUnkSite
;
2848 IUnknown_AddRef(This
->pSite
);
2852 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
*iface
, REFIID riid
, PVOID
*ppvSite
)
2854 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2856 TRACE("(%p/%p)->(%s)\n", This
, iface
,debugstr_guid(riid
));
2862 return IUnknown_QueryInterface(This
->pSite
, riid
, ppvSite
);
2865 static const IObjectWithSiteVtbl IObjectWithSite_VTable
=
2867 ObjectWithSite_QueryInterface
,
2868 ObjectWithSite_AddRef
,
2869 ObjectWithSite_Release
,
2870 ObjectWithSite_SetSite
,
2871 ObjectWithSite_GetSite
,
2874 static HRESULT
GetTargetInterface(IFilterGraphImpl
* pGraph
, REFIID riid
, LPVOID
* ppvObj
)
2876 HRESULT hr
= E_NOINTERFACE
;
2880 /* Check if the interface type is already registered */
2881 for (entry
= 0; entry
< pGraph
->nItfCacheEntries
; entry
++)
2882 if (riid
== pGraph
->ItfCacheEntries
[entry
].riid
)
2884 if (pGraph
->ItfCacheEntries
[entry
].iface
)
2886 /* Return the interface if available */
2887 *ppvObj
= pGraph
->ItfCacheEntries
[entry
].iface
;
2893 if (entry
>= MAX_ITF_CACHE_ENTRIES
)
2895 FIXME("Not enough space to store interface in the cache\n");
2896 return E_OUTOFMEMORY
;
2899 /* Find a filter supporting the requested interface */
2900 for (i
= 0; i
< pGraph
->nFilters
; i
++)
2902 hr
= IBaseFilter_QueryInterface(pGraph
->ppFiltersInGraph
[i
], riid
, ppvObj
);
2905 pGraph
->ItfCacheEntries
[entry
].riid
= riid
;
2906 pGraph
->ItfCacheEntries
[entry
].filter
= pGraph
->ppFiltersInGraph
[i
];
2907 pGraph
->ItfCacheEntries
[entry
].iface
= *ppvObj
;
2908 if (entry
>= pGraph
->nItfCacheEntries
)
2909 pGraph
->nItfCacheEntries
++;
2912 if (hr
!= E_NOINTERFACE
)
2919 static inline IFilterGraphImpl
*impl_from_IBasicAudio(IBasicAudio
*iface
)
2921 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicAudio_iface
);
2924 static HRESULT WINAPI
BasicAudio_QueryInterface(IBasicAudio
*iface
, REFIID riid
, void **ppvObj
)
2926 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2928 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2930 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2933 static ULONG WINAPI
BasicAudio_AddRef(IBasicAudio
*iface
)
2935 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2937 TRACE("(%p/%p)->()\n", This
, iface
);
2939 return Filtergraph_AddRef(This
);
2942 static ULONG WINAPI
BasicAudio_Release(IBasicAudio
*iface
)
2944 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2946 TRACE("(%p/%p)->()\n", This
, iface
);
2948 return Filtergraph_Release(This
);
2951 /*** IDispatch methods ***/
2952 static HRESULT WINAPI
BasicAudio_GetTypeInfoCount(IBasicAudio
*iface
, UINT
*pctinfo
)
2954 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2955 IBasicAudio
* pBasicAudio
;
2958 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
2960 EnterCriticalSection(&This
->cs
);
2962 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2965 hr
= IBasicAudio_GetTypeInfoCount(pBasicAudio
, pctinfo
);
2967 LeaveCriticalSection(&This
->cs
);
2972 static HRESULT WINAPI
BasicAudio_GetTypeInfo(IBasicAudio
*iface
, UINT iTInfo
, LCID lcid
,
2973 ITypeInfo
**ppTInfo
)
2975 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2976 IBasicAudio
* pBasicAudio
;
2979 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
2981 EnterCriticalSection(&This
->cs
);
2983 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2986 hr
= IBasicAudio_GetTypeInfo(pBasicAudio
, iTInfo
, lcid
, ppTInfo
);
2988 LeaveCriticalSection(&This
->cs
);
2993 static HRESULT WINAPI
BasicAudio_GetIDsOfNames(IBasicAudio
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
2994 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
2996 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2997 IBasicAudio
* pBasicAudio
;
3000 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3002 EnterCriticalSection(&This
->cs
);
3004 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3007 hr
= IBasicAudio_GetIDsOfNames(pBasicAudio
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3009 LeaveCriticalSection(&This
->cs
);
3014 static HRESULT WINAPI
BasicAudio_Invoke(IBasicAudio
*iface
, DISPID dispIdMember
, REFIID riid
,
3015 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3018 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3019 IBasicAudio
* pBasicAudio
;
3022 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
);
3024 EnterCriticalSection(&This
->cs
);
3026 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3029 hr
= IBasicAudio_Invoke(pBasicAudio
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3031 LeaveCriticalSection(&This
->cs
);
3036 /*** IBasicAudio methods ***/
3037 static HRESULT WINAPI
BasicAudio_put_Volume(IBasicAudio
*iface
, LONG lVolume
)
3039 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3040 IBasicAudio
* pBasicAudio
;
3043 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
3045 EnterCriticalSection(&This
->cs
);
3047 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3050 hr
= IBasicAudio_put_Volume(pBasicAudio
, lVolume
);
3052 LeaveCriticalSection(&This
->cs
);
3057 static HRESULT WINAPI
BasicAudio_get_Volume(IBasicAudio
*iface
, LONG
*plVolume
)
3059 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3060 IBasicAudio
* pBasicAudio
;
3063 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
3065 EnterCriticalSection(&This
->cs
);
3067 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3070 hr
= IBasicAudio_get_Volume(pBasicAudio
, plVolume
);
3072 LeaveCriticalSection(&This
->cs
);
3077 static HRESULT WINAPI
BasicAudio_put_Balance(IBasicAudio
*iface
, LONG lBalance
)
3079 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3080 IBasicAudio
* pBasicAudio
;
3083 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
3085 EnterCriticalSection(&This
->cs
);
3087 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3090 hr
= IBasicAudio_put_Balance(pBasicAudio
, lBalance
);
3092 LeaveCriticalSection(&This
->cs
);
3097 static HRESULT WINAPI
BasicAudio_get_Balance(IBasicAudio
*iface
, LONG
*plBalance
)
3099 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3100 IBasicAudio
* pBasicAudio
;
3103 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
3105 EnterCriticalSection(&This
->cs
);
3107 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3110 hr
= IBasicAudio_get_Balance(pBasicAudio
, plBalance
);
3112 LeaveCriticalSection(&This
->cs
);
3117 static const IBasicAudioVtbl IBasicAudio_VTable
=
3119 BasicAudio_QueryInterface
,
3122 BasicAudio_GetTypeInfoCount
,
3123 BasicAudio_GetTypeInfo
,
3124 BasicAudio_GetIDsOfNames
,
3126 BasicAudio_put_Volume
,
3127 BasicAudio_get_Volume
,
3128 BasicAudio_put_Balance
,
3129 BasicAudio_get_Balance
3132 static inline IFilterGraphImpl
*impl_from_IBasicVideo2(IBasicVideo2
*iface
)
3134 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicVideo2_iface
);
3137 static HRESULT WINAPI
BasicVideo_QueryInterface(IBasicVideo2
*iface
, REFIID riid
, void **ppvObj
)
3139 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3141 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3143 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
3146 static ULONG WINAPI
BasicVideo_AddRef(IBasicVideo2
*iface
)
3148 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3150 TRACE("(%p/%p)->()\n", This
, iface
);
3152 return Filtergraph_AddRef(This
);
3155 static ULONG WINAPI
BasicVideo_Release(IBasicVideo2
*iface
)
3157 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3159 TRACE("(%p/%p)->()\n", This
, iface
);
3161 return Filtergraph_Release(This
);
3164 /*** IDispatch methods ***/
3165 static HRESULT WINAPI
BasicVideo_GetTypeInfoCount(IBasicVideo2
*iface
, UINT
*pctinfo
)
3167 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3168 IBasicVideo
*pBasicVideo
;
3171 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3173 EnterCriticalSection(&This
->cs
);
3175 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3178 hr
= IBasicVideo_GetTypeInfoCount(pBasicVideo
, pctinfo
);
3180 LeaveCriticalSection(&This
->cs
);
3185 static HRESULT WINAPI
BasicVideo_GetTypeInfo(IBasicVideo2
*iface
, UINT iTInfo
, LCID lcid
,
3186 ITypeInfo
**ppTInfo
)
3188 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3189 IBasicVideo
*pBasicVideo
;
3192 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3194 EnterCriticalSection(&This
->cs
);
3196 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3199 hr
= IBasicVideo_GetTypeInfo(pBasicVideo
, iTInfo
, lcid
, ppTInfo
);
3201 LeaveCriticalSection(&This
->cs
);
3206 static HRESULT WINAPI
BasicVideo_GetIDsOfNames(IBasicVideo2
*iface
, REFIID riid
,
3207 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3209 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3210 IBasicVideo
*pBasicVideo
;
3213 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3215 EnterCriticalSection(&This
->cs
);
3217 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3220 hr
= IBasicVideo_GetIDsOfNames(pBasicVideo
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3222 LeaveCriticalSection(&This
->cs
);
3227 static HRESULT WINAPI
BasicVideo_Invoke(IBasicVideo2
*iface
, DISPID dispIdMember
, REFIID riid
,
3228 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3231 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3232 IBasicVideo
*pBasicVideo
;
3235 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
);
3237 EnterCriticalSection(&This
->cs
);
3239 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3242 hr
= IBasicVideo_Invoke(pBasicVideo
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3244 LeaveCriticalSection(&This
->cs
);
3249 /*** IBasicVideo methods ***/
3250 static HRESULT WINAPI
BasicVideo_get_AvgTimePerFrame(IBasicVideo2
*iface
, REFTIME
*pAvgTimePerFrame
)
3252 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3253 IBasicVideo
*pBasicVideo
;
3256 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
3258 EnterCriticalSection(&This
->cs
);
3260 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3263 hr
= IBasicVideo_get_AvgTimePerFrame(pBasicVideo
, pAvgTimePerFrame
);
3265 LeaveCriticalSection(&This
->cs
);
3270 static HRESULT WINAPI
BasicVideo_get_BitRate(IBasicVideo2
*iface
, LONG
*pBitRate
)
3272 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3273 IBasicVideo
*pBasicVideo
;
3276 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
3278 EnterCriticalSection(&This
->cs
);
3280 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3283 hr
= IBasicVideo_get_BitRate(pBasicVideo
, pBitRate
);
3285 LeaveCriticalSection(&This
->cs
);
3290 static HRESULT WINAPI
BasicVideo_get_BitErrorRate(IBasicVideo2
*iface
, LONG
*pBitErrorRate
)
3292 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3293 IBasicVideo
*pBasicVideo
;
3296 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
3298 EnterCriticalSection(&This
->cs
);
3300 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3303 hr
= IBasicVideo_get_BitErrorRate(pBasicVideo
, pBitErrorRate
);
3305 LeaveCriticalSection(&This
->cs
);
3310 static HRESULT WINAPI
BasicVideo_get_VideoWidth(IBasicVideo2
*iface
, LONG
*pVideoWidth
)
3312 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3313 IBasicVideo
*pBasicVideo
;
3316 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
3318 EnterCriticalSection(&This
->cs
);
3320 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3323 hr
= IBasicVideo_get_VideoWidth(pBasicVideo
, pVideoWidth
);
3325 LeaveCriticalSection(&This
->cs
);
3330 static HRESULT WINAPI
BasicVideo_get_VideoHeight(IBasicVideo2
*iface
, LONG
*pVideoHeight
)
3332 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3333 IBasicVideo
*pBasicVideo
;
3336 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
3338 EnterCriticalSection(&This
->cs
);
3340 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3343 hr
= IBasicVideo_get_VideoHeight(pBasicVideo
, pVideoHeight
);
3345 LeaveCriticalSection(&This
->cs
);
3350 static HRESULT WINAPI
BasicVideo_put_SourceLeft(IBasicVideo2
*iface
, LONG SourceLeft
)
3352 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3353 IBasicVideo
*pBasicVideo
;
3356 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceLeft
);
3358 EnterCriticalSection(&This
->cs
);
3360 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3363 hr
= IBasicVideo_put_SourceLeft(pBasicVideo
, SourceLeft
);
3365 LeaveCriticalSection(&This
->cs
);
3370 static HRESULT WINAPI
BasicVideo_get_SourceLeft(IBasicVideo2
*iface
, LONG
*pSourceLeft
)
3372 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3373 IBasicVideo
*pBasicVideo
;
3376 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
3378 EnterCriticalSection(&This
->cs
);
3380 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3383 hr
= IBasicVideo_get_SourceLeft(pBasicVideo
, pSourceLeft
);
3385 LeaveCriticalSection(&This
->cs
);
3390 static HRESULT WINAPI
BasicVideo_put_SourceWidth(IBasicVideo2
*iface
, LONG SourceWidth
)
3392 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3393 IBasicVideo
*pBasicVideo
;
3396 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceWidth
);
3398 EnterCriticalSection(&This
->cs
);
3400 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3403 hr
= IBasicVideo_put_SourceWidth(pBasicVideo
, SourceWidth
);
3405 LeaveCriticalSection(&This
->cs
);
3410 static HRESULT WINAPI
BasicVideo_get_SourceWidth(IBasicVideo2
*iface
, LONG
*pSourceWidth
)
3412 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3413 IBasicVideo
*pBasicVideo
;
3416 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
3418 EnterCriticalSection(&This
->cs
);
3420 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3423 hr
= IBasicVideo_get_SourceWidth(pBasicVideo
, pSourceWidth
);
3425 LeaveCriticalSection(&This
->cs
);
3430 static HRESULT WINAPI
BasicVideo_put_SourceTop(IBasicVideo2
*iface
, LONG SourceTop
)
3432 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3433 IBasicVideo
*pBasicVideo
;
3436 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceTop
);
3438 EnterCriticalSection(&This
->cs
);
3440 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3443 hr
= IBasicVideo_put_SourceTop(pBasicVideo
, SourceTop
);
3445 LeaveCriticalSection(&This
->cs
);
3450 static HRESULT WINAPI
BasicVideo_get_SourceTop(IBasicVideo2
*iface
, LONG
*pSourceTop
)
3452 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3453 IBasicVideo
*pBasicVideo
;
3456 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
3458 EnterCriticalSection(&This
->cs
);
3460 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3463 hr
= IBasicVideo_get_SourceTop(pBasicVideo
, pSourceTop
);
3465 LeaveCriticalSection(&This
->cs
);
3470 static HRESULT WINAPI
BasicVideo_put_SourceHeight(IBasicVideo2
*iface
, LONG SourceHeight
)
3472 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3473 IBasicVideo
*pBasicVideo
;
3476 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceHeight
);
3478 EnterCriticalSection(&This
->cs
);
3480 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3483 hr
= IBasicVideo_put_SourceHeight(pBasicVideo
, SourceHeight
);
3485 LeaveCriticalSection(&This
->cs
);
3490 static HRESULT WINAPI
BasicVideo_get_SourceHeight(IBasicVideo2
*iface
, LONG
*pSourceHeight
)
3492 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3493 IBasicVideo
*pBasicVideo
;
3496 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
3498 EnterCriticalSection(&This
->cs
);
3500 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3503 hr
= IBasicVideo_get_SourceHeight(pBasicVideo
, pSourceHeight
);
3505 LeaveCriticalSection(&This
->cs
);
3510 static HRESULT WINAPI
BasicVideo_put_DestinationLeft(IBasicVideo2
*iface
, LONG DestinationLeft
)
3512 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3513 IBasicVideo
*pBasicVideo
;
3516 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationLeft
);
3518 EnterCriticalSection(&This
->cs
);
3520 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3523 hr
= IBasicVideo_put_DestinationLeft(pBasicVideo
, DestinationLeft
);
3525 LeaveCriticalSection(&This
->cs
);
3530 static HRESULT WINAPI
BasicVideo_get_DestinationLeft(IBasicVideo2
*iface
, LONG
*pDestinationLeft
)
3532 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3533 IBasicVideo
*pBasicVideo
;
3536 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
3538 EnterCriticalSection(&This
->cs
);
3540 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3543 hr
= IBasicVideo_get_DestinationLeft(pBasicVideo
, pDestinationLeft
);
3545 LeaveCriticalSection(&This
->cs
);
3550 static HRESULT WINAPI
BasicVideo_put_DestinationWidth(IBasicVideo2
*iface
, LONG DestinationWidth
)
3552 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3553 IBasicVideo
*pBasicVideo
;
3556 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationWidth
);
3558 EnterCriticalSection(&This
->cs
);
3560 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3563 hr
= IBasicVideo_put_DestinationWidth(pBasicVideo
, DestinationWidth
);
3565 LeaveCriticalSection(&This
->cs
);
3570 static HRESULT WINAPI
BasicVideo_get_DestinationWidth(IBasicVideo2
*iface
, LONG
*pDestinationWidth
)
3572 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3573 IBasicVideo
*pBasicVideo
;
3576 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
3578 EnterCriticalSection(&This
->cs
);
3580 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3583 hr
= IBasicVideo_get_DestinationWidth(pBasicVideo
, pDestinationWidth
);
3585 LeaveCriticalSection(&This
->cs
);
3590 static HRESULT WINAPI
BasicVideo_put_DestinationTop(IBasicVideo2
*iface
, LONG DestinationTop
)
3592 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3593 IBasicVideo
*pBasicVideo
;
3596 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationTop
);
3598 EnterCriticalSection(&This
->cs
);
3600 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3603 hr
= IBasicVideo_put_DestinationTop(pBasicVideo
, DestinationTop
);
3605 LeaveCriticalSection(&This
->cs
);
3610 static HRESULT WINAPI
BasicVideo_get_DestinationTop(IBasicVideo2
*iface
, LONG
*pDestinationTop
)
3612 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3613 IBasicVideo
*pBasicVideo
;
3616 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
3618 EnterCriticalSection(&This
->cs
);
3620 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3623 hr
= IBasicVideo_get_DestinationTop(pBasicVideo
, pDestinationTop
);
3625 LeaveCriticalSection(&This
->cs
);
3630 static HRESULT WINAPI
BasicVideo_put_DestinationHeight(IBasicVideo2
*iface
, LONG DestinationHeight
)
3632 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3633 IBasicVideo
*pBasicVideo
;
3636 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationHeight
);
3638 EnterCriticalSection(&This
->cs
);
3640 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3643 hr
= IBasicVideo_put_DestinationHeight(pBasicVideo
, DestinationHeight
);
3645 LeaveCriticalSection(&This
->cs
);
3650 static HRESULT WINAPI
BasicVideo_get_DestinationHeight(IBasicVideo2
*iface
,
3651 LONG
*pDestinationHeight
)
3653 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3654 IBasicVideo
*pBasicVideo
;
3657 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
3659 EnterCriticalSection(&This
->cs
);
3661 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3664 hr
= IBasicVideo_get_DestinationHeight(pBasicVideo
, pDestinationHeight
);
3666 LeaveCriticalSection(&This
->cs
);
3671 static HRESULT WINAPI
BasicVideo_SetSourcePosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3672 LONG Width
, LONG Height
)
3674 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3675 IBasicVideo
*pBasicVideo
;
3678 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3680 EnterCriticalSection(&This
->cs
);
3682 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3685 hr
= IBasicVideo_SetSourcePosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3687 LeaveCriticalSection(&This
->cs
);
3692 static HRESULT WINAPI
BasicVideo_GetSourcePosition(IBasicVideo2
*iface
, LONG
*pLeft
, LONG
*pTop
,
3693 LONG
*pWidth
, LONG
*pHeight
)
3695 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3696 IBasicVideo
*pBasicVideo
;
3699 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3701 EnterCriticalSection(&This
->cs
);
3703 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3706 hr
= IBasicVideo_GetSourcePosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3708 LeaveCriticalSection(&This
->cs
);
3713 static HRESULT WINAPI
BasicVideo_SetDefaultSourcePosition(IBasicVideo2
*iface
)
3715 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3716 IBasicVideo
*pBasicVideo
;
3719 TRACE("(%p/%p)->()\n", This
, iface
);
3721 EnterCriticalSection(&This
->cs
);
3723 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3726 hr
= IBasicVideo_SetDefaultSourcePosition(pBasicVideo
);
3728 LeaveCriticalSection(&This
->cs
);
3733 static HRESULT WINAPI
BasicVideo_SetDestinationPosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3734 LONG Width
, LONG Height
)
3736 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3737 IBasicVideo
*pBasicVideo
;
3740 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3742 EnterCriticalSection(&This
->cs
);
3744 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3747 hr
= IBasicVideo_SetDestinationPosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3749 LeaveCriticalSection(&This
->cs
);
3754 static HRESULT WINAPI
BasicVideo_GetDestinationPosition(IBasicVideo2
*iface
, LONG
*pLeft
,
3755 LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
3757 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3758 IBasicVideo
*pBasicVideo
;
3761 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3763 EnterCriticalSection(&This
->cs
);
3765 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3768 hr
= IBasicVideo_GetDestinationPosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3770 LeaveCriticalSection(&This
->cs
);
3775 static HRESULT WINAPI
BasicVideo_SetDefaultDestinationPosition(IBasicVideo2
*iface
)
3777 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3778 IBasicVideo
*pBasicVideo
;
3781 TRACE("(%p/%p)->()\n", This
, iface
);
3783 EnterCriticalSection(&This
->cs
);
3785 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3788 hr
= IBasicVideo_SetDefaultDestinationPosition(pBasicVideo
);
3790 LeaveCriticalSection(&This
->cs
);
3795 static HRESULT WINAPI
BasicVideo_GetVideoSize(IBasicVideo2
*iface
, LONG
*pWidth
, LONG
*pHeight
)
3797 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3798 IBasicVideo
*pBasicVideo
;
3801 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
3803 EnterCriticalSection(&This
->cs
);
3805 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3808 hr
= IBasicVideo_GetVideoSize(pBasicVideo
, pWidth
, pHeight
);
3810 LeaveCriticalSection(&This
->cs
);
3815 static HRESULT WINAPI
BasicVideo_GetVideoPaletteEntries(IBasicVideo2
*iface
, LONG StartIndex
,
3816 LONG Entries
, LONG
*pRetrieved
, LONG
*pPalette
)
3818 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3819 IBasicVideo
*pBasicVideo
;
3822 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3824 EnterCriticalSection(&This
->cs
);
3826 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3829 hr
= IBasicVideo_GetVideoPaletteEntries(pBasicVideo
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3831 LeaveCriticalSection(&This
->cs
);
3836 static HRESULT WINAPI
BasicVideo_GetCurrentImage(IBasicVideo2
*iface
, LONG
*pBufferSize
,
3839 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3840 IBasicVideo
*pBasicVideo
;
3843 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pBufferSize
, pDIBImage
);
3845 EnterCriticalSection(&This
->cs
);
3847 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3850 hr
= IBasicVideo_GetCurrentImage(pBasicVideo
, pBufferSize
, pDIBImage
);
3852 LeaveCriticalSection(&This
->cs
);
3857 static HRESULT WINAPI
BasicVideo_IsUsingDefaultSource(IBasicVideo2
*iface
)
3859 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3860 IBasicVideo
*pBasicVideo
;
3863 TRACE("(%p/%p)->()\n", This
, iface
);
3865 EnterCriticalSection(&This
->cs
);
3867 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3870 hr
= IBasicVideo_IsUsingDefaultSource(pBasicVideo
);
3872 LeaveCriticalSection(&This
->cs
);
3877 static HRESULT WINAPI
BasicVideo_IsUsingDefaultDestination(IBasicVideo2
*iface
)
3879 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3880 IBasicVideo
*pBasicVideo
;
3883 TRACE("(%p/%p)->()\n", This
, iface
);
3885 EnterCriticalSection(&This
->cs
);
3887 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3890 hr
= IBasicVideo_IsUsingDefaultDestination(pBasicVideo
);
3892 LeaveCriticalSection(&This
->cs
);
3897 static HRESULT WINAPI
BasicVideo2_GetPreferredAspectRatio(IBasicVideo2
*iface
, LONG
*plAspectX
,
3900 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3901 IBasicVideo2
*pBasicVideo2
;
3904 TRACE("(%p/%p)->()\n", This
, iface
);
3906 EnterCriticalSection(&This
->cs
);
3908 hr
= GetTargetInterface(This
, &IID_IBasicVideo2
, (LPVOID
*)&pBasicVideo2
);
3911 hr
= BasicVideo2_GetPreferredAspectRatio(iface
, plAspectX
, plAspectY
);
3913 LeaveCriticalSection(&This
->cs
);
3918 static const IBasicVideo2Vtbl IBasicVideo_VTable
=
3920 BasicVideo_QueryInterface
,
3923 BasicVideo_GetTypeInfoCount
,
3924 BasicVideo_GetTypeInfo
,
3925 BasicVideo_GetIDsOfNames
,
3927 BasicVideo_get_AvgTimePerFrame
,
3928 BasicVideo_get_BitRate
,
3929 BasicVideo_get_BitErrorRate
,
3930 BasicVideo_get_VideoWidth
,
3931 BasicVideo_get_VideoHeight
,
3932 BasicVideo_put_SourceLeft
,
3933 BasicVideo_get_SourceLeft
,
3934 BasicVideo_put_SourceWidth
,
3935 BasicVideo_get_SourceWidth
,
3936 BasicVideo_put_SourceTop
,
3937 BasicVideo_get_SourceTop
,
3938 BasicVideo_put_SourceHeight
,
3939 BasicVideo_get_SourceHeight
,
3940 BasicVideo_put_DestinationLeft
,
3941 BasicVideo_get_DestinationLeft
,
3942 BasicVideo_put_DestinationWidth
,
3943 BasicVideo_get_DestinationWidth
,
3944 BasicVideo_put_DestinationTop
,
3945 BasicVideo_get_DestinationTop
,
3946 BasicVideo_put_DestinationHeight
,
3947 BasicVideo_get_DestinationHeight
,
3948 BasicVideo_SetSourcePosition
,
3949 BasicVideo_GetSourcePosition
,
3950 BasicVideo_SetDefaultSourcePosition
,
3951 BasicVideo_SetDestinationPosition
,
3952 BasicVideo_GetDestinationPosition
,
3953 BasicVideo_SetDefaultDestinationPosition
,
3954 BasicVideo_GetVideoSize
,
3955 BasicVideo_GetVideoPaletteEntries
,
3956 BasicVideo_GetCurrentImage
,
3957 BasicVideo_IsUsingDefaultSource
,
3958 BasicVideo_IsUsingDefaultDestination
,
3959 BasicVideo2_GetPreferredAspectRatio
3962 static inline IFilterGraphImpl
*impl_from_IVideoWindow(IVideoWindow
*iface
)
3964 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IVideoWindow_iface
);
3967 static HRESULT WINAPI
VideoWindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, void **ppvObj
)
3969 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
3971 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3973 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
3976 static ULONG WINAPI
VideoWindow_AddRef(IVideoWindow
*iface
)
3978 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
3980 TRACE("(%p/%p)->()\n", This
, iface
);
3982 return Filtergraph_AddRef(This
);
3985 static ULONG WINAPI
VideoWindow_Release(IVideoWindow
*iface
)
3987 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
3989 TRACE("(%p/%p)->()\n", This
, iface
);
3991 return Filtergraph_Release(This
);
3994 /*** IDispatch methods ***/
3995 static HRESULT WINAPI
VideoWindow_GetTypeInfoCount(IVideoWindow
*iface
, UINT
*pctinfo
)
3997 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
3998 IVideoWindow
*pVideoWindow
;
4001 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
4003 EnterCriticalSection(&This
->cs
);
4005 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4008 hr
= IVideoWindow_GetTypeInfoCount(pVideoWindow
, pctinfo
);
4010 LeaveCriticalSection(&This
->cs
);
4015 static HRESULT WINAPI
VideoWindow_GetTypeInfo(IVideoWindow
*iface
, UINT iTInfo
, LCID lcid
,
4016 ITypeInfo
**ppTInfo
)
4018 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4019 IVideoWindow
*pVideoWindow
;
4022 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4024 EnterCriticalSection(&This
->cs
);
4026 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4029 hr
= IVideoWindow_GetTypeInfo(pVideoWindow
, iTInfo
, lcid
, ppTInfo
);
4031 LeaveCriticalSection(&This
->cs
);
4036 static HRESULT WINAPI
VideoWindow_GetIDsOfNames(IVideoWindow
*iface
, REFIID riid
,
4037 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
4039 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4040 IVideoWindow
*pVideoWindow
;
4043 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4045 EnterCriticalSection(&This
->cs
);
4047 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4050 hr
= IVideoWindow_GetIDsOfNames(pVideoWindow
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4052 LeaveCriticalSection(&This
->cs
);
4057 static HRESULT WINAPI
VideoWindow_Invoke(IVideoWindow
*iface
, DISPID dispIdMember
, REFIID riid
,
4058 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
4061 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4062 IVideoWindow
*pVideoWindow
;
4065 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
);
4067 EnterCriticalSection(&This
->cs
);
4069 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4072 hr
= IVideoWindow_Invoke(pVideoWindow
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
4074 LeaveCriticalSection(&This
->cs
);
4080 /*** IVideoWindow methods ***/
4081 static HRESULT WINAPI
VideoWindow_put_Caption(IVideoWindow
*iface
, BSTR strCaption
)
4083 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4084 IVideoWindow
*pVideoWindow
;
4087 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strCaption
), strCaption
);
4089 EnterCriticalSection(&This
->cs
);
4091 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4094 hr
= IVideoWindow_put_Caption(pVideoWindow
, strCaption
);
4096 LeaveCriticalSection(&This
->cs
);
4101 static HRESULT WINAPI
VideoWindow_get_Caption(IVideoWindow
*iface
, BSTR
*strCaption
)
4103 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4104 IVideoWindow
*pVideoWindow
;
4107 TRACE("(%p/%p)->(%p)\n", This
, iface
, strCaption
);
4109 EnterCriticalSection(&This
->cs
);
4111 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4114 hr
= IVideoWindow_get_Caption(pVideoWindow
, strCaption
);
4116 LeaveCriticalSection(&This
->cs
);
4121 static HRESULT WINAPI
VideoWindow_put_WindowStyle(IVideoWindow
*iface
, LONG WindowStyle
)
4123 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4124 IVideoWindow
*pVideoWindow
;
4127 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyle
);
4129 EnterCriticalSection(&This
->cs
);
4131 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4134 hr
= IVideoWindow_put_WindowStyle(pVideoWindow
, WindowStyle
);
4136 LeaveCriticalSection(&This
->cs
);
4141 static HRESULT WINAPI
VideoWindow_get_WindowStyle(IVideoWindow
*iface
, LONG
*WindowStyle
)
4143 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4144 IVideoWindow
*pVideoWindow
;
4147 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyle
);
4149 EnterCriticalSection(&This
->cs
);
4151 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4154 hr
= IVideoWindow_get_WindowStyle(pVideoWindow
, WindowStyle
);
4156 LeaveCriticalSection(&This
->cs
);
4161 static HRESULT WINAPI
VideoWindow_put_WindowStyleEx(IVideoWindow
*iface
, LONG WindowStyleEx
)
4163 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4164 IVideoWindow
*pVideoWindow
;
4167 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyleEx
);
4169 EnterCriticalSection(&This
->cs
);
4171 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4174 hr
= IVideoWindow_put_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4176 LeaveCriticalSection(&This
->cs
);
4181 static HRESULT WINAPI
VideoWindow_get_WindowStyleEx(IVideoWindow
*iface
, LONG
*WindowStyleEx
)
4183 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4184 IVideoWindow
*pVideoWindow
;
4187 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyleEx
);
4189 EnterCriticalSection(&This
->cs
);
4191 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4194 hr
= IVideoWindow_get_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4196 LeaveCriticalSection(&This
->cs
);
4201 static HRESULT WINAPI
VideoWindow_put_AutoShow(IVideoWindow
*iface
, LONG AutoShow
)
4203 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4204 IVideoWindow
*pVideoWindow
;
4207 TRACE("(%p/%p)->(%d)\n", This
, iface
, AutoShow
);
4209 EnterCriticalSection(&This
->cs
);
4211 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4214 hr
= IVideoWindow_put_AutoShow(pVideoWindow
, AutoShow
);
4216 LeaveCriticalSection(&This
->cs
);
4221 static HRESULT WINAPI
VideoWindow_get_AutoShow(IVideoWindow
*iface
, LONG
*AutoShow
)
4223 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4224 IVideoWindow
*pVideoWindow
;
4227 TRACE("(%p/%p)->(%p)\n", This
, iface
, AutoShow
);
4229 EnterCriticalSection(&This
->cs
);
4231 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4234 hr
= IVideoWindow_get_AutoShow(pVideoWindow
, AutoShow
);
4236 LeaveCriticalSection(&This
->cs
);
4241 static HRESULT WINAPI
VideoWindow_put_WindowState(IVideoWindow
*iface
, LONG WindowState
)
4243 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4244 IVideoWindow
*pVideoWindow
;
4247 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowState
);
4249 EnterCriticalSection(&This
->cs
);
4251 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4254 hr
= IVideoWindow_put_WindowState(pVideoWindow
, WindowState
);
4256 LeaveCriticalSection(&This
->cs
);
4261 static HRESULT WINAPI
VideoWindow_get_WindowState(IVideoWindow
*iface
, LONG
*WindowState
)
4263 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4264 IVideoWindow
*pVideoWindow
;
4267 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowState
);
4269 EnterCriticalSection(&This
->cs
);
4271 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4274 hr
= IVideoWindow_get_WindowState(pVideoWindow
, WindowState
);
4276 LeaveCriticalSection(&This
->cs
);
4281 static HRESULT WINAPI
VideoWindow_put_BackgroundPalette(IVideoWindow
*iface
, LONG BackgroundPalette
)
4283 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4284 IVideoWindow
*pVideoWindow
;
4287 TRACE("(%p/%p)->(%d)\n", This
, iface
, BackgroundPalette
);
4289 EnterCriticalSection(&This
->cs
);
4291 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4294 hr
= IVideoWindow_put_BackgroundPalette(pVideoWindow
, BackgroundPalette
);
4296 LeaveCriticalSection(&This
->cs
);
4301 static HRESULT WINAPI
VideoWindow_get_BackgroundPalette(IVideoWindow
*iface
,
4302 LONG
*pBackgroundPalette
)
4304 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4305 IVideoWindow
*pVideoWindow
;
4308 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBackgroundPalette
);
4310 EnterCriticalSection(&This
->cs
);
4312 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4315 hr
= IVideoWindow_get_BackgroundPalette(pVideoWindow
, pBackgroundPalette
);
4317 LeaveCriticalSection(&This
->cs
);
4322 static HRESULT WINAPI
VideoWindow_put_Visible(IVideoWindow
*iface
, LONG Visible
)
4324 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4325 IVideoWindow
*pVideoWindow
;
4328 TRACE("(%p/%p)->(%d)\n", This
, iface
, Visible
);
4330 EnterCriticalSection(&This
->cs
);
4332 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4335 hr
= IVideoWindow_put_Visible(pVideoWindow
, Visible
);
4337 LeaveCriticalSection(&This
->cs
);
4342 static HRESULT WINAPI
VideoWindow_get_Visible(IVideoWindow
*iface
, LONG
*pVisible
)
4344 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4345 IVideoWindow
*pVideoWindow
;
4348 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVisible
);
4350 EnterCriticalSection(&This
->cs
);
4352 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4355 hr
= IVideoWindow_get_Visible(pVideoWindow
, pVisible
);
4357 LeaveCriticalSection(&This
->cs
);
4362 static HRESULT WINAPI
VideoWindow_put_Left(IVideoWindow
*iface
, LONG Left
)
4364 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4365 IVideoWindow
*pVideoWindow
;
4368 TRACE("(%p/%p)->(%d)\n", This
, iface
, Left
);
4370 EnterCriticalSection(&This
->cs
);
4372 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4375 hr
= IVideoWindow_put_Left(pVideoWindow
, Left
);
4377 LeaveCriticalSection(&This
->cs
);
4382 static HRESULT WINAPI
VideoWindow_get_Left(IVideoWindow
*iface
, LONG
*pLeft
)
4384 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4385 IVideoWindow
*pVideoWindow
;
4388 TRACE("(%p/%p)->(%p)\n", This
, iface
, pLeft
);
4390 EnterCriticalSection(&This
->cs
);
4392 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4395 hr
= IVideoWindow_get_Left(pVideoWindow
, pLeft
);
4397 LeaveCriticalSection(&This
->cs
);
4402 static HRESULT WINAPI
VideoWindow_put_Width(IVideoWindow
*iface
, LONG Width
)
4404 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4405 IVideoWindow
*pVideoWindow
;
4408 TRACE("(%p/%p)->(%d)\n", This
, iface
, Width
);
4410 EnterCriticalSection(&This
->cs
);
4412 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4415 hr
= IVideoWindow_put_Width(pVideoWindow
, Width
);
4417 LeaveCriticalSection(&This
->cs
);
4422 static HRESULT WINAPI
VideoWindow_get_Width(IVideoWindow
*iface
, LONG
*pWidth
)
4424 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4425 IVideoWindow
*pVideoWindow
;
4428 TRACE("(%p/%p)->(%p)\n", This
, iface
, pWidth
);
4430 EnterCriticalSection(&This
->cs
);
4432 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4435 hr
= IVideoWindow_get_Width(pVideoWindow
, pWidth
);
4437 LeaveCriticalSection(&This
->cs
);
4442 static HRESULT WINAPI
VideoWindow_put_Top(IVideoWindow
*iface
, LONG Top
)
4444 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4445 IVideoWindow
*pVideoWindow
;
4448 TRACE("(%p/%p)->(%d)\n", This
, iface
, Top
);
4450 EnterCriticalSection(&This
->cs
);
4452 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4455 hr
= IVideoWindow_put_Top(pVideoWindow
, Top
);
4457 LeaveCriticalSection(&This
->cs
);
4462 static HRESULT WINAPI
VideoWindow_get_Top(IVideoWindow
*iface
, LONG
*pTop
)
4464 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4465 IVideoWindow
*pVideoWindow
;
4468 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTop
);
4470 EnterCriticalSection(&This
->cs
);
4472 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4475 hr
= IVideoWindow_get_Top(pVideoWindow
, pTop
);
4477 LeaveCriticalSection(&This
->cs
);
4482 static HRESULT WINAPI
VideoWindow_put_Height(IVideoWindow
*iface
, LONG Height
)
4484 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4485 IVideoWindow
*pVideoWindow
;
4488 TRACE("(%p/%p)->(%d)\n", This
, iface
, Height
);
4490 EnterCriticalSection(&This
->cs
);
4492 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4495 hr
= IVideoWindow_put_Height(pVideoWindow
, Height
);
4497 LeaveCriticalSection(&This
->cs
);
4502 static HRESULT WINAPI
VideoWindow_get_Height(IVideoWindow
*iface
, LONG
*pHeight
)
4504 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4505 IVideoWindow
*pVideoWindow
;
4508 TRACE("(%p/%p)->(%p)\n", This
, iface
, pHeight
);
4510 EnterCriticalSection(&This
->cs
);
4512 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4515 hr
= IVideoWindow_get_Height(pVideoWindow
, pHeight
);
4517 LeaveCriticalSection(&This
->cs
);
4522 static HRESULT WINAPI
VideoWindow_put_Owner(IVideoWindow
*iface
, OAHWND Owner
)
4524 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4525 IVideoWindow
*pVideoWindow
;
4528 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Owner
);
4530 EnterCriticalSection(&This
->cs
);
4532 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4535 hr
= IVideoWindow_put_Owner(pVideoWindow
, Owner
);
4537 LeaveCriticalSection(&This
->cs
);
4542 static HRESULT WINAPI
VideoWindow_get_Owner(IVideoWindow
*iface
, OAHWND
*Owner
)
4544 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4545 IVideoWindow
*pVideoWindow
;
4548 TRACE("(%p/%p)->(%p)\n", This
, iface
, Owner
);
4550 EnterCriticalSection(&This
->cs
);
4552 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4555 hr
= IVideoWindow_get_Owner(pVideoWindow
, Owner
);
4557 LeaveCriticalSection(&This
->cs
);
4562 static HRESULT WINAPI
VideoWindow_put_MessageDrain(IVideoWindow
*iface
, OAHWND Drain
)
4564 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4565 IVideoWindow
*pVideoWindow
;
4568 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Drain
);
4570 EnterCriticalSection(&This
->cs
);
4572 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4575 hr
= IVideoWindow_put_MessageDrain(pVideoWindow
, Drain
);
4577 LeaveCriticalSection(&This
->cs
);
4582 static HRESULT WINAPI
VideoWindow_get_MessageDrain(IVideoWindow
*iface
, OAHWND
*Drain
)
4584 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4585 IVideoWindow
*pVideoWindow
;
4588 TRACE("(%p/%p)->(%p)\n", This
, iface
, Drain
);
4590 EnterCriticalSection(&This
->cs
);
4592 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4595 hr
= IVideoWindow_get_MessageDrain(pVideoWindow
, Drain
);
4597 LeaveCriticalSection(&This
->cs
);
4602 static HRESULT WINAPI
VideoWindow_get_BorderColor(IVideoWindow
*iface
, LONG
*Color
)
4604 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4605 IVideoWindow
*pVideoWindow
;
4608 TRACE("(%p/%p)->(%p)\n", This
, iface
, Color
);
4610 EnterCriticalSection(&This
->cs
);
4612 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4615 hr
= IVideoWindow_get_BorderColor(pVideoWindow
, Color
);
4617 LeaveCriticalSection(&This
->cs
);
4622 static HRESULT WINAPI
VideoWindow_put_BorderColor(IVideoWindow
*iface
, LONG Color
)
4624 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4625 IVideoWindow
*pVideoWindow
;
4628 TRACE("(%p/%p)->(%d)\n", This
, iface
, Color
);
4630 EnterCriticalSection(&This
->cs
);
4632 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4635 hr
= IVideoWindow_put_BorderColor(pVideoWindow
, Color
);
4637 LeaveCriticalSection(&This
->cs
);
4642 static HRESULT WINAPI
VideoWindow_get_FullScreenMode(IVideoWindow
*iface
, LONG
*FullScreenMode
)
4644 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4645 IVideoWindow
*pVideoWindow
;
4648 TRACE("(%p/%p)->(%p)\n", This
, iface
, FullScreenMode
);
4650 EnterCriticalSection(&This
->cs
);
4652 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4655 hr
= IVideoWindow_get_FullScreenMode(pVideoWindow
, FullScreenMode
);
4657 LeaveCriticalSection(&This
->cs
);
4662 static HRESULT WINAPI
VideoWindow_put_FullScreenMode(IVideoWindow
*iface
, LONG FullScreenMode
)
4664 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4665 IVideoWindow
*pVideoWindow
;
4668 TRACE("(%p/%p)->(%d)\n", This
, iface
, FullScreenMode
);
4670 EnterCriticalSection(&This
->cs
);
4672 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4675 hr
= IVideoWindow_put_FullScreenMode(pVideoWindow
, FullScreenMode
);
4677 LeaveCriticalSection(&This
->cs
);
4682 static HRESULT WINAPI
VideoWindow_SetWindowForeground(IVideoWindow
*iface
, LONG Focus
)
4684 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4685 IVideoWindow
*pVideoWindow
;
4688 TRACE("(%p/%p)->(%d)\n", This
, iface
, Focus
);
4690 EnterCriticalSection(&This
->cs
);
4692 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4695 hr
= IVideoWindow_SetWindowForeground(pVideoWindow
, Focus
);
4697 LeaveCriticalSection(&This
->cs
);
4702 static HRESULT WINAPI
VideoWindow_NotifyOwnerMessage(IVideoWindow
*iface
, OAHWND hwnd
, LONG uMsg
,
4703 LONG_PTR wParam
, LONG_PTR lParam
)
4705 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4706 IVideoWindow
*pVideoWindow
;
4709 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This
, iface
, hwnd
, uMsg
, wParam
, lParam
);
4711 EnterCriticalSection(&This
->cs
);
4713 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4716 hr
= IVideoWindow_NotifyOwnerMessage(pVideoWindow
, hwnd
, uMsg
, wParam
, lParam
);
4718 LeaveCriticalSection(&This
->cs
);
4723 static HRESULT WINAPI
VideoWindow_SetWindowPosition(IVideoWindow
*iface
, LONG Left
, LONG Top
,
4724 LONG Width
, LONG Height
)
4726 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4727 IVideoWindow
*pVideoWindow
;
4730 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
4732 EnterCriticalSection(&This
->cs
);
4734 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4737 hr
= IVideoWindow_SetWindowPosition(pVideoWindow
, Left
, Top
, Width
, Height
);
4739 LeaveCriticalSection(&This
->cs
);
4744 static HRESULT WINAPI
VideoWindow_GetWindowPosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4745 LONG
*pWidth
, LONG
*pHeight
)
4747 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4748 IVideoWindow
*pVideoWindow
;
4751 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4753 EnterCriticalSection(&This
->cs
);
4755 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4758 hr
= IVideoWindow_GetWindowPosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4760 LeaveCriticalSection(&This
->cs
);
4765 static HRESULT WINAPI
VideoWindow_GetMinIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4768 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4769 IVideoWindow
*pVideoWindow
;
4772 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4774 EnterCriticalSection(&This
->cs
);
4776 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4779 hr
= IVideoWindow_GetMinIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4781 LeaveCriticalSection(&This
->cs
);
4786 static HRESULT WINAPI
VideoWindow_GetMaxIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4789 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4790 IVideoWindow
*pVideoWindow
;
4793 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4795 EnterCriticalSection(&This
->cs
);
4797 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4800 hr
= IVideoWindow_GetMaxIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4802 LeaveCriticalSection(&This
->cs
);
4807 static HRESULT WINAPI
VideoWindow_GetRestorePosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4808 LONG
*pWidth
, LONG
*pHeight
)
4810 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4811 IVideoWindow
*pVideoWindow
;
4814 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4816 EnterCriticalSection(&This
->cs
);
4818 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4821 hr
= IVideoWindow_GetRestorePosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4823 LeaveCriticalSection(&This
->cs
);
4828 static HRESULT WINAPI
VideoWindow_HideCursor(IVideoWindow
*iface
, LONG HideCursor
)
4830 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4831 IVideoWindow
*pVideoWindow
;
4834 TRACE("(%p/%p)->(%d)\n", This
, iface
, HideCursor
);
4836 EnterCriticalSection(&This
->cs
);
4838 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4841 hr
= IVideoWindow_HideCursor(pVideoWindow
, HideCursor
);
4843 LeaveCriticalSection(&This
->cs
);
4848 static HRESULT WINAPI
VideoWindow_IsCursorHidden(IVideoWindow
*iface
, LONG
*CursorHidden
)
4850 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4851 IVideoWindow
*pVideoWindow
;
4854 TRACE("(%p/%p)->(%p)\n", This
, iface
, CursorHidden
);
4856 EnterCriticalSection(&This
->cs
);
4858 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4861 hr
= IVideoWindow_IsCursorHidden(pVideoWindow
, CursorHidden
);
4863 LeaveCriticalSection(&This
->cs
);
4869 static const IVideoWindowVtbl IVideoWindow_VTable
=
4871 VideoWindow_QueryInterface
,
4873 VideoWindow_Release
,
4874 VideoWindow_GetTypeInfoCount
,
4875 VideoWindow_GetTypeInfo
,
4876 VideoWindow_GetIDsOfNames
,
4878 VideoWindow_put_Caption
,
4879 VideoWindow_get_Caption
,
4880 VideoWindow_put_WindowStyle
,
4881 VideoWindow_get_WindowStyle
,
4882 VideoWindow_put_WindowStyleEx
,
4883 VideoWindow_get_WindowStyleEx
,
4884 VideoWindow_put_AutoShow
,
4885 VideoWindow_get_AutoShow
,
4886 VideoWindow_put_WindowState
,
4887 VideoWindow_get_WindowState
,
4888 VideoWindow_put_BackgroundPalette
,
4889 VideoWindow_get_BackgroundPalette
,
4890 VideoWindow_put_Visible
,
4891 VideoWindow_get_Visible
,
4892 VideoWindow_put_Left
,
4893 VideoWindow_get_Left
,
4894 VideoWindow_put_Width
,
4895 VideoWindow_get_Width
,
4896 VideoWindow_put_Top
,
4897 VideoWindow_get_Top
,
4898 VideoWindow_put_Height
,
4899 VideoWindow_get_Height
,
4900 VideoWindow_put_Owner
,
4901 VideoWindow_get_Owner
,
4902 VideoWindow_put_MessageDrain
,
4903 VideoWindow_get_MessageDrain
,
4904 VideoWindow_get_BorderColor
,
4905 VideoWindow_put_BorderColor
,
4906 VideoWindow_get_FullScreenMode
,
4907 VideoWindow_put_FullScreenMode
,
4908 VideoWindow_SetWindowForeground
,
4909 VideoWindow_NotifyOwnerMessage
,
4910 VideoWindow_SetWindowPosition
,
4911 VideoWindow_GetWindowPosition
,
4912 VideoWindow_GetMinIdealImageSize
,
4913 VideoWindow_GetMaxIdealImageSize
,
4914 VideoWindow_GetRestorePosition
,
4915 VideoWindow_HideCursor
,
4916 VideoWindow_IsCursorHidden
4919 static inline IFilterGraphImpl
*impl_from_IMediaEventEx(IMediaEventEx
*iface
)
4921 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventEx_iface
);
4924 static HRESULT WINAPI
MediaEvent_QueryInterface(IMediaEventEx
*iface
, REFIID riid
, void **ppvObj
)
4926 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4928 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4930 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
4933 static ULONG WINAPI
MediaEvent_AddRef(IMediaEventEx
*iface
)
4935 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4937 TRACE("(%p/%p)->()\n", This
, iface
);
4939 return Filtergraph_AddRef(This
);
4942 static ULONG WINAPI
MediaEvent_Release(IMediaEventEx
*iface
)
4944 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4946 TRACE("(%p/%p)->()\n", This
, iface
);
4948 return Filtergraph_Release(This
);
4951 /*** IDispatch methods ***/
4952 static HRESULT WINAPI
MediaEvent_GetTypeInfoCount(IMediaEventEx
*iface
, UINT
*pctinfo
)
4954 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4956 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
4961 static HRESULT WINAPI
MediaEvent_GetTypeInfo(IMediaEventEx
*iface
, UINT iTInfo
, LCID lcid
,
4962 ITypeInfo
**ppTInfo
)
4964 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4966 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4971 static HRESULT WINAPI
MediaEvent_GetIDsOfNames(IMediaEventEx
*iface
, REFIID riid
,
4972 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
4974 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4976 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4981 static HRESULT WINAPI
MediaEvent_Invoke(IMediaEventEx
*iface
, DISPID dispIdMember
, REFIID riid
,
4982 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
4985 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4987 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
);
4992 /*** IMediaEvent methods ***/
4993 static HRESULT WINAPI
MediaEvent_GetEventHandle(IMediaEventEx
*iface
, OAEVENT
*hEvent
)
4995 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4997 TRACE("(%p/%p)->(%p)\n", This
, iface
, hEvent
);
4999 *hEvent
= (OAEVENT
)This
->evqueue
.msg_event
;
5004 static HRESULT WINAPI
MediaEvent_GetEvent(IMediaEventEx
*iface
, LONG
*lEventCode
, LONG_PTR
*lParam1
,
5005 LONG_PTR
*lParam2
, LONG msTimeout
)
5007 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5010 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This
, iface
, lEventCode
, lParam1
, lParam2
, msTimeout
);
5012 if (EventsQueue_GetEvent(&This
->evqueue
, &evt
, msTimeout
))
5014 *lEventCode
= evt
.lEventCode
;
5015 *lParam1
= evt
.lParam1
;
5016 *lParam2
= evt
.lParam2
;
5024 static HRESULT WINAPI
MediaEvent_WaitForCompletion(IMediaEventEx
*iface
, LONG msTimeout
,
5027 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5029 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pEvCode
);
5031 if (This
->state
!= State_Running
)
5032 return VFW_E_WRONG_STATE
;
5034 if (WaitForSingleObject(This
->hEventCompletion
, msTimeout
) == WAIT_OBJECT_0
)
5036 *pEvCode
= This
->CompletionStatus
;
5044 static HRESULT WINAPI
MediaEvent_CancelDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5046 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5048 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5050 if (lEvCode
== EC_COMPLETE
)
5051 This
->HandleEcComplete
= FALSE
;
5052 else if (lEvCode
== EC_REPAINT
)
5053 This
->HandleEcRepaint
= FALSE
;
5054 else if (lEvCode
== EC_CLOCK_CHANGED
)
5055 This
->HandleEcClockChanged
= FALSE
;
5062 static HRESULT WINAPI
MediaEvent_RestoreDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5064 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5066 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5068 if (lEvCode
== EC_COMPLETE
)
5069 This
->HandleEcComplete
= TRUE
;
5070 else if (lEvCode
== EC_REPAINT
)
5071 This
->HandleEcRepaint
= TRUE
;
5072 else if (lEvCode
== EC_CLOCK_CHANGED
)
5073 This
->HandleEcClockChanged
= TRUE
;
5080 static HRESULT WINAPI
MediaEvent_FreeEventParams(IMediaEventEx
*iface
, LONG lEvCode
,
5081 LONG_PTR lParam1
, LONG_PTR lParam2
)
5083 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5085 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This
, iface
, lEvCode
, lParam1
, lParam2
);
5090 /*** IMediaEventEx methods ***/
5091 static HRESULT WINAPI
MediaEvent_SetNotifyWindow(IMediaEventEx
*iface
, OAHWND hwnd
, LONG lMsg
,
5092 LONG_PTR lInstanceData
)
5094 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5096 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This
, iface
, hwnd
, lMsg
, lInstanceData
);
5098 This
->notif
.hWnd
= (HWND
)hwnd
;
5099 This
->notif
.msg
= lMsg
;
5100 This
->notif
.instance
= lInstanceData
;
5105 static HRESULT WINAPI
MediaEvent_SetNotifyFlags(IMediaEventEx
*iface
, LONG lNoNotifyFlags
)
5107 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5109 TRACE("(%p/%p)->(%d)\n", This
, iface
, lNoNotifyFlags
);
5111 if ((lNoNotifyFlags
!= 0) && (lNoNotifyFlags
!= 1))
5112 return E_INVALIDARG
;
5114 This
->notif
.disabled
= lNoNotifyFlags
;
5119 static HRESULT WINAPI
MediaEvent_GetNotifyFlags(IMediaEventEx
*iface
, LONG
*lplNoNotifyFlags
)
5121 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5123 TRACE("(%p/%p)->(%p)\n", This
, iface
, lplNoNotifyFlags
);
5125 if (!lplNoNotifyFlags
)
5128 *lplNoNotifyFlags
= This
->notif
.disabled
;
5134 static const IMediaEventExVtbl IMediaEventEx_VTable
=
5136 MediaEvent_QueryInterface
,
5139 MediaEvent_GetTypeInfoCount
,
5140 MediaEvent_GetTypeInfo
,
5141 MediaEvent_GetIDsOfNames
,
5143 MediaEvent_GetEventHandle
,
5144 MediaEvent_GetEvent
,
5145 MediaEvent_WaitForCompletion
,
5146 MediaEvent_CancelDefaultHandling
,
5147 MediaEvent_RestoreDefaultHandling
,
5148 MediaEvent_FreeEventParams
,
5149 MediaEvent_SetNotifyWindow
,
5150 MediaEvent_SetNotifyFlags
,
5151 MediaEvent_GetNotifyFlags
5155 static inline IFilterGraphImpl
*impl_from_IMediaFilter(IMediaFilter
*iface
)
5157 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaFilter_iface
);
5160 static HRESULT WINAPI
MediaFilter_QueryInterface(IMediaFilter
*iface
, REFIID riid
, void **ppv
)
5162 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5164 return Filtergraph_QueryInterface(This
, riid
, ppv
);
5167 static ULONG WINAPI
MediaFilter_AddRef(IMediaFilter
*iface
)
5169 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5171 return Filtergraph_AddRef(This
);
5174 static ULONG WINAPI
MediaFilter_Release(IMediaFilter
*iface
)
5176 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5178 return Filtergraph_Release(This
);
5181 static HRESULT WINAPI
MediaFilter_GetClassID(IMediaFilter
*iface
, CLSID
* pClassID
)
5183 FIXME("(%p): stub\n", pClassID
);
5188 static HRESULT WINAPI
MediaFilter_Stop(IMediaFilter
*iface
)
5190 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5192 return MediaControl_Stop(&This
->IMediaControl_iface
);
5195 static HRESULT WINAPI
MediaFilter_Pause(IMediaFilter
*iface
)
5197 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5199 return MediaControl_Pause(&This
->IMediaControl_iface
);
5202 static HRESULT WINAPI
MediaFilter_Run(IMediaFilter
*iface
, REFERENCE_TIME tStart
)
5204 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5207 FIXME("Run called with non-null tStart: %x%08x\n",
5208 (int)(tStart
>>32), (int)tStart
);
5210 return MediaControl_Run(&This
->IMediaControl_iface
);
5213 static HRESULT WINAPI
MediaFilter_GetState(IMediaFilter
*iface
, DWORD dwMsTimeout
,
5214 FILTER_STATE
*pState
)
5216 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5218 return MediaControl_GetState(&This
->IMediaControl_iface
, dwMsTimeout
, (OAFilterState
*)pState
);
5221 static HRESULT WINAPI
MediaFilter_SetSyncSource(IMediaFilter
*iface
, IReferenceClock
*pClock
)
5223 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5227 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClock
);
5229 EnterCriticalSection(&This
->cs
);
5231 for (i
= 0;i
< This
->nFilters
;i
++)
5233 hr
= IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], pClock
);
5241 IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], This
->refClock
);
5246 IReferenceClock_Release(This
->refClock
);
5247 This
->refClock
= pClock
;
5249 IReferenceClock_AddRef(This
->refClock
);
5250 This
->defaultclock
= FALSE
;
5252 if (This
->HandleEcClockChanged
)
5254 IMediaEventSink
*pEventSink
;
5257 eshr
= IMediaFilter_QueryInterface(iface
, &IID_IMediaEventSink
, (LPVOID
)&pEventSink
);
5258 if (SUCCEEDED(eshr
))
5260 IMediaEventSink_Notify(pEventSink
, EC_CLOCK_CHANGED
, 0, 0);
5261 IMediaEventSink_Release(pEventSink
);
5266 LeaveCriticalSection(&This
->cs
);
5271 static HRESULT WINAPI
MediaFilter_GetSyncSource(IMediaFilter
*iface
, IReferenceClock
**ppClock
)
5273 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5275 TRACE("(%p/%p)->(%p)\n", iface
, This
, ppClock
);
5280 EnterCriticalSection(&This
->cs
);
5282 *ppClock
= This
->refClock
;
5284 IReferenceClock_AddRef(*ppClock
);
5286 LeaveCriticalSection(&This
->cs
);
5291 static const IMediaFilterVtbl IMediaFilter_VTable
=
5293 MediaFilter_QueryInterface
,
5295 MediaFilter_Release
,
5296 MediaFilter_GetClassID
,
5300 MediaFilter_GetState
,
5301 MediaFilter_SetSyncSource
,
5302 MediaFilter_GetSyncSource
5305 static inline IFilterGraphImpl
*impl_from_IMediaEventSink(IMediaEventSink
*iface
)
5307 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventSink_iface
);
5310 static HRESULT WINAPI
MediaEventSink_QueryInterface(IMediaEventSink
*iface
, REFIID riid
, void **ppv
)
5312 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5314 return Filtergraph_QueryInterface(This
, riid
, ppv
);
5317 static ULONG WINAPI
MediaEventSink_AddRef(IMediaEventSink
*iface
)
5319 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5321 return Filtergraph_AddRef(This
);
5324 static ULONG WINAPI
MediaEventSink_Release(IMediaEventSink
*iface
)
5326 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5328 return Filtergraph_Release(This
);
5331 static HRESULT WINAPI
MediaEventSink_Notify(IMediaEventSink
*iface
, LONG EventCode
,
5332 LONG_PTR EventParam1
, LONG_PTR EventParam2
)
5334 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5337 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This
, iface
, EventCode
, EventParam1
, EventParam2
);
5339 /* We need thread safety here, let's use the events queue's one */
5340 EnterCriticalSection(&This
->evqueue
.msg_crst
);
5342 if ((EventCode
== EC_COMPLETE
) && This
->HandleEcComplete
)
5344 TRACE("Process EC_COMPLETE notification\n");
5345 if (++This
->EcCompleteCount
== This
->nRenderers
)
5347 evt
.lEventCode
= EC_COMPLETE
;
5350 TRACE("Send EC_COMPLETE to app\n");
5351 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5352 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5354 TRACE("Send Window message\n");
5355 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5357 This
->CompletionStatus
= EC_COMPLETE
;
5358 SetEvent(This
->hEventCompletion
);
5361 else if ((EventCode
== EC_REPAINT
) && This
->HandleEcRepaint
)
5363 /* FIXME: Not handled yet */
5367 evt
.lEventCode
= EventCode
;
5368 evt
.lParam1
= EventParam1
;
5369 evt
.lParam2
= EventParam2
;
5370 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5371 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5372 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5375 LeaveCriticalSection(&This
->evqueue
.msg_crst
);
5379 static const IMediaEventSinkVtbl IMediaEventSink_VTable
=
5381 MediaEventSink_QueryInterface
,
5382 MediaEventSink_AddRef
,
5383 MediaEventSink_Release
,
5384 MediaEventSink_Notify
5387 static inline IFilterGraphImpl
*impl_from_IGraphConfig(IGraphConfig
*iface
)
5389 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphConfig_iface
);
5392 static HRESULT WINAPI
GraphConfig_QueryInterface(IGraphConfig
*iface
, REFIID riid
, void **ppv
)
5394 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5396 return Filtergraph_QueryInterface(This
, riid
, ppv
);
5399 static ULONG WINAPI
GraphConfig_AddRef(IGraphConfig
*iface
)
5401 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5403 return Filtergraph_AddRef(This
);
5406 static ULONG WINAPI
GraphConfig_Release(IGraphConfig
*iface
)
5408 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5410 return Filtergraph_Release(This
);
5413 static HRESULT WINAPI
GraphConfig_Reconnect(IGraphConfig
*iface
, IPin
*pOutputPin
, IPin
*pInputPin
,
5414 const AM_MEDIA_TYPE
*pmtFirstConnection
, IBaseFilter
*pUsingFilter
, HANDLE hAbortEvent
,
5417 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5419 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This
, pOutputPin
, pInputPin
, pmtFirstConnection
, pUsingFilter
, hAbortEvent
, dwFlags
);
5424 static HRESULT WINAPI
GraphConfig_Reconfigure(IGraphConfig
*iface
, IGraphConfigCallback
*pCallback
,
5425 void *pvContext
, DWORD dwFlags
, HANDLE hAbortEvent
)
5427 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5430 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This
, pCallback
, pvContext
, dwFlags
, hAbortEvent
);
5433 FIXME("The parameter hAbortEvent is not handled!\n");
5435 EnterCriticalSection(&This
->cs
);
5437 hr
= IGraphConfigCallback_Reconfigure(pCallback
, pvContext
, dwFlags
);
5439 LeaveCriticalSection(&This
->cs
);
5444 static HRESULT WINAPI
GraphConfig_AddFilterToCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5446 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5448 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5453 static HRESULT WINAPI
GraphConfig_EnumCacheFilter(IGraphConfig
*iface
, IEnumFilters
**pEnum
)
5455 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5457 FIXME("(%p)->(%p): stub!\n", This
, pEnum
);
5462 static HRESULT WINAPI
GraphConfig_RemoveFilterFromCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5464 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5466 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5471 static HRESULT WINAPI
GraphConfig_GetStartTime(IGraphConfig
*iface
, REFERENCE_TIME
*prtStart
)
5473 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5475 FIXME("(%p)->(%p): stub!\n", This
, prtStart
);
5480 static HRESULT WINAPI
GraphConfig_PushThroughData(IGraphConfig
*iface
, IPin
*pOutputPin
,
5481 IPinConnection
*pConnection
, HANDLE hEventAbort
)
5483 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5485 FIXME("(%p)->(%p, %p, %p): stub!\n", This
, pOutputPin
, pConnection
, hEventAbort
);
5490 static HRESULT WINAPI
GraphConfig_SetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5493 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5495 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5500 static HRESULT WINAPI
GraphConfig_GetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5503 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5505 FIXME("(%p)->(%p, %p): stub!\n", This
, pFilter
, dwFlags
);
5510 static HRESULT WINAPI
GraphConfig_RemoveFilterEx(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5513 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5515 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5520 static const IGraphConfigVtbl IGraphConfig_VTable
=
5522 GraphConfig_QueryInterface
,
5524 GraphConfig_Release
,
5525 GraphConfig_Reconnect
,
5526 GraphConfig_Reconfigure
,
5527 GraphConfig_AddFilterToCache
,
5528 GraphConfig_EnumCacheFilter
,
5529 GraphConfig_RemoveFilterFromCache
,
5530 GraphConfig_GetStartTime
,
5531 GraphConfig_PushThroughData
,
5532 GraphConfig_SetFilterFlags
,
5533 GraphConfig_GetFilterFlags
,
5534 GraphConfig_RemoveFilterEx
5537 static const IUnknownVtbl IInner_VTable
=
5539 FilterGraphInner_QueryInterface
,
5540 FilterGraphInner_AddRef
,
5541 FilterGraphInner_Release
5544 static HRESULT
Filtergraph_QueryInterface(IFilterGraphImpl
*This
,
5547 if (This
->bAggregatable
)
5548 This
->bUnkOuterValid
= TRUE
;
5550 if (This
->pUnkOuter
)
5552 if (This
->bAggregatable
)
5553 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppv
);
5555 if (IsEqualIID(riid
, &IID_IUnknown
))
5559 IUnknown_AddRef((IUnknown
*)&(This
->IInner_vtbl
));
5560 hr
= IUnknown_QueryInterface((IUnknown
*)&(This
->IInner_vtbl
), riid
, ppv
);
5561 IUnknown_Release((IUnknown
*)&(This
->IInner_vtbl
));
5562 This
->bAggregatable
= TRUE
;
5567 return E_NOINTERFACE
;
5570 return IUnknown_QueryInterface((IUnknown
*)&(This
->IInner_vtbl
), riid
, ppv
);
5573 static ULONG
Filtergraph_AddRef(IFilterGraphImpl
*This
) {
5574 if (This
->pUnkOuter
&& This
->bUnkOuterValid
)
5575 return IUnknown_AddRef(This
->pUnkOuter
);
5576 return IUnknown_AddRef((IUnknown
*)&(This
->IInner_vtbl
));
5579 static ULONG
Filtergraph_Release(IFilterGraphImpl
*This
) {
5580 if (This
->pUnkOuter
&& This
->bUnkOuterValid
)
5581 return IUnknown_Release(This
->pUnkOuter
);
5582 return IUnknown_Release((IUnknown
*)&(This
->IInner_vtbl
));
5585 /* This is the only function that actually creates a FilterGraph class... */
5586 HRESULT
FilterGraph_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5588 IFilterGraphImpl
*fimpl
;
5591 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
5595 fimpl
= CoTaskMemAlloc(sizeof(*fimpl
));
5596 fimpl
->pUnkOuter
= pUnkOuter
;
5597 fimpl
->bUnkOuterValid
= FALSE
;
5598 fimpl
->bAggregatable
= FALSE
;
5599 fimpl
->defaultclock
= TRUE
;
5600 fimpl
->IInner_vtbl
= &IInner_VTable
;
5601 fimpl
->IFilterGraph2_iface
.lpVtbl
= &IFilterGraph2_VTable
;
5602 fimpl
->IMediaControl_iface
.lpVtbl
= &IMediaControl_VTable
;
5603 fimpl
->IMediaSeeking_iface
.lpVtbl
= &IMediaSeeking_VTable
;
5604 fimpl
->IBasicAudio_iface
.lpVtbl
= &IBasicAudio_VTable
;
5605 fimpl
->IBasicVideo2_iface
.lpVtbl
= &IBasicVideo_VTable
;
5606 fimpl
->IVideoWindow_iface
.lpVtbl
= &IVideoWindow_VTable
;
5607 fimpl
->IMediaEventEx_iface
.lpVtbl
= &IMediaEventEx_VTable
;
5608 fimpl
->IMediaFilter_iface
.lpVtbl
= &IMediaFilter_VTable
;
5609 fimpl
->IMediaEventSink_iface
.lpVtbl
= &IMediaEventSink_VTable
;
5610 fimpl
->IGraphConfig_iface
.lpVtbl
= &IGraphConfig_VTable
;
5611 fimpl
->IMediaPosition_iface
.lpVtbl
= &IMediaPosition_VTable
;
5612 fimpl
->IObjectWithSite_iface
.lpVtbl
= &IObjectWithSite_VTable
;
5614 fimpl
->ppFiltersInGraph
= NULL
;
5615 fimpl
->pFilterNames
= NULL
;
5616 fimpl
->nFilters
= 0;
5617 fimpl
->filterCapacity
= 0;
5618 fimpl
->nameIndex
= 1;
5619 fimpl
->refClock
= NULL
;
5620 fimpl
->hEventCompletion
= CreateEventW(0, TRUE
, FALSE
, 0);
5621 fimpl
->HandleEcComplete
= TRUE
;
5622 fimpl
->HandleEcRepaint
= TRUE
;
5623 fimpl
->HandleEcClockChanged
= TRUE
;
5624 fimpl
->notif
.hWnd
= 0;
5625 fimpl
->notif
.disabled
= FALSE
;
5626 fimpl
->nRenderers
= 0;
5627 fimpl
->EcCompleteCount
= 0;
5628 fimpl
->refClockProvider
= NULL
;
5629 fimpl
->state
= State_Stopped
;
5630 fimpl
->pSite
= NULL
;
5631 EventsQueue_Init(&fimpl
->evqueue
);
5632 InitializeCriticalSection(&fimpl
->cs
);
5633 fimpl
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IFilterGraphImpl.cs");
5634 fimpl
->nItfCacheEntries
= 0;
5635 memcpy(&fimpl
->timeformatseek
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
5636 fimpl
->start_time
= fimpl
->pause_time
= 0;
5637 fimpl
->stop_position
= -1;
5638 fimpl
->punkFilterMapper2
= NULL
;
5639 fimpl
->recursioncount
= 0;
5641 /* create Filtermapper aggregated. */
5642 hr
= CoCreateInstance(&CLSID_FilterMapper2
, pUnkOuter
? pUnkOuter
: (IUnknown
*)&fimpl
->IInner_vtbl
, CLSCTX_INPROC_SERVER
,
5643 &IID_IUnknown
, (LPVOID
*)&fimpl
->punkFilterMapper2
);
5645 if (SUCCEEDED(hr
)) {
5646 hr
= IUnknown_QueryInterface(fimpl
->punkFilterMapper2
, &IID_IFilterMapper2
, (LPVOID
*)&fimpl
->pFilterMapper2
);
5649 if (SUCCEEDED(hr
)) {
5650 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5651 if (pUnkOuter
) IUnknown_Release(pUnkOuter
);
5652 else IUnknown_Release((IUnknown
*)&fimpl
->IInner_vtbl
);
5656 ERR("Unable to create filter mapper (%x)\n", hr
);
5657 if (fimpl
->punkFilterMapper2
) IUnknown_Release(fimpl
->punkFilterMapper2
);
5658 CloseHandle(fimpl
->hEventCompletion
);
5659 EventsQueue_Destroy(&fimpl
->evqueue
);
5660 fimpl
->cs
.DebugInfo
->Spare
[0] = 0;
5661 DeleteCriticalSection(&fimpl
->cs
);
5662 CoTaskMemFree(fimpl
);
5670 HRESULT
FilterGraphNoThread_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5672 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5673 return FilterGraph_create(pUnkOuter
, ppObj
);